use of sessionport.rpc.group.GroupRPCSessionPort in project GIPC by pdewan.
the class AnOlderGroupRPCStaticSessionPortLauncher method launchStaticSessionPartipant.
public static void launchStaticSessionPartipant(ServerPortDescription[] aServerList, String anId, String aName) {
Tracer.showInfo(true);
RelayerClientAndServerSupport.setRelayedCommunicaton(false);
GroupRPCSessionPort sessionPort = null;
// fix this later if needed
// GroupRPCStaticSessionPortSelector.createGroupRPCStaticSessionPort(aServerList, anId, aName, REMOTE_END_POINT, null
// );
ConnectionListener connectListener = new AnOldGroupCallingConnectListener(sessionPort);
sessionPort.addConnectionListener(connectListener);
Adder adder = new AnAdder();
sessionPort.register(Adder.class, adder);
Scanner in = new Scanner(System.in);
System.out.println("Press any key to connect to peers");
String message = in.nextLine();
Tracer.info("About to connect to peers");
sessionPort.connect();
}
use of sessionport.rpc.group.GroupRPCSessionPort in project GIPC by pdewan.
the class AnOldestGroupRPCSessionPortLauncher method launchSessionPartipant.
public static void launchSessionPartipant(String anId, String aName) {
Tracer.showInfo(true);
RelayerClientAndServerSupport.setRelayedCommunicaton(false);
GroupRPCSessionPort sessionPort = GroupRPCSessionPortSelector.createGroupRPCSessionPort("localhost", "" + SESSION_SERVER_PORT, SESSION_SERVER_NAME, "Test Session", anId, aName, ParticipantChoice.MEMBER);
ConnectionListener connectListener = new AnOldGroupCallingConnectListener(sessionPort);
sessionPort.addConnectionListener(connectListener);
Adder adder = new AnAdder();
sessionPort.register(Adder.class, adder);
sessionPort.connect();
}
use of sessionport.rpc.group.GroupRPCSessionPort in project GIPC by pdewan.
the class AGroupRPCStaticSessionPortLauncher method registerRemoteObjects.
@Override
protected void registerRemoteObjects() {
super.registerRemoteObjects();
GroupRPCSessionPort aGroupRPCSessionPort = (GroupRPCSessionPort) mainPort;
DuplexCounterAndSenderAwareSummer adder = new AGroupCounterAndSenderAwareSumPrinter(aGroupRPCSessionPort);
aGroupRPCSessionPort.register(DuplexCounterAndSenderAwareSummer.class, adder);
// registerdEchoer = new AnEchoer();
registerdEchoer = new ARegisteredEchoer();
// aGroupRPCSessionPort.register(Echoer.class, registerdEchoer);
aGroupRPCSessionPort.register(ARegisteredEchoer.class, registerdEchoer);
// counter = new ACounter();
// counter = new ACounterWithObjectValue();
// aGroupRPCSessionPort.register(CounterWithObjectValue.class, counter);
// aGroupRPCSessionPort.register(Counter.class, counter);
}
use of sessionport.rpc.group.GroupRPCSessionPort in project GIPC by pdewan.
the class AnOldGroupRPCStaticSessionPortLauncher method launchStaticSessionPartipant.
public static void launchStaticSessionPartipant(ServerPortDescription[] aServerList, String anId, String aName) {
// Tracer.showInfo(true);
// ConnectionEventListener connectionManager = new AConnectionEventManager();
// DistEventsBus.addConnectionEventListener(connectionManager);
// ObjectEditor.edit(connectionManager);
System.out.println("Race conditions galore in this example because of calls to getLastSender() by the registered methods");
PortMisc.displayConnections();
RelayerClientAndServerSupport.setRelayedCommunicaton(false);
GroupRPCSessionPort sessionPort = null;
// fix this later
// GroupRPCStaticSessionPortSelector.createGroupRPCStaticSessionPort(aServerList, anId, aName, null, null
// );
registerMethods(sessionPort);
// ConnectionListener connectListener = new AGroupCallingConnectListener(sessionPort);
// sessionPort.addConnectionListener(connectListener);
// Adder adder = new AnAdder();
// sessionPort.register(Adder.class, adder);
// DuplexCounterAndSenderAwareSumComputerAndPrinter adder = new AGroupCounterAndSenderAwareSumPrinter(sessionPort);
// sessionPort.register(DuplexCounterAndSenderAwareSumComputerAndPrinter.class, adder);
unregisteredEchoer = new AnUnregisteredEchoer();
// registerdEchoer = new ARegisteredEchoer();
// sessionPort.register(Echoer.class, registerdEchoer);
Scanner in = new Scanner(System.in);
// Tracer.showInfo(true);
// waitForUserToOKConnectionThroughConsole(in);
DuplexCounterAndSenderAwareSummer adderProxy = (DuplexCounterAndSenderAwareSummer) GroupRPCProxyGenerator.generateAllRPCProxy(sessionPort, DuplexCounterAndSenderAwareSummer.class, null);
// counter = new ACounter();
// counter = new ACounterWithObjectValue();
// sessionPort.register(CounterWithObjectValue.class, counter);
// sessionPort.register(Counter.class, counter);
// Adder adderProxy = (Adder) GroupRPCProxyGenerator.generateAllRPCProxy(sessionPort, DuplexCounterAndSenderAwareSumComputerAndPrinter.class, null);
waitForUserToOKConnectionThroughDialogBox();
sessionPort.connect();
while (true) {
System.out.println("Please enter two messages:");
String stringMessage1 = in.nextLine();
String stringMessage2 = in.nextLine();
counter.increment(1);
try {
// synchronous
Object[] retVal = (Object[]) adderProxy.sum(stringMessage1, stringMessage2);
for (Object val : retVal) {
System.out.println("Remote sum:" + val);
}
// // sync or async depending on RPC
adderProxy.printUppercase(stringMessage1);
// // sync or async depending on RPC, sync will cause deadlock
// lots of messages being sent. Race conditions determine what last sender is when call others is invoked
adderProxy.printSumAndCallBackProcedureAndFunction(unregisteredEchoer, stringMessage1, stringMessage2);
} catch (Exception e) {
e.printStackTrace();
}
}
// System.out.println("Press any key to ask for group add");
// message = in.nextLine();
// Adder adderProxy = (Adder) GroupRPCProxyGenerator.generateAllRPCProxy(sessionPort, Adder.class, null);
// adderProxy.printSum(5, 6);
}
Aggregations