Package org.serviceconnector.service

Examples of org.serviceconnector.service.Subscription


    // 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:
      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


    String sessionInfo = reqMessage.getHeader(SCMPHeaderAttributeKey.SESSION_INFO);
    int noiSecs = reqMessage.getHeaderInt(SCMPHeaderAttributeKey.NO_DATA_INTERVAL);
    int noiInMillis = noiSecs * Constants.SEC_TO_MILLISEC_FACTOR;
    String cscSCMaskString = reqMessage.getHeader(SCMPHeaderAttributeKey.CASCADED_MASK);
    String cascSubscriptionId = reqMessage.getHeader(SCMPHeaderAttributeKey.CASCADED_SUBSCRIPTION_ID);
    Subscription cscSubscription = this.subscriptionRegistry.getSubscription(cascSubscriptionId);
    SubscriptionMask cscMask = new SubscriptionMask(cscSCMaskString);
    Subscription tmpCascSCSubscription = new Subscription(cscMask, sessionInfo, ipAddressList, noiInMillis, AppContext
        .getBasicConfiguration().getSubscriptionTimeoutMillis(), true);
    tmpCascSCSubscription.setService(abstractService);

    switch (abstractService.getType()) {
    case CASCADED_PUBLISH_SERVICE:
      // publish service is cascaded
      CascadedPublishService cascadedPublishService = (CascadedPublishService) abstractService;
      CascadedSC cascadedSC = cascadedPublishService.getCascadedSC();
      // add server to subscription
      tmpCascSCSubscription.setServer(cascadedSC);

      ISubscriptionCallback callback = null;
      if (cscSubscription == null) {
        // cascaded SC not subscribed yet
        callback = new SubscribeCommandCallback(request, response, responderCallback, tmpCascSCSubscription);
View Full Code Here

   *
   * @param key
   *            the key
   */
  public void removeSubscription(String key) {
    Subscription subscription = this.getSubscription(key);
    this.removeSubscription(subscription);
  }
View Full Code Here

   * @param key
   *            the key
   * @return the subscription
   */
  public Subscription getSubscription(String key) {
    Subscription subscription = super.get(key);
    return subscription;
  }
View Full Code Here

      Set<Entry<String, Subscription>> entries = this.registryMap.entrySet();
      Subscription[] subscriptions = new Subscription[entries.size()];
      int index = 0;
      for (Entry<String, Subscription> entry : entries) {
        // String key = entry.getKey();
        Subscription subscription = entry.getValue();
        subscriptions[index++] = subscription;
      }
      return subscriptions;
    } catch (Exception e) {
      LOGGER.error("getSubscriptions", e);
View Full Code Here

    try {
      List<Subscription> subscriptionList = new ArrayList<Subscription>();
      Set<Entry<String, Subscription>> entries = this.registryMap.entrySet();
      for (Entry<String, Subscription> entry : entries) {
        // String key = entry.getKey();
        Subscription subscription = entry.getValue();
        String subscriptionServiceName = subscription.getService().getName();
        if (subscriptionServiceName.equals(serviceName)) {
          subscriptionList.add(subscription);
        }
      }
      Subscription[] sa = new Subscription[0];
View Full Code Here

    writer.writeAttribute("subscriptionScheduler_largestPoolSize", this.subscriptionScheduler.getLargestPoolSize());
    writer.writeAttribute("subscriptionScheduler_activeCount", this.subscriptionScheduler.getActiveCount());

    Set<Entry<String, Subscription>> entries = this.registryMap.entrySet();
    for (Entry<String, Subscription> entry : entries) {
      Subscription subscriptions = entry.getValue();
      subscriptions.dump(writer);
    }
    writer.writeEndElement(); // end of subscriptions
  }
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);
      SCMPMessage abortMessage = new SCMPMessage();
      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

    SubscriptionMask subscriptionMask = new SubscriptionMask(mask);
    String sessionInfo = reqMessage.getHeader(SCMPHeaderAttributeKey.SESSION_INFO);
    int noiInSecs = reqMessage.getHeaderInt(SCMPHeaderAttributeKey.NO_DATA_INTERVAL);
    int noiInMillis = noiInSecs * Constants.SEC_TO_MILLISEC_FACTOR;
    // create temporary subscription
    Subscription tmpSubscription = new Subscription(subscriptionMask, sessionInfo, ipAddressList, noiInMillis, AppContext
        .getBasicConfiguration().getSubscriptionTimeoutMillis(), false);
    tmpSubscription.setService(abstractService);
    reqMessage.setSessionId(tmpSubscription.getId());

    switch (abstractService.getType()) {
    case CASCADED_PUBLISH_SERVICE:
      // publish service is cascaded
      CascadedPublishService cascadedPublishService = (CascadedPublishService) abstractService;
      CascadedSC cascadedSC = cascadedPublishService.getCascadedSC();
      // add server to subscription
      tmpSubscription.setServer(cascadedSC);
      // service is cascaded - subscribe is made by a normal client
      SubscribeCommandCallback callback = new SubscribeCommandCallback(request, response, responderCallback, tmpSubscription);
      cascadedSC.cascadedSCSubscribe(cascadedPublishService.getCascClient(), reqMessage, callback, oti);
      return;
    default:
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.