@Override public String getSwapPartitionName() { return nodeIdentifier.getId(); }
@Override public NodeIdentifier getNodeIdentifier(final String uuid) { for (final NodeIdentifier nodeId : nodeStatuses.keySet()) { if (nodeId.getId().equals(uuid)) { return nodeId; } } return null; }
@Override public String getClusterNodeIdentifier() { final NodeIdentifier nodeId = flowController.getNodeId(); return nodeId == null ? null : nodeId.getId(); } }
@Override public String getNodeId() { final NodeIdentifier nodeId = controllerFacade.getNodeId(); if (nodeId != null) { return nodeId.getId(); } else { return null; } }
@Override public void mergeStatus(ConnectionStatusDTO clientStatus, boolean clientStatusReadablePermission, ConnectionStatusDTO status, boolean statusReadablePermission, NodeIdentifier statusNodeIdentifier) { StatusMerger.merge(clientStatus, clientStatusReadablePermission, status, statusReadablePermission, statusNodeIdentifier.getId(), statusNodeIdentifier.getApiAddress(), statusNodeIdentifier.getApiPort()); } }
@Override public void mergeStatus(RemoteProcessGroupStatusDTO clientStatus, boolean clientStatusReadablePermission, RemoteProcessGroupStatusDTO status, boolean statusReadablePermission, NodeIdentifier statusNodeIdentifier) { StatusMerger.merge(clientStatus, clientStatusReadablePermission, status, statusReadablePermission, statusNodeIdentifier.getId(), statusNodeIdentifier.getApiAddress(), statusNodeIdentifier.getApiPort()); }
@Override public void mergeStatus(ConnectionStatusDTO clientStatus, boolean clientStatusReadablePermission, ConnectionStatusDTO status, boolean statusReadablePermission, NodeIdentifier statusNodeIdentifier) { StatusMerger.merge(clientStatus, clientStatusReadablePermission, status, statusReadablePermission, statusNodeIdentifier.getId(), statusNodeIdentifier.getApiAddress(), statusNodeIdentifier.getApiPort()); } }
@Override public void mergeStatus(ProcessorStatusDTO clientStatus, boolean clientStatusReadablePermission, ProcessorStatusDTO status, boolean statusReadablePermission, NodeIdentifier statusNodeIdentifier) { StatusMerger.merge(clientStatus, clientStatusReadablePermission, status, statusReadablePermission, statusNodeIdentifier.getId(), statusNodeIdentifier.getApiAddress(), statusNodeIdentifier.getApiPort()); }
@Override public void mergeStatus(ProcessorStatusDTO clientStatus, boolean clientStatusReadablePermission, ProcessorStatusDTO status, boolean statusReadablePermission, NodeIdentifier statusNodeIdentifier) { StatusMerger.merge(clientStatus, clientStatusReadablePermission, status, statusReadablePermission, statusNodeIdentifier.getId(), statusNodeIdentifier.getApiAddress(), statusNodeIdentifier.getApiPort()); } }
@Override public void mergeStatus(PortStatusDTO clientStatus, boolean clientStatusReadablePermission, PortStatusDTO status, boolean statusReadablePermission, NodeIdentifier statusNodeIdentifier) { StatusMerger.merge(clientStatus, clientStatusReadablePermission, status, statusReadablePermission, statusNodeIdentifier.getId(), statusNodeIdentifier.getApiAddress(), statusNodeIdentifier.getApiPort()); }
@Override public void mergeStatus(PortStatusDTO clientStatus, boolean clientStatusReadablePermission, PortStatusDTO status, boolean statusReadablePermission, NodeIdentifier statusNodeIdentifier) { StatusMerger.merge(clientStatus, clientStatusReadablePermission, status, statusReadablePermission, statusNodeIdentifier.getId(), statusNodeIdentifier.getApiAddress(), statusNodeIdentifier.getApiPort()); } }
@Override public void mergeStatus(ProcessGroupStatusDTO clientStatus, boolean clientStatusReadablePermission, ProcessGroupStatusDTO status, boolean statusReadablePermission, NodeIdentifier statusNodeIdentifier) { StatusMerger.merge(clientStatus, clientStatusReadablePermission, status, statusReadablePermission, statusNodeIdentifier.getId(), statusNodeIdentifier.getApiAddress(), statusNodeIdentifier.getApiPort()); }
@Override public void mergeStatus(ProcessGroupStatusDTO clientStatus, boolean clientStatusReadablePermission, ProcessGroupStatusDTO status, boolean statusReadablePermission, NodeIdentifier statusNodeIdentifier) { StatusMerger.merge(clientStatus, clientStatusReadablePermission, status, statusReadablePermission, statusNodeIdentifier.getId(), statusNodeIdentifier.getApiAddress(), statusNodeIdentifier.getApiPort()); } }
@Override public void mergeStatus(RemoteProcessGroupStatusDTO clientStatus, boolean clientStatusReadablePermission, RemoteProcessGroupStatusDTO status, boolean statusReadablePermission, NodeIdentifier statusNodeIdentifier) { StatusMerger.merge(clientStatus, clientStatusReadablePermission, status, statusReadablePermission, statusNodeIdentifier.getId(), statusNodeIdentifier.getApiAddress(), statusNodeIdentifier.getApiPort()); } }
@Override protected void mergeResponses(ProvenanceEventDTO clientDto, Map<NodeIdentifier, ProvenanceEventDTO> dtoMap, Set<NodeResponse> successfulResponses, Set<NodeResponse> problematicResponses) { // The request for a Provenance Event is replicated to a single Node. We simply update its cluster node info. // However, we only do this if the cluster node info isn't set, because if this is replicated across the cluster, // the cluster coordinator will have already set it, and we will be receiving the response from the cluster // coordinator. We do not want to overwrite this value on all DTO's with the cluster coordinator's information. if (clientDto.getClusterNodeId() == null || clientDto.getClusterNodeAddress() == null) { final NodeIdentifier nodeId = successfulResponses.iterator().next().getNodeId(); clientDto.setClusterNodeId(nodeId.getId()); clientDto.setClusterNodeAddress(nodeId.getApiAddress() + ":" + nodeId.getApiPort()); } } }
@Override protected void mergeResponses(SystemDiagnosticsDTO clientDto, Map<NodeIdentifier, SystemDiagnosticsDTO> dtoMap, NodeIdentifier selectedNodeId) { final SystemDiagnosticsDTO mergedSystemDiagnostics = clientDto; mergedSystemDiagnostics.setNodeSnapshots(new ArrayList<NodeSystemDiagnosticsSnapshotDTO>()); final NodeSystemDiagnosticsSnapshotDTO selectedNodeSnapshot = new NodeSystemDiagnosticsSnapshotDTO(); selectedNodeSnapshot.setSnapshot(clientDto.getAggregateSnapshot().clone()); selectedNodeSnapshot.setAddress(selectedNodeId.getApiAddress()); selectedNodeSnapshot.setApiPort(selectedNodeId.getApiPort()); selectedNodeSnapshot.setNodeId(selectedNodeId.getId()); mergedSystemDiagnostics.getNodeSnapshots().add(selectedNodeSnapshot); for (final Map.Entry<NodeIdentifier, SystemDiagnosticsDTO> entry : dtoMap.entrySet()) { final NodeIdentifier nodeId = entry.getKey(); final SystemDiagnosticsDTO toMerge = entry.getValue(); if (toMerge == clientDto) { continue; } StatusMerger.merge(mergedSystemDiagnostics, toMerge, nodeId.getId(), nodeId.getApiAddress(), nodeId.getApiPort()); } }
@Override protected void mergeResponses(CountersDTO clientDto, Map<NodeIdentifier, CountersDTO> dtoMap, NodeIdentifier selectedNodeId) { final CountersDTO mergedCounters = clientDto; mergedCounters.setNodeSnapshots(new ArrayList<NodeCountersSnapshotDTO>()); final NodeCountersSnapshotDTO selectedNodeSnapshot = new NodeCountersSnapshotDTO(); selectedNodeSnapshot.setSnapshot(clientDto.getAggregateSnapshot().clone()); selectedNodeSnapshot.setAddress(selectedNodeId.getApiAddress()); selectedNodeSnapshot.setApiPort(selectedNodeId.getApiPort()); selectedNodeSnapshot.setNodeId(selectedNodeId.getId()); mergedCounters.getNodeSnapshots().add(selectedNodeSnapshot); for (final Map.Entry<NodeIdentifier, CountersDTO> entry : dtoMap.entrySet()) { final NodeIdentifier nodeId = entry.getKey(); final CountersDTO toMerge = entry.getValue(); if (toMerge == clientDto) { continue; } StatusMerger.merge(mergedCounters, toMerge, nodeId.getId(), nodeId.getApiAddress(), nodeId.getApiPort()); } }
protected Response replicate(final String method, final NodeIdentifier targetNode, final Object entity) { ensureFlowInitialized(); try { // Determine whether we should replicate only to the cluster coordinator, or if we should replicate directly // to the cluster nodes themselves. if (getReplicationTarget() == ReplicationTarget.CLUSTER_NODES) { final Set<NodeIdentifier> nodeIds = Collections.singleton(targetNode); return getRequestReplicator().replicate(nodeIds, method, getAbsolutePath(), entity, getHeaders(), true, true).awaitMergedResponse().getResponse(); } else { final Map<String, String> headers = getHeaders(Collections.singletonMap(RequestReplicator.REPLICATION_TARGET_NODE_UUID_HEADER, targetNode.getId())); return requestReplicator.forwardToCoordinator(getClusterCoordinatorNode(), method, getAbsolutePath(), entity, headers).awaitMergedResponse().getResponse(); } } catch (final InterruptedException ie) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Request to " + method + " " + getAbsolutePath() + " was interrupted").type("text/plain").build(); } }
private NodeIdentifier addNodeIdentities(final NodeIdentifier nodeId, final Set<String> nodeIdentities) { return new NodeIdentifier(nodeId.getId(), nodeId.getApiAddress(), nodeId.getApiPort(), nodeId.getSocketAddress(), nodeId.getSocketPort(), nodeId.getLoadBalanceAddress(), nodeId.getLoadBalancePort(), nodeId.getSiteToSiteAddress(), nodeId.getSiteToSitePort(), nodeId.getSiteToSiteHttpApiPort(), nodeId.isSiteToSiteSecure(), nodeIdentities); }
public static NodeIdentifierDescriptor fromNodeIdentifier(final NodeIdentifier nodeId, final boolean localNodeId) { final NodeIdentifierDescriptor descriptor = new NodeIdentifierDescriptor(); descriptor.setId(nodeId.getId()); descriptor.setApiAddress(nodeId.getApiAddress()); descriptor.setApiPort(nodeId.getApiPort()); descriptor.setSocketAddress(nodeId.getSocketAddress()); descriptor.setSocketPort(nodeId.getSocketPort()); descriptor.setSiteToSiteAddress(nodeId.getSiteToSiteAddress()); descriptor.setSiteToSitePort(nodeId.getSiteToSitePort()); descriptor.setSiteToSiteHttpApiPort(nodeId.getSiteToSiteHttpApiPort()); descriptor.setSiteToSiteSecure(nodeId.isSiteToSiteSecure()); descriptor.setNodeIdentities(nodeId.getNodeIdentities()); descriptor.setLoadBalanceAddress(nodeId.getLoadBalanceAddress()); descriptor.setLoadBalancePort(nodeId.getLoadBalancePort()); descriptor.setLocalNodeIdentifier(localNodeId); return descriptor; }