Package org.serviceconnector.scmp

Examples of org.serviceconnector.scmp.SCMPMessage


  /** {@inheritDoc} */
  @Override
  public void run(IRequest request, IResponse response, IResponderCallback responderCallback) {
    // set up response
    SCMPMessage scmpReply = new SCMPMessage();
    scmpReply.setIsReply(true);
    scmpReply.setMessageType(getKey());
    scmpReply.setHeader(SCMPHeaderAttributeKey.LOCAL_DATE_TIME, DateTimeUtility.getCurrentTimeZoneMillis());
    response.setSCMP(scmpReply);
    // initiate responder to send reply
    responderCallback.responseCallback(request, response);
  }
View Full Code Here


  }

  /** {@inheritDoc} */
  @Override
  public void validate(IRequest request) throws Exception {
    SCMPMessage message = request.getMessage();

    try {
      // scVersion mandatory
      String scVersion = message.getHeader(SCMPHeaderAttributeKey.SC_VERSION);
      SCMPMessage.SC_VERSION.isSupported(scVersion);
      // localDateTime mandatory
      ValidatorUtility.validateDateTime(message.getHeader(SCMPHeaderAttributeKey.LOCAL_DATE_TIME), SCMPError.HV_WRONG_LDT);
    } catch (HasFaultResponseException ex) {
      // needs to set message type at this point
      ex.setAttribute(SCMPHeaderAttributeKey.LOCAL_DATE_TIME, DateTimeUtility.getCurrentTimeZoneMillis());
      ex.setMessageType(getKey());
      throw ex;
View Full Code Here

        }
        if (metaEntry != null) {
          writeCacheMetaEntry(writer, cache, key, metaEntry, request);
        }
      } else {
        SCMPMessage cachedMessage = (SCMPMessage) cache.get(key);
        if (cachedMessage == null && simulation > 0) {
          cachedMessage = new SCMPMessage("");
        }
        if (cachedMessage != null) {
          writeCacheMessage(writer, cache, key, cachedMessage, request);
        }
      }
