Package org.hornetq.spi.core.protocol

Examples of org.hornetq.spi.core.protocol.RemotingConnection


               Set<Object> idsToRemove = new HashSet<Object>();

               for (ConnectionEntry entry : connections.values())
               {
                  RemotingConnection conn = entry.connection;

                  boolean flush = true;

                  if (entry.ttl != -1)
                  {
                     if (!conn.checkDataReceived())
                     {
                        if (now >= entry.lastCheck + entry.ttl)
                        {
                           idsToRemove.add(conn.getID());

                           flush = false;
                        }
                     }
                     else
                     {
                        entry.lastCheck = now;
                     }
                  }

                  if (flush)
                  {
                     conn.flush();
                  }
               }

               for (Object id : idsToRemove)
               {
                  RemotingConnection conn = removeConnection(id);
                  if (conn != null)
                  {
                     conn.fail(HornetQMessageBundle.BUNDLE.clientExited(conn.getRemoteAddress()));
                  }
               }

               if (latch.await(pauseInterval, TimeUnit.MILLISECONDS))
                  return;
View Full Code Here


               String value = session.getMetaData(metaKey);
               if (value != null && value.equals(parameterValue))
               {
                  sessionFound = session;
                  operationsExecuted.append("Closing connection " + sessionFound + "\n");
                  RemotingConnection conn = session.getRemotingConnection();
                  if (conn != null)
                  {
                     conn.fail(new HornetQException(HornetQException.DISCONNECTED, "Connection being disconnected per admin's request on destroyConnection(" + metaKey + "=" + parameterValue +")"));
                  }
                  session.close(true);
                  sessions.remove(session);
               }
            }
View Full Code Here

      Listener clientListener = new Listener();

      session.addFailureListener(clientListener);

      RemotingConnection serverConn = null;
      while (serverConn == null)
      {
         Set<RemotingConnection> conns = server.getRemotingService().getConnections();

         if (!conns.isEmpty())
         {
            serverConn = server.getRemotingService().getConnections().iterator().next();
         }
         else
         {
            // It's async so need to wait a while
            Thread.sleep(10);
         }
      }

      Listener serverListener = new Listener();

      serverConn.addFailureListener(serverListener);

      Thread.sleep(PingTest.CLIENT_FAILURE_CHECK_PERIOD * 10);

      Assert.assertNull(clientListener.getException());

      Assert.assertNull(serverListener.getException());

      RemotingConnection serverConn2 = server.getRemotingService().getConnections().iterator().next();

      PingTest.log.info("Server conn2 is " + serverConn2);

      Assert.assertTrue(serverConn == serverConn2);

View Full Code Here

      Listener clientListener = new Listener();

      session.addFailureListener(clientListener);

      RemotingConnection serverConn = null;
      while (serverConn == null)
      {
         Set<RemotingConnection> conns = server.getRemotingService().getConnections();

         if (!conns.isEmpty())
         {
            serverConn = server.getRemotingService().getConnections().iterator().next();
         }
         else
         {
            // It's async so need to wait a while
            Thread.sleep(10);
         }
      }

      Listener serverListener = new Listener();

      serverConn.addFailureListener(serverListener);

      Thread.sleep(HornetQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD);

      Assert.assertNull(clientListener.getException());

      Assert.assertNull(serverListener.getException());

      RemotingConnection serverConn2 = server.getRemotingService().getConnections().iterator().next();

      PingTest.log.info("Serverconn2 is " + serverConn2);

      Assert.assertTrue(serverConn == serverConn2);
View Full Code Here

      // We need to get it to stop pinging after one

      ((FailoverManagerImpl)csf.getFailoverManagers()[0]).stopPingingAfterOne();

      RemotingConnection serverConn = null;

      while (serverConn == null)
      {
         Set<RemotingConnection> conns = server.getRemotingService().getConnections();

         if (!conns.isEmpty())
         {
            serverConn = server.getRemotingService().getConnections().iterator().next();
         }
         else
         {
            // It's async so need to wait a while
            Thread.sleep(10);
         }
      }

      Listener serverListener = new Listener();

      serverConn.addFailureListener(serverListener);

      for (int i = 0; i < 1000; i++)
      {
         // a few tries to avoid a possible race caused by GCs or similar issues
         if (server.getRemotingService().getConnections().isEmpty() && clientListener.getException() != null)
         {
            break;
         }

         Thread.sleep(10);
      }

      if (!server.getRemotingService().getConnections().isEmpty())
      {
         RemotingConnection serverConn2 = server.getRemotingService().getConnections().iterator().next();

         PingTest.log.info("Serverconn2 is " + serverConn2);
      }

      Assert.assertTrue(server.getRemotingService().getConnections().isEmpty());
