Examples of ProtocolSession


Examples of org.apache.mina.protocol.ProtocolSession

    protected void processEvent( Object nextFilter0,
                               Session session0, EventType type,
                               Object data )
    {
        NextFilter nextFilter = ( NextFilter ) nextFilter0;
        ProtocolSession session = ( ProtocolSession ) session0;

        if( type == EventType.RECEIVED )
        {
            nextFilter.messageReceived( session, data );
        }
View Full Code Here

Examples of org.apache.mina.protocol.ProtocolSession

        Service service = new Service( "tennis", TransportType.VM_PIPE, address );
        registry.bind( service, new TennisPlayer() );

        // Connect to the server.
        VmPipeConnector connector = new VmPipeConnector();
        ProtocolSession session = connector.connect( address,
                                                     new TennisPlayer() );

        // Send the first ping message
        session.write( new TennisBall( 10 ) );

        // Wait until the match ends.
        while( session.isConnected() )
        {
            Thread.sleep( 100 );
        }
       
        registry.unbind( service );
View Full Code Here

Examples of org.apache.mina.protocol.ProtocolSession

                ioThreadPoolFilter );
        connector.getFilterChain().addFirst( "threadPool",
                protocolThreadPoolFilter );

        ProtocolProvider protocolProvider = new ClientProtocolProvider( values );
        ProtocolSession session;
        for( ;; )
        {
            try
            {
                session = connector.connect( new InetSocketAddress( HOSTNAME,
                        PORT ), CONNECT_TIMEOUT, protocolProvider );
                break;
            }
            catch( IOException e )
            {
                System.err.println( "Failed to connect." );
                e.printStackTrace();
                Thread.sleep( 5000 );
            }
        }

        // wait until the summation is done
        while( session.isConnected() )
        {
            Thread.sleep( 100 );
        }

        ioThreadPoolFilter.stop();
View Full Code Here

Examples of org.apache.mina.protocol.ProtocolSession

        Service service = new Service( "tennis", TransportType.VM_PIPE, address );
        registry.bind( service, new TennisPlayer() );

        // Connect to the server.
        VmPipeConnector connector = new VmPipeConnector();
        ProtocolSession session = connector.connect( address,
                                                     new TennisPlayer() );

        // Send the first ping message
        session.write( new TennisBall( 10 ) );

        // Wait until the match ends.
        while( session.isConnected() )
        {
            Thread.sleep( 100 );
        }
       
        registry.unbind( service );
View Full Code Here

