Package org.jboss.jms.client.delegate

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


      // We attempt to connect to the next node in a loop, since we might need to go through
      // multiple hops

      int attemptCount = 0;
      ClientConnectionFactoryDelegate delegate = null;

      while (attemptCount < MAX_RECONNECT_HOP_COUNT)
      {
         // since an exceptiong might be captured during an attempt, this has to be the first
         // operation
         attemptCount++;
         try
         {
            int failedNodeIDToServer = -1;

            if (delegate == null)
            {
               if (failedNodeID != null && failedNodeID.intValue() >= 0)
               {
                  delegate = getFailoverDelegateForNode(failedNodeID);
                  failedNodeIDToServer = failedNodeID.intValue();
               }
               else
               {
                  LoadBalancingPolicy loadBalancingPolicy = clusteredDelegate.getLoadBalancingPolicy();
                  delegate = (ClientConnectionFactoryDelegate)loadBalancingPolicy.getNext();
               }
            }

            log.debug(this + " has chosen " + delegate + " as target, " +
               (attemptCount == 0 ? "first connection attempt" : attemptCount + " connection attempts"));

            CreateConnectionResult res = delegate.
               createConnectionDelegate(username, password, failedNodeIDToServer);
            ClientConnectionDelegate cd = (ClientConnectionDelegate)res.getDelegate();

            if (cd != null)
            {
View Full Code Here


         setupReplicator();
      }

      boolean creatingClustered = clustered && replicator != null;

      ClientConnectionFactoryDelegate localDelegate =
         new ClientConnectionFactoryDelegate(id, serverPeer.getServerPeerID(),
                                             locatorURI, version, clientPing);

      log.debug(this + " created local delegate " + localDelegate);

      // When registering a new clustered connection factory I should first create it with the
View Full Code Here

      Collections.sort(localDels,
         new Comparator()
         {
            public int compare(Object obj1, Object obj2)
            {
               ClientConnectionFactoryDelegate del1 = (ClientConnectionFactoryDelegate)obj1;
               ClientConnectionFactoryDelegate del2 = (ClientConnectionFactoryDelegate)obj2;
               return del1.getServerID() - del2.getServerID();
            }
         });

      return localDels;
   }
View Full Code Here

     
      delegates = new ClientConnectionFactoryDelegate[len];
     
      for (int i = 0; i < len; i++)
      {
         delegates[i] = new ClientConnectionFactoryDelegate();
        
         delegates[i].read(is);
      }
     
      len = is.readInt();
View Full Code Here

   // Validate if two distinct CFs are valid
   private void validateCFs(ClientClusteredConnectionFactoryDelegate cfDelegate,
                            ClientClusteredConnectionFactoryDelegate httpcfDelegate)
   {
      ClientConnectionFactoryDelegate delegatesSocket[] = cfDelegate.getDelegates();
      ClientConnectionFactoryDelegate delegatesHTTP[] = httpcfDelegate.getDelegates();

      log.info("ValidateCFs:");

      assertEquals(delegatesSocket.length, delegatesHTTP.length);
      for (int i=0;i<delegatesSocket.length;i++)
View Full Code Here

      //Last one shares the same connector
      ObjectName cf4 = deployConnectionFactory("jboss.messaging.destination:service=TestConnectionFactory4", name3, "/TestConnectionFactory4", "clientid4");
     
     
      JBossConnectionFactory f1 = (JBossConnectionFactory)initialContext.lookup("/TestConnectionFactory1");           
      ClientConnectionFactoryDelegate del1 = (ClientConnectionFactoryDelegate)f1.getDelegate();     
     
      assertTrue(del1.getServerLocatorURI().startsWith("socket://localhost:1234"));
     
      JBossConnectionFactory f2 = (JBossConnectionFactory)initialContext.lookup("/TestConnectionFactory2");           
      ClientConnectionFactoryDelegate del2 = (ClientConnectionFactoryDelegate)f2.getDelegate();     
      assertTrue(del2.getServerLocatorURI().startsWith("socket://localhost:1235"));
     
      JBossConnectionFactory f3 = (JBossConnectionFactory)initialContext.lookup("/TestConnectionFactory3");           
      ClientConnectionFactoryDelegate del3 = (ClientConnectionFactoryDelegate)f3.getDelegate();     
      assertTrue(del3.getServerLocatorURI().startsWith("socket://localhost:1236"));
     
      JBossConnectionFactory f4 = (JBossConnectionFactory)initialContext.lookup("/TestConnectionFactory4");           
      ClientConnectionFactoryDelegate del4 = (ClientConnectionFactoryDelegate)f4.getDelegate();     
      assertTrue(del4.getServerLocatorURI().startsWith("socket://localhost:1236"));
     
      Connection con1 = f1.createConnection();
      Connection con2 = f2.createConnection();
      Connection con3 = f3.createConnection();
      Connection con4 = f4.createConnection();
View Full Code Here

      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());

      assertEquals(2, cf3.getServerID());

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

      Connection conn1 = null;
View Full Code Here

         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());

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

         assertEquals(0, cf1.getServerID());

         assertEquals(1, cf2.getServerID());

         assertEquals(2, cf3.getServerID());


         assertEquals(3, failoverMap.size());

         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());
      }
   }
View Full Code Here

                                               "/TestConnectionFactory4",
                                               "clientid4",
                                               false);

      JBossConnectionFactory f1 = (JBossConnectionFactory)ic.lookup("/TestConnectionFactory1");
      ClientConnectionFactoryDelegate del1 = (ClientConnectionFactoryDelegate)f1.getDelegate();

      assertTrue(del1.getServerLocatorURI().startsWith("bisocket://localhost:1234"));

      JBossConnectionFactory f2 = (JBossConnectionFactory)ic.lookup("/TestConnectionFactory2");
      ClientConnectionFactoryDelegate del2 = (ClientConnectionFactoryDelegate)f2.getDelegate();
      assertTrue(del2.getServerLocatorURI().startsWith("bisocket://localhost:1235"));

      JBossConnectionFactory f3 = (JBossConnectionFactory)ic.lookup("/TestConnectionFactory3");
      ClientConnectionFactoryDelegate del3 = (ClientConnectionFactoryDelegate)f3.getDelegate();
      assertTrue(del3.getServerLocatorURI().startsWith("bisocket://localhost:1236"));

      JBossConnectionFactory f4 = (JBossConnectionFactory)ic.lookup("/TestConnectionFactory4");
      ClientConnectionFactoryDelegate del4 = (ClientConnectionFactoryDelegate)f4.getDelegate();
      assertTrue(del4.getServerLocatorURI().startsWith("bisocket://localhost:1236"));

      Connection con1 = f1.createConnection();
      Connection con2 = f2.createConnection();
      Connection con3 = f3.createConnection();
      Connection con4 = f4.createConnection();
View Full Code Here

      boolean creatingClustered = (supportsFailover || supportsLoadBalancing) && replicator != null;
     
      //The server peer strict setting overrides the connection factory
      boolean useStrict = serverPeer.isStrictTck() || strictTck;

      ClientConnectionFactoryDelegate localDelegate =
         new ClientConnectionFactoryDelegate(uniqueName, id, serverPeer.getServerPeerID(),
                                             locatorURI, version, clientPing, useStrict,
                                             sendAcksAsync, enableOrderingGroup, defaultOrderingGroupName,
                                             maxRetryChangeRate, retryChangeRateInterval, minTimeoutProcessTime);

      log.debug(this + " created local delegate " + localDelegate);
View Full Code Here

TOP

Related Classes of org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate$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.