Search in sources :

Example 1 with GroupRPCSessionPort

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();
}
Also used : Scanner(java.util.Scanner) GroupRPCSessionPort(sessionport.rpc.group.GroupRPCSessionPort) AnOldGroupCallingConnectListener(sessionport.rpc.group.AnOldGroupCallingConnectListener) ConnectionListener(inputport.ConnectionListener) AnAdder(sessionport.rpc.duplex.relayed.example.AnAdder) Adder(sessionport.rpc.duplex.relayed.example.Adder) AnAdder(sessionport.rpc.duplex.relayed.example.AnAdder)

Example 2 with GroupRPCSessionPort

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();
}
Also used : GroupRPCSessionPort(sessionport.rpc.group.GroupRPCSessionPort) AnOldGroupCallingConnectListener(sessionport.rpc.group.AnOldGroupCallingConnectListener) ConnectionListener(inputport.ConnectionListener) AnAdder(sessionport.rpc.duplex.relayed.example.AnAdder) Adder(sessionport.rpc.duplex.relayed.example.Adder) AnAdder(sessionport.rpc.duplex.relayed.example.AnAdder)

Example 3 with GroupRPCSessionPort

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);
}
Also used : GroupRPCSessionPort(sessionport.rpc.group.GroupRPCSessionPort) DuplexCounterAndSenderAwareSummer(inputport.rpc.duplex.example.DuplexCounterAndSenderAwareSummer) AGroupCounterAndSenderAwareSumPrinter(inputport.rpc.group.example.AGroupCounterAndSenderAwareSumPrinter) ARegisteredEchoer(inputport.rpc.duplex.example.ARegisteredEchoer)

Example 4 with GroupRPCSessionPort

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);
}
Also used : Scanner(java.util.Scanner) GroupRPCSessionPort(sessionport.rpc.group.GroupRPCSessionPort) DuplexCounterAndSenderAwareSummer(inputport.rpc.duplex.example.DuplexCounterAndSenderAwareSummer) AnUnregisteredEchoer(inputport.rpc.duplex.example.AnUnregisteredEchoer)

Aggregations

GroupRPCSessionPort (sessionport.rpc.group.GroupRPCSessionPort)4 ConnectionListener (inputport.ConnectionListener)2 DuplexCounterAndSenderAwareSummer (inputport.rpc.duplex.example.DuplexCounterAndSenderAwareSummer)2 Scanner (java.util.Scanner)2 Adder (sessionport.rpc.duplex.relayed.example.Adder)2 AnAdder (sessionport.rpc.duplex.relayed.example.AnAdder)2 AnOldGroupCallingConnectListener (sessionport.rpc.group.AnOldGroupCallingConnectListener)2 ARegisteredEchoer (inputport.rpc.duplex.example.ARegisteredEchoer)1 AnUnregisteredEchoer (inputport.rpc.duplex.example.AnUnregisteredEchoer)1 AGroupCounterAndSenderAwareSumPrinter (inputport.rpc.group.example.AGroupCounterAndSenderAwareSumPrinter)1