@Test
  public void testAssertBigPayload() {
    List<CachePeer> localPeers = manager1.getCachePeerListener("RMI").getBoundCachePeers();
    List<byte[]> payloadList = PayloadUtil.createCompressedPayloadList(localPeers, 150);
    Assert.assertTrue("Payload is not big enough for cacheManager-1", payloadList.size() > 1);

    localPeers = manager2.getCachePeerListener("RMI").getBoundCachePeers();
    payloadList = PayloadUtil.createCompressedPayloadList(localPeers, 150);
    Assert.assertTrue("Payload is not big enough for cacheManager-2", payloadList.size() > 1);

    localPeers = manager3.getCachePeerListener("RMI").getBoundCachePeers();
    payloadList = PayloadUtil.createCompressedPayloadList(localPeers, 150);
    Assert.assertTrue("Payload is not big enough for cacheManager-3", payloadList.size() > 1);

    CacheManager manager4 =
        new CacheManager(
            AbstractCacheTest.TEST_CONFIG_DIR
                + "distribution/ehcache-distributed-big-payload-4.xml");
    try {
      localPeers = manager4.getCachePeerListener("RMI").getBoundCachePeers();
      payloadList = PayloadUtil.createCompressedPayloadList(localPeers, 150);
      Assert.assertTrue("Payload is not big enough for cacheManager-4", payloadList.size() > 1);
    } finally {
      manager4.shutdown();
    }
  }
Exemplo n.º 2
0
  /** Are all of the replicated caches bound to the RMI listener? */
  @Test
  public void testPeersBound() {

    List cachePeers1 =
        ((RMICacheManagerPeerListener) manager1.getCachePeerListener("RMI")).getBoundCachePeers();
    assertEquals(1, cachePeers1.size());
    String[] boundCachePeers1 =
        ((RMICacheManagerPeerListener) manager1.getCachePeerListener("RMI"))
            .listBoundRMICachePeers();
    assertEquals(1, boundCachePeers1.length);
    assertEquals(cachePeers1.size(), boundCachePeers1.length);

    List cachePeers2 =
        ((RMICacheManagerPeerListener) manager2.getCachePeerListener("RMI")).getBoundCachePeers();
    assertEquals(1, cachePeers2.size());
    String[] boundCachePeers2 =
        ((RMICacheManagerPeerListener) manager2.getCachePeerListener("RMI"))
            .listBoundRMICachePeers();
    assertEquals(1, boundCachePeers2.length);
    assertEquals(cachePeers2.size(), boundCachePeers2.length);

    List cachePeers3 =
        ((RMICacheManagerPeerListener) manager3.getCachePeerListener("RMI")).getBoundCachePeers();
    assertEquals(1, cachePeers3.size());
    String[] boundCachePeers3 =
        ((RMICacheManagerPeerListener) manager3.getCachePeerListener("RMI"))
            .listBoundRMICachePeers();
    assertEquals(1, boundCachePeers3.length);
    assertEquals(cachePeers3.size(), boundCachePeers3.length);

    List cachePeers4 =
        ((RMICacheManagerPeerListener) manager4.getCachePeerListener("RMI")).getBoundCachePeers();
    assertEquals(1, cachePeers4.size());
    String[] boundCachePeers4 =
        ((RMICacheManagerPeerListener) manager4.getCachePeerListener("RMI"))
            .listBoundRMICachePeers();
    assertEquals(1, boundCachePeers4.length);
    assertEquals(cachePeers4.size(), boundCachePeers4.length);

    List cachePeers5 =
        ((RMICacheManagerPeerListener) manager5.getCachePeerListener("RMI")).getBoundCachePeers();
    assertEquals(1, cachePeers5.size());
    String[] boundCachePeers5 =
        ((RMICacheManagerPeerListener) manager5.getCachePeerListener("RMI"))
            .listBoundRMICachePeers();
    assertEquals(1, boundCachePeers5.length);
    assertEquals(cachePeers5.size(), boundCachePeers5.length);
  }
Exemplo n.º 3
0
  /** Are all of the CachePeers for replicated caches bound to the listener and working? */
  @Test
  public void testBoundListenerPeersAfterCacheRemove() throws RemoteException {
    String[] boundCachePeers =
        ((RMICacheManagerPeerListener) manager1.getCachePeerListener("RMI"))
            .listBoundRMICachePeers();
    assertEquals(1, boundCachePeers.length);
    validateBoundCachePeer(boundCachePeers);

    // Remove a replicated cache
    manager1.removeCache("asynchronousCache");
    boundCachePeers =
        ((RMICacheManagerPeerListener) manager1.getCachePeerListener("RMI"))
            .listBoundRMICachePeers();
    assertEquals(0, boundCachePeers.length);
    validateBoundCachePeer(boundCachePeers);
  }
