use of inputport.rpc.duplex.example.DuplexCounterAndSenderAwareSummer in project GIPC by pdewan.
the class AnOldGroupRPCStaticSessionPortLauncher method registerMethods.
// public static void displayConnections() {
// ConnectionEventListener connectionManager = new AConnectionEventManager();
// DistEventsBus.addConnectionEventListener(connectionManager);
// ObjectEditor.edit(connectionManager);
// }
public static void registerMethods(GroupRPCSessionPort rpcPort) {
DuplexCounterAndSenderAwareSummer adder = new AGroupCounterAndSenderAwareSumPrinter(rpcPort);
rpcPort.register(DuplexCounterAndSenderAwareSummer.class, adder);
registerdEchoer = new ARegisteredEchoer();
rpcPort.register(AnotherEchoer.class, registerdEchoer);
counter = new AnAnotherCounter();
counter = new ACounterWithObjectValue();
rpcPort.register(CounterWithObjectValue.class, counter);
rpcPort.register(AnotherCounter.class, counter);
}
use of inputport.rpc.duplex.example.DuplexCounterAndSenderAwareSummer in project GIPC by pdewan.
the class AGroupRPCServerInputPortLauncher method registerRemoteObjects.
@Override
protected void registerRemoteObjects() {
GroupRPCServerInputPort aGroupServerInputPort = (GroupRPCServerInputPort) mainPort;
DuplexCounterAndSenderAwareSummer adder = new AGroupCounterAndSenderAwareSumPrinter(aGroupServerInputPort);
aGroupServerInputPort.register(adder);
}
use of inputport.rpc.duplex.example.DuplexCounterAndSenderAwareSummer 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 inputport.rpc.duplex.example.DuplexCounterAndSenderAwareSummer 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);
}
use of inputport.rpc.duplex.example.DuplexCounterAndSenderAwareSummer in project GIPC by pdewan.
the class ASingleResponseReplicatedGroupSessionPortServerLauncher method registerRemoteObjects.
// protected Counter createAndRegisterCounter(RPCRegistry aClientInputPort) {
// Counter counter = new ACounterWithObjectValue();
// aClientInputPort.register(counter);
// return counter;
// }
@Override
protected void registerRemoteObjects() {
GroupRPCServerInputPort aGroupServerInputPort = (GroupRPCServerInputPort) mainPort;
DuplexCounterAndSenderAwareSummer adder = new AGroupCounterAndSenderAwareSumPrinter(aGroupServerInputPort);
aGroupServerInputPort.register(adder);
}
Aggregations