/** * @param locator */ private void closeLocator(final ServerLocatorInternal locator) { if (locator != null) locator.close(); }
private void closeLocator(ServerLocatorInternal backupServerLocator) { if (backupServerLocator != null) { backupServerLocator.close(); } } }
@Override public void stop() throws Exception { //close all the locators for (ServerLocatorInternal serverLocatorInternal : locators.values()) { serverLocatorInternal.close(); } //stop the quorum manager quorumManager.stop(); started = false; }
@Override public void run() { try { if (disconnected) { targetLocator.cleanup(); } else { targetLocator.close(); } } catch (Exception ignored) { logger.debug(ignored.getMessage(), ignored); } } });
@Override public void close(boolean permanently, boolean restarting) throws Exception { if (scaleDownServerLocator != null) { scaleDownServerLocator.close(); scaleDownServerLocator = null; } NodeManager nodeManagerInUse = activeMQServer.getNodeManager(); if (nodeManagerInUse != null) { if (permanently) { nodeManagerInUse.crashLiveServer(); } else { nodeManagerInUse.pauseLiveServer(); } } }
@Override public void postConnectionFreeze() { if (liveOnlyPolicy.getScaleDownPolicy() != null && liveOnlyPolicy.getScaleDownPolicy().isEnabled() && scaleDownClientSessionFactory != null) { try { scaleDown(); } catch (Exception e) { ActiveMQServerLogger.LOGGER.failedToScaleDown(e); } finally { scaleDownClientSessionFactory.close(); scaleDownServerLocator.close(); } } }
clusterLocator.close(); } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorClosingServerLocator(e, clusterLocator);
@Test public void testMultipleConnectorSingleServerNoConnectAttemptReconnect() throws Exception { ServerLocatorInternal locator = (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithoutHA(createTransportConfiguration(isNetty(), false, generateParams(1, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(2, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(3, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(4, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(5, isNetty()))); locator.setReconnectAttempts(15); CountDownLatch countDownLatch = new CountDownLatch(1); Connector target = new Connector(locator, countDownLatch); Thread t = new Thread(target); t.start(); //let them get started Thread.sleep(500); locator.close(); assertTrue(countDownLatch.await(5, TimeUnit.SECONDS)); assertNull(target.csf); }
@Test public void testSingleConnectorSingleServerConnect() throws Exception { ServerLocatorInternal locator = (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithoutHA(createTransportConfiguration(isNetty(), false, generateParams(0, isNetty()))); ClientSessionFactoryInternal csf = locator.connect(); assertNotNull(csf); assertEquals(csf.numConnections(), 1); locator.close(); }
locator.close(); } catch (Exception ignored) {
@Test public void testMultipleConnectorSingleServerConnectReconnect() throws Exception { ServerLocatorInternal locator = (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithoutHA(createTransportConfiguration(isNetty(), false, generateParams(0, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(1, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(2, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(3, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(4, isNetty()))); locator.setReconnectAttempts(15); ClientSessionFactoryInternal csf = locator.connect(); assertNotNull(csf); assertEquals(csf.numConnections(), 1); locator.close(); }
@Test public void testMultipleConnectorSingleServerConnect() throws Exception { ServerLocatorInternal locator = (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithoutHA(createTransportConfiguration(isNetty(), false, generateParams(0, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(1, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(2, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(3, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(4, isNetty()))); ClientSessionFactoryInternal csf = locator.connect(); assertNotNull(csf); assertEquals(csf.numConnections(), 1); locator.close(); }
@Test public void testMultipleConnectorSingleServerNoConnect() throws Exception { ServerLocatorInternal locator = (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithoutHA(createTransportConfiguration(isNetty(), false, generateParams(1, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(2, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(3, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(4, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(5, isNetty()))); ClientSessionFactoryInternal csf = null; try { csf = locator.connect(); } catch (ActiveMQNotConnectedException nce) { //ok } catch (Exception e) { assertTrue(e instanceof ActiveMQException); fail("Invalid Exception type:" + ((ActiveMQException) e).getType()); } assertNull(csf); locator.close(); }