當前位置: 首頁>>代碼示例>>Java>>正文


Java RemovalNotification.getCause方法代碼示例

本文整理匯總了Java中com.google.common.cache.RemovalNotification.getCause方法的典型用法代碼示例。如果您正苦於以下問題:Java RemovalNotification.getCause方法的具體用法?Java RemovalNotification.getCause怎麽用?Java RemovalNotification.getCause使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.cache.RemovalNotification的用法示例。


在下文中一共展示了RemovalNotification.getCause方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onRemoval

import com.google.common.cache.RemovalNotification; //導入方法依賴的package包/類
@Override
public void onRemoval(RemovalNotification<K, V> notification)
{
    switch (notification.getCause())
    {
        case EXPIRED:
            notifyListeners(new GuavaCacheEntryEvent<>(this, EventType.EXPIRED, notification));
            break;

        case EXPLICIT:
            notifyListeners(new GuavaCacheEntryEvent<>(this, EventType.REMOVED, notification));
            break;

        case REPLACED:
            notifyListeners(new GuavaCacheEntryEvent<>(this, EventType.UPDATED, notification));
            break;
    }
}
 
開發者ID:ocafebabe,項目名稱:guava-jcache,代碼行數:19,代碼來源:GuavaCache.java

示例2: testCacheExpire

import com.google.common.cache.RemovalNotification; //導入方法依賴的package包/類
@Test
public void testCacheExpire() throws InterruptedException {
    int total = 10;
    final Map<String, String> expired = new HashMap<>();
    RemovalListener removalListener = new RemovalListener<String, String>() {
        @Override
        public void onRemoval(RemovalNotification<String, String> notification) {
            if(RemovalCause.EXPIRED == notification.getCause()) {
                expired.put(notification.getKey(), notification.getValue());
            }
        }
    };
    Cache<String, String> myCache = CacheBuilder.newBuilder()
            .expireAfterWrite(2, TimeUnit.MILLISECONDS)
            .removalListener(removalListener)
            .build();
    for(int i = 0; i < total; i++) {
        myCache.put("key_" + i, "val_" + i);
    }
    Thread.sleep(10);
    myCache.cleanUp();
    assertEquals(total, expired.size());
}
 
開發者ID:RapturePlatform,項目名稱:Rapture,代碼行數:24,代碼來源:TransactionManagerTest.java

示例3: onRemoval

import com.google.common.cache.RemovalNotification; //導入方法依賴的package包/類
@Override
public void onRemoval(RemovalNotification<CacheValue, NodeDocument> n) {
    //If removed explicitly then we clear from L2
    if (n.getCause() == RemovalCause.EXPLICIT
            || n.getCause() == RemovalCause.REPLACED) {
        offHeapCache.invalidate(n.getKey());
    }

    //If removed because of size then we move it to
    //L2
    if (n.getCause() == RemovalCause.SIZE) {
        NodeDocument doc = n.getValue();
        if (doc != NodeDocument.NULL) {
            offHeapCache.put(n.getKey(),
                    new NodeDocReference(n.getKey(), doc));
        }
    }
}
 
開發者ID:denismo,項目名稱:jackrabbit-dynamodb-store,代碼行數:19,代碼來源:NodeDocOffHeapCache.java

示例4: onRemoval

import com.google.common.cache.RemovalNotification; //導入方法依賴的package包/類
@Override
	public void onRemoval(RemovalNotification<Writable, T> note) {
//		System.err.println("S0 Cache: " + activeKey + " " + note.getKey() + " " + note.getCause() + " " + cache.size());
		if (!(note.wasEvicted() || note.getCause() == RemovalCause.EXPLICIT)) {
			return;
		}
		if (activeKey != null && activeKey.equals(note.getKey())) {
			return;
		}

		try {
//			System.err.println("  s0emit: " + note.getCause() + " " + note.getKey() + " " + note.getValue());
			// Emit the record.
			collector.emit(new FValues(note.getKey(), note.getValue()));
		} catch (Throwable e) {
			lastThrown = e;
		}
	}
 
