Java Code Examples for org.apache.nifi.controller.ProcessorNode#verifyCanUpdate()
The following examples show how to use
org.apache.nifi.controller.ProcessorNode#verifyCanUpdate() .
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: StandardProcessorDAO.java From localization_nifi with Apache License 2.0 | 4 votes |
private void verifyUpdate(ProcessorNode processor, ProcessorDTO processorDTO) { // ensure the state, if specified, is valid if (isNotNull(processorDTO.getState())) { try { final ScheduledState purposedScheduledState = ScheduledState.valueOf(processorDTO.getState()); // only attempt an action if it is changing if (!purposedScheduledState.equals(processor.getScheduledState())) { // perform the appropriate action switch (purposedScheduledState) { case RUNNING: processor.verifyCanStart(); break; case STOPPED: switch (processor.getScheduledState()) { case RUNNING: processor.verifyCanStop(); break; case DISABLED: processor.verifyCanEnable(); break; } break; case DISABLED: processor.verifyCanDisable(); break; } } } catch (IllegalArgumentException iae) { throw new IllegalArgumentException(String.format( "The specified processor state (%s) is not valid. Valid options are 'RUNNING', 'STOPPED', and 'DISABLED'.", processorDTO.getState())); } } boolean modificationRequest = false; if (isAnyNotNull(processorDTO.getName())) { modificationRequest = true; } final ProcessorConfigDTO configDTO = processorDTO.getConfig(); if (configDTO != null) { if (isAnyNotNull(configDTO.getAnnotationData(), configDTO.getAutoTerminatedRelationships(), configDTO.getBulletinLevel(), configDTO.getComments(), configDTO.getConcurrentlySchedulableTaskCount(), configDTO.getPenaltyDuration(), configDTO.getProperties(), configDTO.getSchedulingPeriod(), configDTO.getSchedulingStrategy(), configDTO.getExecutionNode(), configDTO.getYieldDuration())) { modificationRequest = true; } // validate the request final List<String> requestValidation = validateProposedConfiguration(processor, configDTO); // ensure there was no validation errors if (!requestValidation.isEmpty()) { throw new ValidationException(requestValidation); } } if (modificationRequest) { processor.verifyCanUpdate(); } }
Example 2
Source File: StandardProcessorDAO.java From nifi with Apache License 2.0 | 4 votes |
private void verifyUpdate(ProcessorNode processor, ProcessorDTO processorDTO) { // ensure the state, if specified, is valid if (isNotNull(processorDTO.getState())) { try { final ScheduledState purposedScheduledState = ScheduledState.valueOf(processorDTO.getState()); // only attempt an action if it is changing if (!purposedScheduledState.equals(processor.getScheduledState())) { // perform the appropriate action switch (purposedScheduledState) { case RUNNING: processor.verifyCanStart(); break; case STOPPED: switch (processor.getScheduledState()) { case RUNNING: processor.verifyCanStop(); break; case DISABLED: processor.verifyCanEnable(); break; } break; case DISABLED: processor.verifyCanDisable(); break; } } } catch (IllegalArgumentException iae) { throw new IllegalArgumentException(String.format( "The specified processor state (%s) is not valid. Valid options are 'RUNNING', 'STOPPED', and 'DISABLED'.", processorDTO.getState())); } } boolean modificationRequest = false; if (isAnyNotNull(processorDTO.getName(), processorDTO.getBundle())) { modificationRequest = true; } final BundleDTO bundleDTO = processorDTO.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(flowController.getExtensionManager(), processor.getCanonicalClassName(), bundleDTO); // ensure we are only changing to a bundle with the same group and id, but different version processor.verifyCanUpdateBundle(bundleCoordinate); } final ProcessorConfigDTO configDTO = processorDTO.getConfig(); if (configDTO != null) { if (isAnyNotNull(configDTO.getAnnotationData(), configDTO.getAutoTerminatedRelationships(), configDTO.getBulletinLevel(), configDTO.getComments(), configDTO.getConcurrentlySchedulableTaskCount(), configDTO.getPenaltyDuration(), configDTO.getProperties(), configDTO.getSchedulingPeriod(), configDTO.getSchedulingStrategy(), configDTO.getExecutionNode(), configDTO.getYieldDuration())) { modificationRequest = true; } // validate the request final List<String> requestValidation = validateProposedConfiguration(processor, configDTO); // ensure there was no validation errors if (!requestValidation.isEmpty()) { throw new ValidationException(requestValidation); } } if (modificationRequest) { processor.verifyCanUpdate(); } }