Search in sources :

Example 21 with ScheduledState

use of org.apache.nifi.controller.ScheduledState in project nifi by apache.

the class StandardProcessGroup method startProcessor.

@Override
public CompletableFuture<Void> startProcessor(final ProcessorNode processor, final boolean failIfStopping) {
    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 CompletableFuture.completedFuture(null);
        }
        processor.reloadAdditionalResourcesIfNecessary();
        return scheduler.startProcessor(processor, failIfStopping);
    } finally {
        readLock.unlock();
    }
}
Also used : ScheduledState(org.apache.nifi.controller.ScheduledState)

Example 22 with ScheduledState

use of org.apache.nifi.controller.ScheduledState in project nifi by apache.

the class StandardProcessGroup method enableInputPort.

@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();
    }
}
Also used : ScheduledState(org.apache.nifi.controller.ScheduledState)

Example 23 with ScheduledState

use of org.apache.nifi.controller.ScheduledState in project nifi by apache.

the class StandardProcessGroup method enableOutputPort.

@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();
    }
}
Also used : ScheduledState(org.apache.nifi.controller.ScheduledState)

Example 24 with ScheduledState

use of org.apache.nifi.controller.ScheduledState in project nifi by apache.

the class StandardProcessGroup method startOutputPort.

@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();
    }
}
Also used : ScheduledState(org.apache.nifi.controller.ScheduledState)

Example 25 with ScheduledState

use of org.apache.nifi.controller.ScheduledState in project nifi by apache.

the class FlowFromDOMFactory method getPort.

public static PortDTO getPort(final Element element) {
    final PortDTO portDTO = new PortDTO();
    portDTO.setId(getString(element, "id"));
    portDTO.setVersionedComponentId(getString(element, "versionedComponentId"));
    portDTO.setPosition(getPosition(DomUtils.getChild(element, "position")));
    portDTO.setName(getString(element, "name"));
    portDTO.setComments(getString(element, "comments"));
    final ScheduledState scheduledState = getScheduledState(element);
    portDTO.setState(scheduledState.toString());
    final List<Element> maxTasksElements = getChildrenByTagName(element, "maxConcurrentTasks");
    if (!maxTasksElements.isEmpty()) {
        portDTO.setConcurrentlySchedulableTaskCount(Integer.parseInt(maxTasksElements.get(0).getTextContent()));
    }
    final List<Element> userAccessControls = getChildrenByTagName(element, "userAccessControl");
    if (userAccessControls != null && !userAccessControls.isEmpty()) {
        final Set<String> users = new HashSet<>();
        portDTO.setUserAccessControl(users);
        for (final Element userElement : userAccessControls) {
            users.add(userElement.getTextContent());
        }
    }
    final List<Element> groupAccessControls = getChildrenByTagName(element, "groupAccessControl");
    if (groupAccessControls != null && !groupAccessControls.isEmpty()) {
        final Set<String> groups = new HashSet<>();
        portDTO.setGroupAccessControl(groups);
        for (final Element groupElement : groupAccessControls) {
            groups.add(groupElement.getTextContent());
        }
    }
    return portDTO;
}
Also used : ScheduledState(org.apache.nifi.controller.ScheduledState) PortDTO(org.apache.nifi.web.api.dto.PortDTO) Element(org.w3c.dom.Element) HashSet(java.util.HashSet)

Aggregations

ScheduledState (org.apache.nifi.controller.ScheduledState)35 NiFiUser (org.apache.nifi.authorization.user.NiFiUser)9 Map (java.util.Map)7 Set (java.util.Set)7 Collectors (java.util.stream.Collectors)7 ControllerServiceState (org.apache.nifi.controller.service.ControllerServiceState)7 Date (java.util.Date)6 HttpMethod (javax.ws.rs.HttpMethod)6 MediaType (javax.ws.rs.core.MediaType)6 ValidationException (org.apache.nifi.controller.exception.ValidationException)6 List (java.util.List)5 HashSet (java.util.HashSet)4 NiFiServiceFacade (org.apache.nifi.web.NiFiServiceFacade)4 Revision (org.apache.nifi.web.Revision)4 BundleDTO (org.apache.nifi.web.api.dto.BundleDTO)4 ProcessorConfigDTO (org.apache.nifi.web.api.dto.ProcessorConfigDTO)4 ControllerServiceEntity (org.apache.nifi.web.api.entity.ControllerServiceEntity)4 Api (io.swagger.annotations.Api)3 ApiOperation (io.swagger.annotations.ApiOperation)3 ApiParam (io.swagger.annotations.ApiParam)3