/** * 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); }
public void addClusterChannelHandler(Channel channel, Acceptor acceptorUsed, CoreRemotingConnection remotingConnection, Activation activation) { clusterController.addClusterChannelHandler(channel, acceptorUsed, remotingConnection, activation); }
/** * add a locator for a cluster connection. * * @param name the cluster connection name * @param tcConfigs the transport configurations to use */ public void addClusterConnection(SimpleString name, TransportConfiguration[] tcConfigs, ClusterConnectionConfiguration config) { ServerLocatorImpl serverLocator = (ServerLocatorImpl) ActiveMQClient.createServerLocatorWithHA(tcConfigs); configAndAdd(name, serverLocator, config); }
@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(); } }
clusterController.addClusterTopologyListenerForReplication(nodeLocator); clusterController.awaitConnectionToReplicationCluster(); clusterController.addIncomingInterceptorForReplication(new ReplicationError(nodeLocator)); logger.trace("sleeping " + clusterController.getRetryIntervalForReplicatedCluster() + " it should retry"); Thread.sleep(clusterController.getRetryIntervalForReplicatedCluster()); signal = SharedNothingBackupQuorum.BACKUP_ACTIVATION.ALREADY_REPLICATING; continue;
public ClusterManager(final ExecutorFactory executorFactory, final ActiveMQServer server, final PostOffice postOffice, final ScheduledExecutorService scheduledExecutor, final ManagementService managementService, final Configuration configuration, final NodeManager nodeManager, final boolean backup) { this.executorFactory = executorFactory; executor = executorFactory.getExecutor(); this.server = server; this.postOffice = postOffice; this.scheduledExecutor = scheduledExecutor; this.managementService = managementService; this.configuration = configuration; this.nodeManager = nodeManager; clusterController = new ClusterController(server, scheduledExecutor); haManager = server.getActivation().getHAManager(); }
clusterController.addClusterConnection(clusterConnection.getName(), dg, config); } else { TransportConfiguration[] tcConfigs = config.getTransportConfigurations(configuration); clusterController.addClusterConnection(clusterConnection.getName(), tcConfigs, config); clusterController.setDefaultClusterConnectionName(defaultClusterConnection.getName());
public boolean checkLive(TransportConfiguration liveTransportConfiguration) { try { ClusterControl control = clusterController.connectToNode(liveTransportConfiguration); control.close(); return true; } catch (Throwable t) { return false; } }
private static ClusterControl tryConnectToNodeInReplicatedCluster(ClusterController clusterController, TransportConfiguration tc) { try { if (logger.isTraceEnabled()) { logger.trace("Calling clusterController.connectToNodeInReplicatedCluster(" + tc + ")"); } if (tc != null) { return clusterController.connectToNodeInReplicatedCluster(tc); } } catch (Exception e) { logger.debug(e.getMessage(), e); } return null; }
@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); } } }
/** * send a request to a live server to start a backup for us * * @param connectorPair the connector for the node to request a backup from * @param backupSize the current size of the requested nodes backups * @param replicated * @return true if the request wa successful. * @throws Exception */ public boolean requestBackup(Pair<TransportConfiguration, TransportConfiguration> connectorPair, int backupSize, boolean replicated) throws Exception { ClusterController clusterController = server.getClusterManager().getClusterController(); try ( ClusterControl clusterControl = clusterController.connectToNode(connectorPair.getA()); ) { clusterControl.authorize(); if (replicated) { return clusterControl.requestReplicatedBackup(backupSize, server.getNodeID()); } else { return clusterControl.requestSharedStoreBackup(backupSize, server.getConfiguration().getJournalLocation().getAbsolutePath(), server.getConfiguration().getBindingsLocation().getAbsolutePath(), server.getConfiguration().getLargeMessagesLocation().getAbsolutePath(), server.getConfiguration().getPagingLocation().getAbsolutePath()); } } }
/** * 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); }
return; clusterControl = clusterController.connectToNode(serverTC); clusterControl.authorize();
/** * add a locator for a cluster connection. * * @param name the cluster connection name * @param dg the discovery group to use * @param config the cluster connection config */ public void addClusterConnection(SimpleString name, DiscoveryGroupConfiguration dg, ClusterConnectionConfiguration config) { ServerLocatorImpl serverLocator = (ServerLocatorImpl) ActiveMQClient.createServerLocatorWithHA(dg); configAndAdd(name, serverLocator, config); }
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; }