/** * @return cacheElement.getCacheName(); * @see ICacheElement#getCacheName */ @Override public String getCacheName() { return cacheElement.getCacheName(); }
/** * @return cacheElement.getCacheName(); * @see ICacheElement#getCacheName */ @Override public String getCacheName() { return cacheElement.getCacheName(); }
/** * Log some details. * <p> * @param item */ private void logUpdateInfo( ICacheElement<K, V> item ) { // not thread safe, but it doesn't have to be 100% accurate puts++; if ( log.isInfoEnabled() ) { if ( puts % logInterval == 0 ) { log.info( "puts = " + puts ); } } if ( log.isDebugEnabled() ) { log.debug( "In update, put [" + item.getKey() + "] in [" + item.getCacheName() + "]" ); } }
/** * Log some details. * <p> * @param item */ private void logUpdateInfo( ICacheElement<K, V> item ) { if ( log.isInfoEnabled() ) { // not thread safe, but it doesn't have to be accurate puts++; if ( puts % logInterval == 0 ) { log.info( "puts = " + puts ); } } if ( log.isDebugEnabled() ) { log.debug( "In update, put [" + item.getKey() + "] in [" + item.getCacheName() + "]" ); } }
/** * Log some details. * <p> * @param item */ private void logUpdateInfo( ICacheElement<K, V> item ) { if ( log.isInfoEnabled() ) { // not thread safe, but it doesn't have to be accurate puts++; if ( puts % logInterval == 0 ) { log.info( "puts = " + puts ); } } if ( log.isDebugEnabled() ) { log.debug( "In update, put [" + item.getKey() + "] in [" + item.getCacheName() + "]" ); } }
/** * Log some details. * <p> * @param item */ private void logUpdateInfo( ICacheElement<K, V> item ) { // not thread safe, but it doesn't have to be 100% accurate puts++; if ( log.isInfoEnabled() ) { if ( puts % logInterval == 0 ) { log.info( "puts = " + puts ); } } if ( log.isDebugEnabled() ) { log.debug( "In update, put [" + item.getKey() + "] in [" + item.getCacheName() + "]" ); } }
/** * Update lateral. * <p> * @param ce * @throws IOException */ @Override protected void processUpdate( ICacheElement<K, V> ce ) throws IOException { try { if ( log.isDebugEnabled() ) { log.debug( "update: lateral = [" + lateralCacheService + "], " + "CacheInfo.listenerId = " + CacheInfo.listenerId ); } lateralCacheService.update( ce, CacheInfo.listenerId ); } catch ( NullPointerException npe ) { log.error( "Failure updating lateral. lateral = " + lateralCacheService, npe ); handleException( npe, "Failed to put [" + ce.getKey() + "] to " + ce.getCacheName() + "@" + lateralCacheAttributes ); return; } catch ( Exception ex ) { handleException( ex, "Failed to put [" + ce.getKey() + "] to " + ce.getCacheName() + "@" + lateralCacheAttributes ); } }
/** * Constructor for the PurgatoryElement<K, V> object * * @param cacheElement CacheElement */ public PurgatoryElement( ICacheElement<K, V> cacheElement ) { super(cacheElement.getCacheName(), cacheElement.getKey(), cacheElement.getVal(), cacheElement.getElementAttributes()); this.cacheElement = cacheElement; }
/** * Update lateral. * <p> * @param ce * @throws IOException */ @Override protected void processUpdate( ICacheElement<K, V> ce ) throws IOException { try { if (ce != null) { if ( log.isDebugEnabled() ) { log.debug( "update: lateral = [" + lateralCacheService + "], " + "CacheInfo.listenerId = " + CacheInfo.listenerId ); } lateralCacheService.update( ce, CacheInfo.listenerId ); } } catch ( IOException ex ) { handleException( ex, "Failed to put [" + ce.getKey() + "] to " + ce.getCacheName() + "@" + lateralCacheAttributes ); } }
/** * Constructor for the PurgatoryElement<K, V> object * <p> * @param cacheElement CacheElement */ public PurgatoryElement( ICacheElement<K, V> cacheElement ) { super(cacheElement.getCacheName(), cacheElement.getKey(), cacheElement.getVal(), cacheElement.getElementAttributes()); this.cacheElement = cacheElement; }
/** * Increments the put count. Gets the cache that was injected by the lateral factory. Calls put * on the cache. * <p> * @see org.apache.commons.jcs.engine.behavior.ICacheListener#handlePut(org.apache.commons.jcs.engine.behavior.ICacheElement) */ @Override public void handlePut( ICacheElement<K, V> element ) throws IOException { putCnt++; if ( log.isInfoEnabled() ) { if ( getPutCnt() % 100 == 0 ) { log.info( "Put Count (port " + getTcpLateralCacheAttributes().getTcpListenerPort() + ") = " + getPutCnt() ); } } if ( log.isDebugEnabled() ) { log.debug( "handlePut> cacheName=" + element.getCacheName() + ", key=" + element.getKey() ); } getCache( element.getCacheName() ).localUpdate( element ); }
/** * Logs an event if an event logger is configured. * <p> * @param item * @param requesterId * @param eventName * @return ICacheEvent */ private ICacheEvent<ICacheElement<K, V>> createICacheEvent( ICacheElement<K, V> item, long requesterId, String eventName ) { if ( cacheEventLogger == null ) { return new CacheEvent<ICacheElement<K, V>>(); } String ipAddress = getExtraInfoForRequesterId( requesterId ); return cacheEventLogger .createICacheEvent( "RemoteCacheServer", item.getCacheName(), eventName, ipAddress, item ); }
/** * Logs an event if an event logger is configured. * <p> * @param item * @param requesterId * @param eventName * @return ICacheEvent */ private ICacheEvent<ICacheElement<K, V>> createICacheEvent( ICacheElement<K, V> item, long requesterId, String eventName ) { if ( cacheEventLogger == null ) { return new CacheEvent<ICacheElement<K, V>>(); } String ipAddress = getExtraInfoForRequesterId( requesterId ); return cacheEventLogger .createICacheEvent( "RemoteCacheServer", item.getCacheName(), eventName, ipAddress, item ); }
/** * Logs an event if an event logger is configured. * <p> * @param item * @param requesterId * @param eventName * @return ICacheEvent */ protected ICacheEvent<ICacheElement<K, V>> createICacheEvent( ICacheElement<K, V> item, long requesterId, String eventName ) { if ( cacheEventLogger == null ) { return new CacheEvent<ICacheElement<K, V>>(); } String ipAddress = getExtraInfoForRequesterId( requesterId ); return cacheEventLogger.createICacheEvent( getEventLogSourceName(), item.getCacheName(), eventName, ipAddress, item ); }
/** * Logs an event if an event logger is configured. * <p> * @param item * @param requesterId * @param eventName * @return ICacheEvent */ protected ICacheEvent<ICacheElement<K, V>> createICacheEvent( ICacheElement<K, V> item, long requesterId, String eventName ) { if ( cacheEventLogger == null ) { return new CacheEvent<ICacheElement<K, V>>(); } String ipAddress = getExtraInfoForRequesterId( requesterId ); return cacheEventLogger.createICacheEvent( getEventLogSourceName(), item.getCacheName(), eventName, ipAddress, item ); }
/** * Creates an Update Request. * <p> * @param cacheElement * @param requesterId * @return RemoteHttpCacheRequest */ public static <K, V> RemoteCacheRequest<K, V> createUpdateRequest( ICacheElement<K, V> cacheElement, long requesterId ) { RemoteCacheRequest<K, V> request = createRequest(null, RemoteRequestType.UPDATE, requesterId); if ( cacheElement != null ) { request.setCacheName( cacheElement.getCacheName() ); request.setCacheElement( cacheElement ); request.setKey( cacheElement.getKey() ); } else { log.error( "Can't create a proper update request for a null cache element." ); } return request; }
/** * Processes an update request. * <p> * If isLocalClusterConsistency is enabled we will treat this as a normal request of non-remote * origination. * <p> * @param item * @param requesterId * @throws IOException */ @Override public void processUpdate( ICacheElement<K, V> item, long requesterId ) throws IOException { CompositeCache<K, V> cache = getCacheManager().getCache( item.getCacheName() ); boolean keepLocal = !remoteHttpCacheServerAttributes.isLocalClusterConsistency(); if ( keepLocal ) { cache.localUpdate( item ); } else { cache.update( item ); } }
/** * Processes an update request. * <p> * If isLocalClusterConsistency is enabled we will treat this as a normal request of non-remote * origination. * <p> * @param item * @param requesterId * @throws IOException */ @Override public void processUpdate( ICacheElement<K, V> item, long requesterId ) throws IOException { CompositeCache<K, V> cache = getCacheManager().getCache( item.getCacheName() ); boolean keepLocal = !remoteHttpCacheServerAttributes.isLocalClusterConsistency(); if ( keepLocal ) { cache.localUpdate( item ); } else { cache.update( item ); } }
/** * * @throws Exception */ public void testSimpleElementRetrieval() throws Exception { CacheAccess<String, String> jcs = JCS.getInstance( "testCache1" ); jcs.put( "test_key", "test_data" ); long now = System.currentTimeMillis(); ICacheElement<String, String> elem = jcs.getCacheElement( "test_key" ); assertEquals( "Name wasn't right", "testCache1", elem.getCacheName() ); long diff = now - elem.getElementAttributes().getCreateTime(); assertTrue( "Create time should have been at or after the call", diff >= 0 ); }
/** * * @throws Exception */ public void testSimpleElementRetrieval() throws Exception { CacheAccess<String, String> jcs = JCS.getInstance( "testCache1" ); jcs.put( "test_key", "test_data" ); long now = System.currentTimeMillis(); ICacheElement<String, String> elem = jcs.getCacheElement( "test_key" ); assertEquals( "Name wasn't right", "testCache1", elem.getCacheName() ); long diff = now - elem.getElementAttributes().getCreateTime(); assertTrue( "Create time should have been at or after the call", diff >= 0 ); }