Search in sources :

Example 36 with ProcessGroupDTO

use of org.apache.nifi.web.api.dto.ProcessGroupDTO in project kylo by Teradata.

the class TemplateInstanceCreator method ensureInputPortsForReuseableTemplate.

private void ensureInputPortsForReuseableTemplate(String processGroupId) {
    ProcessGroupDTO template = restClient.getProcessGroup(processGroupId, false, false);
    String categoryId = template.getParentGroupId();
    restClient.createReusableTemplateInputPort(categoryId, processGroupId);
}
Also used : ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO)

Example 37 with ProcessGroupDTO

use of org.apache.nifi.web.api.dto.ProcessGroupDTO in project kylo by Teradata.

the class NifiConnectionOrderVisitor method visitProcessGroup.

@Override
public void visitProcessGroup(NifiVisitableProcessGroup processGroup) {
    log.debug(" Visit Process Group: {}, ({}) ", processGroup.getDto().getName(), processGroup.getDto().getId());
    NifiVisitableProcessGroup group = visitedProcessGroups.get(processGroup.getDto().getId());
    if (group == null) {
        group = processGroup;
    }
    this.currentProcessGroup = group;
    if (processGroup.getParentProcessGroup() == null) {
        try {
            ProcessGroupDTO parent = fetchProcessGroupForNameAndIdentifier(processGroup.getDto().getParentGroupId());
            if (parent != null) {
                group.setParentProcessGroup(parent);
            }
        } catch (NifiComponentNotFoundException e) {
        // cant find the parent
        }
    }
    group.accept(this);
    this.visitedProcessGroups.put(group.getDto().getId(), group);
}
Also used : NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException) NifiVisitableProcessGroup(com.thinkbiganalytics.nifi.rest.model.visitor.NifiVisitableProcessGroup) RemoteProcessGroupDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupDTO) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO)

Example 38 with ProcessGroupDTO

use of org.apache.nifi.web.api.dto.ProcessGroupDTO in project kylo by Teradata.

the class NifiConnectionOrderVisitor method getGroup.

private ProcessGroupDTO getGroup(String processGroupId) {
    ProcessGroupDTO group = null;
    if (cache.getProcessGroup(processGroupId).isPresent()) {
        group = cache.getProcessGroup(processGroupId).get();
    } else {
        group = getRestClient().processGroups().findById(processGroupId, true, true).orElse(null);
        if (group != null) {
            cache.add(group);
            NifiProcessUtil.getProcessGroups(group).stream().forEach(processGroupDTO -> cache.add(processGroupDTO));
        }
    }
    return group;
}
Also used : RemoteProcessGroupDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupDTO) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO)

Example 39 with ProcessGroupDTO

use of org.apache.nifi.web.api.dto.ProcessGroupDTO in project kylo by Teradata.

the class AbstractNiFiProcessGroupsRestClientTest method findByName.

/**
 * Verify finding a process group by name.
 */
@Test
public void findByName() {
    // Mock process groups
    final ProcessGroupDTO group1 = new ProcessGroupDTO();
    group1.setId("b179527b-0a7a-4ba8-9817-60f7a9ffb9d5");
    group1.setName("group1");
    final ProcessGroupDTO group2 = new ProcessGroupDTO();
    group2.setId("7ba659c2-6ddd-4215-8709-1eafff04851d");
    group2.setName("group2");
    final ProcessGroupDTO group3 = new ProcessGroupDTO();
    group3.setId("2dbcc8ce-a0e7-455c-9e3d-f4f82d08acc3");
    group3.setName("group3");
    final ProcessGroupDTO fullGroup2 = new ProcessGroupDTO();
    fullGroup2.setId("7ba659c2-6ddd-4215-8709-1eafff04851d");
    fullGroup2.setName("group2");
    fullGroup2.setRunningCount(8);
    fullGroup2.setStoppedCount(0);
    // Mock NiFi Process Groups REST client
    final NiFiProcessGroupsRestClient client = Mockito.mock(AbstractNiFiProcessGroupsRestClient.class, Mockito.CALLS_REAL_METHODS);
    Mockito.when(client.findAll("parent")).thenReturn(ImmutableSet.of(group1, group2, group3));
    Mockito.when(client.findById(group2.getId(), true, true)).thenReturn(Optional.of(fullGroup2));
    // Test finding process group by name
    Assert.assertEquals(group2, client.findByName("parent", "group2", false, false).get());
    Assert.assertEquals(fullGroup2, client.findByName("parent", "group2", true, true).get());
    Assert.assertFalse(client.findByName("parent", "invalid", false, false).isPresent());
    Assert.assertFalse(client.findByName("parent", "invalid", true, true).isPresent());
}
Also used : ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO) Test(org.junit.Test)

Example 40 with ProcessGroupDTO

use of org.apache.nifi.web.api.dto.ProcessGroupDTO in project kylo by Teradata.

the class AbstractNiFiProcessGroupsRestClientTest method deleteWithTimeout.

/**
 * Verify failure to delete due to timeout error.
 */
@Test(expected = NifiClientRuntimeException.class)
public void deleteWithTimeout() {
    // Mock process group
    final ProcessGroupDTO group = new ProcessGroupDTO();
    group.setId("d526adec-1f33-463b-8570-e9cf3e6c8703");
    group.setParentGroupId("93b1abbb-f805-4f52-8a9e-ffdab224dc44");
    // Mock NiFi Process Groups REST client
    final AbstractNiFiProcessGroupsRestClient client = Mockito.mock(AbstractNiFiProcessGroupsRestClient.class, Mockito.CALLS_REAL_METHODS);
    Mockito.when(client.doDelete(group)).thenThrow(new ClientErrorException(409)).thenReturn(Optional.empty());
    // Test failure
    client.deleteWithRetries(group, 0, 0, TimeUnit.NANOSECONDS);
}
Also used : ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO) ClientErrorException(javax.ws.rs.ClientErrorException) Test(org.junit.Test)

Aggregations

ProcessGroupDTO (org.apache.nifi.web.api.dto.ProcessGroupDTO)102 RemoteProcessGroupDTO (org.apache.nifi.web.api.dto.RemoteProcessGroupDTO)43 ConnectionDTO (org.apache.nifi.web.api.dto.ConnectionDTO)34 ArrayList (java.util.ArrayList)32 ProcessorDTO (org.apache.nifi.web.api.dto.ProcessorDTO)30 PortDTO (org.apache.nifi.web.api.dto.PortDTO)29 HashSet (java.util.HashSet)28 HashMap (java.util.HashMap)21 ConnectableDTO (org.apache.nifi.web.api.dto.ConnectableDTO)20 FlowSnippetDTO (org.apache.nifi.web.api.dto.FlowSnippetDTO)19 List (java.util.List)18 Set (java.util.Set)18 Collectors (java.util.stream.Collectors)17 TemplateDTO (org.apache.nifi.web.api.dto.TemplateDTO)17 NifiComponentNotFoundException (com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException)16 Map (java.util.Map)15 Logger (org.slf4j.Logger)15 LoggerFactory (org.slf4j.LoggerFactory)15 NifiClientRuntimeException (com.thinkbiganalytics.nifi.rest.client.NifiClientRuntimeException)14 ProcessGroupEntity (org.apache.nifi.web.api.entity.ProcessGroupEntity)14