/** * connect to a specific node in the cluster used for replication * * @param transportConfiguration the configuration of the node to connect to. * @return the Cluster Control * @throws Exception */ public ClusterControl connectToNodeInReplicatedCluster(TransportConfiguration transportConfiguration) throws Exception { ClientSessionFactoryInternal sessionFactory = (ClientSessionFactoryInternal) replicationLocator.createSessionFactory(transportConfiguration, 0, false); return connectToNodeInCluster(sessionFactory); }
/** * connect to a specific node in the cluster used for replication * * @param transportConfiguration the configuration of the node to connect to. * @return the Cluster Control * @throws Exception */ public ClusterControl connectToNode(TransportConfiguration transportConfiguration) throws Exception { ClientSessionFactoryInternal sessionFactory = (ClientSessionFactoryInternal) defaultLocator.createSessionFactory(transportConfiguration, 0, false); return connectToNodeInCluster(sessionFactory); }
ClusterControl clusterControl = clusterManager.getClusterController().connectToNodeInCluster(backupSessionFactory); clusterControl.authorize(); clusterControl.sendNodeAnnounce(System.currentTimeMillis(), nodeManager.getNodeId().toString(), server.getHAPolicy().getBackupGroupName(), server.getHAPolicy().getScaleDownClustername(), true, connector, null);
@Override public void onConnection(ClientSessionFactoryInternal sf) { TopologyMember localMember = getLocalMember(); if (localMember != null) { ClusterControl clusterControl = manager.getClusterController().connectToNodeInCluster(sf); try { clusterControl.authorize(); clusterControl.sendNodeAnnounce(localMember.getUniqueEventID(), manager.getNodeId(), manager.getBackupGroupName(), manager.getScaleDownGroupName(), false, localMember.getLive(), localMember.getBackup()); } catch (ActiveMQException e) { ActiveMQServerLogger.LOGGER.clusterControlAuthfailure(); } } else { ActiveMQServerLogger.LOGGER.noLocalMemborOnClusterConnection(this); } // TODO: shouldn't we send the current time here? and change the current topology? // sf.sendNodeAnnounce(System.currentTimeMillis(), // manager.getNodeId(), // false, // localMember.getConnector().a, // localMember.getConnector().b); }
public long scaleDown(ClientSessionFactory sessionFactory, ResourceManager resourceManager, Map<SimpleString, List<Pair<byte[], Long>>> duplicateIDMap, SimpleString managementAddress, SimpleString targetNodeId) throws Exception { ClusterControl clusterControl = clusterController.connectToNodeInCluster((ClientSessionFactoryInternal) sessionFactory); clusterControl.authorize(); long num = scaleDownMessages(sessionFactory, targetNodeId, clusterControl.getClusterUser(), clusterControl.getClusterPassword()); ActiveMQServerLogger.LOGGER.infoScaledDownMessages(num); scaleDownTransactions(sessionFactory, resourceManager, clusterControl.getClusterUser(), clusterControl.getClusterPassword()); scaleDownDuplicateIDs(duplicateIDMap, sessionFactory, managementAddress, clusterControl.getClusterUser(), clusterControl.getClusterPassword()); clusterControl.announceScaleDown(new SimpleString(this.targetNodeId), nodeManager.getNodeId()); return num; }
@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(); } }
@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); } } }