Package org.serviceconnector.cache

Examples of org.serviceconnector.cache.SCCacheMetaEntry


    int endIndex = paging.getEndIndex();

    for (int i = startIndex; i < endIndex; i++) {
      String key = cacheKeys.get(i);
      if (cache.getCacheName().equals(SC_CACHE_TYPE.META_DATA_CACHE.name())) {
        SCCacheMetaEntry metaEntry = (SCCacheMetaEntry) cache.get(key);
        if (metaEntry == null && simulation > 0) {
          metaEntry = new SCCacheMetaEntry("");
        }
        if (metaEntry != null) {
          writeCacheMetaEntry(writer, cache, key, metaEntry, request);
        }
      } else {
View Full Code Here


    if (scCache == null) {
      SCMPCommandException scmpCommandException = new SCMPCommandException(SCMPError.CACHE_ERROR, serviceName);
      scmpCommandException.setMessageType(getKey());
      throw scmpCommandException;
    }
    SCCacheMetaEntry metaEntry = (SCCacheMetaEntry) scCache.get(cacheKey);
    if (metaEntry == null) {
      return URLString.toURLResponseString(Constants.CACHE_ID, cacheKey, "return", "notfound");
    }
    SC_CACHE_ENTRY_STATE cacheState = metaEntry.getSCCacheEntryState();
    Date creationTime = metaEntry.getCreationTime();
    Date lastModifiedTime = metaEntry.getLastModifiedTime();
    String expirationDateTime = DateTimeUtility.getDateTimeAsString(scCache.getExpirationTime(cacheKey));
    int size = metaEntry.getNumberOfParts();
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("return", "success");
    parameters.put(Constants.CACHE_ID, metaEntry.getCacheId());
    parameters.put("cacheState", cacheState.toString());
    parameters.put("cacheSize", String.valueOf(size));
    parameters.put("cacheExpiration", expirationDateTime);
    parameters.put("creationTime", DateTimeUtility.getDateTimeAsString(creationTime));
    parameters.put("lastModifiedTime", DateTimeUtility.getDateTimeAsString(lastModifiedTime));
View Full Code Here

          writer.writeAttribute("bodyLength", scmp.getBodyLength());
          writer.writeAttribute("expirationTime", DateTimeUtility.getDateTimeAsString(scCache.getExpirationTime(key)));
          writer.writeAttribute("creationTime", DateTimeUtility.getDateTimeAsString(scCache.getCreationTime(key)));
          writer.writeAttribute("lastAccessTime", DateTimeUtility.getDateTimeAsString(scCache.getLastAccessTime(key)));
        } else if (cacheMessage instanceof SCCacheMetaEntry) {
          SCCacheMetaEntry metaEntry = ((SCCacheMetaEntry) cacheMessage);
          writer.writeAttribute("cacheKey", key);
          writer.writeAttribute("loadingSessionId", metaEntry.getLoadingSessionId());
          writer.writeAttribute("loadingTimeoutMillis", metaEntry.getLoadingTimeoutMillis());
          writer.writeAttribute("scCacheEntryState", metaEntry.getSCCacheEntryState().name());
          writer.writeAttribute("numberOfParts", metaEntry.getNumberOfParts());
          writer.writeAttribute("expirationTime", DateTimeUtility.getDateTimeAsString(scCache.getExpirationTime(key)));
          writer.writeAttribute("creationTime", DateTimeUtility.getDateTimeAsString(scCache.getCreationTime(key)));
          writer.writeAttribute("lastModifiedTime", DateTimeUtility.getDateTimeAsString(metaEntry.getLastModifiedTime()));
          writer.writeAttribute("lastAccessTime", DateTimeUtility.getDateTimeAsString(scCache.getLastAccessTime(key)));
        }
        writer.writeEndElement(); // end of cacheElement
      }
      writer.writeEndElement(); // end of cacheElements