View Full Code Here

  }

  /** {@inheritDoc} */
  @Override
  public void run(IRequest request, IResponse response, IResponderCallback responderCallback) throws Exception {
    SCMPMessage reqMessage = request.getMessage();
    String serviceName = reqMessage.getServiceName();
    int oti = reqMessage.getHeaderInt(SCMPHeaderAttributeKey.OPERATION_TIMEOUT);
    // check service is present
    Service abstractService = this.getService(serviceName);

    SCCacheManager cacheManager = AppContext.getCacheManager();

    switch (abstractService.getType()) {
    case CASCADED_SESSION_SERVICE:
      if (cacheManager.isCacheEnabled()) {
        // try to load response from cache
        SCMPMessage message = cacheManager.tryGetMessageFromCacheOrLoad(reqMessage);
        if (message != null) {
          response.setSCMP(message);
          responderCallback.responseCallback(request, response);
          return;
        }
      }
      this.executeCascadedService(request, response, responderCallback);
      return;
    default:
      // code for other types of services is below
      break;
    }

    int otiOnSCMillis = (int) (oti * basicConf.getOperationTimeoutMultiplier());
    String sessionId = reqMessage.getSessionId();
    Session session = this.getSessionById(sessionId);
    if (session.hasPendingRequest() == true) {
      LOGGER.warn("sid=" + sessionId + " has pending request");
      SCMPCommandException scmpCommandException = new SCMPCommandException(SCMPError.PARALLEL_REQUEST, "service="
          + reqMessage.getServiceName() + " sid=" + sessionId);
      scmpCommandException.setMessageType(this.getKey());
      throw scmpCommandException;
    }
    // sets the time of last execution
    session.resetExecuteTime();
    synchronized (session) {
      session.setPendingRequest(true); // IMPORTANT - set true before reset timeout - because of parallel echo call
      // reset session timeout to OTI+ECI - during wait for server reply
      this.sessionRegistry.resetSessionTimeout(session, (otiOnSCMillis + session.getSessionTimeoutMillis()));
    }
    if (cacheManager.isCacheEnabled()) {
      try {
        // try to load response from cache
        SCMPMessage message = cacheManager.tryGetMessageFromCacheOrLoad(reqMessage);
        if (message != null) {
          synchronized (session) {
            // reset session timeout to ECI
            this.sessionRegistry.resetSessionTimeout(session, session.getSessionTimeoutMillis());
            session.setPendingRequest(false); // IMPORTANT - set false after reset timeout - parallel echo call
View Full Code Here

   * @throws Exception
   *             the exception
   */
  private void executeCascadedService(IRequest request, IResponse response, IResponderCallback responderCallback)
      throws Exception {
    SCMPMessage reqMessage = request.getMessage();
    String serviceName = reqMessage.getServiceName();
    int oti = reqMessage.getHeaderInt(SCMPHeaderAttributeKey.OPERATION_TIMEOUT);
    Service abstractService = this.getService(serviceName);
    CascadedSC cascadedSC = ((CascadedSessionService) abstractService).getCascadedSC();
    ClnExecuteCommandCascCallback callback = new ClnExecuteCommandCascCallback(request, response, responderCallback);
    cascadedSC.execute(reqMessage, callback, oti);
    return;
View Full Code Here

  /** {@inheritDoc} */
  @Override
  public void validate(IRequest request) throws Exception {
    try {
      SCMPMessage message = request.getMessage();
      // 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_CSC, 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);
      // message info optional
      String messageInfo = message.getHeader(SCMPHeaderAttributeKey.MSG_INFO);
      ValidatorUtility.validateStringLengthIgnoreNull(1, messageInfo, Constants.MAX_STRING_LENGTH_256,
          SCMPError.HV_WRONG_MESSAGE_INFO);
      // cacheId optional
      String cacheId = message.getHeader(SCMPHeaderAttributeKey.CACHE_ID);
      ValidatorUtility.validateStringLengthIgnoreNull(1, cacheId, Constants.MAX_STRING_LENGTH_256,
          SCMPError.HV_WRONG_SESSION_INFO);
    } catch (HasFaultResponseException ex) {
      // needs to set message type at this point
      ex.setMessageType(getKey());
View Full Code Here

    SCMPKeepAlive keepAliveMessage = new SCMPKeepAlive();
    connection.incrementNrOfIdles();
    try {
      ConnectionPoolCallback callback = new ConnectionPoolCallback(true);
      connection.send(keepAliveMessage, callback);
      SCMPMessage reply = callback.getMessageSync(this.keepAliveOTIMillis);
      if (reply.isFault() == true) {
        // reply of keep alive is fault
        SCMPMessageFault fault = (SCMPMessageFault) reply;
        LOGGER.error("send keepalive failed - connection gets destroyed, scErrorText="
            + fault.getHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT) + " scErrorCode="
            + fault.getHeader(SCMPHeaderAttributeKey.SC_ERROR_CODE));
View Full Code Here

  /** {@inheritDoc} */
  @Override
  public void run(IRequest request, IResponse response, IResponderCallback responderCallback) throws Exception {
    // set up response
    SCMPMessage scmpReply = new SCMPMessage();
    scmpReply.setIsReply(true);
    scmpReply.setMessageType(getKey());
    response.setSCMP(scmpReply);
    // initiate responder to send reply
    responderCallback.responseCallback(request, response);
  }
View Full Code Here

  }

  /** {@inheritDoc} */
  @Override
  public void run(IRequest request, IResponse response, IResponderCallback responderCallback) throws Exception {
    SCMPMessage reqMsg = request.getMessage();
    String bodyString = (String) reqMsg.getBody();
    String ipAddress = reqMsg.getHeader(SCMPHeaderAttributeKey.IP_ADDRESS_LIST);

    URLString urlRequestString = new URLString();
    urlRequestString.parseRequestURLString(bodyString);
    String callKey = urlRequestString.getCallKey();

    // set up response
    SCMPMessage scmpReply = new SCMPMessage();
    scmpReply.setIsReply(true);
    scmpReply.setMessageType(getKey());
    InetAddress localHost = InetAddress.getLocalHost();
    scmpReply.setHeader(SCMPHeaderAttributeKey.IP_ADDRESS_LIST, localHost.getHostAddress());

    String serviceName = urlRequestString.getParamValue(Constants.SERVICE_NAME);

    // kill command
    if ((ipAddress.equals(localHost.getHostAddress())) && Constants.CC_CMD_KILL.equalsIgnoreCase(callKey)) {
View Full Code Here

  /** {@inheritDoc} */
  @Override
  public void validate(IRequest request) throws Exception {
    try {
      SCMPMessage message = request.getMessage();
      // ipAddressList mandatory
      String ipAddressList = message.getHeader(SCMPHeaderAttributeKey.IP_ADDRESS_LIST);
      ValidatorUtility.validateIpAddressList(ipAddressList);
    } catch (HasFaultResponseException ex) {
      // needs to set message type at this point
      ex.setMessageType(getKey());
      throw ex;
View Full Code Here

TOP

Related Classes of org.serviceconnector.scmp.SCMPMessage

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.