Package org.serviceconnector.server

Examples of org.serviceconnector.server.StatefulServer


      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

      return;
    default:
      // code for other types of services is below
      break;
    }
    StatefulServer server = (StatefulServer) cascSubscription.getServer();

    PublishMessageQueue<SCMPMessage> publishMessageQueue = ((IPublishService) cascSubscription.getService()).getMessageQueue();
    if (cascadedSCMask == null) {
      // subscription abort made by cascaded SC on behalf of his last client
      this.subscriptionRegistry.removeSubscription(cascSubscription.getId());
      publishMessageQueue.unsubscribe(cascSubscription.getId());
      cascSubscription.getServer().removeSession(cascSubscription);
      SubscriptionLogger.logUnsubscribe(serviceName, cascSubscription.getId());
    } else {
      // unsubscribe made by cascaded SC on behalf of a clients, others are left
      SubscriptionMask cascSCMask = new SubscriptionMask(cascadedSCMask);
      publishMessageQueue.changeSubscription(cascSubscription.getId(), cascSCMask);
      cascSubscription.setMask(cascSCMask);
      SubscriptionLogger.logChangeSubscribe(serviceName, cascSubscription.getId(), cascadedSCMask);
    }
    // set up abort message
    SCMPMessage abortMessage = new SCMPMessage();
    abortMessage.setHeader(SCMPHeaderAttributeKey.SC_ERROR_CODE, SCMPError.SESSION_ABORT.getErrorCode());
    abortMessage.setHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT,
        SCMPError.SESSION_ABORT.getErrorText("Cascaded subscription abort received."));
    abortMessage.setServiceName(serviceName);
    abortMessage.setSessionId(reqMessage.getSessionId());
    abortMessage.setHeader(SCMPHeaderAttributeKey.OPERATION_TIMEOUT, oti);
    server.abortSessionAndWaitMech(oti, abortMessage, "Cascaded subscription abort received", true);
    // reply to client
    reqMessage.setIsReply(true);
    response.setSCMP(reqMessage);
    responderCallback.responseCallback(request, response);
    // delete unreferenced nodes in queue
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 abort command", true);
      }
      cascSubscription.getCscSubscriptionIds().clear();
    }
  }
View Full Code Here

      // code for other types of services is below
      break;
    }

    ClnChangeSubscriptionCommandCallback callback = null;
    StatefulServer server = (StatefulServer) subscription.getServer();
    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 ipList&msgType, might have been modified in below change subscription try
      reqMessage.setHeader(SCMPHeaderAttributeKey.IP_ADDRESS_LIST, ipAddressList);
      reqMessage.setMessageType(this.getKey());
      callback = new ClnChangeSubscriptionCommandCallback(request, response, responderCallback, subscription);
      try {
        server.changeSubscription(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 change subscription, tries left=" + tries);
View Full Code Here

      return;
    default:
      // code for other types of services is below
      break;
    }
    StatefulServer server = (StatefulServer) subscription.getServer();
    ClnUnsubscribeCommandCallback callback = null;
    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 ClnUnsubscribeCommandCallback(request, response, responderCallback, subscription);
      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) {
        LOGGER.debug("ConnectionPoolBusyException caught in wait mec of unsubscribe, tries left=" + tries);
        if (i >= (tries - 1)) {
          // only one loop outstanding - don't continue throw current exception
          server.abortSession(subscription, "unsubscribe subscription 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

        }
        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 csc execute, tries left=" + tries);
        if (i >= (tries - 1)) {
View Full Code Here

      return;
    default:
      // code for other types of services is below
      break;
    }
    StatefulServer server = (StatefulServer) cascSubscription.getServer();
    CscChangeSubscriptionCallbackForCasc callback = null;
    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 ipList&msgType, might have been modified in below change subscription try
      reqMessage.setHeader(SCMPHeaderAttributeKey.IP_ADDRESS_LIST, ipAddressList);
      reqMessage.setMessageType(this.getKey());
      callback = new CscChangeSubscriptionCallbackForCasc(request, response, responderCallback, cascSubscription,
          cascadedSCMask);
      try {
        server.changeSubscription(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 csc change subscription, tries left=" + tries);
View Full Code Here

    RemoteNodeConfiguration remoteNodeConfiguration = new RemoteNodeConfiguration(ServerType.STATEFUL_SERVER, serverKey,
        socketAddress.getHostName(), portNr, connectionType, keepAliveIntervalSeconds, checkRegistrationIntervalSeconds,
        maxConnections, maxSessions, httpUrlFileQualifier);
    // create new server
    StatefulServer server = new StatefulServer(remoteNodeConfiguration, serviceName, socketAddress);
    try {
      if (immediateConnect) {
        // server connections get connected immediately
        server.immediateConnect();
      }
    } catch (Exception ex) {
      LOGGER.error("immediate connect", ex);
      HasFaultResponseException communicationException = new SCMPCommunicationException(SCMPError.CONNECTION_EXCEPTION,
          "immediate connect to server=" + serverKey);
      communicationException.setMessageType(getKey());
      throw communicationException;
    }
    // add server to service
    service.addServer(server);
    // add service to server
    server.setService(service);
    // add server to server registry
    this.serverRegistry.addServer(serverKey, server);

    SCMPMessage scmpReply = new SCMPMessage();
    scmpReply.setIsReply(true);
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 csc 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

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.