LDAPMonitor.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.
*/
/**
* Producer who monitor an OpenDS server with LDAP.
*/
public class LDAPMonitor extends Thread {
/**
* Main class of the client.
*/
private MonitoringClient client;
/**
* The properties of the producer.
*/
private Properties params;
/**
* Contructs a LDAPMonitor thread whith the specified values.
*
* @param client The main class of the client.
* @param params The parameters of the thread.
*/
}
/**
* Connect to the server, get the attributes to monitor,
* and wait a notify from the main thread.
*/
public void run() {
// Initialise the LDAP environnement.
"com.sun.jndi.ldap.LdapCtxFactory");
while(true) {
try {
// Allow to desynchronize the producers.
try {
client.getTimeUnit());
} catch (InterruptedException e) {
}
// Connect to the server
// Simulate an important charge for the server
try {
client.getTimeUnit());
} catch (InterruptedException e) {
}
// Retrieve the attributes
for (Data d : attributesToMonitor) {
}
try {
} else {
"(objectclass=*)", ctls);
}
/* System.out.println(new Date() + " " +
d.getParameters().getProperty("protocol") + " " +
d.getParameters().getProperty("baseDN") + " " +
d.getParameters().getProperty("filter") + " " +
d.getAttribute() + " " +
attr.get(0).toString() + " " +
(int)(System.currentTimeMillis() - date.getTime()) +
" ms");*/
}
}
} catch (NameNotFoundException e) {
"the search base does not exist in the Directory Server");
}
}
// Close the LDAP connection
// Processing of the errors
} catch (CommunicationException e) {
if (e.getCause() instanceof ConnectException) {
"Wrong port number");
} else {
"Unknown host");
}
} catch (AuthenticationException e) {
"Invalid Credentials");
} catch (ServiceUnavailableException e) {
"Service Unavailable");
} catch (NamingException e) {
e.getLocalizedMessage());
}
// Wait for the next run
try {
synchronized(MonitoringClient.lock) {
}
} catch (InterruptedException e) {
}
// Update the date
}
}
}