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;
}
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;
}
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();
}
}
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();
}
}
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();
}
}
Aggregations