Examples of SCMPMessage


Examples of org.serviceconnector.scmp.SCMPMessage

  }

  /** {@inheritDoc} */
  @Override
  public void validate(IRequest request) throws Exception {
    SCMPMessage message = request.getMessage();
    try {
      // msgSequenceNr mandatory
      String msgSequenceNr = message.getMessageSequenceNr();
      ValidatorUtility.validateLong(1, msgSequenceNr, SCMPError.HV_WRONG_MESSAGE_SEQUENCE_NR);
      // serviceName mandatory
      String serviceName = message.getServiceName();
      ValidatorUtility.validateStringLengthTrim(1, serviceName, Constants.MAX_LENGTH_SERVICENAME,
          SCMPError.HV_WRONG_SERVICE_NAME);
      // subscriptionId mandatory
      String sessionId = message.getSessionId();
      ValidatorUtility.validateStringLengthTrim(1, sessionId, Constants.MAX_STRING_LENGTH_256, SCMPError.HV_WRONG_SESSION_ID);
      // operation timeout mandatory
      String otiValue = message.getHeader(SCMPHeaderAttributeKey.OPERATION_TIMEOUT);
      ValidatorUtility.validateInt(Constants.MIN_OTI_VALUE_CLN, otiValue, Constants.MAX_OTI_VALUE,
          SCMPError.HV_WRONG_OPERATION_TIMEOUT);
      // ipAddressList mandatory
      String ipAddressList = message.getHeader(SCMPHeaderAttributeKey.IP_ADDRESS_LIST);
      ValidatorUtility.validateIpAddressList(ipAddressList);
      // mask mandatory
      String mask = message.getHeader(SCMPHeaderAttributeKey.MASK);
      ValidatorUtility.validateStringLength(1, mask, Constants.MAX_STRING_LENGTH_256, SCMPError.HV_WRONG_MASK);
      // sessionInfo optional
      ValidatorUtility.validateStringLengthIgnoreNull(1, message.getHeader(SCMPHeaderAttributeKey.SESSION_INFO),
          Constants.MAX_LENGTH_SERVICENAME, SCMPError.HV_WRONG_SESSION_INFO);
    } catch (HasFaultResponseException ex) {
      // needs to set message type at this point
      ex.setMessageType(getKey());
      throw ex;
View Full Code Here

Examples of org.serviceconnector.scmp.SCMPMessage

  }

  /** {@inheritDoc} */
  @Override
  public void run(IRequest request, IResponse response, IResponderCallback responderCallback) throws Exception {
    SCMPMessage reqMessage = request.getMessage();
    String serviceName = reqMessage.getServiceName();

    // check service is present
    Service abstractService = this.getService(serviceName);
    int oti = reqMessage.getHeaderInt(SCMPHeaderAttributeKey.OPERATION_TIMEOUT);
    // service is cascaded - unsubscribe is made by a normal client
    String subscriptionId = reqMessage.getSessionId();
    // lookup session and checks properness
    Subscription subscription = this.getSubscriptionById(subscriptionId);
    // looks up publish message queue and stops publish mechanism
    PublishMessageQueue<SCMPMessage> publishMessageQueue = this.getPublishMessageQueueById(subscription);
    // first remove subscription than unsubscribe
    this.subscriptionRegistry.removeSubscription(subscription);
    publishMessageQueue.unsubscribe(subscriptionId);

    switch (abstractService.getType()) {
    case CASCADED_PUBLISH_SERVICE:
      CascadedPublishService cascadedPublishService = (CascadedPublishService) abstractService;
      // publish service is cascaded
      CascadedSC cascadedSC = cascadedPublishService.getCascadedSC();
      // free server from subscription
      cascadedSC.removeSession(subscription);
      ClnUnsubscribeCommandCallback callback = new ClnUnsubscribeCommandCallback(request, response, responderCallback,
          subscription);
      cascadedSC.cascadedSCUnsubscribe(cascadedPublishService.getCascClient(), reqMessage, callback, oti);
      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;
        }
      }
      // sleep for a while and then try again
View Full Code Here

Examples of org.serviceconnector.scmp.SCMPMessage

  }

  /** {@inheritDoc} */
  @Override
  public void validate(IRequest request) throws Exception {
    SCMPMessage message = request.getMessage();
    try {
      // msgSequenceNr mandatory
      String msgSequenceNr = message.getMessageSequenceNr();
      ValidatorUtility.validateLong(1, msgSequenceNr, SCMPError.HV_WRONG_MESSAGE_SEQUENCE_NR);
      // serviceName mandatory
      String serviceName = message.getServiceName();
      ValidatorUtility.validateStringLengthTrim(1, serviceName, Constants.MAX_LENGTH_SERVICENAME,
          SCMPError.HV_WRONG_SERVICE_NAME);
      // operation timeout mandatory
      String otiValue = message.getHeader(SCMPHeaderAttributeKey.OPERATION_TIMEOUT);
      ValidatorUtility.validateInt(Constants.MIN_OTI_VALUE_CLN, otiValue, Constants.MAX_OTI_VALUE,
          SCMPError.HV_WRONG_OPERATION_TIMEOUT);
      // sessionId mandatory
      String sessionId = message.getSessionId();
      ValidatorUtility.validateStringLengthTrim(1, sessionId, Constants.MAX_STRING_LENGTH_256, SCMPError.HV_WRONG_SESSION_ID);
      // sessionInfo optional
      ValidatorUtility.validateStringLengthIgnoreNull(1, message.getHeader(SCMPHeaderAttributeKey.SESSION_INFO),
          Constants.MAX_STRING_LENGTH_256, SCMPError.HV_WRONG_SESSION_INFO);
    } catch (HasFaultResponseException ex) {
      // needs to set message type at this point
      ex.setMessageType(getKey());
      throw ex;
View Full Code Here

Examples of org.serviceconnector.scmp.SCMPMessage

          ConnectionLogger.logReadBuffer(this.getClass().getSimpleName(), remoteAddress.getHostName(),
              remoteAddress.getPort(), buffer, 0, buffer.length);
        }
        ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
        IEncoderDecoder encoderDecoder = AppContext.getEncoderDecoderFactory().createEncoderDecoder(buffer);
        SCMPMessage ret = (SCMPMessage) encoderDecoder.decode(bais);
        NettyHttpRequesterResponseHandler.this.scmpCallback.receive(ret);
      } catch (Throwable th) {
        LOGGER.error("receive message", th);
        if ((th instanceof Exception) == true) {
          try {
View Full Code Here

Examples of org.serviceconnector.scmp.SCMPMessage

  /** {@inheritDoc} */
  @Override
  public void receive(Exception ex) {
    LOGGER.warn(ex);
    SCMPMessage fault = null;
    if (ex instanceof IdleTimeoutException) {
      // operation timeout handling
      fault = new SCMPMessageFault(SCMPError.OPERATION_TIMEOUT, "Operation timeout expired on SC");
    } else if (ex instanceof IOException) {
      fault = new SCMPMessageFault(SCMPError.CONNECTION_EXCEPTION, "broken connection");
View Full Code Here

Examples of org.serviceconnector.scmp.SCMPMessage

        // release resources
        AppContext.destroy();
        throw new SCServiceException("Attach to " + host + ":" + port + " failed. ", e);
      }
      // 3. receiving reply and error handling
      SCMPMessage reply = callback.getMessageSync(operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
      if (reply.isFault()) {
        this.requester.destroy();
        // release resources
        AppContext.destroy();
        SCServiceException ex = new SCServiceException("Attach to " + host + ":" + port + " failed.");
        ex.setSCErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.SC_ERROR_CODE));
        ex.setSCErrorText(reply.getHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT));
        throw ex;
      }
      // 4. post process, reply to client
      this.attached = true;
      AppContext.attachedCommunicators.incrementAndGet();
View Full Code Here

Examples of org.serviceconnector.scmp.SCMPMessage

        detachCall.invoke(callback, operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
      } catch (Exception e) {
        throw new SCServiceException("Detach client failed. ", e);
      }
      // 3. receiving reply and error handling
      SCMPMessage reply = callback.getMessageSync(operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
      if (reply.isFault()) {
        SCServiceException ex = new SCServiceException("Detach client failed.");
        ex.setSCErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.SC_ERROR_CODE));
        ex.setSCErrorText(reply.getHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT));
        throw ex;
      }
    } finally {
      // 4. post process, reply to client
      this.attached = false;
View Full Code Here

Examples of org.serviceconnector.scmp.SCMPMessage

  }

  /** {@inheritDoc} */
  @Override
  public void receive(SCMPMessage reply) {
    SCMPMessage reqMessage = request.getMessage();
    String serviceName = reqMessage.getServiceName();
    String subscriptionId = subscription.getId();
    if (reply.isFault() == false) {
      boolean rejectSubscriptionFlag = reply.getHeaderFlag(SCMPHeaderAttributeKey.REJECT_SESSION);
      if (rejectSubscriptionFlag == false) {
        // session has not been rejected
        String newMask = reqMessage.getHeader(SCMPHeaderAttributeKey.MASK);
        PublishMessageQueue<SCMPMessage> queue = ((IPublishService) subscription.getService()).getMessageQueue();
        SubscriptionMask mask = new SubscriptionMask(newMask);
        SubscriptionLogger.logChangeSubscribe(serviceName, subscriptionId, newMask);
        queue.changeSubscription(subscriptionId, mask);
        subscription.setMask(mask);
View Full Code Here

Examples of org.serviceconnector.scmp.SCMPMessage

    }
    if (instruction.equalsIgnoreCase(Constants.CC_CMD_KILL)) {
      // on KILL SC cannot reply a message
      return null;
    }
    SCMPMessage reply = callback.getMessageSync(operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
    if (reply.isFault()) {
      SCServiceException ex = new SCServiceException("Inspect failed.");
      ex.setSCErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.SC_ERROR_CODE));
      ex.setSCErrorText(reply.getHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT));
      throw ex;
    }
    return (String) reply.getBody();
  }
View Full Code Here

Examples of org.serviceconnector.scmp.SCMPMessage

  /** {@inheritDoc} */
  @Override
  public void receive(Exception ex) {
    String sid = subscription.getId();
    LOGGER.warn("receive exception sid=" + sid + " " + ex.toString());
    SCMPMessage fault = null;
    SCMPMessage reqMessage = request.getMessage();
    String serviceName = reqMessage.getServiceName();
    if (ex instanceof IdleTimeoutException) {
      // operation timeout handling
      fault = new SCMPMessageFault(SCMPError.OPERATION_TIMEOUT,
          "Operation timeout expired on SC cln change subscription sid=" + sid);
    } else if (ex instanceof IOException) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.