use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class ControllerFacade method getProcessorStatus.
/**
* Gets the status for the specified processor.
*
* @param processorId processor id
* @return the status for the specified processor
*/
public ProcessorStatus getProcessorStatus(final String processorId) {
final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId());
final ProcessorNode processor = root.findProcessor(processorId);
// ensure the processor was found
if (processor == null) {
throw new ResourceNotFoundException(String.format("Unable to locate processor with id '%s'.", processorId));
}
// calculate the process group status
final String groupId = processor.getProcessGroup().getIdentifier();
final ProcessGroupStatus processGroupStatus = flowController.getGroupStatus(groupId, NiFiUserUtils.getNiFiUser());
if (processGroupStatus == null) {
throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId));
}
final ProcessorStatus status = processGroupStatus.getProcessorStatus().stream().filter(processorStatus -> processorId.equals(processorStatus.getId())).findFirst().orElse(null);
if (status == null) {
throw new ResourceNotFoundException(String.format("Unable to locate processor with id '%s'.", processorId));
}
return status;
}
use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class ControllerFacade method getProcessorStatusHistory.
/**
* Returns the status history for the specified processor.
*
* @param processorId processor id
* @return status history
*/
public StatusHistoryDTO getProcessorStatusHistory(final String processorId) {
final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId());
final ProcessorNode processor = root.findProcessor(processorId);
// ensure the processor was found
if (processor == null) {
throw new ResourceNotFoundException(String.format("Unable to locate processor with id '%s'.", processorId));
}
final boolean authorized = processor.isAuthorized(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser());
final StatusHistoryDTO statusHistory = flowController.getProcessorStatusHistory(processorId, authorized);
// if not authorized
if (!authorized) {
statusHistory.getComponentDetails().put(ComponentStatusRepository.COMPONENT_DETAIL_NAME, processorId);
statusHistory.getComponentDetails().put(ComponentStatusRepository.COMPONENT_DETAIL_TYPE, "Processor");
}
return statusHistory;
}
use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class ControllerFacade method getRemoteProcessGroupStatus.
/**
* Gets the status for the specified remote process group.
*
* @param remoteProcessGroupId remote process group id
* @return the status for the specified remote process group
*/
public RemoteProcessGroupStatus getRemoteProcessGroupStatus(final String remoteProcessGroupId) {
final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId());
final RemoteProcessGroup remoteProcessGroup = root.findRemoteProcessGroup(remoteProcessGroupId);
// ensure the output port was found
if (remoteProcessGroup == null) {
throw new ResourceNotFoundException(String.format("Unable to locate remote process group with id '%s'.", remoteProcessGroupId));
}
final String groupId = remoteProcessGroup.getProcessGroup().getIdentifier();
final ProcessGroupStatus groupStatus = flowController.getGroupStatus(groupId, NiFiUserUtils.getNiFiUser());
if (groupStatus == null) {
throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId));
}
final RemoteProcessGroupStatus status = groupStatus.getRemoteProcessGroupStatus().stream().filter(rpgStatus -> remoteProcessGroupId.equals(rpgStatus.getId())).findFirst().orElse(null);
if (status == null) {
throw new ResourceNotFoundException(String.format("Unable to locate remote process group with id '%s'.", remoteProcessGroupId));
}
return status;
}
use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class ControllerFacade method getResources.
public List<Resource> getResources() {
final List<Resource> resources = new ArrayList<>();
resources.add(ResourceFactory.getFlowResource());
resources.add(ResourceFactory.getSystemResource());
resources.add(ResourceFactory.getControllerResource());
resources.add(ResourceFactory.getCountersResource());
resources.add(ResourceFactory.getProvenanceResource());
resources.add(ResourceFactory.getPoliciesResource());
resources.add(ResourceFactory.getTenantResource());
resources.add(ResourceFactory.getProxyResource());
resources.add(ResourceFactory.getResourceResource());
resources.add(ResourceFactory.getSiteToSiteResource());
// restricted components
resources.add(ResourceFactory.getRestrictedComponentsResource());
Arrays.stream(RequiredPermission.values()).forEach(requiredPermission -> resources.add(ResourceFactory.getRestrictedComponentsResource(requiredPermission)));
final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId());
// include the root group
final Resource rootResource = root.getResource();
resources.add(rootResource);
resources.add(ResourceFactory.getDataResource(rootResource));
resources.add(ResourceFactory.getPolicyResource(rootResource));
// add each processor
for (final ProcessorNode processor : root.findAllProcessors()) {
final Resource processorResource = processor.getResource();
resources.add(processorResource);
resources.add(ResourceFactory.getDataResource(processorResource));
resources.add(ResourceFactory.getPolicyResource(processorResource));
}
// add each label
for (final Label label : root.findAllLabels()) {
final Resource labelResource = label.getResource();
resources.add(labelResource);
resources.add(ResourceFactory.getPolicyResource(labelResource));
}
// add each process group
for (final ProcessGroup processGroup : root.findAllProcessGroups()) {
final Resource processGroupResource = processGroup.getResource();
resources.add(processGroupResource);
resources.add(ResourceFactory.getDataResource(processGroupResource));
resources.add(ResourceFactory.getPolicyResource(processGroupResource));
}
// add each remote process group
for (final RemoteProcessGroup remoteProcessGroup : root.findAllRemoteProcessGroups()) {
final Resource remoteProcessGroupResource = remoteProcessGroup.getResource();
resources.add(remoteProcessGroupResource);
resources.add(ResourceFactory.getDataResource(remoteProcessGroupResource));
resources.add(ResourceFactory.getPolicyResource(remoteProcessGroupResource));
}
// add each input port
for (final Port inputPort : root.findAllInputPorts()) {
final Resource inputPortResource = inputPort.getResource();
resources.add(inputPortResource);
resources.add(ResourceFactory.getDataResource(inputPortResource));
resources.add(ResourceFactory.getPolicyResource(inputPortResource));
if (inputPort instanceof RootGroupPort) {
resources.add(ResourceFactory.getDataTransferResource(inputPortResource));
}
}
// add each output port
for (final Port outputPort : root.findAllOutputPorts()) {
final Resource outputPortResource = outputPort.getResource();
resources.add(outputPortResource);
resources.add(ResourceFactory.getDataResource(outputPortResource));
resources.add(ResourceFactory.getPolicyResource(outputPortResource));
if (outputPort instanceof RootGroupPort) {
resources.add(ResourceFactory.getDataTransferResource(outputPortResource));
}
}
// add each controller service
final Consumer<ControllerServiceNode> csConsumer = controllerService -> {
final Resource controllerServiceResource = controllerService.getResource();
resources.add(controllerServiceResource);
resources.add(ResourceFactory.getPolicyResource(controllerServiceResource));
};
flowController.getAllControllerServices().forEach(csConsumer);
root.findAllControllerServices().forEach(csConsumer);
// add each reporting task
for (final ReportingTaskNode reportingTask : flowController.getAllReportingTasks()) {
final Resource reportingTaskResource = reportingTask.getResource();
resources.add(reportingTaskResource);
resources.add(ResourceFactory.getPolicyResource(reportingTaskResource));
}
// add each template
for (final Template template : root.findAllTemplates()) {
final Resource templateResource = template.getResource();
resources.add(templateResource);
resources.add(ResourceFactory.getPolicyResource(templateResource));
}
return resources;
}
use of org.apache.nifi.groups.ProcessGroup in project nifi by apache.
the class ControllerSearchService method buildVersionedGroup.
/**
* Builds the nearest versioned parent result group for a given user.
*
* @param group The containing group
* @param user The current NiFi user
* @return Versioned parent group
*/
private SearchResultGroupDTO buildVersionedGroup(final ProcessGroup group, final NiFiUser user) {
if (group == null) {
return null;
}
ProcessGroup tmpParent = group.getParent();
ProcessGroup tmpGroup = group;
// search for a versioned group by traversing the group tree up to the root
while (!tmpGroup.isRootGroup()) {
if (tmpGroup.getVersionControlInformation() != null) {
return buildResultGroup(tmpGroup, user);
}
tmpGroup = tmpParent;
tmpParent = tmpGroup.getParent();
}
// traversed all the way to the root
return null;
}
Aggregations