開發者ID:JamesLampton,項目名稱:piggybank-squeal,代碼行數:19,代碼來源:Stage0Executor.java

示例5: onRemoval

import com.google.common.cache.RemovalNotification; //導入方法依賴的package包/類
@Override
public void onRemoval(RemovalNotification<String, CachedOffer> notification) {
  if (notification.getCause() == RemovalCause.EXPLICIT) {
    return;
  }

  LOG.debug("Cache removal for {} due to {}", notification.getKey(), notification.getCause());

  synchronized (offerCache) {
    if (notification.getValue().offerState == OfferState.AVAILABLE) {
      declineOffer(notification.getValue());
    } else {
      notification.getValue().expire();
    }
  }
}
 
開發者ID:HubSpot,項目名稱:Singularity,代碼行數:17,代碼來源:SingularityOfferCache.java

示例6: onRemoval

import com.google.common.cache.RemovalNotification; //導入方法依賴的package包/類
@Override
public void onRemoval(RemovalNotification<Object, Object> notification) {
    if (notification.getCause() == RemovalCause.SIZE) {
        if (evictionCounter % logInterval == 0) {
            logger.log(LogLevel.INFO, "Cache entries evicted. In-memory cache of {}: Size{{}} MaxSize{{}}, {} {}", cacheId, cache.size(), maxSize, cache.stats(), EVICTION_MITIGATION_MESSAGE);
        }
        evictionCounter++;
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:10,代碼來源:LoggingEvictionListener.java

示例7: onRemoval

import com.google.common.cache.RemovalNotification; //導入方法依賴的package包/類
@Override
public void onRemoval(RemovalNotification<FileInfo, MuxedFile> notification) {
	if (notification.getCause() != RemovalCause.EXPLICIT) {
		MuxedFile muxedFile = notification.getValue();
		// This is racy, at worst we will re-trigger muxing for unlucky files being re-opened
		if (!openMuxFiles.containsValue(muxedFile)) {
			muxFiles.remove(muxedFile.getInfo(), muxedFile.getMuxer());
			logger.info("Expired {}: {} deleted = {}", notification.getCause(), muxedFile, safeDelete(muxedFile));
		} else {
			logger.warn("BUG: Expired {}: {}, but is still open!", notification.getCause(), muxedFile);
		}
	}
}
 
開發者ID:tfiskgul,項目名稱:mux2fs,代碼行數:14,代碼來源:MuxFs.java

示例8: onRemoval

import com.google.common.cache.RemovalNotification; //導入方法依賴的package包/類
@Override
public void onRemoval(final RemovalNotification<String, List<MemberDescriptor>> notification) {
  final RemovalCause cause = notification.getCause();
  if (cause.equals(RemovalCause.EXPLICIT)) {
    final String key = notification.getKey();
    ProjectDatabaseHelper.deleteMemberDescriptors(key);
  }
}
 
開發者ID:mopemope,項目名稱:meghanada-server,代碼行數:9,代碼來源:MemberCacheLoader.java

示例9: onRemoval

import com.google.common.cache.RemovalNotification; //導入方法依賴的package包/類
@Override
public void onRemoval(final RemovalNotification<File, Source> notification) {
  final RemovalCause cause = notification.getCause();

  final Config config = Config.load();
  if (config.useSourceCache() && cause.equals(RemovalCause.EXPLICIT)) {
    final Source source = notification.getValue();
    try {
      deleteSource(source);
    } catch (Exception e) {
      log.catching(e);
    }
  }
}
 
開發者ID:mopemope,項目名稱:meghanada-server,代碼行數:15,代碼來源:JavaSourceLoader.java

示例10: onRemoval

import com.google.common.cache.RemovalNotification; //導入方法依賴的package包/類
@Override
public void onRemoval(RemovalNotification<String, String> notification) {
    // rollback transaction on expire
    if(RemovalCause.EXPIRED == notification.getCause()) {
        rollback(notification.getKey());
    }
}
 
開發者ID:RapturePlatform,項目名稱:Rapture,代碼行數:8,代碼來源:TransactionManager.java

示例11: onRemoval

import com.google.common.cache.RemovalNotification; //導入方法依賴的package包/類
@Override
public void onRemoval(final RemovalNotification<ChunkCoordIntPair, NBTTagCompound> notification) {
	try {
		// Only flush the entry if it was invalidated. Any entry could
		// be updated prior to it being written by an IO thread so we
		// want to avoid unnecessary writes.
		if (notification.getCause() == RemovalCause.EXPLICIT)
			AnvilChunkLoader.this.writeChunkNBTTags(notification.getKey(), notification.getValue());
	} catch (final Exception e) {
		e.printStackTrace();
	}
}
 
開發者ID:OreCruncher,項目名稱:Jiffy,代碼行數:13,代碼來源:AnvilChunkLoader.java

示例12: onRemoval

import com.google.common.cache.RemovalNotification; //導入方法依賴的package包/類
@Override
public void onRemoval(RemovalNotification<TypedDirectionNamedPath, Notification> event) {
    switch (event.getCause()) {
        case SIZE: {
            LOG.warn(String.format("Evicted notification '%s' with %d events", event.getKey(), event.getValue().getCount()));
            break;
        }
        default: {
            break;
        }
    }
}
 
開發者ID:hflabs,項目名稱:perecoder,代碼行數:13,代碼來源:ByTypedNamedPathCollector.java

示例13: onRemoval

import com.google.common.cache.RemovalNotification; //導入方法依賴的package包/類
/**
 * Callback method for removal of items from the histories cache. Items removed from the cache need to be acked or failed
 * according to the reason they were removed
 */
@Override
public void onRemoval(RemovalNotification<CVParticle, String> notification) {
	// make sure the CVParticle object is removed from the history (even if removal was automatic!)
	history.clear(notification.getKey(), notification.getValue());
	if(notification.getCause() == RemovalCause.EXPIRED || notification.getCause() == RemovalCause.SIZE){
		// item removed automatically --> fail the tuple
		collector.fail(notification.getKey().getTuple());
	}else{
		// item removed explicitly --> ack the tuple
		collector.ack(notification.getKey().getTuple());
	}
}
 
開發者ID:sensorstorm,項目名稱:StormCV,代碼行數:17,代碼來源:BatchInputBolt.java

示例14: onRemoval

import com.google.common.cache.RemovalNotification; //導入方法依賴的package包/類
@Override
	public void onRemoval(RemovalNotification<Writable, T> note) {
//		System.err.println("S1 Cache: " + activeKey + " " + note.getKey() + " " + note.getCause() + " " + cache.size());
		if (!(note.wasEvicted() || note.getCause() == RemovalCause.EXPLICIT)) {
			return;
		}
		
		if (activeKey != null && activeKey.equals(note.getKey())) {
			return;
		}

		try {
			// Determine if the current value is in the backlog or the prefetch.
			T cur;
			if (!stateBacklog.containsKey(note.getKey())) {
				// Pull the values in from the prefetch.
				runPrefetch();
			}
			cur = stateBacklog.remove(note.getKey());
//			System.err.println("stateBacklogged: k=<" + note.getKey() + "> v=" + cur);

			// Apply the update.
			cur = storeAgg.combine(cur, note.getValue());

			// Move things to the writeAhead.
			writeAhead.put(note.getKey(), cur);

			// Emit the result.
			collector.emit(new FValues(note.getKey(), cur));
		} catch (Throwable e) {
			lastThrown = e;
		}
	}
 
開發者ID:JamesLampton,項目名稱:piggybank-squeal,代碼行數:34,代碼來源:Stage1Executor.java

示例15: onRemoval

import com.google.common.cache.RemovalNotification; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public void onRemoval(final RemovalNotification<String, StratumTcpServerConnection> notification)
{
    if (notification.getCause() == RemovalCause.EXPIRED)
        StratumTcpServer.this.onConnectionTimeout(notification.getValue());
}
 
開發者ID:GuyPaddock,項目名稱:JStratum,代碼行數:10,代碼來源:StratumTcpServer.java


注:本文中的com.google.common.cache.RemovalNotification.getCause方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。