Package org.serviceconnector.net.connection

Examples of org.serviceconnector.net.connection.IConnection


    message.setMessageType(SCMPMsgType.ATTACH);
    message.setHeader(SCMPHeaderAttributeKey.SC_VERSION, SCVersion.CURRENT.toString());
    message.setHeader(SCMPHeaderAttributeKey.LOCAL_DATE_TIME, ldt);

    for (int i = 0; i < 10000; i++) {
      IConnection connection = connectionPool.getConnection();
      TestCallback cbk = new TestCallback();
      connection.send(message, cbk);
      cbk.getMessageSync(1000);
      connectionPool.freeConnection(connection);
      if ((i + 1) % 5000 == 0) {
        testLogger.info("connection nr " + (i + 1) + "...");
      }
View Full Code Here


    message.setHeader(SCMPHeaderAttributeKey.LOCAL_DATE_TIME, ldt);

    for (int i = 0; i < 10000; i++) {
      ConnectionPool cp = new ConnectionPool(TestConstants.HOST, this.port, this.connectionType.getValue(),
          this.keepAliveSeconds, this.keepAliveOTIMillis);
      IConnection connection = cp.getConnection();
      TestCallback cbk = new TestCallback();
      connection.send(message, cbk);
      cbk.getMessageSync(1000);
      cp.freeConnection(connection);
      cp.destroy();
      if ((i + 1) % 5000 == 0) {
        testLogger.info("connection nr " + (i + 1) + "...");
View Full Code Here

   * Expectation: passes
   */
  @Test
  public void t01_Send50000() throws Exception {
    ConnectionFactory connectionFactory = AppContext.getConnectionFactory();
    IConnection connection = connectionFactory.createConnection(ConnectionType.NETTY_HTTP.getValue());
    connection.setHost(TestConstants.HOST);
    connection.setPort(TestConstants.PORT_SC0_HTTP);
    connection.setIdleTimeoutSeconds(0); // idle timeout inactive
    IIdleConnectionCallback idleCallback = new IdleCallback();
    ConnectionContext connectionContext = new ConnectionContext(connection, idleCallback, 0);
    connection.setContext(connectionContext);
    String ldt = DateTimeUtility.getCurrentTimeZoneMillis();

    SCMPMessage message = new SCMPMessage();
    message.setMessageType(SCMPMsgType.ATTACH);
    message.setHeader(SCMPHeaderAttributeKey.SC_VERSION, SCVersion.CURRENT.toString());
    message.setHeader(SCMPHeaderAttributeKey.LOCAL_DATE_TIME, ldt);
    connection.connect();

    for (int i = 0; i < 50000; i++) {
      TestCallback cbk = new TestCallback();
      connection.send(message, cbk);
      TestUtil.checkReply(cbk.getMessageSync(3000));
      if ((i + 1) % 10000 == 0) {
        testLogger.info("message nr " + (i + 1) + "...");
      }
    }
    connection.disconnect();
  }
View Full Code Here

   * Expectation: passes
   */
  @Test
  public void t01_ConnectSendAndDisconnect50000() throws Exception {
    ConnectionFactory connectionFactory = AppContext.getConnectionFactory();
    IConnection connection = connectionFactory.createConnection(ConnectionType.NETTY_HTTP.getValue());
    connection.setHost(TestConstants.HOST);
    connection.setPort(TestConstants.PORT_SC0_HTTP);
    connection.setIdleTimeoutSeconds(0); // idle timeout inactive
    IIdleConnectionCallback idleCallback = new IdleCallback();
    ConnectionContext connectionContext = new ConnectionContext(connection, idleCallback, 0);
    connection.setContext(connectionContext);
    String ldt = DateTimeUtility.getCurrentTimeZoneMillis();

    SCMPMessage message = new SCMPMessage();
    message.setMessageType(SCMPMsgType.ATTACH);
    message.setHeader(SCMPHeaderAttributeKey.SC_VERSION, SCVersion.CURRENT.toString());
    message.setHeader(SCMPHeaderAttributeKey.LOCAL_DATE_TIME, ldt);

    for (int i = 0; i < 50000; i++) {
      connection.connect();
      TestCallback cbk = new TestCallback();
      connection.send(message, cbk);
      TestUtil.checkReply(cbk.getMessageSync(3000));
      connection.disconnect();
      if ((i + 1) % 1000 == 0) {
        testLogger.info("connection nr " + (i + 1) + "...");
      }
    }
  }
View Full Code Here

    message.setHeader(SCMPHeaderAttributeKey.SC_VERSION, SCVersion.CURRENT.toString());
    message.setHeader(SCMPHeaderAttributeKey.LOCAL_DATE_TIME, ldt);

    for (int i = 0; i < numberOfConnections; i++) {
      ConnectionFactory connectionFactory = AppContext.getConnectionFactory();
      IConnection connection = connectionFactory.createConnection(ConnectionType.NETTY_HTTP.getValue());
      connections[i] = connection;
      connection.setHost(TestConstants.HOST);
      connection.setPort(TestConstants.PORT_SC0_HTTP);
      connection.setIdleTimeoutSeconds(0);
      IIdleConnectionCallback idleCallback = new IdleCallback();
      ConnectionContext connectionContext = new ConnectionContext(connection, idleCallback, 0);
      connection.setContext(connectionContext);
      connection.connect();
      TestCallback cbk = new TestCallback();
      connection.send(message, cbk);
      TestUtil.checkReply(cbk.getMessageSync(3000));
      if ((i + 1) % 100 == 0) {
        testLogger.info("connection nr " + (i + 1) + "...");
      }
    }
View Full Code Here

  /** {@inheritDoc} */
  @SuppressWarnings("unchecked")
  @Override
  public void send(SCMPMessage message, int timeoutMillis, ISCMPMessageCallback scmpCallback) throws Exception {
    // return an already connected live instance
    IConnection connection = this.connectionPool.getConnection();
    ConnectionContext connectionContext = connection.getContext();

    try {
      ISCMPMessageCallback requesterCallback = null;
      // differ if message is large or not, sending procedure is different
      if (message.isLargeMessage()) {
        // SCMPLargeRequest handles splitting, works like an iterator
        SCMPCompositeSender largeResponse = new SCMPCompositeSender(message);
        requesterCallback = new SCRequesterSCMPCallback(message, scmpCallback, connectionContext, largeResponse,
            msgSequenceNr);
        // setting up operation timeout after successful send
        TimeoutWrapper timeoutWrapper = new TimeoutWrapper((ITimeout) requesterCallback);
        SCRequesterSCMPCallback reqCallback = (SCRequesterSCMPCallback) requesterCallback;
        ScheduledFuture<TimeoutWrapper> timeout = (ScheduledFuture<TimeoutWrapper>) AppContext.otiScheduler.schedule(
            timeoutWrapper, (long) timeoutMillis, TimeUnit.MILLISECONDS);
        reqCallback.setOperationTimeout(timeout);
        reqCallback.setTimeoutMillis(timeoutMillis);
        // extract first part message & send
        SCMPMessage part = largeResponse.getFirst();
        // handling msgSequenceNr
        if (SCMPMessageSequenceNr.necessaryToWrite(message.getMessageType())) {
          part.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, msgSequenceNr.getCurrentNr());
        }
        // send
        connection.send(part, requesterCallback);
      } else {
        requesterCallback = new SCRequesterSCMPCallback(message, scmpCallback, connectionContext, msgSequenceNr);
        // setting up operation timeout after successful send
        TimeoutWrapper timeoutWrapper = new TimeoutWrapper((ITimeout) requesterCallback);
        SCRequesterSCMPCallback reqCallback = (SCRequesterSCMPCallback) requesterCallback;
        ScheduledFuture<TimeoutWrapper> timeout = (ScheduledFuture<TimeoutWrapper>) AppContext.otiScheduler.schedule(
            timeoutWrapper, (long) timeoutMillis, TimeUnit.MILLISECONDS);
        reqCallback.setOperationTimeout(timeout);
        reqCallback.setTimeoutMillis(timeoutMillis);
        // handling msgSequenceNr
        if (SCMPMessageSequenceNr.necessaryToWrite(message.getMessageType())) {
          message.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, msgSequenceNr.getCurrentNr());
        }
        // process send
        connection.send(message, requesterCallback);
      }
    } catch (Exception ex) {
      this.connectionPool.freeConnection(connection);
      throw ex;
    }
View Full Code Here

TOP

Related Classes of org.serviceconnector.net.connection.IConnection

Copyright © 2018 www.massapicom. 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.