Java Code Examples for org.apache.nifi.controller.ScheduledState#RUNNING
The following examples show how to use
org.apache.nifi.controller.ScheduledState#RUNNING .
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: StandardProcessGroup.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override public void startProcessor(final ProcessorNode processor) { readLock.lock(); try { if (getProcessor(processor.getIdentifier()) == null) { throw new IllegalStateException("Processor is not a member of this Process Group"); } final ScheduledState state = processor.getScheduledState(); if (state == ScheduledState.DISABLED) { throw new IllegalStateException("Processor is disabled"); } else if (state == ScheduledState.RUNNING) { return; } scheduler.startProcessor(processor); } finally { readLock.unlock(); } }
Example 2
Source File: StandardProcessGroup.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override public void startInputPort(final Port port) { readLock.lock(); try { if (getInputPort(port.getIdentifier()) == null) { throw new IllegalStateException("Port " + port.getIdentifier() + " is not a member of this Process Group"); } final ScheduledState state = port.getScheduledState(); if (state == ScheduledState.DISABLED) { throw new IllegalStateException("InputPort " + port.getIdentifier() + " is disabled"); } else if (state == ScheduledState.RUNNING) { return; } scheduler.startPort(port); } finally { readLock.unlock(); } }
Example 3
Source File: StandardProcessGroup.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override public void startOutputPort(final Port port) { readLock.lock(); try { if (getOutputPort(port.getIdentifier()) == null) { throw new IllegalStateException("Port is not a member of this Process Group"); } final ScheduledState state = port.getScheduledState(); if (state == ScheduledState.DISABLED) { throw new IllegalStateException("OutputPort is disabled"); } else if (state == ScheduledState.RUNNING) { return; } scheduler.startPort(port); } finally { readLock.unlock(); } }
Example 4
Source File: StandardProcessGroup.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override public void startFunnel(final Funnel funnel) { readLock.lock(); try { if (getFunnel(funnel.getIdentifier()) == null) { throw new IllegalStateException("Funnel is not a member of this Process Group"); } final ScheduledState state = funnel.getScheduledState(); if (state == ScheduledState.RUNNING) { return; } scheduler.startFunnel(funnel); } finally { readLock.unlock(); } }
Example 5
Source File: StandardProcessGroup.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override public void enableInputPort(final Port port) { readLock.lock(); try { if (!inputPorts.containsKey(port.getIdentifier())) { throw new IllegalStateException("No Input Port with ID " + port.getIdentifier() + " belongs to this Process Group"); } final ScheduledState state = port.getScheduledState(); if (state == ScheduledState.STOPPED) { return; } else if (state == ScheduledState.RUNNING) { throw new IllegalStateException("InputPort is currently running"); } scheduler.enablePort(port); } finally { readLock.unlock(); } }
Example 6
Source File: StandardProcessGroup.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override public void enableOutputPort(final Port port) { readLock.lock(); try { if (!outputPorts.containsKey(port.getIdentifier())) { throw new IllegalStateException("No Output Port with ID " + port.getIdentifier() + " belongs to this Process Group"); } final ScheduledState state = port.getScheduledState(); if (state == ScheduledState.STOPPED) { return; } else if (state == ScheduledState.RUNNING) { throw new IllegalStateException("OutputPort is currently running"); } scheduler.enablePort(port); } finally { readLock.unlock(); } }
Example 7
Source File: StandardProcessGroup.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override public void enableProcessor(final ProcessorNode processor) { readLock.lock(); try { if (!processors.containsKey(processor.getIdentifier())) { throw new IllegalStateException("No Processor with ID " + processor.getIdentifier() + " belongs to this Process Group"); } final ScheduledState state = processor.getScheduledState(); if (state == ScheduledState.STOPPED) { return; } else if (state == ScheduledState.RUNNING) { throw new IllegalStateException("Processor is currently running"); } scheduler.enableProcessor(processor); } finally { readLock.unlock(); } }
Example 8
Source File: StandardProcessGroup.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override public void disableInputPort(final Port port) { readLock.lock(); try { if (!inputPorts.containsKey(port.getIdentifier())) { throw new IllegalStateException("No InputPort with ID " + port.getIdentifier() + " belongs to this Process Group"); } final ScheduledState state = port.getScheduledState(); if (state == ScheduledState.DISABLED) { return; } else if (state == ScheduledState.RUNNING) { throw new IllegalStateException("InputPort is currently running"); } scheduler.disablePort(port); } finally { readLock.unlock(); } }
Example 9
Source File: StandardProcessGroup.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override public void disableOutputPort(final Port port) { readLock.lock(); try { if (!outputPorts.containsKey(port.getIdentifier())) { throw new IllegalStateException("No OutputPort with ID " + port.getIdentifier() + " belongs to this Process Group"); } final ScheduledState state = port.getScheduledState(); if (state == ScheduledState.DISABLED) { return; } else if (state == ScheduledState.RUNNING) { throw new IllegalStateException("OutputPort is currently running"); } scheduler.disablePort(port); } finally { readLock.unlock(); } }
Example 10
Source File: StandardProcessGroup.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override public void disableProcessor(final ProcessorNode processor) { readLock.lock(); try { if (!processors.containsKey(processor.getIdentifier())) { throw new IllegalStateException("No Processor with ID " + processor.getIdentifier() + " belongs to this Process Group"); } final ScheduledState state = processor.getScheduledState(); if (state == ScheduledState.DISABLED) { return; } else if (state == ScheduledState.RUNNING) { throw new IllegalStateException("Processor is currently running"); } scheduler.disableProcessor(processor); } finally { readLock.unlock(); } }
Example 11
Source File: LocalComponentLifecycle.java From nifi with Apache License 2.0 | 6 votes |
@Override public Set<AffectedComponentEntity> scheduleComponents(final URI exampleUri, final String groupId, final Set<AffectedComponentEntity> components, final ScheduledState desiredState, final Pause pause, final InvalidComponentAction invalidComponentAction) throws LifecycleManagementException { final Map<String, Revision> processorRevisions = components.stream() .collect(Collectors.toMap(AffectedComponentEntity::getId, entity -> revisionManager.getRevision(entity.getId()))); final Map<String, AffectedComponentEntity> affectedComponentMap = components.stream() .collect(Collectors.toMap(AffectedComponentEntity::getId, Function.identity())); if (desiredState == ScheduledState.RUNNING) { startComponents(groupId, processorRevisions, affectedComponentMap, pause, invalidComponentAction); } else { stopComponents(groupId, processorRevisions, affectedComponentMap, pause, invalidComponentAction); } final Set<AffectedComponentEntity> updatedEntities = components.stream() .map(component -> AffectedComponentUtils.updateEntity(component, serviceFacade, dtoFactory)) .collect(Collectors.toSet()); return updatedEntities; }
Example 12
Source File: LocalComponentLifecycle.java From nifi with Apache License 2.0 | 5 votes |
private boolean isProcessorActionComplete(final Set<ProcessorEntity> processorEntities, final Map<String, AffectedComponentEntity> affectedComponents, final ScheduledState desiredState, final InvalidComponentAction invalidComponentAction) throws LifecycleManagementException { final String desiredStateName = desiredState.name(); updateAffectedProcessors(processorEntities, affectedComponents); for (final ProcessorEntity entity : processorEntities) { if (!affectedComponents.containsKey(entity.getId())) { continue; } final ProcessorStatusDTO status = entity.getStatus(); if (ProcessorDTO.INVALID.equals(entity.getComponent().getValidationStatus())) { switch (invalidComponentAction) { case WAIT: return false; case SKIP: continue; case FAIL: final String action = desiredState == ScheduledState.RUNNING ? "start" : "stop"; throw new LifecycleManagementException("Could not " + action + " " + entity.getComponent().getName() + " because it is invalid"); } } final String runStatus = status.getAggregateSnapshot().getRunStatus(); final boolean stateMatches = desiredStateName.equalsIgnoreCase(runStatus); if (!stateMatches) { return false; } if (desiredState == ScheduledState.STOPPED && status.getAggregateSnapshot().getActiveThreadCount() != 0) { return false; } } return true; }
Example 13
Source File: ClusterReplicationComponentLifecycle.java From nifi with Apache License 2.0 | 5 votes |
private boolean isProcessorActionComplete(final ProcessorsRunStatusDetailsEntity runStatusDetailsEntity, final Map<String, AffectedComponentEntity> affectedComponents, final ScheduledState desiredState, final InvalidComponentAction invalidComponentAction) throws LifecycleManagementException { final String desiredStateName = desiredState.name(); updateAffectedProcessors(runStatusDetailsEntity.getRunStatusDetails(), affectedComponents); for (final ProcessorRunStatusDetailsEntity entity : runStatusDetailsEntity.getRunStatusDetails()) { final ProcessorRunStatusDetailsDTO runStatusDetailsDto = entity.getRunStatusDetails(); if (!affectedComponents.containsKey(runStatusDetailsDto.getId())) { continue; } if (ProcessorRunStatusDetailsDTO.INVALID.equals(runStatusDetailsDto.getRunStatus())) { switch (invalidComponentAction) { case WAIT: return false; case SKIP: continue; case FAIL: final String action = desiredState == ScheduledState.RUNNING ? "start" : "stop"; throw new LifecycleManagementException("Could not " + action + " " + runStatusDetailsDto.getName() + " because it is invalid"); } } final String runStatus = runStatusDetailsDto.getRunStatus(); final boolean stateMatches = desiredStateName.equalsIgnoreCase(runStatus); if (!stateMatches) { return false; } if (desiredState == ScheduledState.STOPPED && runStatusDetailsDto.getActiveThreadCount() != 0) { return false; } } return true; }