Package org.jboss.jms.client.delegate

Examples of org.jboss.jms.client.delegate.ClientClusteredConnectionFactoryDelegate$getTopology_7611120934159013485


    */
   public void testRoundRobinConnectionCreation() throws Exception
   {
      JBossConnectionFactory factory =  (JBossConnectionFactory )ic[0].lookup("/ConnectionFactory");

      ClientClusteredConnectionFactoryDelegate delegate =
         (ClientClusteredConnectionFactoryDelegate)factory.getDelegate();

      log.info ("number of delegates = " + delegate.getDelegates().length);
      log.info ("number of servers = " + ServerManagement.getServer(0).getNodeIDView().size());

      assertEquals(3, delegate.getDelegates().length);

      ClientConnectionFactoryDelegate cf1 = delegate.getDelegates()[0];

      ClientConnectionFactoryDelegate cf2 = delegate.getDelegates()[1];

      ClientConnectionFactoryDelegate cf3 = delegate.getDelegates()[2];

      assertEquals(0, cf1.getServerID());

      assertEquals(1, cf2.getServerID());

View Full Code Here


   public void testDefaultFailoverMap() throws Exception
   {
      {
         JBossConnectionFactory factory =  (JBossConnectionFactory )ic[0].lookup("/ConnectionFactory");

         ClientClusteredConnectionFactoryDelegate delegate =
            (ClientClusteredConnectionFactoryDelegate)factory.getDelegate();

         assertEquals(3, ServerManagement.getServer(0).getNodeIDView().size());

         ClientConnectionFactoryDelegate[] delegates = delegate.getDelegates();

         ClientConnectionFactoryDelegate cf1 = delegate.getDelegates()[0];

         ClientConnectionFactoryDelegate cf2 = delegate.getDelegates()[1];

         ClientConnectionFactoryDelegate cf3 = delegate.getDelegates()[2];

         //The order here depends on the order the servers were started in

         //If any servers get stopped and then started then the order will change

         log.info("cf1 serverid=" + cf1.getServerID());

         log.info("cf2 serverid=" + cf2.getServerID());

         log.info("cf3 serverid=" + cf3.getServerID());


         assertEquals(0, cf1.getServerID());

         assertEquals(1, cf2.getServerID());

         assertEquals(2, cf3.getServerID());

         Map failoverMap = delegate.getFailoverMap();

         assertEquals(3, delegates.length);

         assertEquals(3, failoverMap.size());

         // Default failover policy just chooses the node to the right

         assertEquals(cf2.getServerID(), ((Integer)failoverMap.get(new Integer(cf1.getServerID()))).intValue());

         assertEquals(cf3.getServerID(), ((Integer)failoverMap.get(new Integer(cf2.getServerID()))).intValue());

         assertEquals(cf1.getServerID(), ((Integer)failoverMap.get(new Integer(cf3.getServerID()))).intValue());
      }

      //Now cleanly stop one of the servers

      log.info("************** STOPPING SERVER 0");
      ServerManagement.stop(0);

      log.info("server stopped");

      assertEquals(2, ServerManagement.getServer(1).getNodeIDView().size());

      {
         //Lookup another connection factory

         JBossConnectionFactory factory =  (JBossConnectionFactory )ic[1].lookup("/ConnectionFactory");

         log.info("Got connection factory");

         ClientClusteredConnectionFactoryDelegate delegate =
            (ClientClusteredConnectionFactoryDelegate)factory.getDelegate();

         ClientConnectionFactoryDelegate[] delegates = delegate.getDelegates();

         Map failoverMap = delegate.getFailoverMap();

         log.info("Got failover map");

         assertEquals(2, delegates.length);

         ClientConnectionFactoryDelegate cf1 = delegate.getDelegates()[0];

         ClientConnectionFactoryDelegate cf2 = delegate.getDelegates()[1];

         //Order here depends on order servers were started in

         log.info("cf1 serverid=" + cf1.getServerID());

         log.info("cf2 serverid=" + cf2.getServerID());

         assertEquals(1, cf1.getServerID());

         assertEquals(2, cf2.getServerID());


         assertEquals(2, failoverMap.size());

         assertEquals(cf2.getServerID(), ((Integer)failoverMap.get(new Integer(cf1.getServerID()))).intValue());

         assertEquals(cf1.getServerID(), ((Integer)failoverMap.get(new Integer(cf2.getServerID()))).intValue());
      }

      //Cleanly stop another server

      log.info("Server 1 is started: " + ServerManagement.getServer(1).isServerPeerStarted());

      ServerManagement.stop(1);

      assertEquals(1, ServerManagement.getServer(2).getNodeIDView().size());

      {
         //Lookup another connection factory

         JBossConnectionFactory factory =  (JBossConnectionFactory )ic[2].lookup("/ConnectionFactory");

         ClientClusteredConnectionFactoryDelegate delegate =
            (ClientClusteredConnectionFactoryDelegate)factory.getDelegate();

         ClientConnectionFactoryDelegate[] delegates = delegate.getDelegates();

         Map failoverMap = delegate.getFailoverMap();

         assertEquals(1, delegates.length);

         ClientConnectionFactoryDelegate cf1 = delegate.getDelegates()[0];

         assertEquals(2, cf1.getServerID());


         assertEquals(1, failoverMap.size());

         assertEquals(cf1.getServerID(), ((Integer)failoverMap.get(new Integer(cf1.getServerID()))).intValue());
      }

      //Restart server 0

      ServerManagement.start(0, "all");

      {
         JBossConnectionFactory factory =  (JBossConnectionFactory )ic[0].lookup("/ConnectionFactory");

         log.info("Got connection factory");

         ClientClusteredConnectionFactoryDelegate delegate =
            (ClientClusteredConnectionFactoryDelegate)factory.getDelegate();

         ClientConnectionFactoryDelegate[] delegates = delegate.getDelegates();

         Map failoverMap = delegate.getFailoverMap();

         log.info("Got failover map");

         assertEquals(2, delegates.length);

         ClientConnectionFactoryDelegate cf1 = delegate.getDelegates()[0];

         ClientConnectionFactoryDelegate cf2 = delegate.getDelegates()[1];

         log.info("cf1 serverid=" + cf1.getServerID());

         log.info("cf2 serverid=" + cf2.getServerID());

         assertEquals(0, cf1.getServerID());

         assertEquals(2, cf2.getServerID());


         assertEquals(2, failoverMap.size());

         assertEquals(cf2.getServerID(), ((Integer)failoverMap.get(new Integer(cf1.getServerID()))).intValue());

         assertEquals(cf1.getServerID(), ((Integer)failoverMap.get(new Integer(cf2.getServerID()))).intValue());
      }


      //Restart server 1

      ServerManagement.start(1, "all");

      {
         JBossConnectionFactory factory =  (JBossConnectionFactory )ic[1].lookup("/ConnectionFactory");

         log.info("Got connection factory");

         ClientClusteredConnectionFactoryDelegate delegate =
            (ClientClusteredConnectionFactoryDelegate)factory.getDelegate();

         ClientConnectionFactoryDelegate[] delegates = delegate.getDelegates();

         Map failoverMap = delegate.getFailoverMap();

         log.info("Got failover map");

         assertEquals(3, delegates.length);

         ClientConnectionFactoryDelegate cf1 = delegate.getDelegates()[0];

         ClientConnectionFactoryDelegate cf2 = delegate.getDelegates()[1];

         ClientConnectionFactoryDelegate cf3 = delegate.getDelegates()[2];

         log.info("cf1 serverid=" + cf1.getServerID());

         log.info("cf2 serverid=" + cf2.getServerID());

View Full Code Here

   public void testSimpleFailover() throws Exception
   {
      JBossConnectionFactory factory =  (JBossConnectionFactory )ic[0].lookup("/ConnectionFactory");

      ClientClusteredConnectionFactoryDelegate delegate =
         (ClientClusteredConnectionFactoryDelegate)factory.getDelegate();

      Set nodeIDView = ServerManagement.getServer(0).getNodeIDView();
      assertEquals(3, nodeIDView.size());

      ClientConnectionFactoryDelegate[] delegates = delegate.getDelegates();

      ClientConnectionFactoryDelegate cf1 = delegates[0];

      ClientConnectionFactoryDelegate cf2 = delegates[1];

      ClientConnectionFactoryDelegate cf3 = delegates[2];

      int server0Id = cf1.getServerID();

      int server1Id = cf2.getServerID();

      int server2Id = cf3.getServerID();

      log.info("server 0 id: " + server0Id);

      log.info("server 1 id: " + server1Id);

      log.info("server 2 id: " + server2Id);

      Map failoverMap = delegate.getFailoverMap();

      log.info(failoverMap.get(new Integer(server0Id)));
      log.info(failoverMap.get(new Integer(server1Id)));
      log.info(failoverMap.get(new Integer(server2Id)));
View Full Code Here

   public void testFailoverWithUnackedMessagesClientAcknowledge() throws Exception
   {
      JBossConnectionFactory factory =  (JBossConnectionFactory )ic[0].lookup("/ConnectionFactory");

      ClientClusteredConnectionFactoryDelegate delegate =
         (ClientClusteredConnectionFactoryDelegate)factory.getDelegate();

      Set nodeIDView = ServerManagement.getServer(0).getNodeIDView();
      assertEquals(3, nodeIDView.size());

      ClientConnectionFactoryDelegate[] delegates = delegate.getDelegates();

      ClientConnectionFactoryDelegate cf1 = delegates[0];

      ClientConnectionFactoryDelegate cf2 = delegates[1];

      ClientConnectionFactoryDelegate cf3 = delegates[2];

      int server0Id = cf1.getServerID();

      int server1Id = cf2.getServerID();

      int server2Id = cf3.getServerID();

      log.info("server 0 id: " + server0Id);

      log.info("server 1 id: " + server1Id);

      log.info("server 2 id: " + server2Id);
     
      assertEquals(0, server0Id);
     
      assertEquals(1, server1Id);
     
      assertEquals(2, server2Id);

      Map failoverMap = delegate.getFailoverMap();

      log.info(failoverMap.get(new Integer(server0Id)));
      log.info(failoverMap.get(new Integer(server1Id)));
      log.info(failoverMap.get(new Integer(server2Id)));
View Full Code Here

                        //We still replicate non clustered connection factories since the ClusterPullConnectionFactory
                        //is non clustered but needs to be available across the cluster
                     }
                     else
                     {
                        ClientClusteredConnectionFactoryDelegate del = (ClientClusteredConnectionFactoryDelegate)cfd;

                        Map updatedReplicantMap = replicator.get(key);

                        List newDels = sortDelegatesOnServerID(updatedReplicantMap.values());

                        ClientConnectionFactoryDelegate[] delArr =
                           (ClientConnectionFactoryDelegate[])newDels.
                              toArray(new ClientConnectionFactoryDelegate[newDels.size()]);

                        Map failoverMap = serverPeer.getPostOfficeInstance().getFailoverMap();

                        del.setDelegates(delArr);
                        del.setFailoverMap(failoverMap);

                        ServerConnectionFactoryEndpoint endpoint =
                           (ServerConnectionFactoryEndpoint)endpoints.get(uniqueName);

                        if (endpoint == null)
View Full Code Here

      LoadBalancingPolicy lbp = loadBalancingFactory.createLoadBalancingPolicy(delegates);

      endpoint.updateTopology(delegates, failoverMap);

      return new ClientClusteredConnectionFactoryDelegate(uniqueName, delegates, failoverMap, lbp, supportsFailover);
   }
View Full Code Here

                        //We still replicate non clustered connection factories since the ClusterPullConnectionFactory
                        //is non clustered but needs to be available across the cluster
                     }
                     else
                     {
                        ClientClusteredConnectionFactoryDelegate del = (ClientClusteredConnectionFactoryDelegate)cfd;

                        Map updatedReplicantMap = replicator.get(key);

                        List newDels = sortDelegatesOnServerID(updatedReplicantMap.values());

                        ClientConnectionFactoryDelegate[] delArr =
                           (ClientConnectionFactoryDelegate[])newDels.
                              toArray(new ClientConnectionFactoryDelegate[newDels.size()]);

                        Map failoverMap = serverPeer.getPostOfficeInstance().getFailoverMap();

                        del.setDelegates(delArr);
                        del.setFailoverMap(failoverMap);

                        ServerConnectionFactoryEndpoint endpoint =
                           (ServerConnectionFactoryEndpoint)endpoints.get(uniqueName);

                        if (endpoint == null)
View Full Code Here

   public void testRestartServer() throws Exception
   {
      JBossConnectionFactory cf2 = (JBossConnectionFactory) ic[1].lookup("/ConnectionFactory");

      ClientClusteredConnectionFactoryDelegate clusterCF = (ClientClusteredConnectionFactoryDelegate)cf.getDelegate();
      ClientConnectionFactoryDelegate delegates[] = clusterCF.getDelegates();
      clusterCF.closeCallback(false);

      ServerManagement.kill(1);

      //Restart the server on the same place
      ServiceAttributeOverrides attr = new ServiceAttributeOverrides();
View Full Code Here

   public void testRoundRobinLoadBalancingOneNode() throws Exception
   {
      // the round robin policy is default

      JBossConnectionFactory jbcf = (JBossConnectionFactory)cf;
      ClientClusteredConnectionFactoryDelegate clusteredDelegate =
         (ClientClusteredConnectionFactoryDelegate )jbcf.getDelegate();

      assertSame(RoundRobinLoadBalancingPolicy.class,
         clusteredDelegate.getLoadBalancingPolicy().getClass());

      Connection conn0 = cf.createConnection();

      final int oneId = getServerId(conn0);
      final int otherId = 1 - oneId;
View Full Code Here


   public void testRoundRobinLoadBalancingTwoNodes() throws Exception
   {
      JBossConnectionFactory jbcf = (JBossConnectionFactory)cf;
      ClientClusteredConnectionFactoryDelegate clusteredDelegate =
         (ClientClusteredConnectionFactoryDelegate )jbcf.getDelegate();

      assertSame(RoundRobinLoadBalancingPolicy.class,
         clusteredDelegate.getLoadBalancingPolicy().getClass());

      Connection conn0 = cf.createConnection();

      final int oneId = getServerId(conn0);
      final int otherId = 1 - oneId;
View Full Code Here

TOP

Related Classes of org.jboss.jms.client.delegate.ClientClusteredConnectionFactoryDelegate$getTopology_7611120934159013485

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.