@Override public String describe() { StringWriter str = new StringWriter(); PrintWriter out = new PrintWriter(str); out.println(this); out.println("***************************************"); out.println(name + " connected to"); for (MessageFlowRecord messageFlow : records.values()) { out.println("\t Bridge = " + messageFlow.getBridge()); out.println("\t Flow Record = " + messageFlow); } out.println("***************************************"); return str.toString(); }
@Override public boolean isNodeActive(String nodeId) { MessageFlowRecord rec = records.get(nodeId); if (rec == null) { return false; } return rec.getBridge().isConnected(); }
@Override public Map<String, String> getNodes() { synchronized (recordsGuard) { Map<String, String> nodes = new HashMap<>(); for (Entry<String, MessageFlowRecord> entry : records.entrySet()) { RemotingConnection fwdConnection = entry.getValue().getBridge().getForwardingConnection(); if (fwdConnection != null) { nodes.put(entry.getKey(), fwdConnection.getRemoteAddress()); } } return nodes; } }
@Override public ClusterConnectionMetrics getMetrics() { long messagesPendingAcknowledgement = 0; long messagesAcknowledged = 0; for (MessageFlowRecord record : records.values()) { final BridgeMetrics metrics = record.getBridge() != null ? record.getBridge().getMetrics() : null; messagesPendingAcknowledgement += metrics != null ? metrics.getMessagesPendingAcknowledgement() : 0; messagesAcknowledged += metrics != null ? metrics.getMessagesAcknowledged() : 0; } return new ClusterConnectionMetrics(messagesPendingAcknowledgement, messagesAcknowledged); }
private void pauseClusteringBridges(ActiveMQServer server) throws Exception { for (ClusterConnection clusterConnection : server.getClusterManager().getClusterConnections()) { for (MessageFlowRecord record : ((ClusterConnectionImpl) clusterConnection).getRecords().values()) { record.getBridge().pause(); } } }
private void crash() throws Exception { /* * Rather than just calling stop() on the server here we want to simulate an actual node crash or bridge failure * so the bridge's failure listener needs to get something other than a DISCONNECTED message. In this case we * simulate a NOT_CONNECTED exception. */ final CountDownLatch latch = new CountDownLatch(1); ClusterConnectionImpl next = (ClusterConnectionImpl) server1.getClusterManager().getClusterConnections().iterator().next(); BridgeImpl bridge = (BridgeImpl) next.getRecords().values().iterator().next().getBridge(); RemotingConnection forwardingConnection = getForwardingConnection(bridge); forwardingConnection.addFailureListener(new FailureListener() { @Override public void connectionFailed(ActiveMQException exception, boolean failedOver) { latch.countDown(); } @Override public void connectionFailed(final ActiveMQException me, boolean failedOver, String scaleDownTargetNodeID) { connectionFailed(me, failedOver); } }); forwardingConnection.fail(new ActiveMQNotConnectedException()); assertTrue(latch.await(5000, TimeUnit.MILLISECONDS)); if (crash) { jmsServer2.stop(); } }
logger.debug("Setting up notificationConsumer between " + this.clusterConnection.getConnector() + " and " + flowRecord.getBridge().getForwardingConnection() + " clusterConnection = " + this.clusterConnection.getName() +
ClusterConnectionBridge bridge = (ClusterConnectionBridge) record.getBridge();
record.getBridge().pause();