Package org.serviceconnector.service

Examples of org.serviceconnector.service.Subscription


   * @return the subscription by id
   * @throws SCMPCommandException
   *             the sCMP command exception
   */
  protected Subscription getSubscriptionById(String subscriptionId) throws SCMPCommandException {
    Subscription subscription = this.subscriptionRegistry.getSubscription(subscriptionId);

    if (subscription == null) {
      // subscription not found in registry
      LOGGER.info("subscription not found sid=" + subscriptionId);
      SCMPCommandException scmpCommandException = new SCMPCommandException(SCMPError.SUBSCRIPTION_NOT_FOUND, subscriptionId);
View Full Code Here


    // check service is present and enabled
    Service abstractService = this.getService(serviceName);

    String cascSubscriptionId = reqMessage.getHeader(SCMPHeaderAttributeKey.CASCADED_SUBSCRIPTION_ID);
    Subscription cascSubscription = this.getSubscriptionById(cascSubscriptionId);
    String cascadedSCMask = reqMessage.getHeader(SCMPHeaderAttributeKey.CASCADED_MASK);
    // enhance ipAddressList
    String ipAddressList = reqMessage.getHeader(SCMPHeaderAttributeKey.IP_ADDRESS_LIST);
    ipAddressList = ipAddressList + Constants.SLASH + request.getRemoteSocketAddress().getAddress().getHostAddress();
    reqMessage.setHeader(SCMPHeaderAttributeKey.IP_ADDRESS_LIST, ipAddressList);
    int oti = reqMessage.getHeaderInt(SCMPHeaderAttributeKey.OPERATION_TIMEOUT);

    switch (abstractService.getType()) {
    case CASCADED_PUBLISH_SERVICE:
    case CASCADED_CACHE_GUARDIAN:
      CascadedPublishService cascadedPublishService = (CascadedPublishService) abstractService;
      // publish service is cascaded
      CascadedSC cascadedSC = cascadedPublishService.getCascadedSC();
      CscChangeSubscriptionCallbackForCasc callback = new CscChangeSubscriptionCallbackForCasc(request, response,
          responderCallback, cascSubscription, cascadedSCMask);
      cascadedSC.cascadedSCChangeSubscription(cascadedPublishService.getCascClient(), reqMessage, callback, oti);
      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;
View Full Code Here

   *            the reason {@inheritDoc}
   */
  @Override
  public void abortSession(AbstractSession session, String reason) {
    if (session instanceof Subscription) {
      Subscription subscription = (Subscription) session;
      CascadedPublishService casService = (CascadedPublishService) subscription.getService();

      PublishMessageQueue<SCMPMessage> publishMessageQueue = casService.getMessageQueue();
      // unsubscribe subscription
      publishMessageQueue.unsubscribe(subscription.getId());
      publishMessageQueue.removeNonreferencedNodes();

      CascadedClient cascClient = casService.getCascClient();
      // remove timed out subscription id from client subscription list
      cascClient.removeClientSubscriptionId(subscription.getId());

      if (cascClient.isDestroyed() == true) {
        // cascaded client got destroyed - do not continue
        return;
      }

      long msgSeqNr = cascClient.getMsgSequenceNr().incrementAndGetMsgSequenceNr();
      IRequest request = new NettyHttpRequest(null, null, null);
      // SCMP Version current
      SCMPMessage abortMessage = new SCMPMessage(SCMPVersion.LOWEST);
      abortMessage.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, msgSeqNr);
      abortMessage.setHeader(SCMPHeaderAttributeKey.SERVICE_NAME, casService.getName());
      // cascaded id will be set in following (cascadedSCAbortSubscription) method
      request.setMessage(abortMessage);

      if (subscription.isCascaded() == true) {
        // XAB procedure for casc subscriptions
        Set<String> subscriptionIds = subscription.getCscSubscriptionIds().keySet();

        for (String id : subscriptionIds) {
          abortMessage.setSessionId(id);
          this.cascadedSCAbortSubscription(cascClient, abortMessage, new CscAbortSubscriptionCallbackForCasc(request,
              subscription), AppContext.getBasicConfiguration().getSrvAbortOTIMillis());
        }
        subscription.getCscSubscriptionIds().clear();
      } else {
        // normal XAB procedure
        abortMessage.setSessionId(subscription.getId());
        SubscriptionLogger.logAbortSubscription((Subscription) session, reason);
        this.cascadedSCAbortSubscription(cascClient, abortMessage, new CscAbortSubscriptionCallbackForCasc(request,
            subscription), AppContext.getBasicConfiguration().getSrvAbortOTIMillis());
      }
    } else {
View Full Code Here

   *
   * @param subscriptionId
   *            the subscription id
   */
  public void removeSession(String subscriptionId) {
    Subscription subscription = AppContext.getSubscriptionRegistry().getSubscription(subscriptionId);
    this.removeSession(subscription);
  }
View Full Code Here

    abortMessage.setHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT, SCMPError.SESSION_ABORT.getErrorText(reason));
    abortMessage.setServiceName(this.getServiceName());
    abortMessage.setHeader(SCMPHeaderAttributeKey.OPERATION_TIMEOUT, oti);

    if (session.isCascaded() == true) {
      Subscription subscription = ((Subscription) session);
      // XAB procedure for casc subscriptions
      Set<String> subscriptionIds = subscription.getCscSubscriptionIds().keySet();

      for (String id : subscriptionIds) {
        abortMessage.setSessionId(id);
        this.abortSessionAndWaitMech(oti, abortMessage, reason, true);
      }
      subscription.getCscSubscriptionIds().clear();
      // subscription is of type cascaded - do not forward to server
      return;
    }

    abortMessage.setSessionId(session.getId());
View Full Code Here

        // remove non referenced nodes
        publishMessageQueue.removeNonreferencedNodes();
        SubscriptionLogger.logAbortSubscription((Subscription) session, reason);

        if (session.isCascaded() == true) {
          Subscription subscription = ((Subscription) session);
          // XAB procedure for casc subscriptions
          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()
View Full Code Here

TOP

Related Classes of org.serviceconnector.service.Subscription

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.