Exemplo n.º 4
0
 private void validateBoundCachePeer(String[] boundCachePeers) {
   for (String boundCacheName : boundCachePeers) {
     Remote remote =
         ((RMICacheManagerPeerListener) manager1.getCachePeerListener("RMI"))
             .lookupPeer(boundCacheName);
     assertNotNull(remote);
   }
 }
Exemplo n.º 5
0
  /** Are all of the CachePeers for replicated caches bound to the listener and working? */
  @Test
  public void testBoundListenerPeersAfterDefaultCacheAdd() throws RemoteException {

    String[] boundCachePeers =
        ((RMICacheManagerPeerListener) manager1.getCachePeerListener("RMI"))
            .listBoundRMICachePeers();
    assertEquals(1, boundCachePeers.length);
    validateBoundCachePeer(boundCachePeers);

    // Add from default which is has a CacheReplicator configured.
    manager1.addCache("fromDefaultCache");
    boundCachePeers =
        ((RMICacheManagerPeerListener) manager1.getCachePeerListener("RMI"))
            .listBoundRMICachePeers();
    assertEquals(2, boundCachePeers.length);
    validateBoundCachePeer(boundCachePeers);
  }
Exemplo n.º 6
0
  /** Are all of the replicated caches bound to the listener and working? */
  @Test
  public void testBoundListenerPeers() throws RemoteException {

    String[] boundCachePeers =
        ((RMICacheManagerPeerListener) manager1.getCachePeerListener("RMI"))
            .listBoundRMICachePeers();
    validateBoundCachePeer(boundCachePeers);
  }
Exemplo n.º 7
0
  /** Does the RMI listener stop? */
  @Test
  public void testListenerShutsdown() {
    CacheManagerPeerListener cachePeerListener = manager1.getCachePeerListener("RMI");
    List cachePeers1 = cachePeerListener.getBoundCachePeers();
    assertEquals(1, cachePeers1.size());
    assertEquals(Status.STATUS_ALIVE, cachePeerListener.getStatus());

    manager1.shutdown();
    assertEquals(Status.STATUS_SHUTDOWN, cachePeerListener.getStatus());
  }
Exemplo n.º 8
0
  /** Are all of the CachePeers for replicated caches bound to the listener and working? */
  @Test
  public void testBoundListenerPeersAfterProgrammaticCacheAdd() throws RemoteException {

    String[] boundCachePeers =
        ((RMICacheManagerPeerListener) manager1.getCachePeerListener("RMI"))
            .listBoundRMICachePeers();
    assertEquals(1, boundCachePeers.length);
    validateBoundCachePeer(boundCachePeers);

    // Add from default which is has a CacheReplicator configured.

    RMICacheReplicatorFactory factory = new RMICacheReplicatorFactory();
    CacheEventListener replicatingListener = factory.createCacheEventListener(null);
    Cache cache =
        new Cache(new CacheConfiguration().name("programmaticallyAdded").maxEntriesLocalHeap(0));
    cache.getCacheEventNotificationService().registerListener(replicatingListener);

    manager1.addCache(cache);
    boundCachePeers =
        ((RMICacheManagerPeerListener) manager1.getCachePeerListener("RMI"))
            .listBoundRMICachePeers();
    assertEquals(2, boundCachePeers.length);
    validateBoundCachePeer(boundCachePeers);
  }
 /**
  * @param rmiUrls
  * @return true if our own hostname and listener port are found in the list. This then means we
  *     have caught our onw multicast, and should be ignored.
  */
 private boolean self(String rmiUrls) {
   CacheManager cacheManager = peerProvider.getCacheManager();
   CacheManagerPeerListener cacheManagerPeerListener = cacheManager.getCachePeerListener("RMI");
   if (cacheManagerPeerListener == null) {
     return false;
   }
   List boundCachePeers = cacheManagerPeerListener.getBoundCachePeers();
   if (boundCachePeers == null || boundCachePeers.size() == 0) {
     return false;
   }
   CachePeer peer = (CachePeer) boundCachePeers.get(0);
   String cacheManagerUrlBase = null;
   try {
     cacheManagerUrlBase = peer.getUrlBase();
   } catch (RemoteException e) {
     LOG.log(Level.SEVERE, "Error geting url base");
   }
   int baseUrlMatch = rmiUrls.indexOf(cacheManagerUrlBase);
   return baseUrlMatch != -1;
 }