use of org.apache.nifi.controller.ReportingTaskNode in project nifi by apache.
the class ControllerServiceAuditor method getUpdateActionsForReferencingComponents.
/**
* Gets the update actions for all specified referencing components.
*
* @param user user
* @param actions actions
* @param visitedServices services
* @param referencingComponents components
*/
private void getUpdateActionsForReferencingComponents(final NiFiUser user, final Collection<Action> actions, final Collection<String> visitedServices, final Set<ConfiguredComponent> referencingComponents) {
// consider each component updates
for (final ConfiguredComponent component : referencingComponents) {
if (component instanceof ProcessorNode) {
final ProcessorNode processor = ((ProcessorNode) component);
// create the processor details
FlowChangeExtensionDetails processorDetails = new FlowChangeExtensionDetails();
processorDetails.setType(processor.getComponentType());
// create a processor action
FlowChangeAction processorAction = new FlowChangeAction();
processorAction.setUserIdentity(user.getIdentity());
processorAction.setTimestamp(new Date());
processorAction.setSourceId(processor.getIdentifier());
processorAction.setSourceName(processor.getName());
processorAction.setSourceType(Component.Processor);
processorAction.setComponentDetails(processorDetails);
processorAction.setOperation(ScheduledState.RUNNING.equals(processor.getScheduledState()) ? Operation.Start : Operation.Stop);
actions.add(processorAction);
} else if (component instanceof ReportingTask) {
final ReportingTaskNode reportingTask = ((ReportingTaskNode) component);
// create the reporting task details
FlowChangeExtensionDetails taskDetails = new FlowChangeExtensionDetails();
taskDetails.setType(reportingTask.getComponentType());
// create a reporting task action
FlowChangeAction reportingTaskAction = new FlowChangeAction();
reportingTaskAction.setUserIdentity(user.getIdentity());
reportingTaskAction.setTimestamp(new Date());
reportingTaskAction.setSourceId(reportingTask.getIdentifier());
reportingTaskAction.setSourceName(reportingTask.getName());
reportingTaskAction.setSourceType(Component.ReportingTask);
reportingTaskAction.setComponentDetails(taskDetails);
reportingTaskAction.setOperation(ScheduledState.RUNNING.equals(reportingTask.getScheduledState()) ? Operation.Start : Operation.Stop);
actions.add(reportingTaskAction);
} else if (component instanceof ControllerServiceNode) {
final ControllerServiceNode controllerService = ((ControllerServiceNode) component);
// create the controller service details
FlowChangeExtensionDetails serviceDetails = new FlowChangeExtensionDetails();
serviceDetails.setType(controllerService.getComponentType());
// create a controller service action
FlowChangeAction serviceAction = new FlowChangeAction();
serviceAction.setUserIdentity(user.getIdentity());
serviceAction.setTimestamp(new Date());
serviceAction.setSourceId(controllerService.getIdentifier());
serviceAction.setSourceName(controllerService.getName());
serviceAction.setSourceType(Component.ControllerService);
serviceAction.setComponentDetails(serviceDetails);
serviceAction.setOperation(isDisabled(controllerService) ? Operation.Disable : Operation.Enable);
actions.add(serviceAction);
// need to consider components referencing this controller service (transitive)
if (!visitedServices.contains(controllerService.getIdentifier())) {
getUpdateActionsForReferencingComponents(user, actions, visitedServices, controllerService.getReferences().getReferencingComponents());
}
}
}
}
use of org.apache.nifi.controller.ReportingTaskNode in project nifi by apache.
the class StandardControllerServiceProvider method unscheduleReferencingComponents.
@Override
public Set<ConfiguredComponent> unscheduleReferencingComponents(final ControllerServiceNode serviceNode) {
// find all of the schedulable components (processors, reporting tasks) that refer to this Controller Service,
// or a service that references this controller service, etc.
final List<ProcessorNode> processors = serviceNode.getReferences().findRecursiveReferences(ProcessorNode.class);
final List<ReportingTaskNode> reportingTasks = serviceNode.getReferences().findRecursiveReferences(ReportingTaskNode.class);
final Set<ConfiguredComponent> updated = new HashSet<>();
// verify that we can stop all components (that are running) before doing anything
for (final ProcessorNode node : processors) {
if (node.getScheduledState() == ScheduledState.RUNNING) {
node.verifyCanStop();
}
}
for (final ReportingTaskNode node : reportingTasks) {
if (node.getScheduledState() == ScheduledState.RUNNING) {
node.verifyCanStop();
}
}
// stop all of the components that are running
for (final ProcessorNode node : processors) {
if (node.getScheduledState() == ScheduledState.RUNNING) {
node.getProcessGroup().stopProcessor(node);
updated.add(node);
}
}
for (final ReportingTaskNode node : reportingTasks) {
if (node.getScheduledState() == ScheduledState.RUNNING) {
processScheduler.unschedule(node);
updated.add(node);
}
}
return updated;
}
use of org.apache.nifi.controller.ReportingTaskNode in project nifi by apache.
the class StandardNiFiServiceFacade method getReportingTaskState.
@Override
public ComponentStateDTO getReportingTaskState(final String reportingTaskId) {
final StateMap clusterState = isClustered() ? reportingTaskDAO.getState(reportingTaskId, Scope.CLUSTER) : null;
final StateMap localState = reportingTaskDAO.getState(reportingTaskId, Scope.LOCAL);
// reporting task will be non null as it was already found when getting the state
final ReportingTaskNode reportingTask = reportingTaskDAO.getReportingTask(reportingTaskId);
return dtoFactory.createComponentStateDTO(reportingTaskId, reportingTask.getReportingTask().getClass(), localState, clusterState);
}
use of org.apache.nifi.controller.ReportingTaskNode in project nifi by apache.
the class StandardReportingTaskDAO method deleteReportingTask.
@Override
public void deleteReportingTask(String reportingTaskId) {
final ReportingTaskNode reportingTask = locateReportingTask(reportingTaskId);
reportingTaskProvider.removeReportingTask(reportingTask);
}
use of org.apache.nifi.controller.ReportingTaskNode in project nifi by apache.
the class StandardReportingTaskDAO method verifyClearState.
@Override
public void verifyClearState(String reportingTaskId) {
final ReportingTaskNode reportingTask = locateReportingTask(reportingTaskId);
reportingTask.verifyCanClearState();
}
Aggregations