Client.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
// information:
// Portions Copyright [yyyy] [name of copyright owner]
//
// CDDL HEADER END
//
//
// Copyright 2008 Sun Microsystems, Inc.
public class Client {
static int NB_MAX_srchs=100;
static int nb_srchs_started=0;
static int nb_srchs_done=0;
static int total_nb_srchs=0;
static int nb_threads=3;
static int nb_thread_ready=0;
static int portnumber;
static String authentication;
static String attributeName;
static long duration=0;
static long maxDuration=0;
static long startup=0;
static long timeTostopTest=0;
static long delayCnx=1000;
static long delaySec=1;
static long delayPrint=60000;
public Client()
{
/*
* Execute a search on baseDN to get the list of uid
* and set the DNlist
* This connexion can be secure or not depending of the client's configuration
* the BindDN is directory manager
*/
try {
// Search options
int count = 0;
try {
count++;
}
DNList.trimToSize();
}
}
throw exc;
}
} catch (Exception e) {
e.printStackTrace();
}
try {
// execute the threads
for (int i=0; i < nb_threads; i++ ) {
}
// Wait until all the threads have initialized their context
// and are ready to bind
try {
while ( nb_thread_ready() < nb_threads) {
// wait
}
// All the threads are ready, wake up all the threads
synchronized(this) {
notifyAll();
}
}
}
int seconds=0;
// work until Max duration is reached
while (true) {
// end of the system test. Exit
// inform all the threads it's the end
synchronized (this) {
}
break;
}
// status every delayPrint
try {
synchronized(this) {
}
}
}
// status every second
// println("INFO", (nb_srchs_done/delaySec) + " srch/sec.");
// inform all the threads the max nb searchs has been reached
synchronized (this) {
}
// Wait all the threads to close their cnx and sleep
try {
while ( nb_thread_ready() < nb_threads) {
// wait
}
// All the threads are ready, wake up all the threads
synchronized(this) {
notifyAll();
}
}
}
}
}
}
catch( Exception e ) {
e.printStackTrace();
}
}
/* =========================================
* MAIN
* ======================================= */
{
// ===========================================
// Get the arguments specified for each option.
//
// Ldap port
// BaseDN
// nb_threads
// test duration
// credential for simple bind
// attribute to search
// Max number of searchs
// hostname
// protocol : SSL or TLS
// authentication : EXTERNAL or simple
// delay Sec before closing conx
if ( maxDuration != 0 ) {
}
// ===========================================
// Initialize the Server
public void run() {
}
});
}
/* =========================================
* return true if the number of NB_MAX_srchs has been reached
* else, increase nb_srchs_started
* ======================================= */
public boolean nb_srchs_started_reached() {
synchronized (this) {
if ( nb_srchs_started>=NB_MAX_srchs ) {
return true;
} else {
return false;
}
}
}
/* =========================================
* thread is waiting for a notify from the main thread
* ======================================= */
public void thread_go_to_sleep() {
synchronized (this) {
try {
this.wait();
} catch ( Exception e ) {
e.printStackTrace();
}
}
}
/* =========================================
* increase the number of srchs started
* ======================================= */
public void inc_srchs_started() {
synchronized (this) {
if ( nb_srchs_started>=NB_MAX_srchs ) {
try {
this.wait();
} catch ( Exception e ) {
e.printStackTrace();
}
} else {
}
}
}
/* =========================================
* increase the number of srchs done
* ======================================= */
public void inc_srchs_done() {
synchronized (this) {
try {
} catch ( Exception e ) {
e.printStackTrace();
}
}
}
/* =========================================
* Configure the Properties depending of the selected authentication and protocol
* authentication : EXTERNAL or simple
* protocol ssl, tls or clear
* ======================================= */
public static Hashtable set_properties_LDAP() {
"com.sun.jndi.ldap.LdapCtxFactory");
}
} else {
}
return envLdap;
}
/* =========================================
* Configure the Properties for a simple Bind
* bind as directory manager
* use the selected protocol : ssl, tls or clear
* ======================================= */
public static Hashtable set_properties_LDAP_simpleBind() {
"com.sun.jndi.ldap.LdapCtxFactory");
} else {
}
return envLdap;
}
/* =========================================
* Get Date
* ======================================= */
// Initialize the today's date string
}
/* =========================================
* print
* ======================================= */
}
/* =========================================
* increase the number of threads ready
* ======================================= */
public void inc_thread_ready() {
synchronized (this) {
try {
this.wait();
} catch (Exception e) {
e.printStackTrace();
}
}
}
/* =========================================
* return the number of threads ready
* ======================================= */
public static int nb_thread_ready() {
return nb_thread_ready;
}
/* =========================================
* getTime
* ======================================= */
if ( d > 10000 ) {
} else if ( d > 300 ) {
}
return time;
}
}