use of inputport.rpc.duplex.DuplexRPCClientInputPort in project GIPC by pdewan.
the class GIPCComparableCounterClient method main.
public static void main(String[] args) {
try {
(new ADuplexRPCInputPortLauncherSupport()).init();
DuplexRPCClientInputPort aClientInputPort = DuplexRPCInputPortSelector.createDuplexRPCClientInputPort("localhost", SERVER_PORT, SERVER_NAME, "counter client");
RPCProxyGenerator rpcProxyGenerator = aClientInputPort.getRPCProxyGenerator();
ComparableCounter counter11 = (ComparableCounter) rpcProxyGenerator.generateRPCProxy(ComparableCounter.class, COUNTER1);
ComparableCounter counter12 = (ComparableCounter) rpcProxyGenerator.generateRPCProxy(ComparableCounter.class, COUNTER1);
ComparableCounter counter2 = (ComparableCounter) rpcProxyGenerator.generateRPCProxy(ComparableCounter.class, COUNTER2);
aClientInputPort.connect();
ComparableCounter greaterCounter = counter11.greater(counter11);
System.out.println(greaterCounter == counter11);
System.out.println(greaterCounter.equals(counter11));
System.out.println(counter12 == counter11);
System.out.println(counter12.equals(counter11));
System.out.println(counter11.hashCode() == counter12.hashCode());
System.out.println(greaterCounter.hashCode() == counter11.hashCode());
System.out.println(counter11.equals(counter2));
} catch (Exception e) {
e.printStackTrace();
}
}
use of inputport.rpc.duplex.DuplexRPCClientInputPort in project GIPC by pdewan.
the class AFaultTolerantSessionPortLauncher method launchSessionPartipant.
public static void launchSessionPartipant(String anId, String aName, boolean addConnectListener, boolean addReplyingReceiveListener, boolean greetOnReadingInput) {
Tracer.showInfo(true);
RelayerClientAndServerSupport.setRelayedCommunicaton(false);
DelayUtlity.setDelayClientBufferSends(true);
// GlobalState.setCausalBroadcast(true);
// GroupSessionPort<Object> groupSessionPort = ObjectGroupStaticSessionPortSelector.createObjectGroupStaticSessionPort(serversDescription, null, aName);
// GroupMultiServerClientPort<Object> groupMultiServerPort = ObjectGroupMultiServerPortSelector.createGroupMultiServerClientPort(serversDescription, null, aName);
// DuplexClientInputPort<Object> sessionsServerObjectPort = new AReplicatedServerDuplexClientPort<Object>(groupMultiServerPort, SESSION_SERVER_NAME );
// DuplexRPCClientInputPort sessionsServerClientPort = DuplexRPCInputPortSelector.createDuplexRPCClientInputPort(sessionsServerObjectPort);
DuplexRPCClientInputPort sessionsServerClientPort = ReplicatedServerDuplexRPCClientPortSelector.createDuplexRPCPort(serversDescription, SESSION_SERVER_NAME, aName, ParticipantChoice.SYMMETRIC_JOIN);
DuplexSingleResponseUtlity.supportSingleResponse(sessionsServerClientPort);
// GlobalState.setDelayAndCausal(true);
// DuplexRPCClientInputPort sessionManagerClientPort = DuplexRPCInputPortSelector.createDuplexRPCClientInputPort(
// "localhost", "" + SESSION_SERVER_PORT, SESSION_SERVER_NAME, aName);
GroupSessionPort<Object> sessionPort = ObjectGroupSessionPortSelector.createObjectGroupSessionPort(sessionsServerClientPort, "Test Session", anId, aName, ParticipantChoice.MEMBER);
ACausalGroupSessionPortLauncherSupport.doCausalBroadcast(sessionPort);
// PrintingReplyingReceiveListener printingReplyingReceiveListener = new PrintingReplyingReceiveListener(sessionPort);
if (addConnectListener) {
ConnectionListener connectListener = new AnObjectGroupSendingConnectListener(sessionPort);
// sessionPort.addConnectListener(printingReplyingReceiveListener);
sessionPort.addConnectionListener(connectListener);
}
if (addReplyingReceiveListener)
sessionPort.addReceiveListener(new AnObjectGroupSendingReceiveListener(sessionPort));
else
sessionPort.addReceiveListener(new AnEchoingObjectReceiveListener());
// serverInputPort.addDisconnectListener(echoingReceiveListener);
// sessionPort.addReceiveListener(printingReplyingReceiveListener);
sessionPort.connect();
System.out.println("-----------------------Connected to Session Port---------------------------------------");
Scanner in = new Scanner(System.in);
if (greetOnReadingInput) {
String message = in.nextLine();
sessionPort.sendAll(aName + " says hi to all");
}
while (true) {
String message = in.nextLine();
sessionPort.sendAll(aName + message);
}
}
use of inputport.rpc.duplex.DuplexRPCClientInputPort in project GIPC by pdewan.
the class AnRPCClientLauncher method launchRPCClient.
public static void launchRPCClient(String clientName) {
// Tracer.showInfo(true);
DuplexRPCClientInputPort clientInputPort = DuplexRPCInputPortSelector.createDuplexRPCClientInputPort("localhost", "9090", "Test Server", clientName);
PrintingTypedReceiveListener messageReceiver = new PrintingTypedReceiveListener(clientInputPort);
clientInputPort.addConnectionListener(messageReceiver);
// clientInputPort.addDisconnectListener(messageReceiver);
clientInputPort.register(messageReceiver.getClass(), messageReceiver);
clientInputPort.addReceiveListener(messageReceiver);
clientInputPort.addSendListener(messageReceiver);
// clientInputPort.register(TypedReceiveListener.class, messageReceiver);
Adder adder = new AnAdder();
clientInputPort.register(Adder.class, adder);
clientInputPort.connect();
// clientInputPort.send("hello from" + clientName);
try {
// Class[] parameterTypes = {String.class, Serializable.class};
// Method typedMethod = TypedReceiveListener.class.getMethod("messageReceived", parameterTypes);
// Method rpcMethod = RPCReceiver.class.getMethod("messageReceived", parameterTypes);
// Serializable[] args = {clientName, "hello from " + clientName};
// clientInputPort.call(typedMethod, args);
// clientInputPort.call(RPCReceiver.class, rpcMethod, args);
// Method groupAddMethod = GroupAdder.class.getMethod("messageReceived", parameterTypes);
// clientInputPort.call(GroupAdder.class, groupAddMethod, args);
// Integer[] args2 = { 5, 6};
// Class[] parameterTypes2 = {Integer.class, Integer.class};
// Method intAddMethod = Adder.class.getMethod("add", parameterTypes2);
// // Object retVal = clientInputPort.call(Adder.class, intAddMethod, args2);
// Integer[] args3 = { 5, 6};
// Class[] parameterTypes3 = {Integer.TYPE, Integer.TYPE};
// Method intAddMethod2 = Adder.class.getMethod("add", parameterTypes2);
// Object retVal2 = clientInputPort.call(Adder.class, intAddMethod, args2);
// System.out.println(retVal2);
GroupAdder groupAdderProxy = (GroupAdder) DirectedRPCProxyGenerator.generateRPCProxy(clientInputPort, null, GroupAdder.class, null);
groupAdderProxy.groupSum(5, 6);
Adder adderProxy = (Adder) DirectedRPCProxyGenerator.generateRPCProxy(clientInputPort, null, Adder.class, null);
Object result = adderProxy.sum(5, 6);
System.out.println("Result of adding:" + result);
} catch (Exception e) {
e.printStackTrace();
}
}
use of inputport.rpc.duplex.DuplexRPCClientInputPort in project GIPC by pdewan.
the class AnEchoingDuplexRPCClientLauncher method registerRemoteObjects.
protected void registerRemoteObjects() {
DuplexRPCClientInputPort aDuplexRPCClientInputPort = (DuplexRPCClientInputPort) mainPort;
counter = new ACounter();
aDuplexRPCClientInputPort.register(counter);
}
use of inputport.rpc.duplex.DuplexRPCClientInputPort in project GIPC by pdewan.
the class ADelayingRelayerLauncher method main.
public static void main(String[] args) {
// Tracer.showInfo(true);
// Message.setKeyWordStatus(Message.ALL_KEYWORDS, false);
// Message.setKeyWordStatus("nioip", true);
// GlobalState.setDelayServerBufferSends(true);
DelayUtlity.getDelayManager().setMinimumDelay("Alice", 1000);
DelayUtlity.getDelayManager().setMinimumDelay("Bob", 100);
DelayUtlity.getDelayManager().setMinimumDelay("Cathy", 500);
// GroupRPCServerInputPort serverInputPort = GroupRPCInputPortSelector.createGroupRPCServerInputPort("" +
// ASessionsServer.SESSION_SERVER_PORT, ASessionsServer.SESSION_SERVER_NAME);
GroupRPCServerInputPort serverInputPort = GroupRPCInputPortSelector.createGroupRPCServerInputPort("" + RELAYER_PORT, RELAYER_NAME);
Relayer relayer = new ARelayer(serverInputPort);
serverInputPort.register(Relayer.class, relayer);
serverInputPort.register(RELAYER_NAME, relayer);
serverInputPort.connect();
ServerPortDescription serverPortDescription = new AServerPortDescription("localhost", "" + RELAYER_PORT, RELAYER_NAME);
DuplexRPCClientInputPort sessionServerClientPort = DuplexRPCInputPortSelector.createDuplexRPCClientInputPort("localhost", "" + ADelayingSessionsServerLauncher.SESSION_SERVER_PORT, ADelayingSessionsServerLauncher.SESSION_SERVER_NAME, RELAYER_NAME);
RelayerSupportingSessionServer sessionsServer = (RelayerSupportingSessionServer) DirectedRPCProxyGenerator.generateRPCProxy(sessionServerClientPort, null, RelayerSupportingSessionServer.class, null);
sessionServerClientPort.connect();
sessionsServer.setRelayerDescripton(serverPortDescription);
}
Aggregations