コード例 #1
0
  @Test
  public void testGetCache() throws Exception {

    // Create on missing

    IntrabandPortalCacheManager<String, String> intraBandPortalCacheManager =
        new IntrabandPortalCacheManager<String, String>(_mockRegistrationReference);

    Map<String, PortalCache<?, ?>> portalCaches = getPortalCaches(intraBandPortalCacheManager);

    Assert.assertTrue(portalCaches.isEmpty());

    String portalCacheName = "portalCacheName";

    PortalCache<?, ?> portalCache = intraBandPortalCacheManager.getCache(portalCacheName);

    Assert.assertNotNull(portalCache);
    Assert.assertEquals(portalCacheName, portalCache.getName());
    Assert.assertEquals(1, portalCaches.size());
    Assert.assertSame(portalCache, portalCaches.get(portalCacheName));

    // Get existing

    PortalCache<?, ?> portalCache2 = intraBandPortalCacheManager.getCache(portalCacheName);

    Assert.assertNotNull(portalCache2);
    Assert.assertEquals(portalCacheName, portalCache2.getName());
    Assert.assertEquals(1, portalCaches.size());
    Assert.assertSame(portalCache, portalCache2);
  }
コード例 #2
0
  @Override
  public void notifyRemoveAll(PortalCache<K, V> portalCache) throws PortalCacheException {

    if (!_replicateRemovals) {
      return;
    }

    PortalCacheManager<K, V> portalCacheManager = portalCache.getPortalCacheManager();

    PortalCacheClusterEvent portalCacheClusterEvent =
        new PortalCacheClusterEvent(
            portalCacheManager.getName(),
            portalCache.getName(),
            null,
            PortalCacheClusterEventType.REMOVE_ALL);

    PortalCacheClusterLinkUtil.sendEvent(portalCacheClusterEvent);
  }
コード例 #3
0
  @Override
  public void notifyEntryRemoved(PortalCache<K, V> portalCache, K key, V value, int timeToLive)
      throws PortalCacheException {

    if (!_replicateRemovals) {
      return;
    }

    PortalCacheManager<K, V> portalCacheManager = portalCache.getPortalCacheManager();

    PortalCacheClusterEvent portalCacheClusterEvent =
        new PortalCacheClusterEvent(
            portalCacheManager.getName(),
            portalCache.getName(),
            key,
            PortalCacheClusterEventType.REMOVE);

    PortalCacheClusterLinkUtil.sendEvent(portalCacheClusterEvent);
  }
コード例 #4
0
  @Override
  public void notifyEntryPut(PortalCache<K, V> portalCache, K key, V value, int timeToLive)
      throws PortalCacheException {

    if (!_replicatePuts) {
      return;
    }

    PortalCacheManager<K, V> portalCacheManager = portalCache.getPortalCacheManager();

    PortalCacheClusterEvent portalCacheClusterEvent =
        new PortalCacheClusterEvent(
            portalCacheManager.getName(),
            portalCache.getName(),
            key,
            PortalCacheClusterEventType.PUT);

    if (_replicatePutsViaCopy) {
      portalCacheClusterEvent.setElementValue(value);
      portalCacheClusterEvent.setTimeToLive(timeToLive);
    }

    PortalCacheClusterLinkUtil.sendEvent(portalCacheClusterEvent);
  }