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_mod=100;
static int nb_mod_started=0;
static int nb_mod_done=0;
static int total_nb_mod=0;
static int nb_threads=3;
static int nb_thread_ready=0;
static int portnumber;
static String authentication;
static String attributeName;
static long timeTostopTest=0;
static long maxDuration=0;
static long duration=0;
static long startup=0;
static long delayCnx=1000;
static long delaySec=1;
static long delayPrint=60000;
public Client()
{
try {
/*
* bind as directory manager to get the full list of DN
* create a list of DN
*/
// 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++ ) {
}
//println ("INFO", "Will search using filter \"(" + attr + " = <value> )\" (MAX =" + NB_MAX_mod + ")" );
// 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;
// initialize startup
// 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) {
total_nb_mod=0;
}
}
}
// status every delayCnx
// println("INFO", (nb_mod_done/delaySec) + " mod/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) {
nb_mod_done=0;
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
// Max number of searchs
// attribute to modify or add
// operation to perform: modify or add
// hostname
// protocol : SSL or TLS
// authentication : EXTERNAL or simple
// delay Sec before closing conx
if ( maxDuration != 0 ) {
}
// ===========================================
// Initialize the Server
public void run() {
}
});
}
/* =========================================
* Get Date
* ======================================= */
if ( d > 10000 ) {
} else if ( d > 300 ) {
}
return time;
}
/* =========================================
* return true if the number of NB_MAX_mod has been reached
* else, increase nb_mod_started
* ======================================= */
public boolean nb_mod_started_reached() {
synchronized (this) {
if ( nb_mod_started>=NB_MAX_mod ) {
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 mod started
* ======================================= */
public void inc_mod_started() {
synchronized (this) {
if ( nb_mod_started>=NB_MAX_mod ) {
try {
this.wait();
} catch ( Exception e ) {
e.printStackTrace();
}
} else {
}
}
}
/* =========================================
* increase the number of mod done
* ======================================= */
public void inc_mod_done() {
synchronized (this) {
try {
nb_mod_done++;
} 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;
}
}