use of org.apache.activemq.artemis.core.server.cluster.ClusterControl in project activemq-artemis by apache.
the class ClusterConnectionImpl method onConnection.
@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);
}
use of org.apache.activemq.artemis.core.server.cluster.ClusterControl in project activemq-artemis by apache.
the class QuorumManager method checkLive.
public boolean checkLive(TransportConfiguration liveTransportConfiguration) {
try {
ClusterControl control = clusterController.connectToNode(liveTransportConfiguration);
control.close();
return true;
} catch (Throwable t) {
return false;
}
}
use of org.apache.activemq.artemis.core.server.cluster.ClusterControl in project activemq-artemis by apache.
the class ScaleDownHandler method scaleDown.
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;
}
use of org.apache.activemq.artemis.core.server.cluster.ClusterControl in project activemq-artemis by apache.
the class ClusterControllerTest method controlWithDifferentPassword.
@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);
}
}
}
use of org.apache.activemq.artemis.core.server.cluster.ClusterControl in project activemq-artemis by apache.
the class ClusterControllerTest method controlWithDifferentConnector.
@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();
}
}
Aggregations