ErrorsOutputFile.java revision d81978a0815d5b8a75633c35e3e1f8708d36f017
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
*/
/**
* Consumer who save the errors in a file.
*/
public class ErrorsOutputFile extends Thread {
/**
* Main class of the client.
*/
private MonitoringClient client;
/**
* The errors retrieved by the producers.
*/
private ErrorsBuffer errors;
/**
* The output string to write in the error file.
*/
private String errorsOutput;
/**
* The name of the errors file.
*/
private String errorsFileName;
private SimpleDateFormat sdf;
/**
* Indicate if the client have just been launched.
*/
/**
* Contructs a ErrorsOutputFile thread whith the specified values.
*
* @param client The main class of the client.
* @param errorsFileName The name of the errors file.
*/
this.errorsOutput = new String();
this.errorsFileName = errorsFileName;
firstRun = true;
}
/**
* Retrieve the errors, format its and save its in a file.
*/
public void run () {
while(true) {
try {
synchronized(client.getErrorsBuffer()) {
}
} catch (InterruptedException e) {
}
}
}
/**
* Retrieve the errors.
*/
private void errorsRetrieving() {
}
/**
* Format the errors.
*/
private void errorsProcessing() {
errorsOutput = "";
if (firstRun) {
errorsOutput += "# DATE PROTOCOL|ATTRIBUTE MESSAGE\n";
}
errorsOutput += "General";
} else {
errorsOutput += e.getAttribute();
}
}
}
/**
* Save the errorsOutput string in a file.
*/
private void errorsExploitation() {
try {
if (firstRun) {
firstRun = false;
} else {
}
} catch (IOException e) {
}
}
}