Search in sources :

Example 1 with RemoteProcessGroupStatusSnapshotDTO

use of org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusSnapshotDTO in project nifi by apache.

the class DtoFactory method createRemoteProcessGroupStatusDto.

public RemoteProcessGroupStatusDTO createRemoteProcessGroupStatusDto(final RemoteProcessGroupStatus remoteProcessGroupStatus) {
    final RemoteProcessGroupStatusDTO dto = new RemoteProcessGroupStatusDTO();
    dto.setId(remoteProcessGroupStatus.getId());
    dto.setGroupId(remoteProcessGroupStatus.getGroupId());
    dto.setTargetUri(remoteProcessGroupStatus.getTargetUri());
    dto.setName(remoteProcessGroupStatus.getName());
    dto.setTransmissionStatus(remoteProcessGroupStatus.getTransmissionStatus().toString());
    dto.setStatsLastRefreshed(new Date());
    final RemoteProcessGroupStatusSnapshotDTO snapshot = new RemoteProcessGroupStatusSnapshotDTO();
    dto.setAggregateSnapshot(snapshot);
    snapshot.setId(remoteProcessGroupStatus.getId());
    snapshot.setGroupId(remoteProcessGroupStatus.getGroupId());
    snapshot.setName(remoteProcessGroupStatus.getName());
    snapshot.setTargetUri(remoteProcessGroupStatus.getTargetUri());
    snapshot.setTransmissionStatus(remoteProcessGroupStatus.getTransmissionStatus().toString());
    snapshot.setActiveThreadCount(remoteProcessGroupStatus.getActiveThreadCount());
    snapshot.setFlowFilesSent(remoteProcessGroupStatus.getSentCount());
    snapshot.setBytesSent(remoteProcessGroupStatus.getSentContentSize());
    snapshot.setFlowFilesReceived(remoteProcessGroupStatus.getReceivedCount());
    snapshot.setBytesReceived(remoteProcessGroupStatus.getReceivedContentSize());
    StatusMerger.updatePrettyPrintedFields(snapshot);
    return dto;
}
Also used : RemoteProcessGroupStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusSnapshotDTO) RemoteProcessGroupStatusDTO(org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO) Date(java.util.Date)

Example 2 with RemoteProcessGroupStatusSnapshotDTO

use of org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusSnapshotDTO in project nifi by apache.

the class RemoteProcessGroupEntityMergerTest method testMergeRemoteProcessGroups.

@Test
public void testMergeRemoteProcessGroups() throws Exception {
    final NodeIdentifier node1 = new NodeIdentifier("node-1", "host-1", 8080, "host-1", 19998, null, null, null, false);
    final NodeIdentifier node2 = new NodeIdentifier("node-2", "host-2", 8081, "host-2", 19999, null, null, null, false);
    final PermissionsDTO permissed = new PermissionsDTO();
    permissed.setCanRead(true);
    permissed.setCanWrite(true);
    final RemoteProcessGroupStatusDTO status = new RemoteProcessGroupStatusDTO();
    status.setAggregateSnapshot(new RemoteProcessGroupStatusSnapshotDTO());
    final RemoteProcessGroupPortDTO in1_1 = new RemoteProcessGroupPortDTO();
    in1_1.setName("in1");
    final RemoteProcessGroupPortDTO in1_2 = new RemoteProcessGroupPortDTO();
    in1_2.setName("in2");
    final Set<RemoteProcessGroupPortDTO> inputs1 = new HashSet<>();
    inputs1.add(in1_1);
    inputs1.add(in1_2);
    final RemoteProcessGroupPortDTO out1_1 = new RemoteProcessGroupPortDTO();
    out1_1.setName("out1");
    final Set<RemoteProcessGroupPortDTO> outputs1 = new HashSet<>();
    outputs1.add(out1_1);
    final RemoteProcessGroupContentsDTO contents1 = new RemoteProcessGroupContentsDTO();
    contents1.setInputPorts(inputs1);
    contents1.setOutputPorts(outputs1);
    final RemoteProcessGroupDTO rpg1 = new RemoteProcessGroupDTO();
    rpg1.setContents(contents1);
    final RemoteProcessGroupEntity entity1 = new RemoteProcessGroupEntity();
    entity1.setPermissions(permissed);
    entity1.setStatus(status);
    entity1.setComponent(rpg1);
    final RemoteProcessGroupPortDTO in2_1 = new RemoteProcessGroupPortDTO();
    in2_1.setName("in1");
    final Set<RemoteProcessGroupPortDTO> inputs2 = new HashSet<>();
    inputs2.add(in2_1);
    final RemoteProcessGroupPortDTO out2_1 = new RemoteProcessGroupPortDTO();
    out2_1.setName("out1");
    final RemoteProcessGroupPortDTO out2_2 = new RemoteProcessGroupPortDTO();
    out2_2.setName("out2");
    final Set<RemoteProcessGroupPortDTO> outputs2 = new HashSet<>();
    outputs2.add(out2_1);
    outputs2.add(out2_2);
    final RemoteProcessGroupContentsDTO contents2 = new RemoteProcessGroupContentsDTO();
    contents2.setInputPorts(inputs2);
    contents2.setOutputPorts(outputs2);
    final RemoteProcessGroupDTO rpg2 = new RemoteProcessGroupDTO();
    rpg2.setContents(contents2);
    final RemoteProcessGroupEntity entity2 = new RemoteProcessGroupEntity();
    entity2.setPermissions(permissed);
    entity2.setStatus(status);
    entity2.setComponent(rpg2);
    final Map<NodeIdentifier, RemoteProcessGroupEntity> nodeMap = new HashMap<>();
    nodeMap.put(node1, entity1);
    nodeMap.put(node2, entity2);
    final RemoteProcessGroupEntityMerger merger = new RemoteProcessGroupEntityMerger();
    merger.merge(entity1, nodeMap);
    // should only include ports in common to all rpg's
    assertEquals(1, entity1.getComponent().getContents().getInputPorts().size());
    assertEquals("in1", entity1.getComponent().getContents().getInputPorts().iterator().next().getName());
    assertEquals(1, entity1.getComponent().getContents().getOutputPorts().size());
    assertEquals("out1", entity1.getComponent().getContents().getOutputPorts().iterator().next().getName());
}
Also used : HashMap(java.util.HashMap) PermissionsDTO(org.apache.nifi.web.api.dto.PermissionsDTO) RemoteProcessGroupContentsDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupContentsDTO) RemoteProcessGroupDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupDTO) RemoteProcessGroupPortDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO) RemoteProcessGroupEntity(org.apache.nifi.web.api.entity.RemoteProcessGroupEntity) NodeIdentifier(org.apache.nifi.cluster.protocol.NodeIdentifier) RemoteProcessGroupStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusSnapshotDTO) RemoteProcessGroupStatusDTO(org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

RemoteProcessGroupStatusDTO (org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO)2 RemoteProcessGroupStatusSnapshotDTO (org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusSnapshotDTO)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 NodeIdentifier (org.apache.nifi.cluster.protocol.NodeIdentifier)1 PermissionsDTO (org.apache.nifi.web.api.dto.PermissionsDTO)1 RemoteProcessGroupContentsDTO (org.apache.nifi.web.api.dto.RemoteProcessGroupContentsDTO)1 RemoteProcessGroupDTO (org.apache.nifi.web.api.dto.RemoteProcessGroupDTO)1 RemoteProcessGroupPortDTO (org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO)1 RemoteProcessGroupEntity (org.apache.nifi.web.api.entity.RemoteProcessGroupEntity)1 Test (org.junit.Test)1