Examples of org.apache.mina.protocol.ProtocolSession

    protected void processEvent( Object nextFilter0,
                               Session session0, EventType type,
                               Object data )
    {
        NextFilter nextFilter = ( NextFilter ) nextFilter0;
        ProtocolSession session = ( ProtocolSession ) session0;

        if( type == EventType.RECEIVED )
        {
            nextFilter.messageReceived( session, data );
        }
View Full Code Here

Examples of org.apache.mina.protocol.ProtocolSession

    protected void processEvent( Object nextFilter0,
                               Session session0, EventType type,
                               Object data )
    {
        NextFilter nextFilter = ( NextFilter ) nextFilter0;
        ProtocolSession session = ( ProtocolSession ) session0;

        if( type == EventType.RECEIVED )
        {
            nextFilter.messageReceived( session, data );
        }
View Full Code Here

Examples of org.apache.mina.protocol.ProtocolSession

                ioThreadPoolFilter );
        connector.getFilterChain().addFirst( "threadPool",
                protocolThreadPoolFilter );

        ProtocolProvider protocolProvider = new ClientProtocolProvider( values );
        ProtocolSession session;
        for( ;; )
        {
            try
            {
                session = connector.connect( new InetSocketAddress( HOSTNAME,
                        PORT ), CONNECT_TIMEOUT, protocolProvider );
                break;
            }
            catch( IOException e )
            {
                System.err.println( "Failed to connect." );
                e.printStackTrace();
                Thread.sleep( 5000 );
            }
        }

        // wait until the summation is done
        while( session.isConnected() )
        {
            Thread.sleep( 100 );
        }

        ioThreadPoolFilter.stop();
View Full Code Here

Examples of org.apache.mina.protocol.ProtocolSession

        Service service = new Service( "tennis", TransportType.VM_PIPE, address );
        registry.bind( service, new TennisPlayer() );

        // Connect to the server.
        VmPipeConnector connector = new VmPipeConnector();
        ProtocolSession session = connector.connect( address,
                                                     new TennisPlayer() );

        // Send the first ping message
        session.write( new TennisBall( 10 ) );

        // Wait until the match ends.
        while( session.isConnected() )
        {
            Thread.sleep( 100 );
        }
       
        registry.unbind( service );
View Full Code Here

Examples of org.nasutekds.server.replication.protocol.ProtocolSession

    Socket socket = new Socket();
    socket.setReceiveBufferSize(1000000);
    socket.setTcpNoDelay(true);
    socket.connect(ServerAddr, 500);
    ReplSessionSecurity replSessionSecurity = getReplSessionSecurity();
    ProtocolSession session =
         replSessionSecurity.createClientSession(serverURL, socket,
         ReplSessionSecurity.HANDSHAKE_TIMEOUT);

    boolean sslEncryption =
         DirectoryConfig.getCryptoManager().isSslEncryption();

    try
    {
      // send a ServerStartMsg with an empty ServerState.
      ServerStartMsg msg =
        new ServerStartMsg( 1723, TEST_ROOT_DN_STRING,
            WINDOW, (long) 5000, new ServerState(),
            ProtocolVersion.getCurrentVersion(), 0, sslEncryption, (byte)-1);
      session.publish(msg);

      // Read the Replication Server state from the ReplServerStartDSMsg that
      // comes back.
      ReplServerStartDSMsg replStartDSMsg =
        (ReplServerStartDSMsg) session.receive();
      int serverwindow = replStartDSMsg.getWindowSize();
      ServerState replServerState = replStartDSMsg.getServerState();

      if (!sslEncryption)
      {
        session.stopEncryption();
      }

      // Send StartSessionMsg
      StartSessionMsg startSessionMsg =
        new StartSessionMsg(ServerStatus.NORMAL_STATUS,
        new ArrayList<String>());
      session.publish(startSessionMsg);

      // Read the TopologyMsg that should come back.
      ReplicationMsg repMsg = session.receive();
      assertTrue(repMsg instanceof TopologyMsg);

      // close the session
      session.close();

      // Sleep a while so the following connection is not perturbed by some
      // topo messages signalling first connection has been dropped: let
      // disocnnection fully happen before, connecting a second session
      Thread.sleep(2000);

      // open a new session to the replication Server
      socket = new Socket();
      socket.setReceiveBufferSize(1000000);
      socket.setTcpNoDelay(true);
      socket.connect(ServerAddr, 500);
      session = replSessionSecurity.createClientSession(serverURL, socket, 4000);

      // send a ServerStartMsg containing the ServerState that was just
      // received.
      DN baseDn = DN.decode(TEST_ROOT_DN_STRING);
      msg = new ServerStartMsg(
           1724, TEST_ROOT_DN_STRING,
          WINDOW, (long) 5000, replServerState,
          ProtocolVersion.getCurrentVersion(),
          ReplicationTestCase.getGenerationId(baseDn),
          sslEncryption, (byte)10);
      session.publish(msg);

      // Read the ReplServerStartDSMsg that should come back.
      repMsg = session.receive();
      assertTrue(repMsg instanceof ReplServerStartDSMsg);

      if (!sslEncryption)
      {
        session.stopEncryption();
      }

      // Send StartSessionMsg
      startSessionMsg = new StartSessionMsg(ServerStatus.NORMAL_STATUS,
        new ArrayList<String>());
      session.publish(startSessionMsg);

      // Read the TopologyMsg that should come back.
      repMsg = session.receive();
      assertTrue(repMsg instanceof TopologyMsg);

      // Now comes the real test : check that the Replication Server
      // answers correctly to a WindowProbeMsg Message.
      session.publish(new WindowProbeMsg());

      WindowMsg windowMsg = (WindowMsg) session.receive();
      assertEquals(serverwindow, windowMsg.getNumAck());

      // check that this did not change the window by sending a probe again.
      session.publish(new WindowProbeMsg());

      // We may receive some MonitoringMsg so use filter method
      windowMsg = (WindowMsg)waitForSpecificMsg(session, WindowMsg.class.getName());
      assertEquals(serverwindow, windowMsg.getNumAck());
      debugInfo("Ending windowProbeTest");
    }
    finally
    {
      session.close();
    }
  }
View Full Code Here

Examples of org.nasutekds.server.replication.protocol.ProtocolSession

    {
      // Wait on the replicationServer port.
      // Read incoming messages and create LDAP or ReplicationServer listener
      // and Publisher.

      ProtocolSession session;
      Socket newSocket = null;

      try
      {
        try
        {
          newSocket = listenSocket.accept();
          newSocket.setTcpNoDelay(true);
          newSocket.setKeepAlive(true);
          session =
            replSessionSecurity.createServerSession(newSocket,
                ReplSessionSecurity.HANDSHAKE_TIMEOUT);
          if (session == null) // Error, go back to accept
            continue;
        }
        catch (Exception e)
        {
          // If problems happen during the SSL handshake, it is necessary
          // to close the socket to free the associated resources.
          if (newSocket != null)
            newSocket.close();
          continue;
        }

        ReplicationMsg msg = session.receive();

        if (msg instanceof ServerStartMsg)
        {
          session.setProtocolVersion(((StartMsg)msg).getVersion());
          DataServerHandler handler = new DataServerHandler(session,
              queueSize,serverURL,serverId,this,rcvWindow);
          handler.startFromRemoteDS((ServerStartMsg)msg);
        }
        else if (msg instanceof ReplServerStartMsg)
        {
          session.setProtocolVersion(((StartMsg)msg).getVersion());
          ReplicationServerHandler handler = new ReplicationServerHandler(
              session,queueSize,serverURL,serverId,this,rcvWindow);
          handler.startFromRemoteRS((ReplServerStartMsg)msg);
        }
        else if (msg instanceof ServerStartECLMsg)
        {
          session.setProtocolVersion(((StartMsg)msg).getVersion());
          ECLServerHandler handler = new ECLServerHandler(
              session,queueSize,serverURL,serverId,this,rcvWindow);
          handler.startFromRemoteServer((ServerStartECLMsg)msg);
        }
        else
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.