Search in sources :

Example 1 with ServerPortDescription

use of port.sessionserver.ServerPortDescription in project GIPC by pdewan.

the class ALatecomerRelayerAndSessionServerFactory method createLatecomerSessionsServerAndRelayer.

// @Override
// public GroupRPCServerInputPort createLatecomerSessionsServerAndRelayer(
// String aSessionServerId, String aSessionsServerName,
// String aLogicalServerName) {
// 
// 
// 
// 
// GroupRPCServerInputPort serverInputPort = GroupRPCInputPortSelector.createGroupRPCServerInputPort(
// aSessionServerId, aSessionsServerName);
// //		GroupSingleResponseSetter.supportSingleResponse(serverInputPort);
// LocalLatecomerSessionsServer sessionsServer = new ALatecomerSessionsServer(serverInputPort);
// serverInputPort.register(sessionsServer);
// //		serverInputPort.register(LatecomerSessionsServer.class, sessionsServer);
// serverInputPort.register(aSessionsServerName, sessionsServer);
// Tracer.info(this, "Created and registered Latecomer session server object connected to server port " + serverInputPort + " for " + aSessionServerId );
// GroupRPCServerInputPort relayPort = serverInputPort; // this causes confusion as multiple client input ports may be opened to same server port
// // those that will use the description should get a separate port, those who do not will simply connect to the same port
// LatecomerRelayer relayer =  LatecomerRelayerObjectSelector.createRelayer(relayPort, sessionsServer);
// relayPort.register(relayer);
// 
// //		relayPort.register(LatecomerRelayer.class, relayer);
// Tracer.info(this, "Created and registered relayer  object connected to server port " + serverInputPort);
// //		relayPort.register(aSessionsServerName, relayer);
// ServerPortDescription relayerPortDescription = new AServerPortDescription("localhost", "" + aSessionServerId, aSessionsServerName);
// Tracer.info(this, "Registering relayer description " + relayerPortDescription + " with session server");
// sessionsServer.setRelayerDescripton(relayerPortDescription);
// 
// //		serverInputPort.connect();
// return serverInputPort;
// }
@Override
public GroupRPCServerInputPort createLatecomerSessionsServerAndRelayer(String aSessionServerId, String aSessionsServerName, String aLogicalServerName) {
    GroupRPCServerInputPort serverInputPort = GroupRPCInputPortSelector.createGroupRPCServerInputPort(aSessionServerId, // group so that it can be integrated with the relayer to avoid extra port creation and message cost
    aSessionsServerName);
    // GroupSingleResponseSetter.supportSingleResponse(serverInputPort);
    LocalLatecomerSessionsServer sessionsServer = new ALatecomerSessionServer(serverInputPort);
    serverInputPort.register(sessionsServer);
    // serverInputPort.register(LatecomerSessionsServer.class, sessionsServer);
    serverInputPort.register(aSessionsServerName, sessionsServer);
    serverInputPort.register(aLogicalServerName, sessionsServer);
    Tracer.info(this, "Created and registered Latecomer session server object connected to server port " + serverInputPort + " for " + aSessionServerId);
    // this causes confusion as multiple client input ports may be opened to same server port
    // however, registering under a different port means an additional port must be chosen and used
    // best to let the client be aware that the session server is also the relayer
    // by sending null fields in the server port description
    GroupRPCServerInputPort relayPort = serverInputPort;
    // ServerPortDescription relayerPortDescription = new AServerPortDescription("localhost", "" + aSessionServerId, aSessionsServerName);
    // ServerPortDescription relayerPortDescription = new AServerPortDescription(null, null, null);
    // for some reason I put null here instead of a server port description
    ServerPortDescription relayerPortDescription = null;
    // GroupRPCServerInputPort relayPort = GroupRPCInputPortSelector.createGroupRPCServerInputPort(
    // relayerPortDescription.getID(), relayerPortDescription.getName());
    // those that will use the description should get a separate port, those who do not will simply connect to the same port
    LatecomerRelayer relayer = LatecomerRelayerObjectSelector.createRelayer(relayPort, sessionsServer);
    relayPort.register(relayer);
    // relayPort.register(LatecomerRelayer.class, relayer);
    Tracer.info(this, "Created and registered relayer  object connected to server port " + serverInputPort);
    // relayPort.register(aSessionsServerName, relayer);
    // regster after creating the relayer
    sessionsServer.setRelayerDescripton(relayerPortDescription);
    Tracer.info(this, "Registered relayer description " + relayerPortDescription + " with session server");
    // serverInputPort.connect();
    return serverInputPort;
}
Also used : ServerPortDescription(port.sessionserver.ServerPortDescription) GroupRPCServerInputPort(inputport.rpc.group.GroupRPCServerInputPort)

