Package org.jboss.jms.client.delegate

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


   public void testUpdateConnectionFactoryRaceCondition() throws Exception
   {
      // This connection needs to be opened, as we need the callback to update CF from this conn
      Connection conn = createConnectionOnServer(cf, 0);
      JBossConnectionFactory jbcf = (JBossConnectionFactory) cf;
      ClientClusteredConnectionFactoryDelegate cfDelegate =
         (ClientClusteredConnectionFactoryDelegate) jbcf.getDelegate();
      assertEquals(2, cfDelegate.getDelegates().length);

      Connection conn1 = cf.createConnection();

      Connection conn2 = cf.createConnection();

      assertEquals(1, getServerId(conn1));
     
      assertEquals(0, getServerId(conn2));

      ConnectionState state = this.getConnectionState(conn1);

      // Disable Leasing for Failover
      state.getRemotingConnection().removeConnectionListener();

      ServerManagement.kill(1);

      Thread.sleep(20000);

      // This will force Failover from Valve to kick in
      conn1.createSession(true, Session.SESSION_TRANSACTED);

      // first part of the test, verifies if the CF was updated
      assertEquals(1, cfDelegate.getDelegates().length);

      assertEquals(0, getServerId(conn1));
     
      conn.close();
      conn1.close();
View Full Code Here


        
         if (factoryDelegate instanceof ClientClusteredConnectionFactoryDelegate)
         {
            if (log.isTraceEnabled()) { log.trace(this + " getting XAResources from the cluster"); }

            ClientClusteredConnectionFactoryDelegate clusteredFactoryDelegate = (ClientClusteredConnectionFactoryDelegate)factoryDelegate;

            ClientConnectionFactoryDelegate[] delegates = clusteredFactoryDelegate.getDelegates();

            for (ClientConnectionFactoryDelegate del : delegates)
            {
               try
               {
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

    *  are not making any hard references */
   public void testUpdateTopology() throws Throwable
   {

      JBossConnectionFactory cf = (JBossConnectionFactory)ic[0].lookup("/ClusteredConnectionFactory");
      ClientClusteredConnectionFactoryDelegate clusterDelegate = (ClientClusteredConnectionFactoryDelegate)cf.getDelegate();
      assertEquals(2, clusterDelegate.getDelegates().length);
      clusterDelegate.getTopology();
      assertEquals(2, clusterDelegate.getDelegates().length);

      // Kill the same node as the CF is connected to
      ServerManagement.kill(1);
     
      // the sleep time has to be longer than the sum of validatorPingPeriod and validatorPingTimeout.
      // see remoting-bisocket-service.xml
      Thread.sleep(20000);
     
      assertEquals(1, clusterDelegate.getDelegates().length);
      TopologyResult topology = clusterDelegate.getTopology();
      assertEquals(1, topology.getDelegates().length);

      clusterDelegate.closeCallback();
   }
View Full Code Here

    
     Connection conn = createConnectionOnServer(cf, 0);
      try
      {

         ClientClusteredConnectionFactoryDelegate cfDelegate =
            (ClientClusteredConnectionFactoryDelegate)cf.getDelegate();

         assertEquals(1, cfDelegate.getDelegates().length);
      }
      finally
      {
         conn.close();
      }
View Full Code Here

  
   public void testUpdateConnectionFactoryWithNoInitialConnections() throws Exception
   {
      try
      {
         ClientClusteredConnectionFactoryDelegate clusterDelegate = (ClientClusteredConnectionFactoryDelegate)this.cf.getDelegate();

         //JBossConnectionFactory cf2 = (JBossConnectionFactory)ic[0].lookup("/ClusteredConnectionFactory");
         //ClientClusteredConnectionFactoryDelegate clusterDelegate2 = (ClientClusteredConnectionFactoryDelegate)cf2.getDelegate();

         //We kill all the servers - this tests the connection factory's ability to create a first connection
         //when its entire cached set of delegates is stale

         startDefaultServer(2, currentOverrides, false);

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

         // assertEquals(3, clusterDelegate2.getDelegates().length);
         log.info("#################################### Killing server 1 and 0");
         ServerManagement.log(ServerManagement.INFO, "Killing server1", 2);
         ServerManagement.kill(1);
         // Need some time for Lease
         Thread.sleep(5000);

         assertEquals("Delegates are different on topology", 2,clusterDelegate.getTopology().getDelegates().length);
         assertEquals(2, clusterDelegate.getDelegates().length);

         ServerManagement.log(ServerManagement.INFO, "Stopping server0", 2);
         ServerManagement.stop(0);

         Thread.sleep(1000);

         assertEquals(1, clusterDelegate.getDelegates().length);

         Connection conn = createConnectionOnServer(cf, 2);

         ClientClusteredConnectionFactoryDelegate cfDelegate =
            (ClientClusteredConnectionFactoryDelegate)cf.getDelegate();

         assertEquals(1, cfDelegate.getDelegates().length);

         conn.close();
      }
      finally
      {
View Full Code Here

   /** Case the updateCF is not captured, the hopping should run nicely.
    *  This test will disable CF callback for a connection and validate if hoping is working*/
   public void testNoUpdateCaptured() throws Exception
   {
      JBossConnectionFactory cfNoCallback = (JBossConnectionFactory)ic[0].lookup("/ClusteredConnectionFactory");
      ClientClusteredConnectionFactoryDelegate noCallbackDelegate =  (ClientClusteredConnectionFactoryDelegate )cfNoCallback.getDelegate();
      noCallbackDelegate.closeCallback();

      ServerManagement.kill(1);

      Connection conn = null;

View Full Code Here

   {
      Connection conn = createConnectionOnServer(cf, 0);

      JBossConnectionFactory jbcf = (JBossConnectionFactory)cf;

      ClientClusteredConnectionFactoryDelegate cfDelegate =
         (ClientClusteredConnectionFactoryDelegate)jbcf.getDelegate();

      assertEquals(2, cfDelegate.getDelegates().length);

      Connection conn1 = cf.createConnection();

      assertEquals(1, getServerId(conn1));

      ServerManagement.kill(1);

      log.info("sleeping 20 secs ...");
      Thread.sleep(20000);

      // first part of the test, verifies if the CF was updated
      assertEquals(1, cfDelegate.getDelegates().length);
      conn.close();

      log.info("sleeping 5 secs ...");
      Thread.sleep(5000);

      // Second part, verifies a possible race condition on failoverMap and handleFilover

      log.info("ServerId=" + getServerId(conn1));
      assertEquals(0, getServerId(conn1));
      
      //restart
      log.info("Restarting server");
      ServerManagement.start(1, "all", false);
     
      Thread.sleep(5000);
     
      assertEquals(2, cfDelegate.getDelegates().length);
     
      conn1.close();
           
      ServerManagement.stop(1);
   }
View Full Code Here

TOP

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

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.