View Full Code Here

    } else if (objectValue instanceof SCMPMessage) {
      SCMPMessage copiedSCMPMsg = null;
      copiedSCMPMsg = new SCMPMessage((SCMPMessage) objectValue);
      return (T) copiedSCMPMsg;
    } else if (objectValue instanceof SCCacheMetaEntry) {
      SCCacheMetaEntry copiedMetaEntry = null;
      copiedMetaEntry = new SCCacheMetaEntry((SCCacheMetaEntry) objectValue);
      return (T) copiedMetaEntry;
    } else {
      LOGGER.error("Unexpected instance copy procedure not properly done!");
      return (T) objectValue;
    }
View Full Code Here

    if (value instanceof SCMPPart) {
      value = (T) new SCMPPart((SCMPPart) value);
    } else if (value instanceof SCMPMessage) {
      value = (T) new SCMPMessage((SCMPMessage) value);
    } else if (value instanceof SCCacheMetaEntry) {
      value = (T) new SCCacheMetaEntry((SCCacheMetaEntry) value);
    } else {
      LOGGER.error("Unexpected instance copy procedure not properly done!");
    }

    // key, value, eternal, timeToIdle (0 = unlimited), timeToLive
View Full Code Here

    if (value instanceof SCMPPart) {
      value = (T) new SCMPPart((SCMPPart) value);
    } else if (value instanceof SCMPMessage) {
      value = (T) new SCMPMessage((SCMPMessage) value);
    } else if (value instanceof SCCacheMetaEntry) {
      value = (T) new SCCacheMetaEntry((SCCacheMetaEntry) value);
    } else {
      LOGGER.error("Unexpected instance copy procedure not properly done!");
    }
    // key, value, eternal, timeToIdle (0 = unlimited), timeToLive
    Element element = new Element(key, value, false, 0, timeToLiveSeconds);
