Java 类net.sf.ehcache.constructs.blocking.LockTimeoutException 实例源码

项目:lutece-core    文件:HeadersPageCachingFilter.java   
/**
 * {@inheritDoc }
 */
@Override
protected void doFilter( HttpServletRequest request, HttpServletResponse response, FilterChain chain ) throws AlreadyGzippedException,
        AlreadyCommittedException, FilterNonReentrantException, LockTimeoutException, Exception
{
    if ( !_bInit )
    {
        init( );
    }

    if ( _bEnable )
    {
        super.doFilter( request, response, chain );
        _logger.debug( "URI served from cache : " + request.getRequestURI( ) );
    }
    else
    {
        chain.doFilter( request, response );
    }
}
项目:sharks    文件:RestCacheFilter.java   
@Override
protected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws AlreadyGzippedException,
        AlreadyCommittedException, FilterNonReentrantException, LockTimeoutException, Exception {

    String url = request.getRequestURL().toString();
    if (matchExcludePatterns(url)) {
        chain.doFilter(request, response);
        return;
    }

    super.doFilter(request, response, chain);
}
项目:xslweb    文件:CachingFilter.java   
@Override
protected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws AlreadyGzippedException, AlreadyCommittedException, FilterNonReentrantException, LockTimeoutException, Exception {
  WebApp webApp = (WebApp) request.getAttribute(Definitions.ATTRNAME_WEBAPP);
  PipelineHandler pipelineHandler = (PipelineHandler) request.getAttribute(Definitions.ATTRNAME_PIPELINEHANDLER);
  if (!webApp.getDevelopmentMode() && pipelineHandler.getCache()) {
    super.doFilter(request, response, chain);                  
  } else {
    chain.doFilter(request, response);
  }
}
项目:mtools    文件:PageEhCacheFilter.java   
@Override
protected void doFilter(final HttpServletRequest request,
        final HttpServletResponse response, final FilterChain chain)
        throws AlreadyGzippedException, AlreadyCommittedException,
        FilterNonReentrantException, LockTimeoutException, Exception {
    if (cacheURLs == null) {
        init();
    }

    String url = request.getRequestURI();
    boolean flag = false;
    if (cacheURLs != null && cacheURLs.length > 0) {
        for (String cacheURL : cacheURLs) {
            if (url.contains(cacheURL.trim())) {
                flag = true;
                break;
            }
        }
    }
    // 如果包含我们要缓存的url 就缓存该页面,否则执行正常的页面转向
    if (flag) {
        String query = request.getQueryString();
        if (query != null) {
            query = "?" + query;
        }
        log.info("当前请求被缓存:" + url + query);
        super.doFilter(request, response, chain);
    } else {
        chain.doFilter(request, response);
    }
}
项目:Free-Choice.Net    文件:MyPageCachingFilter.java   
@Override
    protected void doFilter(final HttpServletRequest request,
            final HttpServletResponse response, final FilterChain chain)
            throws AlreadyGzippedException, AlreadyCommittedException,
            FilterNonReentrantException, LockTimeoutException, Exception {


System.err.println("---------cached-----------");
        super.doFilter(request, response, chain);

//        if (cacheURLs == null) {
//            init();
//        }
//        
//        String url = request.getRequestURI();
//        
//        boolean flag = false;
//        
//        if (cacheURLs != null && cacheURLs.length > 0) {
//            for (String cacheURL : cacheURLs) {
//                if (url.contains(cacheURL.trim())) {
//                    flag = true;
//                    break;
//                }
//            }
//        }
//        flag = true;
//        // 如果包含我们要缓存的url 就缓存该页面,否则执行正常的页面转向
//        if (flag) {
//            String query = request.getQueryString();
//System.err.println("request.getQueryString():" + request.getQueryString());
//            if (query != null) {
//                query = "?" + query;
//            }
//System.err.println("当前请求被缓存:" + url + query);
//            super.doFilter(request, response, chain);
//        } else {
//            chain.doFilter(request, response);
//        }
    }
