use of org.apache.nifi.web.api.dto.status.ProcessGroupStatusDTO in project nifi by apache.
the class GroupStatusEndpointMerger method mergeResponses.
@Override
protected void mergeResponses(ProcessGroupStatusEntity clientEntity, Map<NodeIdentifier, ProcessGroupStatusEntity> entityMap, Set<NodeResponse> successfulResponses, Set<NodeResponse> problematicResponses) {
final ProcessGroupStatusDTO mergedProcessGroupStatus = clientEntity.getProcessGroupStatus();
mergedProcessGroupStatus.setNodeSnapshots(new ArrayList<>());
final NodeIdentifier selectedNodeId = entityMap.entrySet().stream().filter(e -> e.getValue() == clientEntity).map(e -> e.getKey()).findFirst().orElse(null);
final NodeProcessGroupStatusSnapshotDTO selectedNodeSnapshot = new NodeProcessGroupStatusSnapshotDTO();
selectedNodeSnapshot.setStatusSnapshot(mergedProcessGroupStatus.getAggregateSnapshot().clone());
selectedNodeSnapshot.setAddress(selectedNodeId.getApiAddress());
selectedNodeSnapshot.setApiPort(selectedNodeId.getApiPort());
selectedNodeSnapshot.setNodeId(selectedNodeId.getId());
mergedProcessGroupStatus.getNodeSnapshots().add(selectedNodeSnapshot);
for (final Map.Entry<NodeIdentifier, ProcessGroupStatusEntity> entry : entityMap.entrySet()) {
final NodeIdentifier nodeId = entry.getKey();
final ProcessGroupStatusEntity nodeProcessGroupStatusEntity = entry.getValue();
final ProcessGroupStatusDTO nodeProcessGroupStatus = nodeProcessGroupStatusEntity.getProcessGroupStatus();
if (nodeProcessGroupStatus == mergedProcessGroupStatus) {
continue;
}
mergeStatus(mergedProcessGroupStatus, clientEntity.getCanRead(), nodeProcessGroupStatus, nodeProcessGroupStatusEntity.getCanRead(), nodeId);
}
}
use of org.apache.nifi.web.api.dto.status.ProcessGroupStatusDTO in project kylo by Teradata.
the class ImportReusableTemplate method cleanup.
public void cleanup() {
if (newTemplateInstance != null) {
String templateName = importTemplate.getTemplateName();
VersionedProcessGroup versionedProcessGroup = newTemplateInstance.getVersionedProcessGroup();
if (versionedProcessGroup != null) {
// ensure we have contents in the versionedProcess group
if (versionedProcessGroup.getVersionedProcessGroup().getContents() == null) {
FlowDTO flowDTO = nifiRestClient.getNiFiRestClient().processGroups().flow(versionedProcessGroup.getVersionedProcessGroup().getId()).getFlow();
if (flowDTO != null) {
versionedProcessGroup.getVersionedProcessGroup().setContents(NifiFlowUtil.flowToFlowSnippet(flowDTO));
}
}
// importTemplate.getTemplateResults().getVersionedProcessGroup().getVersionedProcessGroup()
uploadProgressService.addUploadStatus(importTemplateOptions.getUploadKey(), "The Reusable template " + templateName + " is valid. Attempting to clean up and remove the previous instance ", true, true);
// if the versioned group doesnt have anything in queue delete it
Optional<ProcessGroupStatusDTO> status = nifiRestClient.getNiFiRestClient().processGroups().getStatus(versionedProcessGroup.getVersionedProcessGroup().getId());
if (!status.isPresent() || (status.isPresent() && status.get().getAggregateSnapshot().getFlowFilesQueued() > 0)) {
uploadProgressService.addUploadStatus(importTemplateOptions.getUploadKey(), "Warning! The previous version of this template '" + templateName + "', now located in NiFi under the process group '" + versionedProcessGroup.getVersionedProcessGroupName() + "' still has items in queue. Unable to delete it. ", true, true);
// if the versioned group still had items in queue then wire it back up to the newly created group
// ?? are they still wired up to the output ports
log.info("Unable to delete versioned group '{}' Items are still in queue", versionedProcessGroup.getVersionedProcessGroupName());
// stop the inputs and mark the rest as running
versionedProcessGroup.getVersionedProcessGroup().getContents().getInputPorts().stream().forEach(portDTO -> {
nifiRestClient.stopInputPort(versionedProcessGroup.getVersionedProcessGroup().getId(), portDTO.getId());
});
// start the output ports
versionedProcessGroup.getVersionedProcessGroup().getContents().getOutputPorts().stream().forEach(portDTO -> {
nifiRestClient.startOutputPort(versionedProcessGroup.getVersionedProcessGroup().getId(), portDTO.getId());
});
} else {
// delete the versioned group
try {
nifiRestClient.removeProcessGroup(importTemplate.getTemplateResults().getVersionedProcessGroup().getVersionedProcessGroup().getId(), importTemplate.getTemplateResults().getVersionedProcessGroup().getVersionedProcessGroup().getParentGroupId());
} catch (NifiClientRuntimeException e) {
log.error("Template has sucessfully imported, but Kylo is unable to remove versioned process group '{}' with id '{}'. You will need to go into NiFi and manually remove it.", versionedProcessGroup.getVersionedProcessGroupName(), versionedProcessGroup.getVersionedProcessGroup().getId());
uploadProgressService.addUploadStatus(importTemplateOptions.getUploadKey(), "Warning! Unable to remove the previous version of this template, process group: '" + versionedProcessGroup.getVersionedProcessGroupName() + "' with id of " + versionedProcessGroup.getVersionedProcessGroup().getId() + ". You will need to manually delete it from NiFi. ", true, false);
}
}
}
}
}
use of org.apache.nifi.web.api.dto.status.ProcessGroupStatusDTO in project nifi by apache.
the class StandardNiFiServiceFacade method getProcessGroupStatus.
@Override
public ProcessGroupStatusEntity getProcessGroupStatus(final String groupId, final boolean recursive) {
final ProcessGroup processGroup = processGroupDAO.getProcessGroup(groupId);
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processGroup);
final ProcessGroupStatusDTO dto = dtoFactory.createProcessGroupStatusDto(processGroup, controllerFacade.getProcessGroupStatus(groupId));
// prune the response as necessary
if (!recursive) {
pruneChildGroups(dto.getAggregateSnapshot());
if (dto.getNodeSnapshots() != null) {
for (final NodeProcessGroupStatusSnapshotDTO nodeSnapshot : dto.getNodeSnapshots()) {
pruneChildGroups(nodeSnapshot.getStatusSnapshot());
}
}
}
return entityFactory.createProcessGroupStatusEntity(dto, permissions);
}
use of org.apache.nifi.web.api.dto.status.ProcessGroupStatusDTO in project nifi by apache.
the class StandardNiFiServiceFacade method updateProcessGroup.
@Override
public ProcessGroupEntity updateProcessGroup(final Revision revision, final ProcessGroupDTO processGroupDTO) {
final ProcessGroup processGroupNode = processGroupDAO.getProcessGroup(processGroupDTO.getId());
final RevisionUpdate<ProcessGroupDTO> snapshot = updateComponent(revision, processGroupNode, () -> processGroupDAO.updateProcessGroup(processGroupDTO), processGroup -> dtoFactory.createProcessGroupDto(processGroup));
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processGroupNode);
final RevisionDTO updatedRevision = dtoFactory.createRevisionDTO(snapshot.getLastModification());
final ProcessGroupStatusDTO status = dtoFactory.createConciseProcessGroupStatusDto(controllerFacade.getProcessGroupStatus(processGroupNode.getIdentifier()));
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(processGroupNode.getIdentifier()));
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
return entityFactory.createProcessGroupEntity(snapshot.getComponent(), updatedRevision, permissions, status, bulletinEntities);
}
use of org.apache.nifi.web.api.dto.status.ProcessGroupStatusDTO in project nifi by apache.
the class StandardNiFiServiceFacade method createProcessGroupEntity.
private ProcessGroupEntity createProcessGroupEntity(final ProcessGroup group) {
final RevisionDTO revision = dtoFactory.createRevisionDTO(revisionManager.getRevision(group.getIdentifier()));
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(group);
final ProcessGroupStatusDTO status = dtoFactory.createConciseProcessGroupStatusDto(controllerFacade.getProcessGroupStatus(group.getIdentifier()));
final List<BulletinEntity> bulletins = getProcessGroupBulletins(group);
return entityFactory.createProcessGroupEntity(dtoFactory.createProcessGroupDto(group), revision, permissions, status, bulletins);
}
Aggregations