DatasOutputFile.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 datas in a file.
*/
public class DatasOutputFile extends Thread {
/**
* Main class of the client.
*/
private MonitoringClient client;
/**
* The datas retrieved by the producers.
*/
private DatasBuffer datas;
/**
* The previous datas retrieved by the producers to do an average.
*/
private DatasBuffer previousDatas;
/**
* The output string to write in the datas file.
*/
private String datasOutput;
/**
* The name of the datas file.
*/
private String datasFileName;
private SimpleDateFormat sdf;
/**
* Indicate if the client have just been launched.
*/
/**
* Contructs a DataOutputFile thread whith the specified values.
*
* @param client The main class of the client.
* @param datasFileName The name of the datas file.
*/
this.datasOutput = new String();
this.datasFileName = datasFileName;
firstRun = true;
}
/**
* Retrieve the datas, format its and save its in a file.
*/
public void run () {
while(true) {
try {
synchronized(client.getDatasBuffer()) {
}
} catch (InterruptedException e) {
}
}
}
/**
* Retrieve the datas and clear the main class containers.
*/
private void datasRetrieving() {
}
/**
* Format the datas to be easy to parse with graph generators.
*/
private void datasProcessing() {
datasOutput = "";
if (firstRun) {
datasOutput += "# DATE";
datasOutput += "|value";
datasOutput += "|diff";
datasOutput += "|average";
}
} else {
datasOutput += "|value";
}
}
datasOutput += "\n";
}
try {
d.getParameters());
datasOutput += " -1";
} else if (firstRun) {
datasOutput += " 0";
} else {
"average")) {
}
}
} else {
}
} catch (NumberFormatException e) {
}
}
// datasOutput += " [" + sdf.format(new Date()) +"]";
datasOutput += "\n";
}
/**
* Save the datasOutput string in a file.
*/
private void datasExploitation() {
try {
if (firstRun) {
firstRun = false;
} else {
}
} catch (IOException e) {
}
}
}