Search in sources :

Example 1 with DuplexRPCClientInputPort

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();
    }
}
Also used : ADuplexRPCInputPortLauncherSupport(inputport.rpc.duplex.ADuplexRPCInputPortLauncherSupport) DuplexRPCClientInputPort(inputport.rpc.duplex.DuplexRPCClientInputPort) RPCProxyGenerator(inputport.rpc.RPCProxyGenerator)

Example 2 with DuplexRPCClientInputPort

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);
    }
}
Also used : Scanner(java.util.Scanner) DuplexRPCClientInputPort(inputport.rpc.duplex.DuplexRPCClientInputPort) AnEchoingObjectReceiveListener(port.delay.example.AnEchoingObjectReceiveListener) ConnectionListener(inputport.ConnectionListener) AnObjectGroupSendingConnectListener(sessionport.datacomm.group.object.example.AnObjectGroupSendingConnectListener) AnObjectGroupSendingReceiveListener(port.delay.example.AnObjectGroupSendingReceiveListener)

Example 3 with DuplexRPCClientInputPort

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();
    }
}
Also used : DuplexRPCClientInputPort(inputport.rpc.duplex.DuplexRPCClientInputPort) PrintingTypedReceiveListener(port.old.PrintingTypedReceiveListener) AnAdder(sessionport.rpc.duplex.relayed.example.AnAdder) Adder(sessionport.rpc.duplex.relayed.example.Adder) AnAdder(sessionport.rpc.duplex.relayed.example.AnAdder)

Example 4 with DuplexRPCClientInputPort

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);
}
Also used : DuplexRPCClientInputPort(inputport.rpc.duplex.DuplexRPCClientInputPort) ACounter(examples.mvc.local.duplex.ACounter)

Example 5 with DuplexRPCClientInputPort

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);
}
Also used : ServerPortDescription(port.sessionserver.ServerPortDescription) AServerPortDescription(port.sessionserver.AServerPortDescription) RelayerSupportingSessionServer(port.sessionserver.relay.RelayerSupportingSessionServer) DuplexRPCClientInputPort(inputport.rpc.duplex.DuplexRPCClientInputPort) ARelayer(port.relay.ARelayer) Relayer(port.relay.Relayer) AServerPortDescription(port.sessionserver.AServerPortDescription) ARelayer(port.relay.ARelayer) GroupRPCServerInputPort(inputport.rpc.group.GroupRPCServerInputPort)

Aggregations

DuplexRPCClientInputPort (inputport.rpc.duplex.DuplexRPCClientInputPort)17 ConnectionListener (inputport.ConnectionListener)4 Scanner (java.util.Scanner)4 AnObjectGroupSendingConnectListener (sessionport.datacomm.group.object.example.AnObjectGroupSendingConnectListener)4 AnEchoingObjectReceiveListener (port.delay.example.AnEchoingObjectReceiveListener)3 AnObjectGroupSendingReceiveListener (port.delay.example.AnObjectGroupSendingReceiveListener)3 AServerPortDescription (port.sessionserver.AServerPortDescription)3 ServerPortDescription (port.sessionserver.ServerPortDescription)3 Adder (sessionport.rpc.duplex.relayed.example.Adder)3 AnAdder (sessionport.rpc.duplex.relayed.example.AnAdder)3 ACounter (examples.mvc.local.duplex.ACounter)2 DuplexUpperCaser (examples.mvc.local.duplex.DuplexUpperCaser)2 GroupRPCServerInputPort (inputport.rpc.group.GroupRPCServerInputPort)2 RelayerSupportingSessionServer (port.sessionserver.relay.RelayerSupportingSessionServer)2 RPCProxyGenerator (inputport.rpc.RPCProxyGenerator)1 ADuplexRPCInputPortLauncherSupport (inputport.rpc.duplex.ADuplexRPCInputPortLauncherSupport)1 PrintingTypedReceiveListener (oldtypedip.PrintingTypedReceiveListener)1 PrintingTypedReceiveListener (port.old.PrintingTypedReceiveListener)1 ARelayer (port.relay.ARelayer)1 Relayer (port.relay.Relayer)1