Search in sources :

Example 26 with ProcessorStatus

use of org.apache.nifi.controller.status.ProcessorStatus in project nifi by apache.

the class TestMetricsService method testGetProcessGroupStatusMetricsWithID.

@Test
public void testGetProcessGroupStatusMetricsWithID() {
    ProcessGroupStatus status = new ProcessGroupStatus();
    String id = "1234";
    status.setId(id);
    status.setFlowFilesReceived(5);
    status.setBytesReceived(10000);
    status.setFlowFilesSent(10);
    status.setBytesSent(20000);
    status.setQueuedCount(100);
    status.setQueuedContentSize(1024L);
    status.setBytesRead(60000L);
    status.setBytesWritten(80000L);
    status.setActiveThreadCount(5);
    // create a processor status with processing time
    ProcessorStatus procStatus = new ProcessorStatus();
    procStatus.setProcessingNanos(123456789);
    Collection<ProcessorStatus> processorStatuses = new ArrayList<>();
    processorStatuses.add(procStatus);
    status.setProcessorStatus(processorStatuses);
    // create a group status with processing time
    ProcessGroupStatus groupStatus = new ProcessGroupStatus();
    groupStatus.setProcessorStatus(processorStatuses);
    Collection<ProcessGroupStatus> groupStatuses = new ArrayList<>();
    groupStatuses.add(groupStatus);
    status.setProcessGroupStatus(groupStatuses);
    final MetricsService service = new MetricsService();
    final Map<String, String> metrics = service.getMetrics(status, true);
    Assert.assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_RECEIVED + MetricNames.METRIC_NAME_SEPARATOR + id));
}
Also used : ProcessGroupStatus(org.apache.nifi.controller.status.ProcessGroupStatus) ArrayList(java.util.ArrayList) ProcessorStatus(org.apache.nifi.controller.status.ProcessorStatus) Test(org.junit.Test)

Example 27 with ProcessorStatus

use of org.apache.nifi.controller.status.ProcessorStatus in project nifi by apache.

the class TestMetricsService method testGetProcessGroupStatusMetrics.

@Test
public void testGetProcessGroupStatusMetrics() {
    ProcessGroupStatus status = new ProcessGroupStatus();
    status.setId("1234");
    status.setFlowFilesReceived(5);
    status.setBytesReceived(10000);
    status.setFlowFilesSent(10);
    status.setBytesSent(20000);
    status.setQueuedCount(100);
    status.setQueuedContentSize(1024L);
    status.setBytesRead(60000L);
    status.setBytesWritten(80000L);
    status.setActiveThreadCount(5);
    // create a processor status with processing time
    ProcessorStatus procStatus = new ProcessorStatus();
    procStatus.setProcessingNanos(123456789);
    Collection<ProcessorStatus> processorStatuses = new ArrayList<>();
    processorStatuses.add(procStatus);
    status.setProcessorStatus(processorStatuses);
    // create a group status with processing time
    ProcessGroupStatus groupStatus = new ProcessGroupStatus();
    groupStatus.setProcessorStatus(processorStatuses);
    Collection<ProcessGroupStatus> groupStatuses = new ArrayList<>();
    groupStatuses.add(groupStatus);
    status.setProcessGroupStatus(groupStatuses);
    final MetricsService service = new MetricsService();
    final Map<String, String> metrics = service.getMetrics(status, false);
    Assert.assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_RECEIVED));
    Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_RECEIVED));
    Assert.assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_SENT));
    Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_SENT));
    Assert.assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_QUEUED));
    Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_QUEUED));
    Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_READ));
    Assert.assertTrue(metrics.containsKey(MetricNames.BYTES_WRITTEN));
    Assert.assertTrue(metrics.containsKey(MetricNames.ACTIVE_THREADS));
    Assert.assertTrue(metrics.containsKey(MetricNames.TOTAL_TASK_DURATION_SECONDS));
    Assert.assertTrue(metrics.containsKey(MetricNames.TOTAL_TASK_DURATION_NANOS));
}
Also used : ProcessGroupStatus(org.apache.nifi.controller.status.ProcessGroupStatus) ArrayList(java.util.ArrayList) ProcessorStatus(org.apache.nifi.controller.status.ProcessorStatus) Test(org.junit.Test)

Example 28 with ProcessorStatus

use of org.apache.nifi.controller.status.ProcessorStatus in project nifi by apache.

the class TestNiFiFlowAnalyzer method connect.

private void connect(ProcessGroupStatus pg0, Object o0, Object o1) {
    Function<Object, Tuple<String, String>> toTupple = o -> {
        Tuple<String, String> comp;
        if (o instanceof ProcessorStatus) {
            ProcessorStatus p = (ProcessorStatus) o;
            comp = new Tuple<>(p.getId(), p.getName());
        } else if (o instanceof PortStatus) {
            PortStatus p = (PortStatus) o;
            comp = new Tuple<>(p.getId(), p.getName());
        } else {
            throw new IllegalArgumentException("Not supported");
        }
        return comp;
    };
    connect(pg0, toTupple.apply(o0), toTupple.apply(o1));
}
Also used : ProcessGroupStatus(org.apache.nifi.controller.status.ProcessGroupStatus) AtlasUtils.toQualifiedName(org.apache.nifi.atlas.AtlasUtils.toQualifiedName) Test(org.junit.Test) Function(java.util.function.Function) ATTR_QUALIFIED_NAME(org.apache.nifi.atlas.NiFiTypes.ATTR_QUALIFIED_NAME) PortStatus(org.apache.nifi.controller.status.PortStatus) Tuple(org.apache.nifi.util.Tuple) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId) Map(java.util.Map) TYPE_NIFI_QUEUE(org.apache.nifi.atlas.NiFiTypes.TYPE_NIFI_QUEUE) ITReportLineageToAtlas(org.apache.nifi.atlas.reporting.ITReportLineageToAtlas) ConnectionStatus(org.apache.nifi.controller.status.ConnectionStatus) ProcessorStatus(org.apache.nifi.controller.status.ProcessorStatus) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) PortStatus(org.apache.nifi.controller.status.PortStatus) ProcessorStatus(org.apache.nifi.controller.status.ProcessorStatus) Tuple(org.apache.nifi.util.Tuple)

