Package org.jgroups.stack

Examples of org.jgroups.stack.GossipRouter$ConnectionTearListener


                bind_addr="::1";
            else
                bind_addr="127.0.0.1";
        }
        promise=new Promise<Boolean>();
        gossipRouter=new GossipRouter(GossipRouter.PORT,bind_addr);
        gossipRouter.start();
    }
View Full Code Here


            if(type == StackType.IPv6)
                bind_addr="::1";
            else
                bind_addr="127.0.0.1";
        }
        gossipRouter=new GossipRouter(12001, bind_addr);
        gossipRouter.start();
    }
View Full Code Here

        changeMergeInterval(c2);
        c2.setReceiver(new MyReceiver("c2", done, lock, cond));
        c2.connect("demo");

        System.out.println("-- starting GossipRouter");
        router=new GossipRouter(12001, bind_addr);
        router.start();

        System.out.println("-- waiting for merge to happen --");
        long target_time=System.currentTimeMillis() + 40000;
        lock.lock();
View Full Code Here

        }
    }

    @BeforeMethod
    void startRouter() throws Exception {
        gr1 = new GossipRouter(12003,bindAddress);
        gr1.start();

        gr2 = new GossipRouter(12004,bindAddress);
        gr2.start();
    }
View Full Code Here

    private static final String props = "tcpgossip.xml";

    @BeforeClass
    void startRouter() throws Exception {
        String bind_addr = getRouterBindAddress();
        gossipRouter = new GossipRouter(12001, bind_addr);
        gossipRouter.start();
    }
