Package org.jboss.jms.client.delegate

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


   /** testcase for http://jira.jboss.com/jira/browse/JBMESSAGING-1038 */
   public void testHopping() throws Exception
   {

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

      ((ClientClusteredConnectionFactoryDelegate)cf.getDelegate()).closeCallback();

      // After this, the CF won't get any callbacks
      cfdelegate.closeCallback();

      Connection conn = createConnectionOnServer(localcf, 1);

      try
      {

         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
         MessageProducer producer = sess.createProducer(queue[1]);

         MessageConsumer consumer = sess.createConsumer(queue[1]);

         conn.start();

         producer.send(sess.createTextMessage("sent before kill"));
         TextMessage msg = (TextMessage)consumer.receive(2000);

         assertNotNull(msg);
         assertEquals("sent before kill", msg.getText());

         ServerManagement.kill(2);
         ServerManagement.kill(1);

         // We need to guarantee we still have the old failover map (before the topology change for the test to be valid)
         assertEquals(3, cfdelegate.getDelegates().length);

         log.info("Sending Message");
         producer.send(sess.createTextMessage("sent after kill"));
         msg = (TextMessage) consumer.receive(2000);

View Full Code Here


         {
            fail("Thre is a leak on ClusteredConnectionFactory");
         }
      }
      
      ClientClusteredConnectionFactoryDelegate cfDelegate =  (ClientClusteredConnectionFactoryDelegate)cf.getDelegate();

      cfDelegate.closeCallback();

      ClusterClientCrash command = new ClusterClientCrash(cf);

      assertEquals("OK", remoteServer.executeCommand(command));

      assertEquals(new Integer(1),ServerManagement.getServer(1).executeCommand(new VerifySizeOfCFClients(cfDelegate.getUniqueName())));

      ServerManagement.kill(2);
      Thread.sleep((long)(60000));

      assertEquals(new Integer(0), ServerManagement.getServer(0).executeCommand(new VerifySizeOfCFClients(cfDelegate.getUniqueName())));
      assertEquals(new Integer(0), ServerManagement.getServer(1).executeCommand(new VerifySizeOfCFClients(cfDelegate.getUniqueName())));
   }
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(11000);

         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

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

      // Second part, verifies a possible race condition on failoverMap and handleFilover
      assertEquals(0, getServerId(conn1));
    
      //restart
      ServerManagement.start(1, "all", false);
     
      Thread.sleep(12000);
     
      assertEquals(2, cfDelegate.getDelegates().length);
     
      conn1.close();
     
      ServerManagement.stop(1);
   }
View Full Code Here

   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

                        //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

TOP

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

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.