Package org.serviceconnector.cmd.sc

Examples of org.serviceconnector.cmd.sc.CommandCallback


      message.setHeader(SCMPHeaderAttributeKey.CASCADED_SUBSCRIPTION_ID, cascClient.getSubscriptionId());
      message.setServiceName(cascClient.getServiceName());
      long msgSeqNr = cascClient.getMsgSequenceNr().incrementAndGetMsgSequenceNr();
      message.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, msgSeqNr);
      SCMPCscUnsubscribeCall unsubscribeCall = new SCMPCscUnsubscribeCall(this.requester, message);
      unsubscribeCall.invoke(new CommandCallback(false), AppContext.getBasicConfiguration().getSrvAbortOTIMillis());
    } catch (Exception e) {
      LOGGER.warn("unsubscribing cascaded client failed service=" + cascClient.getServiceName() + " " + e.toString());
    }
  }
View Full Code Here


      // server got already destroyed - no need to continue.
      return;
    }
    int tries = (int) ((oti * AppContext.getBasicConfiguration().getOperationTimeoutMultiplier()) / Constants.WAIT_FOR_FREE_CONNECTION_INTERVAL_MILLIS);
    int i = 0;
    CommandCallback callback = null;
    int otiOnServerMillis = 0;
    try {
      // Following loop implements the wait mechanism in case of a busy connection pool
      do {
        callback = new CommandCallback(true);
        try {
          otiOnServerMillis = oti - (i * Constants.WAIT_FOR_FREE_CONNECTION_INTERVAL_MILLIS);
          if (abortSubscription == true) {
            this.serverAbortSubscription(abortMessage, callback, otiOnServerMillis);
          } else {
            this.serverAbortSession(abortMessage, callback, otiOnServerMillis);
          }
          // no exception has been thrown - get out of wait loop
          break;
        } catch (ConnectionPoolBusyException ex) {
          LOGGER.warn("ConnectionPoolBusyException caught in wait mec of session abort");
          if (i >= (tries - 1)) {
            // only one loop outstanding - don't continue throw current exception
            LOGGER.warn(SCMPError.NO_FREE_CONNECTION.getErrorText("service=" + abortMessage.getServiceName()));
            SCMPCommandException scmpCommandException = new SCMPCommandException(SCMPError.NO_FREE_CONNECTION,
                "service=" + abortMessage.getServiceName());
            throw scmpCommandException;
          }
        }
        // sleep for a while and then try again
        Thread.sleep(Constants.WAIT_FOR_FREE_CONNECTION_INTERVAL_MILLIS);
      } while (++i < tries);

      // validate reply of server
      SCMPMessage reply = callback.getMessageSync(oti);
      if (reply.isFault()) {
        // error in server abort session - destroy server
        this.abortSessionsAndDestroy("Session abort failed, abort reason: " + reason);
      }
    } catch (SCMPCommandException scmpCommandException) {
      LOGGER.warn("ConnectionPoolBusyException in aborting session wait mec " + scmpCommandException.toString());
      // ConnectionPoolBusyException after wait mec - try opening a new connection

      // RemoteNodeConfiguration remoteNodeConfiguration = this.requester.getRemoteNodeConfiguration();
      // set up a new requester to make the SAS - only 1 connection is allowed
      Requester sasRequester = new Requester(this.sasRemoteNodeConfiguration);
      try {
        this.serverAbortSessionWithExtraRequester(sasRequester, abortMessage, callback, oti);
      } catch (ConnectionPoolBusyException e) {
        sasRequester.destroy();
        LOGGER.warn("ConnectionPoolBusyException in aborting session wait mec over special connection. " + e.toString());
        if (this.service.getType() == ServiceType.SESSION_SERVICE) {
          this.abortSessionsAndDestroy("Session abort over a new connection failed");
        }
        return;
      }
      sasRequester.destroy();
      // validate reply of server
      SCMPMessage reply = callback.getMessageSync(oti);
      if (reply.isFault()) {
        LOGGER.warn("Fault in aborting session wait mec over special connection");
        // error in server abort session - destroy server
        this.abortSessionsAndDestroy("Session abort over a new connection failed");
      }
View Full Code Here

          Set<String> subscriptionIds = subscription.getCscSubscriptionIds().keySet();

          for (String id : subscriptionIds) {
            abortMessage.setSessionId(id);
            try {
              this.serverAbortSubscription(abortMessage, new CommandCallback(false), AppContext
                  .getBasicConfiguration().getSrvAbortOTIMillis());
            } catch (ConnectionPoolBusyException e) {
              LOGGER.warn("aborting subscription failed because of busy connection pool. " + e.toString());
            } catch (Exception e) {
              LOGGER.warn("aborting subscription failed. " + e.toString());
            }
          }
          subscription.getCscSubscriptionIds().clear();
          // subscription is of type cascaded - do not forward to server
          continue;
        }
        try {
          this.serverAbortSubscription(abortMessage, new CommandCallback(false), AppContext.getBasicConfiguration()
              .getSrvAbortOTIMillis());
        } catch (ConnectionPoolBusyException e) {
          LOGGER.warn("aborting subscription failed because of busy connection pool. " + e.toString());
        } catch (Exception e) {
          LOGGER.warn("aborting subscription failed. " + e.toString());
        }
      } else {
        SessionLogger.logAbortSession((Session) session, reason);
        try {
          this.serverAbortSession(abortMessage, new CommandCallback(false), AppContext.getBasicConfiguration()
              .getSrvAbortOTIMillis());
        } catch (ConnectionPoolBusyException e) {
          LOGGER.warn("aborting session failed because of busy connection pool. " + e.toString());
        } catch (Exception e) {
          LOGGER.warn("aborting session failed. " + e.toString());
View Full Code Here

      message.setHeader(SCMPHeaderAttributeKey.CASCADED_SUBSCRIPTION_ID, cascClient.getSubscriptionId());
      message.setServiceName(cascClient.getServiceName());
      long msgSeqNr = cascClient.getMsgSequenceNr().incrementAndGetMsgSequenceNr();
      message.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, msgSeqNr);
      SCMPCscUnsubscribeCall unsubscribeCall = new SCMPCscUnsubscribeCall(this.requester, message);
      unsubscribeCall.invoke(new CommandCallback(false), AppContext.getBasicConfiguration().getSrvAbortOTIMillis());
    } catch (Exception e) {
      LOGGER.warn("unsubscribing cascaded client failed service=" + cascClient.getServiceName() + " " + e.toString());
    }
  }