View Full Code Here

            producer.send(message);
         }

         ClientConsumer consumer = session.createConsumer(ReattachTest.ADDRESS);

         RemotingConnection conn = ((ClientSessionInternal)session).getConnection();

         conn.fail(new HornetQException(HornetQException.NOT_CONNECTED));

         session.start();

         for (int i = 0; i < numMessages; i++)
         {
View Full Code Here

      ClientConsumer consumer = session.createConsumer(ReattachTest.ADDRESS);

      InVMConnector.failOnCreateConnection = true;

      RemotingConnection conn = ((ClientSessionInternal)session).getConnection();

      Thread t = new Thread()
      {
         @Override
         public void run()
         {
            try
            {
               Thread.sleep(retryInterval * 3);
            }
            catch (InterruptedException ignore)
            {
            }

            InVMConnector.failOnCreateConnection = false;
         }
      };

      t.start();

      conn.fail(new HornetQException(HornetQException.NOT_CONNECTED));

      session.start();

      for (int i = 0; i < numMessages; i++)
      {
View Full Code Here

      ClientConsumer consumer = session.createConsumer(ReattachTest.ADDRESS);

      InVMConnector.numberOfFailures = 10;
      InVMConnector.failOnCreateConnection = true;

      final RemotingConnection conn = ((ClientSessionInternal)session).getConnection();

      final RemotingConnection conn2 = ((ClientSessionInternal)session2).getConnection();

      Thread t = new Thread()
      {
         @Override
         public void run()
         {
            try
            {
               Thread.sleep(asyncFailDelay);
            }
            catch (InterruptedException ignore)
            {
            }

            conn2.fail(new HornetQException(HornetQException.NOT_CONNECTED, "Did not receive pong from server"));
         }
      };

      t.start();
View Full Code Here

      session.createConsumer(ReattachTest.ADDRESS);

      InVMConnector.failOnCreateConnection = true;

      RemotingConnection conn = ((ClientSessionInternal)session).getConnection();

      // Sleep for longer than max retries so should fail to reconnect

      Thread t = new Thread()
      {
         @Override
         public void run()
         {
            try
            {
               Thread.sleep(retryInterval * (reconnectAttempts + 1));
            }
            catch (InterruptedException ignore)
            {
            }

            InVMConnector.failOnCreateConnection = false;
         }
      };

      t.start();

      conn.fail(new HornetQException(HornetQException.NOT_CONNECTED));

      // Should throw exception since didn't reconnect

      try
      {
View Full Code Here

         locator.setConfirmationWindowSize(1024 * 1024);
         final ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)locator.createSessionFactory();

         session = sf.createSession();

         final RemotingConnection connFailure = ((ClientSessionInternal)session).getConnection();

         int numberOfThreads = 100;
         final int numberOfSessionsToCreate = 10;

         final CountDownLatch alignLatch = new CountDownLatch(numberOfThreads);
         final CountDownLatch startFlag = new CountDownLatch(1);

         class CreateSessionThread extends Thread
         {
            Throwable failure;

            @Override
            public void run()
            {
               try
               {
                  alignLatch.countDown();
                  startFlag.await();
                  for (int i = 0; i < numberOfSessionsToCreate; i++)
                  {
                     Thread.yield();
                     ClientSession session = sf.createSession(false, true, true);

                     session.close();
                  }
               }
               catch (Throwable e)
               {
                  e.printStackTrace();
                  failure = e;
               }
            }
         }

         CreateSessionThread threads[] = new CreateSessionThread[numberOfThreads];
         for (int i = 0; i < numberOfThreads; i++)
         {
            threads[i] = new CreateSessionThread();
            threads[i].start();
         }

         alignLatch.await();

         timer.schedule(new TimerTask()
         {
            @Override
            public void run()
            {
               try
               {
                  connFailure.fail(new HornetQException(HornetQException.NOT_CONNECTED));
               }
               catch (Exception e)
               {
                  ReattachTest.log.warn("Error on the timer " + e);
               }
View Full Code Here

TOP

Related Classes of org.hornetq.spi.core.protocol.RemotingConnection

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.