コード例 #1
0
  public void onCacheDelete(HttpServletRequest request, final FilterDirector director)
      throws DatastoreOperationException, MalformedCacheRequestException {
    final CacheRequest cacheDelete = CacheRequest.marshallCacheRequest(request);
    hashRingDatastore.remove(
        cacheDelete.getCacheKey(),
        encodingProvider.decode(cacheDelete.getCacheKey()),
        cacheDelete.getRequestedRemoteBehavior());

    director.setResponseStatus(HttpStatusCode.ACCEPTED);
    director.setFilterAction(FilterAction.RETURN);
  }
コード例 #2
0
  public void onCachePut(HttpServletRequest request, final FilterDirector director)
      throws MalformedCacheRequestException, DatastoreOperationException {
    final CacheRequest cachePut = CacheRequest.marshallCachePutRequest(request);
    hashRingDatastore.put(
        cachePut.getCacheKey(),
        encodingProvider.decode(cachePut.getCacheKey()),
        cachePut.getPayload(),
        cachePut.getTtlInSeconds(),
        TimeUnit.SECONDS,
        cachePut.getRequestedRemoteBehavior());

    director.setResponseStatus(HttpStatusCode.ACCEPTED);
    director.setFilterAction(FilterAction.RETURN);
  }
コード例 #3
0
  public void onCacheGet(CacheRequest cacheGet, FilterDirector director) {
    final StoredElement element =
        hashRingDatastore.get(
            cacheGet.getCacheKey(),
            encodingProvider.decode(cacheGet.getCacheKey()),
            cacheGet.getRequestedRemoteBehavior());

    if (!element.elementIsNull()) {
      try {
        director.getResponseOutputStream().write(element.elementBytes());

        director.setResponseStatus(HttpStatusCode.OK);
        director.setFilterAction(FilterAction.RETURN);
      } catch (IOException ioe) {
        LOG.error(ioe.getMessage(), ioe);

        director.setResponseStatus(HttpStatusCode.INTERNAL_SERVER_ERROR);
        director.setFilterAction(FilterAction.RETURN);
      }
    } else {
      director.setResponseStatus(HttpStatusCode.NOT_FOUND);
      director.setFilterAction(FilterAction.RETURN);
    }
  }