View Full Code Here

  /** {@inheritDoc} */
  @Override
  public void notifyElementExpired(Ehcache cache, Element element) {
    Object entry = element.getValue();
    if (entry instanceof SCCacheMetaEntry) {
      SCCacheMetaEntry metaEntry = (SCCacheMetaEntry) entry;
      LOGGER.debug("Cache element of type SCCacheMetaEntry expired, cid: " + metaEntry.getCacheId());
      CacheLogger.messageExpired(metaEntry.getCacheId());
      AppContext.getSCCache().removeDataEntriesByMetaEntry(metaEntry, "Meta Entry expired!");
      Statistics.getInstance().decrementMessagesInCache();
    } else if (entry instanceof byte[]) {
      LOGGER.debug("Cache element of type byte[] expired.");
      try {
        ByteArrayInputStream b = new ByteArrayInputStream((byte[]) entry);
        ObjectInputStream o = new ObjectInputStream(b);
        SCCacheMetaEntry metaEntry = (SCCacheMetaEntry) o.readObject();
        CacheLogger.messageExpired(metaEntry.getCacheId());
        AppContext.getSCCache().removeDataEntriesByMetaEntry((SCCacheMetaEntry) metaEntry, "Meta Entry expired!");
        Statistics.getInstance().decrementMessagesInCache();
      } catch (Exception e) {
        LOGGER.error("Deserializing of byte[] failed: " + e);
      }
View Full Code Here

    int endIndex = paging.getEndIndex();

    for (int i = startIndex; i < endIndex; i++) {
      String key = cacheKeys.get(i);
      if (cacheModule.getCacheModuleName().equals(SC_CACHE_MODULE_TYPE.META_DATA_CACHE_MODULE.name())) {
        SCCacheMetaEntry metaEntry = (SCCacheMetaEntry) cacheModule.get(key);
        if (metaEntry == null && simulation > 0) {
          metaEntry = new SCCacheMetaEntry("");
        }
        if (metaEntry != null) {
          writeCacheMetaEntry(writer, cacheModule, key, metaEntry, request);
        }
      } else {
View Full Code Here

    if (scCacheModule == null) {
      SCMPCommandException scmpCommandException = new SCMPCommandException(SCMPError.CACHE_ERROR, serviceName);
      scmpCommandException.setMessageType(getKey());
      throw scmpCommandException;
    }
    SCCacheMetaEntry metaEntry = (SCCacheMetaEntry) scCacheModule.get(cacheKey);
    if (metaEntry == null) {
      return URLString.toURLResponseString(Constants.CACHE_ID, cacheKey, "return", "notfound");
    }
    SC_CACHE_ENTRY_STATE cacheState = metaEntry.getSCCacheEntryState();
    Date creationTime = metaEntry.getCreationTime();
    Date lastModifiedTime = metaEntry.getLastModifiedTime();
    String expirationDateTime = DateTimeUtility.getDateTimeAsString(scCacheModule.getExpirationTime(cacheKey));
    String assignedUpdateGuardian = metaEntry.getCacheGuardianName();
    String partInfo = metaEntry.nrOfPartsByAppendixAsString();
    int nrOfAppendix = metaEntry.getNrOfAppendix();
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("return", "success");
    parameters.put(Constants.CACHE_ID, metaEntry.getCacheId());
    parameters.put("cacheMessageState", cacheState.toString());
    parameters.put("cacheMessagePartInfo", partInfo);
    parameters.put("cacheMessageNrOfAppendix", String.valueOf(nrOfAppendix));
    parameters.put("cacheMessageAssignedUpdateGuardian", assignedUpdateGuardian);
    parameters.put("cacheMessageExpiration", expirationDateTime);
View Full Code Here

          writer.writeAttribute("bodyLength", scmp.getBodyLength());
          writer.writeAttribute("expirationTime", DateTimeUtility.getDateTimeAsString(scCache.getExpirationTime(key)));
          writer.writeAttribute("creationTime", DateTimeUtility.getDateTimeAsString(scCache.getCreationTime(key)));
          writer.writeAttribute("lastAccessTime", DateTimeUtility.getDateTimeAsString(scCache.getLastAccessTime(key)));
        } else if (cacheMessage instanceof SCCacheMetaEntry) {
          SCCacheMetaEntry metaEntry = ((SCCacheMetaEntry) cacheMessage);
          writer.writeAttribute("cacheKey", key);
          writer.writeAttribute("loadingSessionId", metaEntry.getLoadingSessionId());
          writer.writeAttribute("loadingTimeoutMillis", metaEntry.getLoadingTimeoutMillis());
          writer.writeAttribute("scCacheEntryState", metaEntry.getSCCacheEntryState().name());
          writer.writeAttribute("numberOfAppendix", metaEntry.getNrOfAppendix());
          writer.writeAttribute("cacheGuardian", metaEntry.getCacheGuardianName());
          if (metaEntry.getSCCacheEntryState() == SC_CACHE_ENTRY_STATE.LOADING_APPENDIX) {
            writer.writeAttribute("expectedAppendix", metaEntry.getExpectedAppendix());
          }
          writer.writeAttribute("isManaged", metaEntry.isManaged());
          writer.writeAttribute("expirationTime", DateTimeUtility.getDateTimeAsString(scCache.getExpirationTime(key)));
          writer.writeAttribute("creationTime", DateTimeUtility.getDateTimeAsString(scCache.getCreationTime(key)));
          writer.writeAttribute("lastModifiedTime", DateTimeUtility.getDateTimeAsString(metaEntry.getLastModifiedTime()));
          writer.writeAttribute("lastAccessTime", DateTimeUtility.getDateTimeAsString(scCache.getLastAccessTime(key)));
        }
        writer.writeEndElement(); // end of cacheElement
      }
      writer.writeEndElement(); // end of cacheElements
View Full Code Here

TOP

Related Classes of org.serviceconnector.cache.SCCacheMetaEntry

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.