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);
}
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);
}
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;
}
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());
}
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);
}
Aggregations