Package org.serviceconnector.server

Examples of org.serviceconnector.server.StatefulServer


      this.serverIndex++;
      if (this.serverIndex >= numberOfServer) {
        // serverIndex reached the end of list no more servers
        this.serverIndex = 0;
      }
      StatefulServer server = this.listOfServers.get(serverIndex);
      if (server.hasFreeSession()) {
        callback.setServer(server);
        server.addSession(session);
        try {
          server.createSession(msgToForward, callback, timeoutMillis);
        } catch (Exception e) {
          server.removeSession(session);
          callback.setServer(null);
          throw e;
        }
        return;
      }
View Full Code Here


      this.serverIndex++;
      if (this.serverIndex >= numberOfServer) {
        // serverIndex reached the end of list no more servers
        this.serverIndex = 0;
      }
      StatefulServer server = this.listOfServers.get(serverIndex);
      if (server.hasFreeSession()) {
        server.addSession(subscription);
        subscription.setServer(server);
        try {
          server.subscribe(msgToForward, callback, timeoutMillis);
        } catch (Exception e) {
          server.removeSession(subscription);
          throw e;
        }
        return;
      }
    }
View Full Code Here

        }
        throw e;
      }
    }
    ExecuteCommandCallback callback = null;
    StatefulServer server = session.getStatefulServer();
    int tries = (otiOnSCMillis / Constants.WAIT_FOR_FREE_CONNECTION_INTERVAL_MILLIS);
    // Following loop implements the wait mechanism in case of a busy connection pool
    int i = 0;
    do {
      // reset msgType, might have been modified in below execute try
      reqMessage.setMessageType(this.getKey());
      callback = new ExecuteCommandCallback(request, response, responderCallback, sessionId);
      try {
        server.execute(reqMessage, callback, otiOnSCMillis - (i * Constants.WAIT_FOR_FREE_CONNECTION_INTERVAL_MILLIS));
        // no exception has been thrown - get out of wait loop
        break;
      } catch (ConnectionPoolBusyException ex) {
        LOGGER.debug("ConnectionPoolBusyException caught in wait mec of execute, tries left=" + tries);
        if (i >= (tries - 1)) {
View Full Code Here

    case UNDEFINED:
    default:
      throw new SCMPCommandException(SCMPError.SC_ERROR, "delete session not allowed for service "
          + abstractService.getName());
    }
    StatefulServer statefulServer = (StatefulServer) abstractServer;
    DeleteSessionCommandCallback callback;
    // free server from session
    statefulServer.removeSession(session);

    int otiOnSCMillis = (int) (oti * basicConf.getOperationTimeoutMultiplier());
    int tries = (otiOnSCMillis / Constants.WAIT_FOR_FREE_CONNECTION_INTERVAL_MILLIS);
    // Following loop implements the wait mechanism in case of a busy connection pool
    int i = 0;
    do {
      // reset msgType, might have been modified in below delete session try
      reqMessage.setMessageType(this.getKey());
      callback = new DeleteSessionCommandCallback(request, response, responderCallback, session, statefulServer);
      try {
        statefulServer.deleteSession(reqMessage, callback, otiOnSCMillis
            - (i * Constants.WAIT_FOR_FREE_CONNECTION_INTERVAL_MILLIS));
        // no exception has been thrown - get out of wait loop
        break;
      } catch (ConnectionPoolBusyException ex) {
        LOGGER.debug("ConnectionPoolBusyException caught in wait mec of delete session, tries left=" + tries);
        if (i >= (tries - 1)) {
          // only one loop outstanding - don't continue throw current exception
          statefulServer.abortSession(session, "deleting session failed, connection pool to server busy");
          LOGGER.debug(SCMPError.NO_FREE_CONNECTION.getErrorText("service=" + reqMessage.getServiceName()));
          SCMPCommandException scmpCommandException = new SCMPCommandException(SCMPError.NO_FREE_CONNECTION, "service="
              + reqMessage.getServiceName());
          scmpCommandException.setMessageType(this.getKey());
          throw scmpCommandException;
View Full Code Here

    String serviceName = message.getServiceName();
    InetSocketAddress socketAddress = request.getRemoteSocketAddress();

    String serverKey = serviceName + "_" + socketAddress.getHostName() + Constants.SLASH + socketAddress.getPort();
    // looks up server & validate server is registered
    StatefulServer server = this.getStatefulServerByName(serverKey);
    // deregister server from service
    server.getService().removeServer(server);

    server.abortSessionsAndDestroy("deregister of server");
    this.serverRegistry.removeServer(serverKey);

    SCMPMessage scmpReply = new SCMPMessage();
    scmpReply.setIsReply(true);
    scmpReply.setMessageType(getKey());
View Full Code Here

    case UNDEFINED:
    default:
      throw new SCMPCommandException(SCMPError.SC_ERROR, "delete session not allowed for service "
          + abstractService.getName());
    }
    StatefulServer statefulServer = (StatefulServer) abstractServer;
    DeleteSessionCommandCallback callback;
    // free server from session
    statefulServer.removeSession(session);

    int otiOnSCMillis = (int) (oti * basicConf.getOperationTimeoutMultiplier());
    int tries = (otiOnSCMillis / Constants.WAIT_FOR_FREE_CONNECTION_INTERVAL_MILLIS);
    // Following loop implements the wait mechanism in case of a busy connection pool
    int i = 0;
    do {
      // reset msgType, might have been modified in below delete session try
      reqMessage.setMessageType(this.getKey());
      callback = new DeleteSessionCommandCallback(request, response, responderCallback, session, statefulServer);
      try {
        statefulServer.deleteSession(reqMessage, callback, otiOnSCMillis
            - (i * Constants.WAIT_FOR_FREE_CONNECTION_INTERVAL_MILLIS));
        // no exception has been thrown - get out of wait loop
        break;
      } catch (ConnectionPoolBusyException ex) {
        LOGGER.debug("ConnectionPoolBusyException caught in wait mec of delete session, tries left=" + tries);
        if (i >= (tries - 1)) {
          // only one loop outstanding - don't continue throw current exception
          statefulServer.abortSession(session, "deleting session failed, connection pool to server busy");
          LOGGER.debug(SCMPError.NO_FREE_CONNECTION.getErrorText("service=" + reqMessage.getServiceName()));
          SCMPCommandException scmpCommandException = new SCMPCommandException(SCMPError.NO_FREE_CONNECTION, "service="
              + reqMessage.getServiceName());
          scmpCommandException.setMessageType(this.getKey());
          throw scmpCommandException;
View Full Code Here

    String serviceName = message.getServiceName();
    InetSocketAddress socketAddress = request.getRemoteSocketAddress();

    String serverKey = serviceName + "_" + socketAddress.getHostName() + Constants.SLASH + socketAddress.getPort();
    // looks up server & validate server is registered
    StatefulServer server = this.getStatefulServerByName(serverKey);
    // deregister server from service
    server.getService().removeServer(server);

    server.abortSessionsAndDestroy("deregister of server");
    this.serverRegistry.removeServer(serverKey);
   
    // SCMP Version request
    SCMPMessage scmpReply = new SCMPMessage(message.getSCMPVersion());
    scmpReply.setIsReply(true);
View Full Code Here

        }
        throw e;
      }
    }
    ExecuteCommandCallback callback = null;
    StatefulServer server = session.getStatefulServer();
    int tries = (otiOnSCMillis / Constants.WAIT_FOR_FREE_CONNECTION_INTERVAL_MILLIS);
    // Following loop implements the wait mechanism in case of a busy connection pool
    int i = 0;
    do {
      // reset msgType, might have been modified in below execute try
      reqMessage.setMessageType(this.getKey());
      callback = new ExecuteCommandCallback(request, response, responderCallback, sessionId);
      try {
        server.execute(reqMessage, callback, otiOnSCMillis - (i * Constants.WAIT_FOR_FREE_CONNECTION_INTERVAL_MILLIS));
        // no exception has been thrown - get out of wait loop
        break;
      } catch (ConnectionPoolBusyException ex) {
        LOGGER.debug("ConnectionPoolBusyException caught in wait mec of execute, tries left=" + tries);
        if (i >= (tries - 1)) {
View Full Code Here

      publishMessageQueue.changeSubscription(cascSubscription.getId(), cascSCMask);
      cascSubscription.setMask(cascSCMask);
      SubscriptionLogger.logChangeSubscribe(serviceName, cascSubscription.getId(), cascadedSCMask);
    }
    // use server of cascaded client to unsubscribe
    StatefulServer server = (StatefulServer) cascSubscription.getServer();

    // unsubscribe on backend server
    CscUnsubscribeCommandCallback callback;
    int otiOnSCMillis = (int) (oti * basicConf.getOperationTimeoutMultiplier());
    int tries = (otiOnSCMillis / Constants.WAIT_FOR_FREE_CONNECTION_INTERVAL_MILLIS);
    int i = 0;
    // Following loop implements the wait mechanism in case of a busy connection pool
    do {
      // reset msgType, might have been modified in below unsubscribe try
      reqMessage.setMessageType(this.getKey());
      // set up callback for normal client unsubscribe operation
      callback = new CscUnsubscribeCommandCallback(request, response, responderCallback, cascSubscription);
      try {
        server.unsubscribe(reqMessage, callback, otiOnSCMillis - (i * Constants.WAIT_FOR_FREE_CONNECTION_INTERVAL_MILLIS));
        // delete unreferenced nodes in queue
        publishMessageQueue.removeNonreferencedNodes();
        // no exception has been thrown - get out of wait loop
        break;
      } catch (ConnectionPoolBusyException ex) {
View Full Code Here

      abortMessage.setHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT,
          SCMPError.SESSION_ABORT.getErrorText("Cascaded subscription abort received."));
      abortMessage.setServiceName(cascSubscription.getService().getName());
      abortMessage.setHeader(SCMPHeaderAttributeKey.OPERATION_TIMEOUT, oti);

      StatefulServer server = (StatefulServer) cascSubscription.getServer();

      for (String id : subscriptionIds) {
        abortMessage.setSessionId(id);
        server.abortSessionAndWaitMech(oti, abortMessage, "Cascaded subscription abort in csc unsubscribe command", true);
      }
      cascSubscription.getCscSubscriptionIds().clear();
    }
  }
View Full Code Here

TOP

Related Classes of org.serviceconnector.server.StatefulServer

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.