Java Code Examples for org.apache.nifi.controller.ScheduledState#DISABLED

The following examples show how to use org.apache.nifi.controller.ScheduledState#DISABLED . 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 vote down vote up
@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 2
Source File: StandardProcessGroup.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@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 3
Source File: StandardProcessGroup.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Override
public void stopProcessor(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) {
            throw new IllegalStateException("Processor is disabled");
        } else if (state == ScheduledState.STOPPED) {
            return;
        }

        scheduler.stopProcessor(processor);
    } finally {
        readLock.unlock();
    }
}
 
Example 4
Source File: StandardProcessGroup.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Override
public void stopInputPort(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.DISABLED) {
            throw new IllegalStateException("InputPort is disabled");
        } else if (state == ScheduledState.STOPPED) {
            return;
        }

        scheduler.stopPort(port);
    } finally {
        readLock.unlock();
    }
}
 
Example 5
Source File: StandardProcessGroup.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Override
public void stopOutputPort(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.DISABLED) {
            throw new IllegalStateException("OutputPort is disabled");
        } else if (state == ScheduledState.STOPPED) {
            return;
        }

        scheduler.stopPort(port);
    } finally {
        readLock.unlock();
    }
}
 
Example 6
Source File: StandardProcessGroup.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
private void stopFunnel(final Funnel funnel) {
    readLock.lock();
    try {
        if (!funnels.containsKey(funnel.getIdentifier())) {
            throw new IllegalStateException("No Funnel with ID " + funnel.getIdentifier() + " belongs to this Process Group");
        }

        final ScheduledState state = funnel.getScheduledState();
        if (state == ScheduledState.DISABLED) {
            throw new IllegalStateException("Funnel is disabled");
        } else if (state == ScheduledState.STOPPED) {
            return;
        }

        scheduler.stopFunnel(funnel);
    } finally {
        readLock.unlock();
    }
}
 
Example 7
Source File: StandardProcessGroup.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@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 8
Source File: StandardProcessGroup.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@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 9
Source File: StandardProcessGroup.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@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 10
Source File: StandardControllerServiceProvider.java    From nifi with Apache License 2.0 6 votes vote down vote up
@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 11
Source File: StandardProcessScheduler.java    From nifi with Apache License 2.0 6 votes vote down vote up
private synchronized void startConnectable(final Connectable connectable) {
    if (connectable.getScheduledState() == ScheduledState.DISABLED) {
        throw new IllegalStateException(connectable.getIdentifier() + " is disabled, so it cannot be started");
    }

    final LifecycleState lifecycleState = getLifecycleState(requireNonNull(connectable), true);
    if (lifecycleState.isScheduled()) {
        return;
    }

    final int activeThreads = lifecycleState.getActiveThreadCount();
    if (activeThreads > 0) {
        throw new IllegalStateException("Port cannot be scheduled to run until its last " + activeThreads + " threads finish");
    }

    lifecycleState.clearTerminationFlag();
    getSchedulingAgent(connectable).schedule(connectable, lifecycleState);
    lifecycleState.setScheduled(true);
}
 
Example 12
Source File: StandardControllerServiceProvider.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@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 13
Source File: StandardProcessScheduler.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void enablePort(final Port port) {
    if (port.getScheduledState() != ScheduledState.DISABLED) {
        throw new IllegalStateException("Funnel cannot be enabled because it is not disabled");
    }

    if (!(port instanceof AbstractPort)) {
        throw new IllegalArgumentException();
    }

    ((AbstractPort) port).enable();
}
 
Example 14
Source File: StandardProcessScheduler.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void enableFunnel(final Funnel funnel) {
    if (funnel.getScheduledState() != ScheduledState.DISABLED) {
        throw new IllegalStateException("Funnel cannot be enabled because it is not disabled");
    }
    funnel.setScheduledState(ScheduledState.STOPPED);
}
 
Example 15
Source File: StandardProcessScheduler.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
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 16
Source File: StandardProcessScheduler.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void enablePort(final Port port) {
    if (port.getScheduledState() != ScheduledState.DISABLED) {
        throw new IllegalStateException("Funnel cannot be enabled because it is not disabled");
    }

    if (!(port instanceof AbstractPort)) {
        throw new IllegalArgumentException();
    }

    ((AbstractPort) port).enable();
}
 
Example 17
Source File: StandardProcessScheduler.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void enableFunnel(final Funnel funnel) {
    if (funnel.getScheduledState() != ScheduledState.DISABLED) {
        throw new IllegalStateException("Funnel cannot be enabled because it is not disabled");
    }
    funnel.setScheduledState(ScheduledState.STOPPED);
}
 
Example 18
Source File: StandardProcessScheduler.java    From nifi with Apache License 2.0 5 votes vote down vote up
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 19
Source File: AbstractReportingTaskNode.java    From nifi with Apache License 2.0 4 votes vote down vote up
public boolean isDisabled() {
    return scheduledState == ScheduledState.DISABLED;
}
 
Example 20
Source File: AbstractReportingTaskNode.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
public boolean isDisabled() {
    return scheduledState == ScheduledState.DISABLED;
}