MonitoringClient.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.
*/
/**
* Main class of the monitoring client.
*/
public class MonitoringClient {
/**
* The parameters of the producers.
*/
private Hashtable producersConfig;
/**
* The parameters of the consumers.
*/
private String outputRepository;
/**
* Interval of time between each threads wake up.
*/
private int interval;
/**
* Unit of time.
*/
private int timeUnit;
/**
* Lock for the producers.
*/
/**
* Buffer for the datas.
*/
private DatasBuffer datas;
/**
* Buffer for the errors.
*/
private ErrorsBuffer errors;
/**
* Number of consumers.
*/
private int nbConsumers = 1;
/**
* Value for the datas where an error occured.
*/
/**
* Wake up the producers very interval of time.
*
* @param parsedArguments The parsed arguments
*/
datas = new DatasBuffer(this);
errors = new ErrorsBuffer(this);
// Config
this.init(parsedArguments);
}
/**
* The main method of the MonitoringClient class.
*
* @param args The command-line arguments provided to this program.
*/
}
/**
* Start the producers and de consumers and wake up the producers every
* interval of time.
*/
public void start() {
// Start of the producers
}
}
}
}
// Start of the consumers
new DatasOutputFile(
new ErrorsOutputFile(
while(true) {
try {
} catch (InterruptedException e) {
}
// Wake up the producers
synchronized(lock) {
}
}
}
/**
* Returns the buffer for the datas.
*
* @return The buffer for the datas.
*/
public DatasBuffer getDatasBuffer() {
return datas;
}
/**
* Returns the buffer for the errors.
*
* @return The buffer for the errors.
*/
public ErrorsBuffer getErrorsBuffer() {
return errors;
}
/**
* Returns the interval.
*
* @return The interval of time between each threads wake up.
*/
public int getInterval() {
return interval;
}
/**
* Return the time unit.
*
* @return the time unit
*/
public int getTimeUnit() {
return timeUnit;
}
/**
* Returns the number of consumers.
*
* @return The number of consumers.
*/
public int getNbConsumers() {
return nbConsumers;
}
/**
* Sets the properties of the producers.
*
* @param producersConfig The properties of the producers.
*/
this.producersConfig = producersConfig;
}
/**
* Parse the command line argument.
*
* @param args the command line argument
* @return the parsed argument
*/
"[-p <LDAPport>] [-x <JMXport>] [-m <JVMport>] [-s <SNMPport] " +
"[-D <bindDN>] -w <bindPW> [-f <configFile>] [-r <repository>]" +
"[-i <interval>] [-u <timeUnit>]\n\n";
try {
usage +
"-h, --hostname\n" +
" Directory server hostname or IP address\n" +
"-p, --LDAPport\n" +
" Directory server LDAP port number\n" +
"-x, --JMXport\n" +
" Directory server JMX port number\n" +
"-m, --JVMport\n" +
" JMX port number of the host JVM\n" +
"-s, --SNMPport\n" +
" Directory server SNMP port number\n" +
"-D, --bindDN\n" +
" DN to use to bind to the server\n" +
"-w, --bindPassword\n" +
" Password to use to bind to the server\n" +
"-f, --configFile\n" +
" Config file to use to monitor the server\n" +
"-r, --repository\n" +
" Repository for the output files" +
"-i, --interval\n" +
" Interval of time between each attributes retrieving\n" +
"-u, --timeUnit\n" +
" Time unit of the interval of time (s | min | h)"
);
}
} else {
throw new IllegalArgumentException();
}
i++;
} else {
throw new IllegalArgumentException();
}
i++;
} else {
throw new IllegalArgumentException();
}
i++;
} else {
throw new IllegalArgumentException();
}
i++;
} else {
throw new IllegalArgumentException();
}
i++;
} else {
throw new IllegalArgumentException();
}
i++;
} else {
throw new IllegalArgumentException();
}
i++;
} else {
throw new IllegalArgumentException();
}
i++;
} else {
}
} else {
throw new IllegalArgumentException();
}
i++;
} else {
throw new IllegalArgumentException();
}
i++;
} else {
throw new IllegalArgumentException();
}
i++;
} else {
throw new IllegalArgumentException();
}
} else {
throw new IllegalArgumentException();
}
}
// parsedArguments.setProperty("host","havmann");
// throw new IllegalArgumentException();
}
// parsedArguments.setProperty("LDAPport", "1389");
// throw new IllegalArgumentException();
}
// throw new IllegalArgumentException();
}
// throw new IllegalArgumentException();
}
// throw new IllegalArgumentException();
}
// parsedArguments.setProperty("bindPW","toto123");
throw new IllegalArgumentException();
}
// throw new IllegalArgumentException();
}
// throw new IllegalArgumentException();
}
// throw new IllegalArgumentException();
}
// throw new IllegalArgumentException();
}
if (JMXport == -1) {
JMXport = 1689;
}
// throw new IllegalArgumentException();
}
} catch (IllegalArgumentException e) {
"more usage help");
} catch (ArrayIndexOutOfBoundsException e) {
"more usage help");
}
return parsedArguments;
}
/**
* Retrieve the JMX port.
*
* @param host Directory server hostname or IP address
* @param port Directory server port number
* @param bindDN DN to use to bind to the server
* @param bindPW Password to use to bind to the server
* @return The port number of the JMX port, -1 if an error occured
*/
int JMXport = 0;
try {
"com.sun.jndi.ldap.LdapCtxFactory");
}
}
} catch (CommunicationException e) {
if (e.getCause() instanceof ConnectException) {
"Wrong port number");
} else {
"Unknown host");
}
JMXport = -1;
} catch (AuthenticationException e) {
"Invalid Credentials");
JMXport = -1;
} catch (ServiceUnavailableException e) {
"Service Unavailable");
JMXport = -1;
} catch (NamingException e) {
e.getLocalizedMessage());
JMXport = -1;
}
return JMXport;
}
/**
* Set the parameters of the producers.
*
* @param parsedArguments The parsed arguments
*/
try {
factory.setValidating(true);
new ConfigHandler(this, parsedArguments));
} catch (ParserConfigurationException e) {
} catch (SAXException e) {
} catch (IOException e) {
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}