Example 2 with ServerPortDescription

use of port.sessionserver.ServerPortDescription in project GIPC by pdewan.

the class ARelayerConnectingConnectListener method participateInSession.

@Override
protected void participateInSession() {
    ConnectionListener connectionListener = ASessionServerClientLauncher.createParticipatingConnectionListener(inputPort, participantChoice, ARelayerSupportingSessionServer.class, serverPortDescription, sessionObserver, uiCreator);
    ServerPortDescription relayerDesccription = ((RelayerSupportingSessionServer) sessionServerProxy).getRelayerDescripton(sessionName);
    if (relayerDesccription == null) {
        relayerPort = (DuplexRPCClientInputPort) inputPort;
    // relayerPort.addReceiveListener(receiveListener);
    // connectionListener.connected(relayerPort.getLogicalRemoteEndPoint()); // fake a connection
    // return;
    } else {
        relayerPort = DuplexRPCInputPortSelector.createDuplexRPCClientInputPort(relayerDesccription.getHost(), relayerDesccription.getID(), relayerDesccription.getName(), myName);
    }
    try {
        relayerProxy = (Relayer) DirectedRPCProxyGenerator.generateRPCProxy((DuplexRPCClientInputPort) relayerPort, null, ARelayer.class, null);
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (// JOIN_ONLY
    sessionObserver != null)
        sessionObserver.setRelayerProxy(relayerProxy);
    // relayerPort.addConnectionListener(
    // ASessionServerClientLauncher.createParticipatingConnectionListener(
    // inputPort, participantChoice, RelayerSupportingSessionServer.class,  serverPortDescription, sessionObserver, uiCreator));
    relayerPort.addReceiveListener(receiveListener);
    if (relayerPort != inputPort) {
        relayerPort.addConnectionListener(connectionListener);
        // relayerPort.addReceiveListener(receiveListener);
        relayerPort.connect();
    } else {
        // fake a connection
        connectionListener.connected(relayerPort.getLogicalRemoteEndPoint(), null);
    }
}
Also used : ServerPortDescription(port.sessionserver.ServerPortDescription) RelayerSupportingSessionServer(port.sessionserver.relay.RelayerSupportingSessionServer) ARelayerSupportingSessionServer(port.sessionserver.relay.ARelayerSupportingSessionServer) ConnectionListener(inputport.ConnectionListener)

Example 3 with ServerPortDescription

use of port.sessionserver.ServerPortDescription in project GIPC by pdewan.

the class ADelayingRelayingSessionsServerLauncher method main.

public static void main(String[] args) {
    // Tracer.showInfo(true);
    // Message.setKeyWordStatus(Message.ALL_KEYWORDS, false);
    // Message.setKeyWordStatus("nioip", true);
    // GlobalState.setDelayServerBufferSends(true);
    // GlobalState.getDelayManager().setMinimumDelay("Alice", 1000);
    // GlobalState.getDelayManager().setMinimumDelay("Bob", 100);
    // GlobalState.getDelayManager().setMinimumDelay("Cathy", 500);
    // GroupRPCServerInputPort serverInputPort = GroupRPCInputPortSelector.createGroupRPCServerInputPort("" +
    // ASessionsServer.SESSION_SERVER_PORT, ASessionsServer.SESSION_SERVER_NAME);
    DuplexRPCServerInputPort serverInputPort = DuplexRPCInputPortSelector.createDuplexRPCServerInputPort("" + SESSION_SERVER_PORT, SESSION_SERVER_NAME);
    RelayerSupportingSessionServer sessionServer = new ARelayerSupportingSessionServer(serverInputPort);
    ServerPortDescription serverPortDescription = new AServerPortDescription("localhost", "" + RELAYER_PORT, RELAYER_NAME);
    sessionServer.setRelayerDescripton(serverPortDescription);
    serverInputPort.register(RelayerSupportingSessionServer.class, sessionServer);
    serverInputPort.register(SESSION_SERVER_NAME, sessionServer);
    serverInputPort.connect();
    GroupRPCServerInputPort relayerPort = GroupRPCInputPortSelector.createGroupRPCServerInputPort("" + RELAYER_PORT, RELAYER_NAME);
    Relayer relayer = new ARelayer(relayerPort);
    relayerPort.register(Relayer.class, relayer);
    serverInputPort.register(RELAYER_NAME, relayer);
    relayerPort.connect();
}
Also used : RelayerSupportingSessionServer(port.sessionserver.relay.RelayerSupportingSessionServer) ARelayerSupportingSessionServer(port.sessionserver.relay.ARelayerSupportingSessionServer) ServerPortDescription(port.sessionserver.ServerPortDescription) AServerPortDescription(port.sessionserver.AServerPortDescription) ARelayer(port.relay.ARelayer) Relayer(port.relay.Relayer) AServerPortDescription(port.sessionserver.AServerPortDescription) ARelayer(port.relay.ARelayer) DuplexRPCServerInputPort(inputport.rpc.duplex.DuplexRPCServerInputPort) ARelayerSupportingSessionServer(port.sessionserver.relay.ARelayerSupportingSessionServer) GroupRPCServerInputPort(inputport.rpc.group.GroupRPCServerInputPort)

Example 4 with ServerPortDescription

use of port.sessionserver.ServerPortDescription 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)

