@Override public ServerLocatorInternal createServerLocator(Topology topology) { if (tcConfigs != null && tcConfigs.length > 0) { if (logger.isDebugEnabled()) { logger.debug(BackupManager.this + "Creating a serverLocator for " + Arrays.toString(tcConfigs)); } ServerLocatorImpl locator = new ServerLocatorImpl(topology, true, tcConfigs); locator.setClusterConnection(true); locator.setProtocolManagerFactory(ActiveMQServerSideProtocolManagerFactory.getInstance(locator)); return locator; } return null; }
public static ActiveMQServerSideProtocolManagerFactory getInstance(ServerLocator locator) { ActiveMQServerSideProtocolManagerFactory instance = new ActiveMQServerSideProtocolManagerFactory(); instance.setLocator(locator); return instance; }
/** * connect to an already defined node in the cluster * * @param sf the session factory * @return the Cluster Control */ public ClusterControl connectToNodeInCluster(ClientSessionFactoryInternal sf) { sf.getServerLocator().setProtocolManagerFactory(ActiveMQServerSideProtocolManagerFactory.getInstance(sf.getServerLocator())); return new ClusterControl(sf, server); }
void start() { stopping = false; backupAnnounced = false; ClusterConnection clusterConnection = clusterManager.getClusterConnection(name); //NB we use the same topology as the sister cluster connection so it knows when started about all the nodes to bridge to backupServerLocator = createServerLocator(clusterConnection.getTopology()); if (backupServerLocator != null) { backupServerLocator.setIdentity("backupLocatorFor='" + server + "'"); backupServerLocator.setReconnectAttempts(-1); backupServerLocator.setInitialConnectAttempts(-1); backupServerLocator.setProtocolManagerFactory(ActiveMQServerSideProtocolManagerFactory.getInstance(backupServerLocator)); } }
@Override public void postLoad(Journal messageJournal, ResourceManager resourceManager, Map<SimpleString, List<Pair<byte[], Long>>> duplicateIDMap) throws Exception { ScaleDownHandler scaleDownHandler = new ScaleDownHandler(pagingManager, postOffice, nodeManager, clusterController, parentServer.getStorageManager()); locator.setProtocolManagerFactory(ActiveMQServerSideProtocolManagerFactory.getInstance(locator)); try (ClientSessionFactory sessionFactory = locator.createSessionFactory()) { scaleDownHandler.scaleDown(sessionFactory, resourceManager, duplicateIDMap, parentServer.getConfiguration().getManagementAddress(), parentServer.getNodeID()); } }
@Override protected ClientSessionFactoryInternal createSessionFactory() throws Exception { serverLocator.setProtocolManagerFactory(ActiveMQServerSideProtocolManagerFactory.getInstance(serverLocator)); ClientSessionFactoryInternal factory = (ClientSessionFactoryInternal) serverLocator.createSessionFactory(targetNodeID); //if it is null then its possible the broker was removed after a disconnect so lets try the original connectors if (factory == null) { factory = reconnectOnOriginalNode(); if (factory == null) { return null; } } setSessionFactory(factory); if (factory == null) { return null; } factory.setReconnectAttempts(0); factory.getConnection().addFailureListener(this); return factory; }
private void configAndAdd(SimpleString name, ServerLocatorInternal serverLocator, ClusterConnectionConfiguration config) { serverLocator.setConnectionTTL(config.getConnectionTTL()); serverLocator.setClientFailureCheckPeriod(config.getClientFailureCheckPeriod()); //if the cluster isn't available we want to hang around until it is serverLocator.setReconnectAttempts(config.getReconnectAttempts()); serverLocator.setInitialConnectAttempts(config.getInitialConnectAttempts()); serverLocator.setRetryInterval(config.getRetryInterval()); serverLocator.setRetryIntervalMultiplier(config.getRetryIntervalMultiplier()); serverLocator.setMaxRetryInterval(config.getMaxRetryInterval()); //this is used for replication so need to use the server packet decoder serverLocator.setProtocolManagerFactory(ActiveMQServerSideProtocolManagerFactory.getInstance(serverLocator)); serverLocator.setThreadPools(server.getThreadPool(), server.getScheduledPool()); try { serverLocator.initialize(); } catch (Exception e) { throw new IllegalStateException(e.getMessage(), e); } locators.put(name, serverLocator); }
scaleDownServerLocator = ScaleDownPolicy.getScaleDownConnector(scaleDownPolicy, activeMQServer); scaleDownServerLocator.setProtocolManagerFactory(ActiveMQServerSideProtocolManagerFactory.getInstance(scaleDownServerLocator)); LiveNodeLocator nodeLocator = scaleDownPolicy.getGroupName() == null ? new AnyLiveNodeLocatorForScaleDown(activeMQServer) : new NamedLiveNodeLocatorForScaleDown(scaleDownPolicy.getGroupName(), activeMQServer); scaleDownServerLocator.addClusterTopologyListener(nodeLocator);
@Test public void controlWithDifferentConnector() throws Exception { try (ServerLocatorImpl locator = (ServerLocatorImpl) createInVMNonHALocator()) { locator.setProtocolManagerFactory(ActiveMQServerSideProtocolManagerFactory.getInstance(locator)); ClusterController controller = new ClusterController(getServer(0), getServer(0).getScheduledPool()); ClusterControl clusterControl = controller.connectToNodeInCluster((ClientSessionFactoryInternal) locator.createSessionFactory()); clusterControl.authorize(); } }
serverLocator.setProtocolManagerFactory(ActiveMQServerSideProtocolManagerFactory.getInstance(serverLocator));
protected void setupSessionFactory(final int node, final boolean netty, boolean ha, final String user, final String password) throws Exception { if (sfs[node] != null) { throw new IllegalArgumentException("Already a factory at " + node); } Map<String, Object> params = generateParams(node, netty); TransportConfiguration serverTotc; if (netty) { serverTotc = new TransportConfiguration(ActiveMQTestBase.NETTY_CONNECTOR_FACTORY, params); } else { serverTotc = new TransportConfiguration(INVM_CONNECTOR_FACTORY, params); } setSessionFactoryCreateLocator(node, ha, serverTotc); locators[node].setProtocolManagerFactory(ActiveMQServerSideProtocolManagerFactory.getInstance(locators[node])); locators[node].setBlockOnNonDurableSend(true).setBlockOnDurableSend(true); addServerLocator(locators[node]); ClientSessionFactory sf = createSessionFactory(locators[node]); ClientSession session = sf.createSession(user, password, false, true, true, ActiveMQClient.DEFAULT_PRE_ACKNOWLEDGE, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE); session.close(); sfs[node] = sf; }
@Test public void controlWithDifferentPassword() throws Exception { try (ServerLocatorImpl locator = (ServerLocatorImpl) createInVMNonHALocator()) { locator.setProtocolManagerFactory(ActiveMQServerSideProtocolManagerFactory.getInstance(locator)); ClusterController controller = new ClusterController(getServer(1), getServer(1).getScheduledPool()); ClusterControl clusterControl = controller.connectToNodeInCluster((ClientSessionFactoryInternal) locator.createSessionFactory()); try { clusterControl.authorize(); fail("should throw ActiveMQClusterSecurityException"); } catch (Exception e) { assertTrue("should throw ActiveMQClusterSecurityException", e instanceof ActiveMQClusterSecurityException); } } }
serverLocator.setProtocolManagerFactory(ActiveMQServerSideProtocolManagerFactory.getInstance(serverLocator));