use of org.apache.nifi.web.api.dto.status.PortStatusDTO in project nifi by apache.
the class PortStatusEndpointMerger method mergeResponses.
@Override
protected void mergeResponses(PortStatusEntity clientEntity, Map<NodeIdentifier, PortStatusEntity> entityMap, Set<NodeResponse> successfulResponses, Set<NodeResponse> problematicResponses) {
final PortStatusDTO mergedPortStatus = clientEntity.getPortStatus();
mergedPortStatus.setNodeSnapshots(new ArrayList<>());
final NodeIdentifier selectedNodeId = entityMap.entrySet().stream().filter(e -> e.getValue() == clientEntity).map(e -> e.getKey()).findFirst().orElse(null);
if (selectedNodeId == null) {
throw new IllegalArgumentException("Attempted to merge Status request but could not find the appropriate Node Identifier");
}
final NodePortStatusSnapshotDTO selectedNodeSnapshot = new NodePortStatusSnapshotDTO();
selectedNodeSnapshot.setStatusSnapshot(mergedPortStatus.getAggregateSnapshot().clone());
selectedNodeSnapshot.setAddress(selectedNodeId.getApiAddress());
selectedNodeSnapshot.setApiPort(selectedNodeId.getApiPort());
selectedNodeSnapshot.setNodeId(selectedNodeId.getId());
mergedPortStatus.getNodeSnapshots().add(selectedNodeSnapshot);
// merge the other nodes
for (final Map.Entry<NodeIdentifier, PortStatusEntity> entry : entityMap.entrySet()) {
final NodeIdentifier nodeId = entry.getKey();
final PortStatusEntity nodePortStatusEntity = entry.getValue();
final PortStatusDTO nodePortStatus = nodePortStatusEntity.getPortStatus();
if (nodePortStatus == mergedPortStatus) {
continue;
}
mergeStatus(mergedPortStatus, clientEntity.getCanRead(), nodePortStatus, nodePortStatusEntity.getCanRead(), nodeId);
}
}
use of org.apache.nifi.web.api.dto.status.PortStatusDTO in project nifi by apache.
the class DtoFactory method createPortStatusDto.
/**
* Creates a PortStatusDTO for the specified PortStatus.
*
* @param portStatus status
* @return dto
*/
public PortStatusDTO createPortStatusDto(final PortStatus portStatus) {
final PortStatusDTO dto = new PortStatusDTO();
dto.setId(portStatus.getId());
dto.setGroupId(portStatus.getGroupId());
dto.setName(portStatus.getName());
dto.setRunStatus(portStatus.getRunStatus().toString());
dto.setTransmitting(portStatus.isTransmitting());
dto.setStatsLastRefreshed(new Date());
final PortStatusSnapshotDTO snapshot = new PortStatusSnapshotDTO();
dto.setAggregateSnapshot(snapshot);
snapshot.setId(portStatus.getId());
snapshot.setGroupId(portStatus.getGroupId());
snapshot.setName(portStatus.getName());
snapshot.setRunStatus(portStatus.getRunStatus().toString());
snapshot.setActiveThreadCount(portStatus.getActiveThreadCount());
snapshot.setFlowFilesOut(portStatus.getOutputCount());
snapshot.setBytesOut(portStatus.getOutputBytes());
snapshot.setFlowFilesIn(portStatus.getInputCount());
snapshot.setBytesIn(portStatus.getInputBytes());
StatusMerger.updatePrettyPrintedFields(snapshot);
return dto;
}
use of org.apache.nifi.web.api.dto.status.PortStatusDTO in project nifi by apache.
the class DtoFactory method createProcessGroupStatusDto.
public ProcessGroupStatusDTO createProcessGroupStatusDto(final ProcessGroup processGroup, final ProcessGroupStatus processGroupStatus) {
final ProcessGroupStatusDTO processGroupStatusDto = createConciseProcessGroupStatusDto(processGroupStatus);
final ProcessGroupStatusSnapshotDTO snapshot = processGroupStatusDto.getAggregateSnapshot();
// processor status
final Collection<ProcessorStatusSnapshotEntity> processorStatusSnapshotEntities = new ArrayList<>();
snapshot.setProcessorStatusSnapshots(processorStatusSnapshotEntities);
final Collection<ProcessorStatus> processorStatusCollection = processGroupStatus.getProcessorStatus();
if (processorStatusCollection != null) {
for (final ProcessorStatus processorStatus : processorStatusCollection) {
final ProcessorStatusDTO processorStatusDto = createProcessorStatusDto(processorStatus);
final ProcessorNode processor = processGroup.findProcessor(processorStatusDto.getId());
final PermissionsDTO processorPermissions = createPermissionsDto(processor);
processorStatusSnapshotEntities.add(entityFactory.createProcessorStatusSnapshotEntity(processorStatusDto.getAggregateSnapshot(), processorPermissions));
}
}
// connection status
final Collection<ConnectionStatusSnapshotEntity> connectionStatusDtoCollection = new ArrayList<>();
snapshot.setConnectionStatusSnapshots(connectionStatusDtoCollection);
final Collection<ConnectionStatus> connectionStatusCollection = processGroupStatus.getConnectionStatus();
if (connectionStatusCollection != null) {
for (final ConnectionStatus connectionStatus : connectionStatusCollection) {
final ConnectionStatusDTO connectionStatusDto = createConnectionStatusDto(connectionStatus);
final Connection connection = processGroup.findConnection(connectionStatusDto.getId());
final PermissionsDTO connectionPermissions = createPermissionsDto(connection);
connectionStatusDtoCollection.add(entityFactory.createConnectionStatusSnapshotEntity(connectionStatusDto.getAggregateSnapshot(), connectionPermissions));
}
}
// local child process groups
final Collection<ProcessGroupStatusSnapshotEntity> childProcessGroupStatusDtoCollection = new ArrayList<>();
snapshot.setProcessGroupStatusSnapshots(childProcessGroupStatusDtoCollection);
final Collection<ProcessGroupStatus> childProcessGroupStatusCollection = processGroupStatus.getProcessGroupStatus();
if (childProcessGroupStatusCollection != null) {
for (final ProcessGroupStatus childProcessGroupStatus : childProcessGroupStatusCollection) {
final ProcessGroupStatusDTO childProcessGroupStatusDto = createProcessGroupStatusDto(processGroup, childProcessGroupStatus);
final ProcessGroup childProcessGroup = processGroup.findProcessGroup(childProcessGroupStatusDto.getId());
final PermissionsDTO childProcessGroupPermissions = createPermissionsDto(childProcessGroup);
childProcessGroupStatusDtoCollection.add(entityFactory.createProcessGroupStatusSnapshotEntity(childProcessGroupStatusDto.getAggregateSnapshot(), childProcessGroupPermissions));
}
}
// remote child process groups
final Collection<RemoteProcessGroupStatusSnapshotEntity> childRemoteProcessGroupStatusDtoCollection = new ArrayList<>();
snapshot.setRemoteProcessGroupStatusSnapshots(childRemoteProcessGroupStatusDtoCollection);
final Collection<RemoteProcessGroupStatus> childRemoteProcessGroupStatusCollection = processGroupStatus.getRemoteProcessGroupStatus();
if (childRemoteProcessGroupStatusCollection != null) {
for (final RemoteProcessGroupStatus childRemoteProcessGroupStatus : childRemoteProcessGroupStatusCollection) {
final RemoteProcessGroupStatusDTO childRemoteProcessGroupStatusDto = createRemoteProcessGroupStatusDto(childRemoteProcessGroupStatus);
final RemoteProcessGroup remoteProcessGroup = processGroup.findRemoteProcessGroup(childRemoteProcessGroupStatusDto.getId());
final PermissionsDTO remoteProcessGroupPermissions = createPermissionsDto(remoteProcessGroup);
childRemoteProcessGroupStatusDtoCollection.add(entityFactory.createRemoteProcessGroupStatusSnapshotEntity(childRemoteProcessGroupStatusDto.getAggregateSnapshot(), remoteProcessGroupPermissions));
}
}
// input ports
final Collection<PortStatusSnapshotEntity> inputPortStatusDtoCollection = new ArrayList<>();
snapshot.setInputPortStatusSnapshots(inputPortStatusDtoCollection);
final Collection<PortStatus> inputPortStatusCollection = processGroupStatus.getInputPortStatus();
if (inputPortStatusCollection != null) {
for (final PortStatus portStatus : inputPortStatusCollection) {
final PortStatusDTO portStatusDto = createPortStatusDto(portStatus);
final Port inputPort = processGroup.findInputPort(portStatus.getId());
final PermissionsDTO inputPortPermissions = createPermissionsDto(inputPort);
inputPortStatusDtoCollection.add(entityFactory.createPortStatusSnapshotEntity(portStatusDto.getAggregateSnapshot(), inputPortPermissions));
}
}
// output ports
final Collection<PortStatusSnapshotEntity> outputPortStatusDtoCollection = new ArrayList<>();
snapshot.setOutputPortStatusSnapshots(outputPortStatusDtoCollection);
final Collection<PortStatus> outputPortStatusCollection = processGroupStatus.getOutputPortStatus();
if (outputPortStatusCollection != null) {
for (final PortStatus portStatus : outputPortStatusCollection) {
final PortStatusDTO portStatusDto = createPortStatusDto(portStatus);
final Port outputPort = processGroup.findOutputPort(portStatus.getId());
final PermissionsDTO outputPortPermissions = createPermissionsDto(outputPort);
outputPortStatusDtoCollection.add(entityFactory.createPortStatusSnapshotEntity(portStatusDto.getAggregateSnapshot(), outputPortPermissions));
}
}
return processGroupStatusDto;
}
Aggregations