"FRAG(frag_size=16000;down_thread=false;up_thread=false):" +
"pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;shun=false;print_local_addr=true):" +
"pbcast.STATE_TRANSFER";
DistributedHashtable distHash=new DistributedHashtable("ADMINT", null, props, 20000);
boolean odd=false;
int numberofelements=1000;
Util.sleep(5000);
System.out.println("size: " + distHash.size());
if(distHash.size() > 0)//The first instance counts up when numbers are even
{ //The second when numbers are odd
odd=true;
}
boolean fillup=false;
if(!odd) System.out.println("Loading hashtable with " + numberofelements + " elements. Don't start the other instance");
for(int i=0; !odd && i < numberofelements; i++)//if the table isn't full we fill it
{
if(i % 50 == 0) System.out.print(i + " ");
distHash.put("number" + i, new Integer(0));
fillup=true;
}
if(fillup) System.out.println("\n\nHashtable filled, you can now start the other instance\n");
System.out.println("initilising with odd: " + odd + " and size " + distHash.size());
while(true) {
try {
System.out.println("#######################################################");
Thread.sleep(10000);
int count=0;
for(int i=0; i < numberofelements; i++) {
int value=((Integer)distHash.get("number" + i)).intValue();
System.out.print(value + " ");
if(i % 50 == 0) System.out.print("\n");
if(odd && (value % 2 != 0))//If the number is odd, and the instance is supposed to count odd numbers up
{
count++;
value++;
distHash.put("number" + i, new Integer(value));
continue;
}
if(!odd && (value % 2 == 0))//If the number is even, and the instance is supposed to count even numbers up
{
count++;
value++;
distHash.put("number" + i, new Integer(value));
continue;
}
}
System.out.println("\n" + odd + " through all session, changed: " + count);