コード例 #1
0
  protected void doDestroyNearCacheAndDestroyAllNearCaches() {
    NearCacheManager nearCacheManager = createNearCacheManager();

    for (int i = 0; i < DEFAULT_NEAR_CACHE_COUNT; i++) {
      createNearCache(nearCacheManager, DEFAULT_NEAR_CACHE_NAME + "-" + i);
    }

    Collection<NearCache> nearCaches1 = nearCacheManager.listAllNearCaches();
    assertEquals(DEFAULT_NEAR_CACHE_COUNT, nearCaches1.size());

    for (int i = 0; i < DEFAULT_NEAR_CACHE_COUNT; i++) {
      assertTrue(nearCacheManager.destroyNearCache(DEFAULT_NEAR_CACHE_NAME + "-" + i));
    }

    Collection<NearCache> nearCaches2 = nearCacheManager.listAllNearCaches();
    // destroy also removes Near Cache
    assertEquals(0, nearCaches2.size());

    assertFalse(
        nearCacheManager.clearNearCache(DEFAULT_NEAR_CACHE_NAME + "-" + DEFAULT_NEAR_CACHE_COUNT));

    for (int i = 0; i < DEFAULT_NEAR_CACHE_COUNT; i++) {
      createNearCache(nearCacheManager, DEFAULT_NEAR_CACHE_NAME + "-" + i);
    }

    Collection<NearCache> nearCaches3 = nearCacheManager.listAllNearCaches();
    assertEquals(DEFAULT_NEAR_CACHE_COUNT, nearCaches3.size());

    nearCacheManager.destroyAllNearCaches();
    Collection<NearCache> nearCaches4 = nearCacheManager.listAllNearCaches();
    // destroy all also removes Near Caches
    assertEquals(0, nearCaches4.size());
  }
コード例 #2
0
 @Override
 public void destroy() {
   if (nearCache != null) {
     removeInvalidationListener();
     nearCacheManager.destroyNearCache(nearCache.getName());
   }
   if (statisticsEnabled) {
     statistics.clear();
   }
   super.destroy();
 }