Package org.serviceconnector.cache

Examples of org.serviceconnector.cache.SCCache


  /** {@inheritDoc} */
  @Override
  public void receive(SCMPMessage reply) {
    String serviceName = this.requestMessage.getServiceName();
    // caching
    SCCache cache = AppContext.getSCCache();
    if (cache.isCacheEnabled() == true) {
      cache.cacheMessage(this.requestMessage, reply);
    }
    // forward server reply to client
    reply.setIsReply(true);
    reply.setMessageType(this.msgType);
    reply.setServiceName(serviceName);
View Full Code Here


      fault = new SCMPMessageFault(scmpVersion, SCMPError.CONNECTION_EXCEPTION, "broken connection to server sid=" + sid);
    } else {
      fault = new SCMPMessageFault(scmpVersion, SCMPError.SC_ERROR, "error executing " + this.msgType + " sid=" + sid);
    }
    // caching
    SCCache cache = AppContext.getSCCache();
    if (cache.isCacheEnabled() == true) {
      cache.cacheMessage(this.requestMessage, fault);
    }
    String serviceName = this.requestMessage.getServiceName();
    // forward server reply to client
    fault.setSessionId(sid);
    fault.setIsReply(true);
View Full Code Here

        writer.writeEndElement(); // messages
        return;
      }
      if ("clearCache".equals(action)) {
        XMLLoaderFactory.LOGGER.debug("clear cache by user interface");
        SCCache cache = AppContext.getSCCache();
        cache.clearAll();
        writer.writeStartElement("status");
        writer.writeCharacters("success");
        writer.writeEndElement();
        writer.writeStartElement("messages");
        writer.writeStartElement("message");
View Full Code Here

    String serviceName = reqMessage.getServiceName();
    int oti = reqMessage.getHeaderInt(SCMPHeaderAttributeKey.OPERATION_TIMEOUT);
    // check service is present
    Service abstractService = this.getService(serviceName);

    SCCache cache = AppContext.getSCCache();

    switch (abstractService.getType()) {
    case CASCADED_SESSION_SERVICE:
      if (cache.isCacheEnabled()) {
        // try to load response from cache
        SCMPMessage message = cache.tryGetMessageFromCacheOrLoad(reqMessage);
        if (message != null) {
          // message found in cache - hand it to the client
          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("session " + 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 (cache.isCacheEnabled()) {
      try {
        // try to load response from cache
        SCMPMessage message = cache.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

  }

  /** {@inheritDoc} */
  @Override
  public void receive(SCMPMessage reply) {
    SCCache cache = AppContext.getSCCache();
    if (cache.isCacheEnabled() == true) {
      cache.cacheMessage(this.requestMessage, reply);
    }
    // forward server reply to client
    reply.setIsReply(true);
    reply.setMessageType(this.msgType);
    reply.setServiceName(this.requestServiceName);
View Full Code Here

      fault = new SCMPMessageFault(scmpVersion, SCMPError.CONNECTION_EXCEPTION, "broken connection to server sid=" + this.sid);
    } else {
      fault = new SCMPMessageFault(scmpVersion, SCMPError.SC_ERROR, "error executing " + this.msgType + " sid=" + this.sid);
    }
    // caching
    SCCache cache = AppContext.getSCCache();
    if (cache.isCacheEnabled() == true) {
      cache.cacheMessage(this.requestMessage, fault);
    }
    // forward server reply to client
    fault.setSessionId(this.sid);
    fault.setIsReply(true);
    fault.setMessageType(this.msgType);
View Full Code Here

    String serviceName = reqMessage.getServiceName();
    int oti = reqMessage.getHeaderInt(SCMPHeaderAttributeKey.OPERATION_TIMEOUT);
    // check service is present
    Service abstractService = this.getService(serviceName);

    SCCache cache = AppContext.getSCCache();

    switch (abstractService.getType()) {
    case CASCADED_SESSION_SERVICE:
      if (cache.isCacheEnabled()) {
        // try to load response from cache
        SCMPMessage message = cache.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 (cache.isCacheEnabled()) {
      try {
        // try to load response from cache
        SCMPMessage message = cache.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

      responderCallback.responseCallback(request, response);
      return;
    }

    if (Constants.CC_CMD_CLEAR_CACHE.equalsIgnoreCase(callKey)) {
      SCCache cache = AppContext.getSCCache();
      cache.clearAll();
      response.setSCMP(scmpReply);
      responderCallback.responseCallback(request, response);
      return;
    }
View Full Code Here

   * @throws UnsupportedEncodingException
   *             encoding response string failed
   */
  private String getCacheInspectString(final String serviceName, final String cacheKey) throws SCMPCommandException,
      UnsupportedEncodingException {
    SCCache cache = AppContext.getSCCache();
    if (cache == null) {
      SCMPCommandException scmpCommandException = new SCMPCommandException(SCMPError.CACHE_ERROR, "no cache (null)");
      scmpCommandException.setMessageType(getKey());
      throw scmpCommandException;
    }
View Full Code Here

TOP

Related Classes of org.serviceconnector.cache.SCCache

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.