DatasBuffer.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.
*/
/**
* Buffer to store the datas retrieved by the producers.
*/
public class DatasBuffer {
/**
* Main class of the client.
*/
private MonitoringClient client;
/**
* Date of the datas.
*/
/**
* Datas retrieved by the producers.
*/
/**
* Number of consumers who have cloned the buffer.
*/
private int consumers;
/**
* True if the timeout have expired.
*/
private boolean timeout;
/**
* Construct a DatasBuffer object.
*
* @param client The main class of the client.
*/
this.consumers = 0;
this.timeout = false;
}
/**
* Constructor used to clone the DatasBuffer.
*
* @param client The main class of the client.
* @param date The date of the datas.
*/
this.consumers = 0;
this.timeout = false;
}
/**
* Add an attribute to monitor.
*
* @param params The parameters to monitor the attribute.
* @param attribute The name of the attibute to monitor.
* @return true if the attribute have been add; false otherwise.
*/
Properties params) {
}
/**
* Remove an attribute to monitor.
*
* @param attribute The name of the attibute to monitor.
* @param params The parameters to monitor the attribute.
* @return true if the attribute have been removed; false otherwise.
*/
Properties params) {
}
/**
* Returns the attributes to monitor for a well known protocol.
*
* @param protocol The name of the protocol.
* @return The attributes to monitor.
*/
}
}
return attributesToMonitor;
}
/**
* Test if the DatasBuffer contains a data.
*
* @param attribute The name of the attibute monitored.
* @param parameters The parameters to monitor the attribute.
* @return true if the DatasBuffer contains a data, false otherwise.
*/
}
/**
* Returns the specified data.
*
* @param attribute The name of the attibute monitored.
* @param parameters The parameters to monitor the attribute.
* @return The data with the specified protocol and attribute
*/
}
/**
* Sets a data in the buffer.
*
* @param d The data to set
* @param value The value of the attribute monitored.
* @param timer The number of milliseconds beetween the launch of the
* request and the creation of the data.
*/
"Unknown Attribute");
} else {
}
}
/**
* Add a data in the buffer.
*
* @param attribute The name of the attribute
* @param parameters The parameters of the data
* @param value The value of the data
* @param timer The timer of the data
* @return true if the data have been add; false otherwise;
*/
}
/**
* Verify if all the attribute to monitor of a protocol have been set.
*
* @param protocol The name of the protocol used to retrieve the datas.
*/
d.getTimer() != -1) {
this.dataError(d, "This attribute couldn't be retrieved");
}
}
if (this.isFull()) {
notifyAll();
}
}
/**
* If the buffer isn't full, fill the empty data with the error code and wake
* up the consumers; else, reset the date and the number of consumers.
*/
public synchronized void timeoutExpired() {
if (consumers == 0) {
if (!this.isFull()) {
if (d.hasEmptyValue()) {
"This attribute couldn't be retrieved because the " +
"timeout has expired", date);
}
}
}
timeout = true;
notifyAll();
} else {
consumers = 0;
}
}
/**
* Fill all the datas of a well known protocol with the error code and create
* a general error.
*
* @param protocol The name of the protocol.
* @param message The message of the error.
*/
}
}
if (this.isFull()) {
notifyAll();
}
}
/**
* Fill a data with the error code and create a new error.
*
* @param d The data who has the error.
* @param message The message of the error.
*/
}
/**
* Return the datas retrieved by the producers.
*
* @return The datas retrieved by the producers.
*/
return datas;
}
/**
* Return the date of the datas.
*
* @return The date of the datas.
*/
return date;
}
/**
* Clone the DatasBuffer and reset it if all the consumers have cloned it.
*
* @return A clone of the DatasBuffer.
*/
public synchronized DatasBuffer clone () {
d.getTimer());
}
d.reset();
}
if (timeout) {
consumers = 0;
timeout = false;
}
}
return result;
}
/**
* Return the index of the specified data.
*
* @param protocol The name of the protocol used to retrieve the data.
* @param attribute The name of the attibute monitored.
* @return The index of the specified data.
*/
int i = 0;
i++;
}
}
/**
* Test if the DatasBuffer is full.
*
* @return true if the DatasBuffer is full; false otherwise.
*/
public synchronized boolean isFull() {
boolean result = true;
if (d.hasEmptyValue()) {
result = false;
}
}
return result;
}
}