Java Code Examples for org.apache.nifi.controller.ReportingTaskNode#getScheduledState()
The following examples show how to use
org.apache.nifi.controller.ReportingTaskNode#getScheduledState() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StandardControllerServiceProvider.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override public void verifyCanScheduleReferencingComponents(final ControllerServiceNode serviceNode) { final List<ControllerServiceNode> referencingServices = findRecursiveReferences(serviceNode, ControllerServiceNode.class); final List<ReportingTaskNode> referencingReportingTasks = findRecursiveReferences(serviceNode, ReportingTaskNode.class); final List<ProcessorNode> referencingProcessors = findRecursiveReferences(serviceNode, ProcessorNode.class); final Set<ControllerServiceNode> referencingServiceSet = new HashSet<>(referencingServices); for (final ReportingTaskNode taskNode : referencingReportingTasks) { if (taskNode.getScheduledState() != ScheduledState.DISABLED) { taskNode.verifyCanStart(referencingServiceSet); } } for (final ProcessorNode procNode : referencingProcessors) { if (procNode.getScheduledState() != ScheduledState.DISABLED) { procNode.verifyCanStart(referencingServiceSet); } } }
Example 2
Source File: StandardControllerServiceProvider.java From nifi with Apache License 2.0 | 6 votes |
@Override public void verifyCanScheduleReferencingComponents(final ControllerServiceNode serviceNode) { final List<ControllerServiceNode> referencingServices = serviceNode.getReferences().findRecursiveReferences(ControllerServiceNode.class); final List<ReportingTaskNode> referencingReportingTasks = serviceNode.getReferences().findRecursiveReferences(ReportingTaskNode.class); final List<ProcessorNode> referencingProcessors = serviceNode.getReferences().findRecursiveReferences(ProcessorNode.class); final Set<ControllerServiceNode> referencingServiceSet = new HashSet<>(referencingServices); for (final ReportingTaskNode taskNode : referencingReportingTasks) { if (taskNode.getScheduledState() != ScheduledState.DISABLED) { taskNode.verifyCanStart(referencingServiceSet); } } for (final ProcessorNode procNode : referencingProcessors) { if (procNode.getScheduledState() != ScheduledState.DISABLED) { procNode.verifyCanStart(referencingServiceSet); } } }
Example 3
Source File: StandardProcessScheduler.java From localization_nifi with Apache License 2.0 | 5 votes |
public synchronized void enableReportingTask(final ReportingTaskNode taskNode) { if (taskNode.getScheduledState() != ScheduledState.DISABLED) { throw new IllegalStateException("Reporting Task cannot be enabled because it is not disabled"); } taskNode.setScheduledState(ScheduledState.STOPPED); }
Example 4
Source File: StandardProcessScheduler.java From localization_nifi with Apache License 2.0 | 5 votes |
public synchronized void disableReportingTask(final ReportingTaskNode taskNode) { if (taskNode.getScheduledState() != ScheduledState.STOPPED) { throw new IllegalStateException("Reporting Task cannot be disabled because its state is set to " + taskNode.getScheduledState() + " but transition to DISABLED state is allowed only from the STOPPED state"); } taskNode.setScheduledState(ScheduledState.DISABLED); }
Example 5
Source File: StandardProcessScheduler.java From nifi with Apache License 2.0 | 5 votes |
public synchronized void enableReportingTask(final ReportingTaskNode taskNode) { if (taskNode.getScheduledState() != ScheduledState.DISABLED) { throw new IllegalStateException("Reporting Task cannot be enabled because it is not disabled"); } taskNode.setScheduledState(ScheduledState.STOPPED); }
Example 6
Source File: StandardProcessScheduler.java From nifi with Apache License 2.0 | 5 votes |
public synchronized void disableReportingTask(final ReportingTaskNode taskNode) { if (taskNode.getScheduledState() != ScheduledState.STOPPED) { throw new IllegalStateException("Reporting Task cannot be disabled because its state is set to " + taskNode.getScheduledState() + " but transition to DISABLED state is allowed only from the STOPPED state"); } taskNode.setScheduledState(ScheduledState.DISABLED); }
Example 7
Source File: StandardReportingTaskDAO.java From localization_nifi with Apache License 2.0 | 4 votes |
@Override public ReportingTaskNode updateReportingTask(final ReportingTaskDTO reportingTaskDTO) { // get the reporting task final ReportingTaskNode reportingTask = locateReportingTask(reportingTaskDTO.getId()); // ensure we can perform the update verifyUpdate(reportingTask, reportingTaskDTO); // perform the update configureReportingTask(reportingTask, reportingTaskDTO); // configure scheduled state // see if an update is necessary if (isNotNull(reportingTaskDTO.getState())) { final ScheduledState purposedScheduledState = ScheduledState.valueOf(reportingTaskDTO.getState()); // only attempt an action if it is changing if (!purposedScheduledState.equals(reportingTask.getScheduledState())) { try { // perform the appropriate action switch (purposedScheduledState) { case RUNNING: reportingTaskProvider.startReportingTask(reportingTask); break; case STOPPED: switch (reportingTask.getScheduledState()) { case RUNNING: reportingTaskProvider.stopReportingTask(reportingTask); break; case DISABLED: reportingTaskProvider.enableReportingTask(reportingTask); break; } break; case DISABLED: reportingTaskProvider.disableReportingTask(reportingTask); break; } } catch (IllegalStateException | ComponentLifeCycleException ise) { throw new NiFiCoreException(ise.getMessage(), ise); } catch (RejectedExecutionException ree) { throw new NiFiCoreException("Unable to schedule all tasks for the specified reporting task.", ree); } catch (NullPointerException npe) { throw new NiFiCoreException("Unable to update reporting task run state.", npe); } catch (Exception e) { throw new NiFiCoreException("Unable to update reporting task run state: " + e, e); } } } return reportingTask; }
Example 8
Source File: StandardReportingTaskDAO.java From localization_nifi with Apache License 2.0 | 4 votes |
private void verifyUpdate(final ReportingTaskNode reportingTask, final ReportingTaskDTO reportingTaskDTO) { // ensure the state, if specified, is valid if (isNotNull(reportingTaskDTO.getState())) { try { final ScheduledState purposedScheduledState = ScheduledState.valueOf(reportingTaskDTO.getState()); // only attempt an action if it is changing if (!purposedScheduledState.equals(reportingTask.getScheduledState())) { // perform the appropriate action switch (purposedScheduledState) { case RUNNING: reportingTask.verifyCanStart(); break; case STOPPED: switch (reportingTask.getScheduledState()) { case RUNNING: reportingTask.verifyCanStop(); break; case DISABLED: reportingTask.verifyCanEnable(); break; } break; case DISABLED: reportingTask.verifyCanDisable(); break; } } } catch (IllegalArgumentException iae) { throw new IllegalArgumentException(String.format( "The specified reporting task state (%s) is not valid. Valid options are 'RUNNING', 'STOPPED', and 'DISABLED'.", reportingTaskDTO.getState())); } } boolean modificationRequest = false; if (isAnyNotNull(reportingTaskDTO.getName(), reportingTaskDTO.getSchedulingStrategy(), reportingTaskDTO.getSchedulingPeriod(), reportingTaskDTO.getAnnotationData(), reportingTaskDTO.getProperties())) { modificationRequest = true; // validate the request final List<String> requestValidation = validateProposedConfiguration(reportingTask, reportingTaskDTO); // ensure there was no validation errors if (!requestValidation.isEmpty()) { throw new ValidationException(requestValidation); } } if (modificationRequest) { reportingTask.verifyCanUpdate(); } }
Example 9
Source File: StandardReportingTaskDAO.java From nifi with Apache License 2.0 | 4 votes |
@Override public ReportingTaskNode updateReportingTask(final ReportingTaskDTO reportingTaskDTO) { // get the reporting task final ReportingTaskNode reportingTask = locateReportingTask(reportingTaskDTO.getId()); // ensure we can perform the update verifyUpdate(reportingTask, reportingTaskDTO); // perform the update configureReportingTask(reportingTask, reportingTaskDTO); // attempt to change the underlying processor if an updated bundle is specified // updating the bundle must happen after configuring so that any additional classpath resources are set first updateBundle(reportingTask, reportingTaskDTO); // configure scheduled state // see if an update is necessary if (isNotNull(reportingTaskDTO.getState())) { final ScheduledState purposedScheduledState = ScheduledState.valueOf(reportingTaskDTO.getState()); // only attempt an action if it is changing if (!purposedScheduledState.equals(reportingTask.getScheduledState())) { try { // perform the appropriate action switch (purposedScheduledState) { case RUNNING: reportingTaskProvider.startReportingTask(reportingTask); break; case STOPPED: switch (reportingTask.getScheduledState()) { case RUNNING: reportingTaskProvider.stopReportingTask(reportingTask); break; case DISABLED: reportingTaskProvider.enableReportingTask(reportingTask); break; } break; case DISABLED: reportingTaskProvider.disableReportingTask(reportingTask); break; } } catch (IllegalStateException | ComponentLifeCycleException ise) { throw new NiFiCoreException(ise.getMessage(), ise); } catch (RejectedExecutionException ree) { throw new NiFiCoreException("Unable to schedule all tasks for the specified reporting task.", ree); } catch (NullPointerException npe) { throw new NiFiCoreException("Unable to update reporting task run state.", npe); } catch (Exception e) { throw new NiFiCoreException("Unable to update reporting task run state: " + e, e); } } } return reportingTask; }
Example 10
Source File: StandardReportingTaskDAO.java From nifi with Apache License 2.0 | 4 votes |
private void verifyUpdate(final ReportingTaskNode reportingTask, final ReportingTaskDTO reportingTaskDTO) { // ensure the state, if specified, is valid if (isNotNull(reportingTaskDTO.getState())) { try { final ScheduledState purposedScheduledState = ScheduledState.valueOf(reportingTaskDTO.getState()); // only attempt an action if it is changing if (!purposedScheduledState.equals(reportingTask.getScheduledState())) { // perform the appropriate action switch (purposedScheduledState) { case RUNNING: reportingTask.verifyCanStart(); break; case STOPPED: switch (reportingTask.getScheduledState()) { case RUNNING: reportingTask.verifyCanStop(); break; case DISABLED: reportingTask.verifyCanEnable(); break; } break; case DISABLED: reportingTask.verifyCanDisable(); break; } } } catch (IllegalArgumentException iae) { throw new IllegalArgumentException(String.format( "The specified reporting task state (%s) is not valid. Valid options are 'RUNNING', 'STOPPED', and 'DISABLED'.", reportingTaskDTO.getState())); } } boolean modificationRequest = false; if (isAnyNotNull(reportingTaskDTO.getName(), reportingTaskDTO.getSchedulingStrategy(), reportingTaskDTO.getSchedulingPeriod(), reportingTaskDTO.getAnnotationData(), reportingTaskDTO.getProperties(), reportingTaskDTO.getBundle())) { modificationRequest = true; // validate the request final List<String> requestValidation = validateProposedConfiguration(reportingTask, reportingTaskDTO); // ensure there was no validation errors if (!requestValidation.isEmpty()) { throw new ValidationException(requestValidation); } } final BundleDTO bundleDTO = reportingTaskDTO.getBundle(); if (bundleDTO != null) { // ensures all nodes in a cluster have the bundle, throws exception if bundle not found for the given type final BundleCoordinate bundleCoordinate = BundleUtils.getBundle( reportingTaskProvider.getExtensionManager(), reportingTask.getCanonicalClassName(), bundleDTO); // ensure we are only changing to a bundle with the same group and id, but different version reportingTask.verifyCanUpdateBundle(bundleCoordinate); } if (modificationRequest) { reportingTask.verifyCanUpdate(); } }