Search in sources :

Example 16 with ScheduledState

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

the class StandardRemoteProcessGroup method convertRemotePort.

/**
 * Converts a set of ports into a set of remote process group ports.
 *
 * @param ports to convert
 * @return descriptors of ports
 */
private Set<RemoteProcessGroupPortDescriptor> convertRemotePort(final Set<PortDTO> ports) {
    Set<RemoteProcessGroupPortDescriptor> remotePorts = null;
    if (ports != null) {
        remotePorts = new LinkedHashSet<>(ports.size());
        for (final PortDTO port : ports) {
            final StandardRemoteProcessGroupPortDescriptor descriptor = new StandardRemoteProcessGroupPortDescriptor();
            final ScheduledState scheduledState = ScheduledState.valueOf(port.getState());
            descriptor.setId(generatePortId(port.getId()));
            descriptor.setTargetId(port.getId());
            descriptor.setName(port.getName());
            descriptor.setComments(port.getComments());
            descriptor.setTargetRunning(ScheduledState.RUNNING.equals(scheduledState));
            remotePorts.add(descriptor);
        }
    }
    return remotePorts;
}
Also used : RemoteProcessGroupPortDescriptor(org.apache.nifi.groups.RemoteProcessGroupPortDescriptor) ScheduledState(org.apache.nifi.controller.ScheduledState) PortDTO(org.apache.nifi.web.api.dto.PortDTO)

Example 17 with ScheduledState

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

the class FlowFromDOMFactory method getProcessor.

public static ProcessorDTO getProcessor(final Element element, final StringEncryptor encryptor) {
    final ProcessorDTO dto = new ProcessorDTO();
    dto.setId(getString(element, "id"));
    dto.setVersionedComponentId(getString(element, "versionedComponentId"));
    dto.setName(getString(element, "name"));
    dto.setType(getString(element, "class"));
    dto.setBundle(getBundle(DomUtils.getChild(element, "bundle")));
    dto.setPosition(getPosition(DomUtils.getChild(element, "position")));
    dto.setStyle(getStyle(DomUtils.getChild(element, "styles")));
    final ProcessorConfigDTO configDto = new ProcessorConfigDTO();
    dto.setConfig(configDto);
    configDto.setComments(getString(element, "comment"));
    configDto.setConcurrentlySchedulableTaskCount(getInt(element, "maxConcurrentTasks"));
    final String schedulingPeriod = getString(element, "schedulingPeriod");
    configDto.setSchedulingPeriod(schedulingPeriod);
    configDto.setPenaltyDuration(getString(element, "penalizationPeriod"));
    configDto.setYieldDuration(getString(element, "yieldPeriod"));
    configDto.setBulletinLevel(getString(element, "bulletinLevel"));
    configDto.setLossTolerant(getBoolean(element, "lossTolerant"));
    final ScheduledState scheduledState = getScheduledState(element);
    dto.setState(scheduledState.toString());
    // handle scheduling strategy
    final String schedulingStrategyName = getString(element, "schedulingStrategy");
    if (schedulingStrategyName == null || schedulingStrategyName.trim().isEmpty()) {
        configDto.setSchedulingStrategy(SchedulingStrategy.TIMER_DRIVEN.name());
    } else {
        configDto.setSchedulingStrategy(schedulingStrategyName.trim());
    }
    // handle execution node
    final String executionNode = getString(element, "executionNode");
    if (executionNode == null || executionNode.trim().isEmpty()) {
        configDto.setExecutionNode(ExecutionNode.ALL.name());
    } else {
        configDto.setExecutionNode(executionNode.trim());
    }
    final Long runDurationNanos = getOptionalLong(element, "runDurationNanos");
    if (runDurationNanos != null) {
        configDto.setRunDurationMillis(TimeUnit.NANOSECONDS.toMillis(runDurationNanos));
    }
    configDto.setProperties(getProperties(element, encryptor));
    configDto.setAnnotationData(getString(element, "annotationData"));
    final Set<String> autoTerminatedRelationships = new HashSet<>();
    final List<Element> autoTerminateList = getChildrenByTagName(element, "autoTerminatedRelationship");
    for (final Element autoTerminateElement : autoTerminateList) {
        autoTerminatedRelationships.add(autoTerminateElement.getTextContent());
    }
    configDto.setAutoTerminatedRelationships(autoTerminatedRelationships);
    return dto;
}
Also used : ProcessorConfigDTO(org.apache.nifi.web.api.dto.ProcessorConfigDTO) ScheduledState(org.apache.nifi.controller.ScheduledState) ProcessorDTO(org.apache.nifi.web.api.dto.ProcessorDTO) Element(org.w3c.dom.Element) HashSet(java.util.HashSet)

Example 18 with ScheduledState

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

the class StandardProcessGroup method disableInputPort.

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

Example 19 with ScheduledState

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

the class StandardProcessGroup method stopOutputPort.

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

Example 20 with ScheduledState

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

the class StandardProcessGroup method startInputPort.

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

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