public SharedNothingBackupActivation(ActiveMQServerImpl activeMQServer, boolean attemptFailBack, Map<String, Object> activationParams, ActiveMQServerImpl.ShutdownOnCriticalErrorListener shutdownOnCriticalIO, ReplicaPolicy replicaPolicy, NetworkHealthCheck networkHealthCheck) { this.activeMQServer = activeMQServer; this.attemptFailBack = attemptFailBack; this.activationParams = activationParams; this.shutdownOnCriticalIO = shutdownOnCriticalIO; this.replicaPolicy = replicaPolicy; backupSyncLatch.setCount(1); this.networkHealthCheck = networkHealthCheck; }
public ProducerThread setFinished(int value) { finished.setCount(value); return this; }
public ProducerThread setFinished(int value) { finished.setCount(value); return this; }
public void reset() { latch.setCount(1); }
public static void reset() { latch.setCount(1); serverToStop = null; count = 0; thread = null; }
@Before public void before() throws Exception { latch.setCount(1); }
connectionCountLatch.setCount(0);
@Test public void testReferenceValidExecutorUsed() throws Exception { ExecutorService executor = Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory()); LatchRunner runner = new LatchRunner(); ReferenceCounterUtil counter = new ReferenceCounterUtil(runner, executor); counter.increment(); counter.decrement(); runner.latch.await(5, TimeUnit.SECONDS); assertNotSame(runner.lastThreadUsed, Thread.currentThread()); runner.latch.setCount(1); runner.lastThreadUsed = Thread.currentThread(); // force a recheck counter.check(); runner.latch.await(5, TimeUnit.SECONDS); assertNotSame(runner.lastThreadUsed, Thread.currentThread()); executor.shutdown(); }
latch.setCount(noOfMessages);
activationLatch.setCount(1);
latch.setCount(1); embeddedActiveMQ.getActiveMQServer().getReloadManager().setTick(tick); latch.await(10, TimeUnit.SECONDS);
Files.copy(url2.openStream(), brokerXML, StandardCopyOption.REPLACE_EXISTING); brokerXML.toFile().setLastModified(System.currentTimeMillis() + 1000); latch.setCount(1); embeddedActiveMQ.getActiveMQServer().getReloadManager().setTick(tick); latch.await(10, TimeUnit.SECONDS);
latch.setCount(1); embeddedActiveMQ.getActiveMQServer().getReloadManager().setTick(tick); latch.await(10, TimeUnit.SECONDS);
@Test public void testAlreadyShutdown() throws Exception { assumeTrue(purePingWorks(IPV6_LOCAL)); ReusableLatch latch = new ReusableLatch(0); NetworkHealthCheck check = addCheck(new NetworkHealthCheck(null, 100, 100) { @Override public void run() { super.run(); latch.countDown(); System.out.println("Check"); } }); check.addComponent(component); InetAddress address = InetAddress.getByName("127.0.0.1"); check.addAddress(address); component.stop(); latch.setCount(1); Assert.assertTrue(latch.await(1, TimeUnit.MINUTES)); Assert.assertFalse("NetworkHealthCheck should have no business on restarting the component, the network was never down, hence no check needed!", component.isStarted()); }
@Test public void testCheckUsingHTTP() throws Exception { startHTTPServer(); NetworkHealthCheck check = addCheck(new NetworkHealthCheck(null, 100, 1000)); Assert.assertTrue(check.check(new URL("http://localhost:8787"))); stopHTTPServer(); Assert.assertFalse(check.check(new URL("http://localhost:8787"))); check.addComponent(component); URL url = new URL("http://localhost:8787"); Assert.assertFalse(check.check(url)); startHTTPServer(); Assert.assertTrue(check.check(url)); check.addURL(url); Assert.assertFalse(latch.await(500, TimeUnit.MILLISECONDS)); Assert.assertTrue(component.isStarted()); // stopping the web server should stop the component stopHTTPServer(); Assert.assertTrue(latch.await(10, TimeUnit.SECONDS)); Assert.assertFalse(component.isStarted()); latch.setCount(1); startHTTPServer(); Assert.assertTrue(latch.await(10, TimeUnit.SECONDS)); Assert.assertTrue(component.isStarted()); }
latch.setCount(1);
@Test public void testUsingOwnExecutorsOnDemand() throws Throwable { final ReusableLatch latch = new ReusableLatch(1); final ActiveMQScheduledComponent local = new ActiveMQScheduledComponent(10, TimeUnit.MILLISECONDS, true) { @Override public void run() { latch.countDown(); } }; local.start(); local.start(); // should be ok to call start again try { Assert.assertFalse(latch.await(20, TimeUnit.MILLISECONDS)); local.delay(); Assert.assertTrue(latch.await(20, TimeUnit.MILLISECONDS)); latch.setCount(1); Assert.assertFalse(latch.await(20, TimeUnit.MILLISECONDS)); // re-scheduling the executor at a big interval.. // just to make sure it won't hung local.setTimeUnit(TimeUnit.HOURS); local.setPeriod(1); } finally { local.stop(); local.stop(); // calling stop again should not be an issue. } }