use of org.apache.nifi.controller.status.RemoteProcessGroupStatus in project nifi by apache.
the class DtoFactory method createFlowDto.
public FlowDTO createFlowDto(final ProcessGroup group, final ProcessGroupStatus groupStatus, final FlowSnippetDTO snippet, final RevisionManager revisionManager, final Function<ProcessGroup, List<BulletinEntity>> getProcessGroupBulletins) {
if (snippet == null) {
return null;
}
final FlowDTO flow = new FlowDTO();
for (final ConnectionDTO snippetConnection : snippet.getConnections()) {
final Connection connection = group.getConnection(snippetConnection.getId());
// marshal the actual connection as the snippet is pruned
final ConnectionDTO dto = createConnectionDto(connection);
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(connection.getIdentifier()));
final PermissionsDTO accessPolicy = createPermissionsDto(connection);
final ConnectionStatusDTO status = getComponentStatus(() -> groupStatus.getConnectionStatus().stream().filter(connectionStatus -> connection.getIdentifier().equals(connectionStatus.getId())).findFirst().orElse(null), connectionStatus -> createConnectionStatusDto(connectionStatus));
flow.getConnections().add(entityFactory.createConnectionEntity(dto, revision, accessPolicy, status));
}
for (final FunnelDTO snippetFunnel : snippet.getFunnels()) {
final Funnel funnel = group.getFunnel(snippetFunnel.getId());
// marshal the actual funnel as the snippet is pruned
final FunnelDTO dto = createFunnelDto(funnel);
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(funnel.getIdentifier()));
final PermissionsDTO accessPolicy = createPermissionsDto(funnel);
flow.getFunnels().add(entityFactory.createFunnelEntity(dto, revision, accessPolicy));
}
for (final PortDTO snippetInputPort : snippet.getInputPorts()) {
final Port inputPort = group.getInputPort(snippetInputPort.getId());
// marshal the actual port as the snippet is pruned
final PortDTO dto = createPortDto(inputPort);
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(inputPort.getIdentifier()));
final PermissionsDTO permissions = createPermissionsDto(inputPort);
final PortStatusDTO status = getComponentStatus(() -> groupStatus.getInputPortStatus().stream().filter(inputPortStatus -> inputPort.getIdentifier().equals(inputPortStatus.getId())).findFirst().orElse(null), inputPortStatus -> createPortStatusDto(inputPortStatus));
final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(inputPort.getIdentifier()));
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
flow.getInputPorts().add(entityFactory.createPortEntity(dto, revision, permissions, status, bulletinEntities));
}
for (final PortDTO snippetOutputPort : snippet.getOutputPorts()) {
final Port outputPort = group.getOutputPort(snippetOutputPort.getId());
// marshal the actual port as the snippet is pruned
final PortDTO dto = createPortDto(outputPort);
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(outputPort.getIdentifier()));
final PermissionsDTO permissions = createPermissionsDto(outputPort);
final PortStatusDTO status = getComponentStatus(() -> groupStatus.getOutputPortStatus().stream().filter(outputPortStatus -> outputPort.getIdentifier().equals(outputPortStatus.getId())).findFirst().orElse(null), outputPortStatus -> createPortStatusDto(outputPortStatus));
final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(outputPort.getIdentifier()));
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
flow.getOutputPorts().add(entityFactory.createPortEntity(dto, revision, permissions, status, bulletinEntities));
}
for (final LabelDTO snippetLabel : snippet.getLabels()) {
final Label label = group.getLabel(snippetLabel.getId());
// marshal the actual label as the snippet is pruned
final LabelDTO dto = createLabelDto(label);
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(label.getIdentifier()));
final PermissionsDTO accessPolicy = createPermissionsDto(label);
flow.getLabels().add(entityFactory.createLabelEntity(dto, revision, accessPolicy));
}
for (final ProcessGroupDTO snippetProcessGroup : snippet.getProcessGroups()) {
final ProcessGroup processGroup = group.getProcessGroup(snippetProcessGroup.getId());
// marshal the actual group as the snippet is pruned
final ProcessGroupDTO dto = createProcessGroupDto(processGroup);
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(processGroup.getIdentifier()));
final PermissionsDTO permissions = createPermissionsDto(processGroup);
final ProcessGroupStatusDTO status = getComponentStatus(() -> groupStatus.getProcessGroupStatus().stream().filter(processGroupStatus -> processGroup.getIdentifier().equals(processGroupStatus.getId())).findFirst().orElse(null), processGroupStatus -> createConciseProcessGroupStatusDto(processGroupStatus));
final List<BulletinEntity> bulletins = getProcessGroupBulletins.apply(processGroup);
flow.getProcessGroups().add(entityFactory.createProcessGroupEntity(dto, revision, permissions, status, bulletins));
}
for (final ProcessorDTO snippetProcessor : snippet.getProcessors()) {
final ProcessorNode processor = group.getProcessor(snippetProcessor.getId());
// marshal the actual processor as the snippet is pruned
final ProcessorDTO dto = createProcessorDto(processor);
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(processor.getIdentifier()));
final PermissionsDTO permissions = createPermissionsDto(processor);
final ProcessorStatusDTO status = getComponentStatus(() -> groupStatus.getProcessorStatus().stream().filter(processorStatus -> processor.getIdentifier().equals(processorStatus.getId())).findFirst().orElse(null), processorStatus -> createProcessorStatusDto(processorStatus));
final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(processor.getIdentifier()));
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
flow.getProcessors().add(entityFactory.createProcessorEntity(dto, revision, permissions, status, bulletinEntities));
}
for (final RemoteProcessGroupDTO snippetRemoteProcessGroup : snippet.getRemoteProcessGroups()) {
final RemoteProcessGroup remoteProcessGroup = group.getRemoteProcessGroup(snippetRemoteProcessGroup.getId());
// marshal the actual rpm as the snippet is pruned
final RemoteProcessGroupDTO dto = createRemoteProcessGroupDto(remoteProcessGroup);
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(remoteProcessGroup.getIdentifier()));
final PermissionsDTO permissions = createPermissionsDto(remoteProcessGroup);
final RemoteProcessGroupStatusDTO status = getComponentStatus(() -> groupStatus.getRemoteProcessGroupStatus().stream().filter(rpgStatus -> remoteProcessGroup.getIdentifier().equals(rpgStatus.getId())).findFirst().orElse(null), remoteProcessGroupStatus -> createRemoteProcessGroupStatusDto(remoteProcessGroupStatus));
final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(remoteProcessGroup.getIdentifier()));
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
flow.getRemoteProcessGroups().add(entityFactory.createRemoteProcessGroupEntity(dto, revision, permissions, status, bulletinEntities));
}
return flow;
}
use of org.apache.nifi.controller.status.RemoteProcessGroupStatus in project nifi by apache.
the class DtoFactory method createFlowDto.
public FlowDTO createFlowDto(final ProcessGroup group, final ProcessGroupStatus groupStatus, final RevisionManager revisionManager, final Function<ProcessGroup, List<BulletinEntity>> getProcessGroupBulletins) {
final FlowDTO dto = new FlowDTO();
for (final ProcessorNode procNode : group.getProcessors()) {
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(procNode.getIdentifier()));
final PermissionsDTO permissions = createPermissionsDto(procNode);
final ProcessorStatusDTO status = getComponentStatus(() -> groupStatus.getProcessorStatus().stream().filter(processorStatus -> procNode.getIdentifier().equals(processorStatus.getId())).findFirst().orElse(null), processorStatus -> createProcessorStatusDto(processorStatus));
final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(procNode.getIdentifier()));
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
dto.getProcessors().add(entityFactory.createProcessorEntity(createProcessorDto(procNode), revision, permissions, status, bulletinEntities));
}
for (final Connection connNode : group.getConnections()) {
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(connNode.getIdentifier()));
final PermissionsDTO permissions = createPermissionsDto(connNode);
final ConnectionStatusDTO status = getComponentStatus(() -> groupStatus.getConnectionStatus().stream().filter(connectionStatus -> connNode.getIdentifier().equals(connectionStatus.getId())).findFirst().orElse(null), connectionStatus -> createConnectionStatusDto(connectionStatus));
dto.getConnections().add(entityFactory.createConnectionEntity(createConnectionDto(connNode), revision, permissions, status));
}
for (final Label label : group.getLabels()) {
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(label.getIdentifier()));
final PermissionsDTO permissions = createPermissionsDto(label);
dto.getLabels().add(entityFactory.createLabelEntity(createLabelDto(label), revision, permissions));
}
for (final Funnel funnel : group.getFunnels()) {
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(funnel.getIdentifier()));
final PermissionsDTO permissions = createPermissionsDto(funnel);
dto.getFunnels().add(entityFactory.createFunnelEntity(createFunnelDto(funnel), revision, permissions));
}
for (final ProcessGroup childGroup : group.getProcessGroups()) {
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(childGroup.getIdentifier()));
final PermissionsDTO permissions = createPermissionsDto(childGroup);
final ProcessGroupStatusDTO status = getComponentStatus(() -> groupStatus.getProcessGroupStatus().stream().filter(processGroupStatus -> childGroup.getIdentifier().equals(processGroupStatus.getId())).findFirst().orElse(null), processGroupStatus -> createConciseProcessGroupStatusDto(processGroupStatus));
final List<BulletinEntity> bulletins = getProcessGroupBulletins.apply(childGroup);
dto.getProcessGroups().add(entityFactory.createProcessGroupEntity(createProcessGroupDto(childGroup), revision, permissions, status, bulletins));
}
for (final RemoteProcessGroup rpg : group.getRemoteProcessGroups()) {
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(rpg.getIdentifier()));
final PermissionsDTO permissions = createPermissionsDto(rpg);
final RemoteProcessGroupStatusDTO status = getComponentStatus(() -> groupStatus.getRemoteProcessGroupStatus().stream().filter(remoteProcessGroupStatus -> rpg.getIdentifier().equals(remoteProcessGroupStatus.getId())).findFirst().orElse(null), remoteProcessGroupStatus -> createRemoteProcessGroupStatusDto(remoteProcessGroupStatus));
final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(rpg.getIdentifier()));
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
dto.getRemoteProcessGroups().add(entityFactory.createRemoteProcessGroupEntity(createRemoteProcessGroupDto(rpg), revision, permissions, status, bulletinEntities));
}
for (final Port inputPort : group.getInputPorts()) {
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(inputPort.getIdentifier()));
final PermissionsDTO permissions = createPermissionsDto(inputPort);
final PortStatusDTO status = getComponentStatus(() -> groupStatus.getInputPortStatus().stream().filter(inputPortStatus -> inputPort.getIdentifier().equals(inputPortStatus.getId())).findFirst().orElse(null), inputPortStatus -> createPortStatusDto(inputPortStatus));
final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(inputPort.getIdentifier()));
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
dto.getInputPorts().add(entityFactory.createPortEntity(createPortDto(inputPort), revision, permissions, status, bulletinEntities));
}
for (final Port outputPort : group.getOutputPorts()) {
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(outputPort.getIdentifier()));
final PermissionsDTO permissions = createPermissionsDto(outputPort);
final PortStatusDTO status = getComponentStatus(() -> groupStatus.getOutputPortStatus().stream().filter(outputPortStatus -> outputPort.getIdentifier().equals(outputPortStatus.getId())).findFirst().orElse(null), outputPortStatus -> createPortStatusDto(outputPortStatus));
final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(outputPort.getIdentifier()));
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
dto.getOutputPorts().add(entityFactory.createPortEntity(createPortDto(outputPort), revision, permissions, status, bulletinEntities));
}
return dto;
}
use of org.apache.nifi.controller.status.RemoteProcessGroupStatus in project nifi by apache.
the class ControllerFacade method getRemoteProcessGroupStatus.
/**
* Gets the status for the specified remote process group.
*
* @param remoteProcessGroupId remote process group id
* @return the status for the specified remote process group
*/
public RemoteProcessGroupStatus getRemoteProcessGroupStatus(final String remoteProcessGroupId) {
final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId());
final RemoteProcessGroup remoteProcessGroup = root.findRemoteProcessGroup(remoteProcessGroupId);
// ensure the output port was found
if (remoteProcessGroup == null) {
throw new ResourceNotFoundException(String.format("Unable to locate remote process group with id '%s'.", remoteProcessGroupId));
}
final String groupId = remoteProcessGroup.getProcessGroup().getIdentifier();
final ProcessGroupStatus groupStatus = flowController.getGroupStatus(groupId, NiFiUserUtils.getNiFiUser());
if (groupStatus == null) {
throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId));
}
final RemoteProcessGroupStatus status = groupStatus.getRemoteProcessGroupStatus().stream().filter(rpgStatus -> remoteProcessGroupId.equals(rpgStatus.getId())).findFirst().orElse(null);
if (status == null) {
throw new ResourceNotFoundException(String.format("Unable to locate remote process group with id '%s'.", remoteProcessGroupId));
}
return status;
}
use of org.apache.nifi.controller.status.RemoteProcessGroupStatus in project nifi by apache.
the class SiteToSiteStatusReportingTask method serializeProcessGroupStatus.
/**
* Serialize the ProcessGroupStatus and add it to the JsonArrayBuilder.
* @param arrayBuilder
* The JSON Array builder
* @param factory
* The JSON Builder Factory
* @param status
* The ProcessGroupStatus
* @param df
* A date format
* @param hostname
* The current hostname
* @param applicationName
* The root process group name
* @param platform
* The configured platform
* @param parentId
* The parent's component id
*/
void serializeProcessGroupStatus(final JsonArrayBuilder arrayBuilder, final JsonBuilderFactory factory, final ProcessGroupStatus status, final DateFormat df, final String hostname, final String applicationName, final String platform, final String parentId, final Date currentDate) {
final JsonObjectBuilder builder = factory.createObjectBuilder();
final String componentType = (parentId == null) ? "RootProcessGroup" : "ProcessGroup";
final String componentName = status.getName();
if (componentMatchesFilters(componentType, componentName)) {
addCommonFields(builder, df, hostname, applicationName, platform, parentId, currentDate, componentType, componentName);
addField(builder, "componentId", status.getId());
addField(builder, "bytesRead", status.getBytesRead());
addField(builder, "bytesWritten", status.getBytesWritten());
addField(builder, "bytesReceived", status.getBytesReceived());
addField(builder, "bytesSent", status.getBytesSent());
addField(builder, "bytesTransferred", status.getBytesTransferred());
addField(builder, "flowFilesReceived", status.getFlowFilesReceived());
addField(builder, "flowFilesSent", status.getFlowFilesSent());
addField(builder, "flowFilesTransferred", status.getFlowFilesTransferred());
addField(builder, "inputContentSize", status.getInputContentSize());
addField(builder, "inputCount", status.getInputCount());
addField(builder, "outputContentSize", status.getOutputContentSize());
addField(builder, "outputCount", status.getOutputCount());
addField(builder, "queuedContentSize", status.getQueuedContentSize());
addField(builder, "activeThreadCount", status.getActiveThreadCount());
addField(builder, "queuedCount", status.getQueuedCount());
arrayBuilder.add(builder.build());
}
for (ProcessGroupStatus childGroupStatus : status.getProcessGroupStatus()) {
serializeProcessGroupStatus(arrayBuilder, factory, childGroupStatus, df, hostname, applicationName, platform, status.getId(), currentDate);
}
for (ProcessorStatus processorStatus : status.getProcessorStatus()) {
serializeProcessorStatus(arrayBuilder, factory, processorStatus, df, hostname, applicationName, platform, status.getId(), currentDate);
}
for (ConnectionStatus connectionStatus : status.getConnectionStatus()) {
serializeConnectionStatus(arrayBuilder, factory, connectionStatus, df, hostname, applicationName, platform, status.getId(), currentDate);
}
for (PortStatus portStatus : status.getInputPortStatus()) {
serializePortStatus("InputPort", arrayBuilder, factory, portStatus, df, hostname, applicationName, platform, status.getId(), currentDate);
}
for (PortStatus portStatus : status.getOutputPortStatus()) {
serializePortStatus("OutputPort", arrayBuilder, factory, portStatus, df, hostname, applicationName, platform, status.getId(), currentDate);
}
for (RemoteProcessGroupStatus remoteProcessGroupStatus : status.getRemoteProcessGroupStatus()) {
serializeRemoteProcessGroupStatus(arrayBuilder, factory, remoteProcessGroupStatus, df, hostname, applicationName, platform, status.getId(), currentDate);
}
}
use of org.apache.nifi.controller.status.RemoteProcessGroupStatus in project nifi by apache.
the class TestSiteToSiteStatusReportingTask method generateProcessGroupStatus.
public static ProcessGroupStatus generateProcessGroupStatus(String id, String namePrefix, int maxRecursion, int currentDepth) {
Collection<ConnectionStatus> cStatus = new ArrayList<>();
Collection<PortStatus> ipStatus = new ArrayList<>();
Collection<PortStatus> opStatus = new ArrayList<>();
Collection<ProcessorStatus> pStatus = new ArrayList<>();
Collection<RemoteProcessGroupStatus> rpgStatus = new ArrayList<>();
Collection<ProcessGroupStatus> childPgStatus = new ArrayList<>();
if (currentDepth < maxRecursion) {
for (int i = 1; i < 4; i++) {
childPgStatus.add(generateProcessGroupStatus(id + "." + i, namePrefix + "." + i, maxRecursion, currentDepth + 1));
}
}
for (int i = 1; i < 4; i++) {
pStatus.add(generateProcessorStatus(id + ".processor." + i, namePrefix + ".processor." + i));
}
for (int i = 1; i < 4; i++) {
cStatus.add(generateConnectionStatus(id + ".connection." + i, namePrefix + ".connection." + i));
}
for (int i = 1; i < 4; i++) {
rpgStatus.add(generateRemoteProcessGroupStatus(id + ".rpg." + i, namePrefix + ".rpg." + i));
}
for (int i = 1; i < 4; i++) {
ipStatus.add(generatePortStatus(id + ".ip." + i, namePrefix + ".ip." + i));
}
for (int i = 1; i < 4; i++) {
opStatus.add(generatePortStatus(id + ".op." + i, namePrefix + ".op." + i));
}
ProcessGroupStatus pgStatus = new ProcessGroupStatus();
pgStatus.setId(id);
pgStatus.setName(namePrefix + "-" + UUID.randomUUID().toString());
pgStatus.setInputPortStatus(ipStatus);
pgStatus.setOutputPortStatus(opStatus);
pgStatus.setProcessGroupStatus(childPgStatus);
pgStatus.setRemoteProcessGroupStatus(rpgStatus);
pgStatus.setProcessorStatus(pStatus);
pgStatus.setActiveThreadCount(1);
pgStatus.setBytesRead(2L);
pgStatus.setBytesReceived(3l);
pgStatus.setBytesSent(4l);
pgStatus.setBytesTransferred(5l);
pgStatus.setBytesWritten(6l);
pgStatus.setConnectionStatus(cStatus);
pgStatus.setFlowFilesReceived(7);
pgStatus.setFlowFilesSent(8);
pgStatus.setFlowFilesTransferred(9);
pgStatus.setInputContentSize(10l);
pgStatus.setInputCount(11);
pgStatus.setOutputContentSize(12l);
pgStatus.setOutputCount(13);
pgStatus.setQueuedContentSize(14l);
pgStatus.setQueuedCount(15);
return pgStatus;
}
Aggregations