Search in sources :

Example 1 with ClusterControl

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);
}
Also used : ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) TopologyMember(org.apache.activemq.artemis.api.core.client.TopologyMember) ClusterControl(org.apache.activemq.artemis.core.server.cluster.ClusterControl)

Example 2 with ClusterControl

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;
    }
}
Also used : ClusterControl(org.apache.activemq.artemis.core.server.cluster.ClusterControl)

Example 3 with ClusterControl

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;
}
Also used : SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ClusterControl(org.apache.activemq.artemis.core.server.cluster.ClusterControl)

Example 4 with ClusterControl

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);
        }
    }
}
Also used : ClusterController(org.apache.activemq.artemis.core.server.cluster.ClusterController) ActiveMQClusterSecurityException(org.apache.activemq.artemis.api.core.ActiveMQClusterSecurityException) ServerLocatorImpl(org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl) ActiveMQClusterSecurityException(org.apache.activemq.artemis.api.core.ActiveMQClusterSecurityException) ClusterControl(org.apache.activemq.artemis.core.server.cluster.ClusterControl) Test(org.junit.Test)

Example 5 with ClusterControl

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();
    }
}
Also used : ClusterController(org.apache.activemq.artemis.core.server.cluster.ClusterController) ServerLocatorImpl(org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl) ClusterControl(org.apache.activemq.artemis.core.server.cluster.ClusterControl) Test(org.junit.Test)

Aggregations

ClusterControl (org.apache.activemq.artemis.core.server.cluster.ClusterControl)5 ServerLocatorImpl (org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl)2 ClusterController (org.apache.activemq.artemis.core.server.cluster.ClusterController)2 Test (org.junit.Test)2 ActiveMQClusterSecurityException (org.apache.activemq.artemis.api.core.ActiveMQClusterSecurityException)1 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 TopologyMember (org.apache.activemq.artemis.api.core.client.TopologyMember)1