Skip to content
Snippets Groups Projects
Commit 441cdea4 authored by Serguei Kolos's avatar Serguei Kolos
Browse files

Remove unnecessary synchronisation

parent a21f33b7
No related branches found
Tags v0.03.00
No related merge requests found
......@@ -102,46 +102,38 @@ class ClientInterceptor extends org.omg.CORBA.LocalObject implements
ers.Logger.debug(1, threadName + ": [" + exception + "] exception received");
org.omg.CORBA.Object object = ri.target();
ers.Logger.debug(1, threadName + ": target = " + Core.objectToString(object, Core.CORBALOC));
String currentTarget = Core.objectToString(object, Core.IOR);
ers.Logger.debug(1, threadName + ": target = " + currentTarget);
Any any;
String originalTarget;
org.omg.CORBA.Object new_object;
try {
any = ri.get_slot(this.slot);
} catch (InvalidSlot ex) {
Any any = ri.get_slot(this.slot);
originalTarget = any.extract_string();
ers.Logger.debug(1, threadName + ": original target = " + originalTarget);
new_object = Cache.recover(object);
} catch (Exception ex) {
ers.Logger.debug(1, ex);
return;
return;
}
String originalTarget = "";
if (any.type().kind().equals(TCKind.tk_string)) {
originalTarget = any.extract_string();
String newTarget = Core.objectToString(new_object, Core.IOR);
ers.Logger.debug(1, threadName + ": new target = " + newTarget);
if (originalTarget.equals(newTarget)) {
ers.Logger.debug(1, threadName
+ ": The last known object reference is the same as the failed one,"
+ " no further recovery attempts will be made.");
return;
}
synchronized(object) {
org.omg.CORBA.Object new_object;
try {
new_object = Cache.recover(object);
} catch (Exception ex) {
ers.Logger.debug(1, ex);
return;
}
String newTarget = Core.objectToString(new_object, Core.IOR);
if (originalTarget.equals(newTarget)) {
ers.Logger.debug(1, threadName
+ ": The last known object reference is the same as the failed one,"
+ " no further recovery attempts will be made.");
return;
}
String currentTarget = Core.objectToString(object, Core.IOR);
if (newTarget.equals(currentTarget)) {
ers.Logger.debug(1, threadName + ": Recovery had been done in another thread, invoke the same request once more.");
throw new ForwardRequest();
} else {
ers.Logger.debug(1, threadName + ": Invoke the same request with the new object reference.");
throw new ForwardRequest(new_object);
}
if (newTarget.equals(currentTarget)) {
ers.Logger.debug(1, threadName + ": Recovery had been done in another thread, invoke the same request once more.");
throw new ForwardRequest();
} else {
ers.Logger.debug(1, threadName + ": Invoke the same request with the new object reference.");
throw new ForwardRequest(new_object);
}
}
}
......@@ -169,10 +169,49 @@ public class Test
test_typed_iterators();
}
static class TestThread extends Thread {
private String name;
private int timeout;
TestThread(String name, int timeout) {
this.name = name;
this.timeout = timeout;
}
public void run(){
Partition p = new Partition();
try {
ipc.server tt = p.lookup(ipc.server.class, name);
System.out.println("got CORBA object " + tt.hashCode());
Thread.sleep(timeout);
System.out.println("invoking ping on CORBA object " + tt.hashCode());
tt.ping_s("Test string");
System.out.println("ping_s was called successfully");
}
catch (Exception e) {
System.out.println("System exception : " + e);
}
}
}
public static void test_cache(String name) throws InvalidPartitionException, InterruptedException
{
TestThread t1 = new TestThread(name, 5000);
TestThread t2 = new TestThread(name, 6000);
t1.start();
t2.start();
t1.join();
t2.join();
}
public static void main(String args[])
{
try {
test_cache(args[0]);
test_generic_iterators();
test_lookup(args[0]);
......@@ -183,7 +222,7 @@ public class Test
ipc.Core.constructReference(
"initial", "ipc/partition", "initial", "pcatd88.cern.ch", 12345));
}
catch (InvalidPartitionException ex) {
catch (Exception ex) {
System.err.println(ex);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment