/**
   * {@inheritDoc} Sets up two caches: cache1 is local. cache2 is to be receive updates
   *
   * @throws Exception
   */
  @Before
  public void setUp() throws Exception {
    failFastInsufficientMemory();

    MulticastKeepaliveHeartbeatSender.setHeartBeatInterval(1000);

    CountingCacheEventListener.resetCounters();
    manager1 =
        new CacheManager(
            AbstractCacheTest.TEST_CONFIG_DIR
                + "distribution/ehcache-distributed-big-payload-1.xml");
    manager2 =
        new CacheManager(
            AbstractCacheTest.TEST_CONFIG_DIR
                + "distribution/ehcache-distributed-big-payload-2.xml");
    manager3 =
        new CacheManager(
            AbstractCacheTest.TEST_CONFIG_DIR
                + "distribution/ehcache-distributed-big-payload-3.xml");
    // allow cluster to be established
    waitForClusterMembership(
        10,
        TimeUnit.SECONDS,
        Arrays.asList(manager1.getCacheNames()),
        manager1,
        manager2,
        manager3);
  }
示例#2
0
  /**
   * {@inheritDoc} Sets up two caches: cache1 is local. cache2 is to be receive updates
   *
   * @throws Exception
   */
  @Override
  @Before
  public void setUp() throws Exception {

    // Required to get SoftReference tests to pass. The VM clean up SoftReferences rather than
    // allocating
    // memory to -Xmx!
    //        forceVMGrowth();
    //        System.gc();
    MulticastKeepaliveHeartbeatSender.setHeartBeatInterval(1000);

    manager1 = new CacheManager(AbstractCachePerfTest.TEST_CONFIG_DIR + "ehcache-distributed1.xml");
    manager2 = new CacheManager(AbstractCachePerfTest.TEST_CONFIG_DIR + "ehcache-distributed2.xml");
    manager3 = new CacheManager(AbstractCachePerfTest.TEST_CONFIG_DIR + "ehcache-distributed3.xml");
    manager4 = new CacheManager(AbstractCachePerfTest.TEST_CONFIG_DIR + "ehcache-distributed4.xml");
    manager5 = new CacheManager(AbstractCachePerfTest.TEST_CONFIG_DIR + "ehcache-distributed5.xml");

    // manager6 = new CacheManager(AbstractCacheTest.TEST_CONFIG_DIR +
    // "distribution/ehcache-distributed-jndi6.xml");

    // allow cluster to be established
    Thread.sleep(1020);

    cache1 = manager1.getCache(cacheName);
    cache1.removeAll();

    cache2 = manager2.getCache(cacheName);
    cache2.removeAll();

    // enable distributed removeAlls to finish
    Thread.sleep(1500);
  }
  /** Does a down cache manager in the cluster get removed? */
  @Test
  public void testRemoteCachePeersDetectsDownCacheManagerSlow() throws InterruptedException {
    MulticastKeepaliveHeartbeatSender.setHeartBeatInterval(2000);
    try {
      Thread.sleep(2000);
      // Drop a CacheManager from the cluster
      manager3.shutdown();

      // Insufficient time, should be alive till now
      CacheManagerPeerProvider provider = manager1.getCacheManagerPeerProvider("RMI");
      for (String cacheName : manager1.getCacheNames()) {
        List remotePeersOfCache1 = provider.listRemoteCachePeers(manager1.getCache(cacheName));
        assertEquals(2, remotePeersOfCache1.size());
      }
    } finally {
      MulticastKeepaliveHeartbeatSender.setHeartBeatInterval(1000);
      Thread.sleep(2000);
    }
  }