Example 5 with ServerPortDescription

use of port.sessionserver.ServerPortDescription in project GIPC by pdewan.

the class ARelayingDuplexConnectionsManager method getAndConnectToRelayer.

protected void getAndConnectToRelayer() {
    try {
        // sessionServerProxy = (RelayingSessionsServer)
        // UniRPCProxyGenerator.generateUniRPCProxy(sessionsServerInputPort,
        // null,
        // RelayingSessionsServer.class, null);
        // List<ServerPortDescription> currentMembers =
        // sessionServerProxy.join(aSessionName, aSessionClientDescription,
        // this);
        ServerPortDescription relayerDescription = logicalSessionsServerProxy.getRelayerDescripton(sessionName);
        if (relayerDescription == null) {
            // Tracer.error("No relayer registered with session server. Will not be able to send messages");
            // already regiustered as send and receive listener to this port
            relayerClientInputPort = sessionServerClientPort;
            Tracer.info(this, "No separate relayer port, using session server as relayer");
            processRelayerConnect(sessionServerClientPort.getLogicalRemoteEndPoint(), ConnectionType.TO_SERVER);
        } else {
            relayerClientInputPort = DuplexRPCInputPortSelector.createDuplexRPCClientInputPort(relayerDescription.getHost(), relayerDescription.getID(), relayerDescription.getName(), // duplexObjectSessionPort.getLocalName()));
            duplexObjectSessionPort.getLocalName());
            // relayerName = relayerDescription.getName();
            Tracer.info(this, "Created relayer client port " + relayerClientInputPort + " for " + relayerDescription);
            Tracer.info(this, "Registering as receive and send listener for " + relayerClientInputPort);
            ConnectiontEventBus.newEvent(new AConnectionEvent(this, relayerClientInputPort, true));
            relayerClientInputPort.addConnectionListener(this);
            relayerClientInputPort.addReceiveListener(this);
            relayerClientInputPort.addSendListener(this);
            // setRelayerProxy();
            // relayerProxy = (Relayer)
            // UniRPCProxyGenerator.generateUniRPCProxy(relayerClientInputPort,
            // null,
            // Relayer.class, null);
            relayerClientInputPort.connect();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
// List<ServerPortDescription> currentMembers =
// sessionServerProxy.join(sessionName, sessionClientDescription, this);
}
Also used : ServerPortDescription(port.sessionserver.ServerPortDescription) AConnectionEvent(util.trace.port.AConnectionEvent)

Aggregations

ServerPortDescription (port.sessionserver.ServerPortDescription)14 AServerPortDescription (port.sessionserver.AServerPortDescription)11 GroupRPCServerInputPort (inputport.rpc.group.GroupRPCServerInputPort)7 RelayerSupportingSessionServer (port.sessionserver.relay.RelayerSupportingSessionServer)4 DuplexRPCClientInputPort (inputport.rpc.duplex.DuplexRPCClientInputPort)3 ARelayer (port.relay.ARelayer)2 Relayer (port.relay.Relayer)2 JoinInfo (port.sessionserver.JoinInfo)2 SessionParticipantDescription (port.sessionserver.SessionParticipantDescription)2 ARelayerSupportingSessionServer (port.sessionserver.relay.ARelayerSupportingSessionServer)2 ConnectionListener (inputport.ConnectionListener)1 DuplexRPCServerInputPort (inputport.rpc.duplex.DuplexRPCServerInputPort)1 SessionObserver (port.sessionserver.SessionObserver)1 SessionServer (port.sessionserver.SessionServer)1 ARelayingSession (port.sessionserver.relay.ARelayingSession)1 RelayingSession (port.sessionserver.relay.RelayingSession)1 Adder (sessionport.rpc.duplex.relayed.example.Adder)1 AnAdder (sessionport.rpc.duplex.relayed.example.AnAdder)1 AConnectionEvent (util.trace.port.AConnectionEvent)1