Example 29 with ProcessorStatus

use of org.apache.nifi.controller.status.ProcessorStatus in project nifi by apache.

the class TestNiFiFlowAnalyzer method createProcessor.

private ProcessorStatus createProcessor(ProcessGroupStatus pgStatus, String type) {
    final ProcessorStatus processor = new ProcessorStatus();
    processor.setName(type);
    processor.setId(nextComponentId());
    processor.setGroupId(pgStatus.getId());
    pgStatus.getProcessorStatus().add(processor);
    return processor;
}
Also used : ProcessorStatus(org.apache.nifi.controller.status.ProcessorStatus)

Example 30 with ProcessorStatus

use of org.apache.nifi.controller.status.ProcessorStatus 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;
}
Also used : InstantiatedVersionedRemoteGroupPort(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedRemoteGroupPort) RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) RootGroupPort(org.apache.nifi.remote.RootGroupPort) Port(org.apache.nifi.connectable.Port) InstantiatedVersionedPort(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedPort) ArrayList(java.util.ArrayList) PortStatusDTO(org.apache.nifi.web.api.dto.status.PortStatusDTO) RemoteProcessGroupStatusSnapshotEntity(org.apache.nifi.web.api.entity.RemoteProcessGroupStatusSnapshotEntity) ProcessGroupStatusSnapshotEntity(org.apache.nifi.web.api.entity.ProcessGroupStatusSnapshotEntity) PortStatusSnapshotEntity(org.apache.nifi.web.api.entity.PortStatusSnapshotEntity) ConnectionStatusSnapshotEntity(org.apache.nifi.web.api.entity.ConnectionStatusSnapshotEntity) ProcessorStatusDTO(org.apache.nifi.web.api.dto.status.ProcessorStatusDTO) ProcessorNode(org.apache.nifi.controller.ProcessorNode) PortStatus(org.apache.nifi.controller.status.PortStatus) ConnectionStatus(org.apache.nifi.controller.status.ConnectionStatus) NodeConnectionStatus(org.apache.nifi.cluster.coordination.node.NodeConnectionStatus) RemoteProcessGroupStatusDTO(org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO) ProcessGroupStatus(org.apache.nifi.controller.status.ProcessGroupStatus) RemoteProcessGroupStatus(org.apache.nifi.controller.status.RemoteProcessGroupStatus) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) InstantiatedVersionedRemoteProcessGroup(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedRemoteProcessGroup) ProcessGroupStatusDTO(org.apache.nifi.web.api.dto.status.ProcessGroupStatusDTO) RemoteProcessGroupStatusDTO(org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO) Connection(org.apache.nifi.connectable.Connection) InstantiatedVersionedConnection(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedConnection) RemoteProcessGroupStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusSnapshotDTO) ProcessGroupStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.ProcessGroupStatusSnapshotDTO) RemoteProcessGroupStatus(org.apache.nifi.controller.status.RemoteProcessGroupStatus) ProcessorStatus(org.apache.nifi.controller.status.ProcessorStatus) ProcessorStatusSnapshotEntity(org.apache.nifi.web.api.entity.ProcessorStatusSnapshotEntity) ConnectionStatusDTO(org.apache.nifi.web.api.dto.status.ConnectionStatusDTO) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup) InstantiatedVersionedProcessGroup(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedProcessGroup) InstantiatedVersionedRemoteProcessGroup(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedRemoteProcessGroup) RemoteProcessGroupStatusSnapshotEntity(org.apache.nifi.web.api.entity.RemoteProcessGroupStatusSnapshotEntity)

Aggregations

ProcessorStatus (org.apache.nifi.controller.status.ProcessorStatus)31 ProcessGroupStatus (org.apache.nifi.controller.status.ProcessGroupStatus)21 ArrayList (java.util.ArrayList)18 ConnectionStatus (org.apache.nifi.controller.status.ConnectionStatus)12 PortStatus (org.apache.nifi.controller.status.PortStatus)9 RemoteProcessGroupStatus (org.apache.nifi.controller.status.RemoteProcessGroupStatus)9 Test (org.junit.Test)9 List (java.util.List)6 Map (java.util.Map)6 ProcessorNode (org.apache.nifi.controller.ProcessorNode)6 ProcessGroup (org.apache.nifi.groups.ProcessGroup)6 RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)6 HashMap (java.util.HashMap)5 Set (java.util.Set)5 ValidationResult (org.apache.nifi.components.ValidationResult)5 Collection (java.util.Collection)4 Collections (java.util.Collections)4 Date (java.util.Date)4 LinkedHashMap (java.util.LinkedHashMap)4 LinkedHashSet (java.util.LinkedHashSet)4