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; }
@Override public void run() { try { //we should only try once, if its not there we should move on. clusterControl.getSessionFactory().setReconnectAttempts(1); backupQuorum.setSessionFactory(clusterControl.getSessionFactory()); //get the connection and request replication to live clusterControl.authorize(); connectToReplicationEndpoint(clusterControl); replicationEndpoint.start(); clusterControl.announceReplicatingBackupToLive(attemptFailBack, replicaPolicy.getClusterName()); } catch (Exception e) { //we shouldn't stop the server just mark the connector as tried and unavailable ActiveMQServerLogger.LOGGER.replicationStartProblem(e); backupQuorum.causeExit(FAILURE_REPLICATING); } }
public void close() { if (clusterControl != null) { clusterControl.close(); } } }
clusterControl.authorize(); vote = clusterControl.sendQuorumVote(quorumVote.getName(), vote); quorumVote.vote(vote); } else { try { if (clusterControl != null) { clusterControl.close();
/** * 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()); } } }
clusterControl.authorize(); clusterControl.sendNodeAnnounce(System.currentTimeMillis(), nodeManager.getNodeId().toString(), server.getHAPolicy().getBackupGroupName(), server.getHAPolicy().getScaleDownClustername(), true, connector, null); ActiveMQServerLogger.LOGGER.backupAnnounced(); backupAnnounced = true;
@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(); } }
public boolean requestReplicatedBackup(int backupSize, SimpleString nodeID) { BackupRequestMessage backupRequestMessage = new BackupRequestMessage(backupSize, nodeID); return requestBackup(backupRequestMessage); }
/** * 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); }
public Vote sendQuorumVote(SimpleString handler, Vote vote) { try { ActiveMQServerLogger.LOGGER.sendingQuorumVoteRequest(getSessionFactory().getConnection().getRemoteAddress(), vote.toString()); QuorumVoteReplyMessage replyMessage = (QuorumVoteReplyMessage) clusterChannel.sendBlocking(new QuorumVoteMessage(handler, vote), PacketImpl.QUORUM_VOTE_REPLY); QuorumVoteHandler voteHandler = server.getClusterManager().getQuorumManager().getVoteHandler(replyMessage.getHandler()); replyMessage.decodeRest(voteHandler); Vote voteResponse = replyMessage.getVote(); ActiveMQServerLogger.LOGGER.receivedQuorumVoteResponse(getSessionFactory().getConnection().getRemoteAddress(), voteResponse.toString()); return voteResponse; } catch (ActiveMQException e) { return null; } }
private synchronized ReplicationEndpoint connectToReplicationEndpoint(final ClusterControl control) throws Exception { if (!activeMQServer.isStarted()) return null; if (!activeMQServer.getHAPolicy().isBackup()) { throw ActiveMQMessageBundle.BUNDLE.serverNotBackupServer(); } Channel replicationChannel = control.createReplicationChannel(); replicationChannel.setHandler(replicationEndpoint); if (replicationEndpoint.getChannel() != null) { throw ActiveMQMessageBundle.BUNDLE.alreadyHaveReplicationServer(); } replicationEndpoint.setChannel(replicationChannel); return replicationEndpoint; } }
@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); }
@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); } } }
public boolean requestSharedStoreBackup(int backupSize, String journalDirectory, String bindingsDirectory, String largeMessagesDirectory, String pagingDirectory) { BackupRequestMessage backupRequestMessage = new BackupRequestMessage(backupSize, journalDirectory, bindingsDirectory, largeMessagesDirectory, pagingDirectory); return requestBackup(backupRequestMessage); }
public boolean checkLive(TransportConfiguration liveTransportConfiguration) { try { ClusterControl control = clusterController.connectToNode(liveTransportConfiguration); control.close(); return true; } catch (Throwable t) { return false; } }
clusterControl.close(); backupQuorum.reset(); if (replicationEndpoint.getChannel() != null) {