项目:xslweb    文件:CachingFilter.java   
/**
 * Build page info either using the cache or building the page directly.
 * <p/>
 * Some requests are for page fragments which should never be gzipped, or for
 * other pages which are not gzipped.
 */
protected PageInfo buildPageInfo(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) throws Exception {
  PipelineHandler pipelineHandler = (PipelineHandler) request.getAttribute(Definitions.ATTRNAME_PIPELINEHANDLER);
  int tti = pipelineHandler.getCacheTimeToIdle();
  int ttl = pipelineHandler.getCacheTimeToLive();

  // Look up the cached page
  final String key = calculateKey(request);
  PageInfo pageInfo = null;
  try {
    checkNoReentry(request);
    Element element = blockingCache.get(key);
    if (element == null || element.getObjectValue() == null) {
      try {
        // Page is not cached - build the response, cache it, and
        // send to client
        pageInfo = buildPage(request, response, chain);
        if (pageInfo.isOk()) {
          if (logger.isDebugEnabled()) {
            logger.debug("PageInfo ok. Adding to cache " + blockingCache.getName() + " with key " + key);
          }
          blockingCache.put(new Element(key, pageInfo, false, tti, ttl));
        } else {
          if (logger.isDebugEnabled()) {
            logger.debug("PageInfo was not ok(200). Putting null into cache " + blockingCache.getName() + " with key " + key);
          }
          blockingCache.put(new Element(key, null, false, tti, ttl));
        }
      } catch (final Throwable throwable) {
        // Must unlock the cache if the above fails. Will be logged
        // at Filter
        blockingCache.put(new Element(key, null, false, tti, ttl));
        throw new Exception(throwable);
      }
    } else {
      pageInfo = (PageInfo) element.getObjectValue();
    }
  } catch (LockTimeoutException e) {
    // do not release the lock, because you never acquired it
    throw e;
  } finally {
    // all done building page, reset the re-entrant flag
    visitLog.clear();
  }
  return pageInfo;
}
项目:xslweb    文件:CachingFilter.java   
/**
 * Performs the filtering for a request. This method caches based responses
 * keyed by {@link #calculateKey(javax.servlet.http.HttpServletRequest)}
 * <p/>
 * By default this method will queue requests requesting the page response for
 * a given key until the first thread in the queue has completed. The request
 * which occurs when the page expires incurs the cost of waiting for the
 * downstream processing to return the respone.
 * <p/>
 * The maximum time to wait can be configured by setting
 * <code>setTimeoutMillis</code> on the underlying <code>BlockingCache</code>.
 * 
 * @param request
 * @param response
 * @param chain
 * @throws AlreadyGzippedException
 *           if a double gzip is attempted
 * @throws AlreadyCommittedException
 *           if the response was committed on the way in or the on the way
 *           back
 * @throws FilterNonReentrantException
 *           if an attempt is made to reenter this filter in the same request.
 * @throws LockTimeoutException
 *           if this request is waiting on another that is populating the
 *           cache entry and timeouts while waiting. Only occurs if the
 *           BlockingCache has a timeout set.
 * @throws Exception
 *           for all other exceptions. They will be caught and logged in
 *           {@link Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)}
 */
protected void doFilter(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) throws AlreadyGzippedException, AlreadyCommittedException, FilterNonReentrantException, LockTimeoutException, Exception {
  if (response.isCommitted()) {
    throw new AlreadyCommittedException("Response already committed before doing buildPage.");
  }
  logRequestHeaders(request);
  PageInfo pageInfo = buildPageInfo(request, response, chain);

  if (pageInfo.isOk()) {
    if (response.isCommitted()) {
      throw new AlreadyCommittedException("Response already committed after doing buildPage" + " but before writing response from PageInfo.");
    }
    writeResponse(request, response, pageInfo);
  }
}