View Full Code Here

    *
    * @throws Exception
    */
   public void testIsMasterReplica() throws Exception
   {
      GossipRouter router = null;
      ClusterPartition partition1 = null;
      ClusterPartition partition2 = null;
      boolean partition1Started = false;
      boolean partition2Started = false;
     
      log.debug("+++ testIsMasterReplica()");

      try
     
         String partitionName = "DRMTestCasePartition";
         String muxFile = "cluster/drm/drm-test-stacks.xml";
         String stackName = "tunnel1";
        
         log.info("DRMTestCase.testIsMasterReplica() - starting GossipRouter");
         // router characteristics here must match the definition in the stack configuration
         router = new GossipRouter(12001, "localhost");
         router.start();
         Thread.sleep(10000);
         log.info("router routing table = " + router.dumpRoutingTable());
         assertTrue("router is started", router.isStarted());
         assertTrue("router is running", router.isRunning());
        
         JChannelFactory factory1 = new JChannelFactory();
         factory1.setMultiplexerConfig(muxFile);
         factory1.setNamingServicePort(1099);
         factory1.setNodeName("node1");
         factory1.setExposeChannels(false);
         factory1.setExposeProtocols(false);
         factory1.setAddMissingSingletonName(false);
         factory1.create();
         factory1.start();
        
         partition1 = new InjectedChannelClusterPartition(factory1.createChannel(stackName));
         partition1.setPartitionName(partitionName);
         partition1.setStateTransferTimeout(30000);
         partition1.setMethodCallTimeout(60000);
         partition1.setBindIntoJndi(false);
        
         partition1.create();        
         partition1.start();

         DistributedReplicantManager drm1 = partition1.getDistributedReplicantManager();

         Thread.sleep(10000);
        
         // Use a different stack name with the same config to avoid singleton conflicts
         stackName = "tunnel2";
        
         JChannelFactory factory2 = new JChannelFactory();
         factory2.setMultiplexerConfig(muxFile);
         factory2.setNamingServicePort(1099);
         factory2.setNodeName("node2");
         factory2.setExposeChannels(false);
         factory2.setExposeProtocols(false);
         factory2.setAddMissingSingletonName(false);
         factory2.create();
         factory2.start();
        
         partition2 = new InjectedChannelClusterPartition(factory2.createChannel(stackName));
         partition2.setPartitionName(partitionName);
         partition2.setStateTransferTimeout(30000);
         partition2.setMethodCallTimeout(60000);
         partition2.setBindIntoJndi(false);
        
         partition2.create();        
         partition2.start();

         DistributedReplicantManager drm2 = partition2.getDistributedReplicantManager();
        
         Thread.sleep(10000);
        
         // confirm that each partition contains two nodes  
         assertEquals("Partition1 should contain two nodes; ", 2, partition1.getCurrentView().size());
         assertEquals("Partition2 should contain two nodes; ", 2, partition2.getCurrentView().size());
        
         drm1.add(SERVICEA, "valueA1");
         drm2.add(SERVICEA, "valueA2");
         drm2.add(SERVICEB, "valueB2");
        
         // test that only one node is the master replica for serviceA
         assertTrue("ServiceA must have a master replica",
                 drm1.isMasterReplica(SERVICEA) || drm2.isMasterReplica(SERVICEA));
         assertTrue("ServiceA must have a single master replica",
                 drm1.isMasterReplica(SERVICEA) != drm2.isMasterReplica(SERVICEA));
         // ServiceB should only be a master replica on partition2
         assertFalse("ServiceB should not be a master replica on partition1",
                 drm1.isMasterReplica(SERVICEB));
         assertTrue("ServiceB must have a master replica on partition2",
                 drm2.isMasterReplica(SERVICEB));
        
         // confirm that each partition contains correct DRM replicants for services A and B 
         assertEquals("Partition1 should contain two DRM replicants for serviceA; ",
                 2, drm1.lookupReplicants(SERVICEA).size());
         assertEquals("Partition2 should contain two DRM replicants for serviceA; ",
                 2, drm2.lookupReplicants(SERVICEA).size());
         assertEquals("Partition1 should contain one DRM replicant for serviceB; ",
                 1, drm1.lookupReplicants(SERVICEB).size());
         assertEquals("Partition2 should contain one DRM replicant for serviceB; ",
                 1, drm2.lookupReplicants(SERVICEB).size());

         // simulate a split of the partition
         log.info("DRMTestCase.testIsMasterReplica() - stopping GossipRouter");
         router.clear();   // temporary workaround for JGRP-1232
         router.stop();
         sleepThread(15000);
         log.info("router stopped, routing table = " + router.dumpRoutingTable() + ", partition1 view=" + partition1.getCurrentView().toString());
         assertTrue("router is stopped", !router.isStarted());
         assertTrue("router is NOT running", !router.isRunning());

         // confirm that each partition contains one node  
         assertEquals("Partition1 should contain one node after split; ",
                 1, partition1.getCurrentView().size());
         assertEquals("Partition2 should contain one node after split; ",
                 1, partition2.getCurrentView().size());
       
         // confirm that each node is a master replica for serviceA after the split
         assertTrue("ServiceA should be a master replica on partition1 after split",
                 drm1.isMasterReplica(SERVICEA));
         assertTrue("ServiceA should be a master replica on partition2 after split",
                 drm2.isMasterReplica(SERVICEA));
        
         // ServiceB should still only be a master replica on partition2 after split
         assertFalse("ServiceB should not be a master replica on partition1 after split",
                 drm1.isMasterReplica(SERVICEB));
         assertTrue("ServiceB must have a master replica on partition2 after split",
                 drm2.isMasterReplica(SERVICEB));
        
         // Remove ServiceA replicant from partition1        
         drm1.remove(SERVICEA);
        
         // test that this node is not the master replica        
         assertFalse("partition1 is not master replica after dropping ServiceA replicant",
                 drm1.isMasterReplica(SERVICEA));
        
         //Restore the local replicant        
         drm1.add(SERVICEA, "valueA1a");
        
         // simulate a merge
         log.info("DRMTestCase.testIsMasterReplica() - restarting GossipRouter");
         router.start();
         // it seems to take more than 15 seconds for the merge to take effect
         sleepThread(30000);
        
         assertTrue(router.isStarted());

         // confirm that each partition contains two nodes again
         assertEquals("Partition1 should contain two nodes after merge; ",
               2, partition1.getCurrentView().size());
         assertEquals("Partition2 should contain two nodes after merge; ",
                 2, partition2.getCurrentView().size());
        
         // test that only one node is the master replica for serviceA after merge
         assertTrue("ServiceA must have a master replica after merge",
                 drm1.isMasterReplica(SERVICEA) || drm2.isMasterReplica(SERVICEA));
         assertTrue("ServiceA must have a single master replica after merge",
                 drm1.isMasterReplica(SERVICEA) != drm2.isMasterReplica(SERVICEA));
         // ServiceB should only be a master replica on partition2 after merge
         assertFalse("ServiceB should not be a master replica on partition1 after merge",
                 drm1.isMasterReplica(SERVICEB));
         assertTrue("ServiceB must have a master replica on partition2 after merge",
                 drm2.isMasterReplica(SERVICEB));
        
         // confirm that each partition contains correct DRM replicants for services A and B after merge
         assertEquals("Partition1 should contain two DRM replicants for serviceA after merge; ",
                 2, drm1.lookupReplicants(SERVICEA).size());
         assertEquals("Partition2 should contain two DRM replicants for serviceA after merge; ",
                 2, drm2.lookupReplicants(SERVICEA).size());
         assertEquals("Partition1 should contain one DRM replicant for serviceB after merge; ",
                 1, drm1.lookupReplicants(SERVICEB).size());
         assertEquals("Partition2 should contain one DRM replicant for serviceB after merge; ",
                 1, drm2.lookupReplicants(SERVICEB).size());
        
         partition1.stop();
         partition2.stop();
      }
      finally
      {
         log.info("DRMTestCase.testIsMasterReplica() - cleaning up resources");
         if (partition1Started)
            partition1.stop();
         if (partition2Started)
            partition2.stop();
         if (router != null)
            router.stop();
      }
   }
View Full Code Here




    private void startRouter() throws Exception {
        router=new GossipRouter(router_port, bind_addr);
        router.start();
    }
View Full Code Here

        if(gossipRouter != null)
            throw new Exception("GossipRouter already started");

        final int routerPort=getFreePort();
        try {
            gossipRouter=new GossipRouter(routerPort, bind_addr, expiryTime, gossipRequestTimeout, routingClientReplyTimeout);
            gossipRouter.start();
        }
        catch(Exception e) {
            log.error("Failed to start the router on port " + routerPort);
            gossipRouter=null;
View Full Code Here

        CHANNEL_CONFIG = System.getProperty("channel.conf", CHANNEL_CONFIG);

        currentChannelGeneratedName = LETTER_A;

        if(isTunnelUsed()){
            router = new GossipRouter(ROUTER_PORT, BIND_ADDR);
            router.start();
        }

        if(shouldCompareThreadCount()){
            active_threads = Thread.activeCount();
View Full Code Here

            ping.setGossipRefresh(1000);
        }
    }

    private void startRouter(String router_host, int router_port) throws Exception {
        router=new GossipRouter(router_port, router_host);
        router.start();
    }
View Full Code Here

TOP

Related Classes of org.jgroups.stack.GossipRouter$ConnectionTearListener

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.