View Full Code Here

      // server got already destroyed - no need to continue.
      return;
    }
    int tries = (int) ((oti * AppContext.getBasicConfiguration().getOperationTimeoutMultiplier()) / Constants.WAIT_FOR_FREE_CONNECTION_INTERVAL_MILLIS);
    int i = 0;
    CommandCallback callback = null;
    int otiOnServerMillis = 0;
    try {
      // Following loop implements the wait mechanism in case of a busy connection pool
      do {
        callback = new CommandCallback(true);
        try {
          otiOnServerMillis = oti - (i * Constants.WAIT_FOR_FREE_CONNECTION_INTERVAL_MILLIS);
          if (abortSubscription == true) {
            this.serverAbortSubscription(abortMessage, callback, otiOnServerMillis);
          } else {
            this.serverAbortSession(abortMessage, callback, otiOnServerMillis);
          }
          // no exception has been thrown - get out of wait loop
          break;
        } catch (ConnectionPoolBusyException ex) {
          LOGGER.warn("ConnectionPoolBusyException caught in wait mec of session abort");
          if (i >= (tries - 1)) {
            // only one loop outstanding - don't continue throw current exception
            LOGGER.warn(SCMPError.NO_FREE_CONNECTION.getErrorText("service=" + abortMessage.getServiceName()));
            SCMPCommandException scmpCommandException = new SCMPCommandException(SCMPError.NO_FREE_CONNECTION,
                "service=" + abortMessage.getServiceName());
            throw scmpCommandException;
          }
        }
        // sleep for a while and then try again
        Thread.sleep(Constants.WAIT_FOR_FREE_CONNECTION_INTERVAL_MILLIS);
      } while (++i < tries);

      // validate reply of server
      SCMPMessage reply = callback.getMessageSync(oti);
      if (reply.isFault()) {
        // error in server abort session - destroy server
        this.abortSessionsAndDestroy("Session abort failed, abort reason: " + reason);
      }
    } catch (SCMPCommandException scmpCommandException) {
      LOGGER.warn("ConnectionPoolBusyException in aborting session wait mec " + scmpCommandException.toString());
      // ConnectionPoolBusyException after wait mec - try opening a new connection

      // RemoteNodeConfiguration remoteNodeConfiguration = this.requester.getRemoteNodeConfiguration();
      // set up a new requester to make the SAS - only 1 connection is allowed
      Requester sasRequester = new Requester(this.sasRemoteNodeConfiguration);
      try {
        this.serverAbortSessionWithExtraRequester(sasRequester, abortMessage, callback, oti);
      } catch (ConnectionPoolBusyException e) {
        sasRequester.destroy();
        LOGGER.warn("ConnectionPoolBusyException in aborting session wait mec over special connection. " + e.toString());
        if (this.service.getType() == ServiceType.SESSION_SERVICE) {
          this.abortSessionsAndDestroy("Session abort over a new connection failed");
        }
        return;
      }
      sasRequester.destroy();
      // validate reply of server
      SCMPMessage reply = callback.getMessageSync(oti);
      if (reply.isFault()) {
        LOGGER.warn("Fault in aborting session wait mec over special connection");
        // error in server abort session - destroy server
        this.abortSessionsAndDestroy("Session abort over a new connection failed");
      }
View Full Code Here

          Set<String> subscriptionIds = subscription.getCscSubscriptionIds().keySet();

          for (String id : subscriptionIds) {
            abortMessage.setSessionId(id);
            try {
              this.serverAbortSubscription(abortMessage, new CommandCallback(false), AppContext
                  .getBasicConfiguration().getSrvAbortOTIMillis());
            } catch (ConnectionPoolBusyException e) {
              LOGGER.warn("aborting subscription failed because of busy connection pool. " + e.toString());
            } catch (Exception e) {
              LOGGER.warn("aborting subscription failed. " + e.toString());
            }
          }
          subscription.getCscSubscriptionIds().clear();
          // subscription is of type cascaded - do not forward to server
          continue;
        }
        try {
          this.serverAbortSubscription(abortMessage, new CommandCallback(false), AppContext.getBasicConfiguration()
              .getSrvAbortOTIMillis());
        } catch (ConnectionPoolBusyException e) {
          LOGGER.warn("aborting subscription failed because of busy connection pool. " + e.toString());
        } catch (Exception e) {
          LOGGER.warn("aborting subscription failed. " + e.toString());
        }
      } else {
        SessionLogger.logAbortSession((Session) session, reason);
        try {
          this.serverAbortSession(abortMessage, new CommandCallback(false), AppContext.getBasicConfiguration()
              .getSrvAbortOTIMillis());
        } catch (ConnectionPoolBusyException e) {
          LOGGER.warn("aborting session failed because of busy connection pool. " + e.toString());
        } catch (Exception e) {
          LOGGER.warn("aborting session failed. " + e.toString());
View Full Code Here

TOP

Related Classes of org.serviceconnector.cmd.sc.CommandCallback

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.