public static ConnectionResponse createConflictingNodeIdResponse(final String otherNode) { return new ConnectionResponse("The Node Identifier provided already belongs to node " + otherNode); }
public static ConnectionResponse createBlockedByFirewallResponse() { return new ConnectionResponse("Blocked by Firewall"); }
public static ConnectionResponse createRejectionResponse(final String explanation) { return new ConnectionResponse(explanation); }
private ConnectionResponseMessage createFlowElectionInProgressResponse() { final ConnectionResponseMessage responseMessage = new ConnectionResponseMessage(); final String statusDescription = flowElection.getStatusDescription(); responseMessage.setConnectionResponse(new ConnectionResponse(5, "Cluster is still voting on which Flow is the correct flow for the cluster. " + statusDescription)); return responseMessage; }
private ConnectionResponseMessage createConnectionResponse(final ConnectionRequest request, final NodeIdentifier resolvedNodeIdentifier, final DataFlow clusterDataFlow) { if (clusterDataFlow == null) { final ConnectionResponseMessage responseMessage = new ConnectionResponseMessage(); responseMessage.setConnectionResponse(new ConnectionResponse(5, "The cluster dataflow is not yet available")); return responseMessage; } // Set node's status to 'CONNECTING' NodeConnectionStatus status = getConnectionStatus(resolvedNodeIdentifier); if (status == null) { addNodeEvent(resolvedNodeIdentifier, "Connection requested from new node. Setting status to connecting."); } else { addNodeEvent(resolvedNodeIdentifier, "Connection requested from existing node. Setting status to connecting."); } status = new NodeConnectionStatus(resolvedNodeIdentifier, NodeConnectionState.CONNECTING, null, null, null, System.currentTimeMillis()); updateNodeStatus(status); final ConnectionResponse response = new ConnectionResponse(resolvedNodeIdentifier, clusterDataFlow, instanceId, getConnectionStatuses(), revisionManager.getAllRevisions().stream().map(rev -> ComponentRevision.fromRevision(rev)).collect(Collectors.toList())); final ConnectionResponseMessage responseMessage = new ConnectionResponseMessage(); responseMessage.setConnectionResponse(response); return responseMessage; }
@Override public ConnectionResponse unmarshal(final AdaptedConnectionResponse aCr) { if (aCr.shouldTryLater()) { return new ConnectionResponse(aCr.getTryLaterSeconds(), aCr.getRejectionReason()); } else if (aCr.getRejectionReason() != null) { return ConnectionResponse.createRejectionResponse(aCr.getRejectionReason()); } else { return new ConnectionResponse(aCr.getNodeIdentifier(), aCr.getDataFlow(), aCr.getInstanceId(), aCr.getNodeConnectionStatuses(), aCr.getComponentRevisions()); } }
private void handleReconnectionRequest(final ReconnectionRequestMessage request) { try { logger.info("Processing reconnection request from cluster coordinator."); // reconnect ConnectionResponse connectionResponse = new ConnectionResponse(getNodeId(), request.getDataFlow(), request.getInstanceId(), request.getNodeConnectionStatuses(), request.getComponentRevisions()); if (connectionResponse.getDataFlow() == null) { logger.info("Received a Reconnection Request that contained no DataFlow. Will attempt to connect to cluster using local flow."); connectionResponse = connect(false, false, createDataFlowFromController()); } loadFromConnectionResponse(connectionResponse); clusterCoordinator.resetNodeStatuses(connectionResponse.getNodeConnectionStatuses().stream() .collect(Collectors.toMap(NodeConnectionStatus::getNodeIdentifier, status -> status))); // reconnected, this node needs to explicitly write the inherited flow to disk, and resume heartbeats saveFlowChanges(); controller.resumeHeartbeats(); logger.info("Node reconnected."); } catch (final Exception ex) { // disconnect controller if (controller.isClustered()) { disconnect("Failed to properly handle Reconnection request due to " + ex.toString()); } logger.error("Handling reconnection request failed due to: " + ex, ex); handleConnectionFailure(ex); } }
public static ConnectionResponse createRejectionResponse(final String explanation) { return new ConnectionResponse(explanation); }
public static ConnectionResponse createBlockedByFirewallResponse() { return new ConnectionResponse("Blocked by Firewall"); }
public static ConnectionResponse createConflictingNodeIdResponse(final String otherNode) { return new ConnectionResponse("The Node Identifier provided already belongs to node " + otherNode); }
@Override public ConnectionResponse unmarshal(final AdaptedConnectionResponse aCr) { if (aCr.shouldTryLater()) { return new ConnectionResponse(aCr.getTryLaterSeconds(), aCr.getRejectionReason()); } else if (aCr.getRejectionReason() != null) { return ConnectionResponse.createRejectionResponse(aCr.getRejectionReason()); } else { return new ConnectionResponse(aCr.getNodeIdentifier(), aCr.getDataFlow(), aCr.getInstanceId(), aCr.getNodeConnectionStatuses(), aCr.getComponentRevisions()); } }