Package org.jboss.ha.framework.server

Examples of org.jboss.ha.framework.server.DistributedReplicantManagerImpl$MergeMembers


         MBeanServerFactory.createMBeanServer("mockPartition");
      try {
         ClusterNode localAddress = new ClusterNodeImpl(new IpAddress("127.0.0.1", 12345));
         MockHAPartition partition = new MockHAPartition(localAddress);
     
         DistributedReplicantManagerImpl drm = new DistributedReplicantManagerImpl(partition);

         drm.createService();
        
         // Create a fake view for the MockHAPartition
        
         Vector<ClusterNode> remoteAddresses = new Vector<ClusterNode>();
         for (int i = 1; i < 5; i++)
            remoteAddresses.add(new ClusterNodeImpl(new IpAddress("127.0.0.1", 12340 + i)));
        
         Vector<ClusterNode> allNodes = new Vector<ClusterNode>(remoteAddresses);
         allNodes.add(localAddress);
         partition.setCurrentViewClusterNodes(allNodes);
        
         drm.startService();
        
         BlockingListenerThread blt =
            new BlockingListenerThread(drm, true, null);
        
         // Hold the lock monitor so the test thread can't acquire it
         // This keeps the blocking thread alive.
         synchronized(lock) {
            // Spawn a thread that will change a key and then block on the
            // notification back to itself
            blt.start();

            sleepThread(50);
           
            assertTrue("Test thread is alive", blt.isAlive());           
            assertTrue("Test thread is blocking", blt.isBlocking());
           
            RegistrationThread rt = new RegistrationThread(drm);
            rt.start();

            sleepThread(50);
           
            assertTrue("No deadlock on listener registration", rt.isRegistered());
           
            assertTrue("No deadlock on listener unregistration", rt.isUnregistered());
           
            assertNull("No exception in deadlock tester", blt.getException());
           
            assertTrue("Test thread is still blocking", blt.isBlocking());
            assertTrue("Test thread is still alive", blt.isAlive());
         }
        
         drm.unregisterListener("TEST", blt);
        
         sleepThread(50);
        
         // Test going through remove
         blt = new BlockingListenerThread(drm, false, null);
View Full Code Here


         MBeanServerFactory.createMBeanServer("mockPartition");
      try {
         ClusterNode localAddress = new ClusterNodeImpl(new IpAddress("127.0.0.1", 12345));
         MockHAPartition partition = new MockHAPartition(localAddress);
     
         DistributedReplicantManagerImpl drm = new DistributedReplicantManagerImpl(partition);

         drm.createService();
        
         // Create a fake view for the MockHAPartition
        
         Vector<ClusterNode> remoteAddresses = new Vector<ClusterNode>();
         for (int i = 1; i < 5; i++)
            remoteAddresses.add(new ClusterNodeImpl(new IpAddress("127.0.0.1", 12340 + i)));
        
         Vector<ClusterNode> allNodes = new Vector<ClusterNode>(remoteAddresses);
         allNodes.add(localAddress);
         partition.setCurrentViewClusterNodes(allNodes);
        
         drm.startService();
        
         String sender = ((ClusterNode)remoteAddresses.get(0)).getName();
         BlockingListenerThread blt =
            new BlockingListenerThread(drm, true, sender);
        
         // Hold the lock monitor so the test thread can't acquire it
         // This keeps the blocking thread alive.
         synchronized(lock) {
            // Spawn a thread that will change a key and then block on the
            // notification back to itself
            blt.start();

            sleepThread(50);
           
            assertFalse("JGroups thread is not alive", blt.isAlive());           
            assertTrue("Async handler thread is blocking", blt.isBlocking());
           
            assertNull("No exception in JGroups thread", blt.getException());
         }
        
         drm.unregisterListener("TEST", blt);
        
         sleepThread(50);
        
         // Test going through remove
         blt = new BlockingListenerThread(drm, false, sender);
View Full Code Here

         MBeanServerFactory.createMBeanServer("mockPartition");
      try {
         ClusterNode localAddress = new ClusterNodeImpl(new IpAddress("127.0.0.1", 12345));
         MockHAPartition partition = new MockHAPartition(localAddress);
     
         DistributedReplicantManagerImpl drm = new DistributedReplicantManagerImpl(partition);

         drm.createService();
        
         // Create a fake view for the MockHAPartition
        
         Vector<ClusterNode> remoteAddresses = new Vector<ClusterNode>();
         ClusterNode remote = new ClusterNodeImpl(new IpAddress("127.0.0.1", 12341));
         remoteAddresses.add(remote);
        
         Vector<ClusterNode> allNodes = new Vector<ClusterNode>(remoteAddresses);
         allNodes.add(localAddress);
         partition.setCurrentViewClusterNodes(allNodes);
        
         drm.startService();
        
         MockDeployer deployer = new MockDeployer(drm);
        
         if (!conflicting)
         {
            // Register a MockHASingletonDeployer, but since we're in
            // non-conflicting mode, the DeployerThreads won't deal with it
            MockHASingletonDeployer listener =
                  new MockHASingletonDeployer(deployer, "HASingleton", log);
           
            drm.registerListener("HASingleton", listener);
            drm.add("HASingleton", "HASingleton");           
         }
        
         // Create a semaphore to gate the threads and acquire all its permits
         Semaphore semaphore = new Semaphore(count + 1);
         for (int i = 0; i <= count; i++)
View Full Code Here

         }
        
         MockHAPartition partition = new MockHAPartition(nodes[2]);
         partition.setCurrentViewClusterNodes(allNodes);
        
         DistributedReplicantManagerImpl drm = new DistributedReplicantManagerImpl(partition);
         drm.createService();
         drm.startService();
        
         CachingListener listener = new CachingListener();
         drm.registerListener("TEST", listener);
        
         SecureRandom random = new SecureRandom();
         boolean[] added = new boolean[nodes.length];
         List lookup = null;
         for (int i = 0; i < 10; i++)
         {
            int node = random.nextInt(nodes.length);
            if (added[node])
            {
               if (node == 2)
                  drm.remove("TEST");
               else
                  drm._remove("TEST", nodes[node].getName());
               added[node] = false;
            }
            else
            {    
               if (node == 2)
                  drm.add("TEST", replicants[node]);
               else
                  drm._add("TEST", nodes[node].getName(), replicants[node]);  
               added[node] = true;
            }
           
            // Confirm the proper order of the replicant node names
            lookup = maskListClass(drm.lookupReplicantsNodeNames("TEST"));
            confirmReplicantList(lookup, names, added);
           
            // Confirm the proper order of the replicants via lookupReplicants
            lookup = maskListClass(drm.lookupReplicants("TEST"));
            confirmReplicantList(lookup, replicants, added);
           
            // Confirm the listener got the same list
//            assertEquals("Listener received a correct list", lookup,
//                         maskListClass(listener.replicants));
View Full Code Here

         }
        
         MockHAPartition partition = new MockHAPartition(nodes[2]);
         partition.setCurrentViewClusterNodes(allNodes);
        
         DistributedReplicantManagerImpl drm = new DistributedReplicantManagerImpl(partition);
         drm.createService();
         drm.startService();
        
         CachingListener listener = new CachingListener();
         drm.registerListener("TEST", listener);
        
         SecureRandom random = new SecureRandom();
         boolean[] added = new boolean[nodes.length];
         List lookup = null;
         List<ClusterNode> lookupReplicantsNodes = null;
         for (int i = 0; i < 10; i++)
         {
            int node = random.nextInt(nodes.length);
            if (added[node])
            {
               if (node == 2)
                  drm.remove("TEST");
               else
                  drm._remove("TEST", nodes[node].getName());
               added[node] = false;
            }
            else
            {    
               if (node == 2)
                  drm.add("TEST", replicants[node]);
               else
                  drm._add("TEST", nodes[node].getName(), replicants[node]);  
               added[node] = true;
            }
           
            // Confirm the proper order of the replicant node names
            lookupReplicantsNodes = maskListClass(drm.lookupReplicantsNodes("TEST"));
            confirmReplicantList(lookupReplicantsNodes, nodes, added);
           
            // Confirm the proper order of the replicants via lookupReplicants
            lookup = maskListClass(drm.lookupReplicants("TEST"));
            confirmReplicantList(lookup, replicants, added);
           
            // Confirm the listener got the same list
//            assertEquals("Listener received a correct list", lookup,
//                         maskListClass(listener.replicants));
View Full Code Here

TOP

Related Classes of org.jboss.ha.framework.server.DistributedReplicantManagerImpl$MergeMembers

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.