Search in sources :

Example 1 with ClusterConnectionControl

use of org.apache.activemq.artemis.api.core.management.ClusterConnectionControl in project wildfly by wildfly.

the class ClusterConnectionControlHandler method handleReadAttribute.

@Override
protected void handleReadAttribute(String attributeName, OperationContext context, ModelNode operation) throws OperationFailedException {
    if (ClusterConnectionDefinition.NODE_ID.getName().equals(attributeName)) {
        ClusterConnectionControl control = getActiveMQComponentControl(context, operation, false);
        context.getResult().set(control.getNodeID());
    } else if (ClusterConnectionDefinition.TOPOLOGY.getName().equals(attributeName)) {
        ClusterConnectionControl control = getActiveMQComponentControl(context, operation, false);
        context.getResult().set(control.getTopology());
    } else {
        unsupportedAttribute(attributeName);
    }
}
Also used : ClusterConnectionControl(org.apache.activemq.artemis.api.core.management.ClusterConnectionControl)

Example 2 with ClusterConnectionControl

use of org.apache.activemq.artemis.api.core.management.ClusterConnectionControl in project wildfly by wildfly.

the class ClusterConnectionControlHandler method handleOperation.

@Override
protected Object handleOperation(String operationName, OperationContext context, ModelNode operation) throws OperationFailedException {
    if (ClusterConnectionDefinition.GET_NODES.equals(operationName)) {
        ClusterConnectionControl control = getActiveMQComponentControl(context, operation, false);
        try {
            Map<String, String> nodes = control.getNodes();
            final ModelNode result = context.getResult();
            result.setEmptyObject();
            for (Map.Entry<String, String> entry : nodes.entrySet()) {
                result.get(entry.getKey()).set(entry.getValue());
            }
        } catch (Exception e) {
            context.getFailureDescription().set(e.getLocalizedMessage());
        }
    } else {
        unsupportedOperation(operationName);
    }
    return null;
}
Also used : ModelNode(org.jboss.dmr.ModelNode) ClusterConnectionControl(org.apache.activemq.artemis.api.core.management.ClusterConnectionControl) Map(java.util.Map) OperationFailedException(org.jboss.as.controller.OperationFailedException)

Aggregations

ClusterConnectionControl (org.apache.activemq.artemis.api.core.management.ClusterConnectionControl)2 Map (java.util.Map)1 OperationFailedException (org.jboss.as.controller.OperationFailedException)1 ModelNode (org.jboss.dmr.ModelNode)1