use of org.apache.nifi.web.api.dto.PortDTO in project kylo by Teradata.
the class NiFiObjectCache method getReusableTemplateInputPort.
/**
* return the matching inputport in the 'reusable_templates' process group
*/
public PortDTO getReusableTemplateInputPort(String inputPortName) {
if (reusableTemplateCategoryInputPortsByName.containsKey(inputPortName)) {
return reusableTemplateCategoryInputPortsByName.get(inputPortName);
} else {
ProcessGroupDTO reusableTemplateCategoryGroupId = getReusableTemplateCategoryProcessGroup();
Set<PortDTO> inputPortsEntity = restClient.getNiFiRestClient().processGroups().getInputPorts(reusableTemplateCategoryGroupId.getId());
if (inputPortsEntity != null) {
inputPortsEntity.stream().forEach(inputPort -> reusableTemplateCategoryInputPortsByName.put(inputPort.getName(), inputPort));
PortDTO inputPort = NifiConnectionUtil.findPortMatchingName(inputPortsEntity, inputPortName);
return inputPort;
}
}
return null;
}
use of org.apache.nifi.web.api.dto.PortDTO in project kylo by Teradata.
the class NiFiObjectCache method getCategoryOutputPort.
/**
* finds the matching outputport for the category looking by the port name
*/
public PortDTO getCategoryOutputPort(String categoryProcessGroupId, String outputPortName) {
if (!categoryProcessGroupIdToOutputPortByName.containsKey(categoryProcessGroupId)) {
categoryProcessGroupIdToOutputPortByName.put(categoryProcessGroupId, new ConcurrentHashMap<>());
}
PortDTO outputPort = categoryProcessGroupIdToOutputPortByName.get(categoryProcessGroupId).get(outputPortName);
if (outputPort == null) {
Set<PortDTO> outputPorts = restClient.getNiFiRestClient().processGroups().getOutputPorts(categoryProcessGroupId);
if (outputPorts != null) {
outputPorts.stream().forEach(port -> categoryProcessGroupIdToOutputPortByName.get(categoryProcessGroupId).put(port.getName(), port));
outputPort = NifiConnectionUtil.findPortMatchingName(outputPorts, outputPortName);
}
}
return outputPort;
}
use of org.apache.nifi.web.api.dto.PortDTO in project kylo by Teradata.
the class LegacyNifiRestClient method startInputPort.
public PortDTO startInputPort(String groupId, String portId) throws NifiClientRuntimeException {
PortDTO portDTO = new PortDTO();
portDTO.setId(portId);
portDTO.setState(NifiProcessUtil.PROCESS_STATE.RUNNING.name());
return client.ports().updateInputPort(groupId, portDTO);
}
use of org.apache.nifi.web.api.dto.PortDTO in project kylo by Teradata.
the class LegacyNifiRestClient method stopInputs.
public void stopInputs(ProcessGroupDTO groupDTO) {
List<ProcessorDTO> inputs = NifiProcessUtil.getInputProcessors(groupDTO);
if (inputs != null) {
for (ProcessorDTO input : inputs) {
stopProcessor(input);
}
}
Set<PortDTO> inputPorts = getInputPorts(groupDTO.getId());
if (inputPorts != null) {
for (PortDTO port : inputPorts) {
stopInputPort(groupDTO.getId(), port.getId());
}
}
}
use of org.apache.nifi.web.api.dto.PortDTO in project kylo by Teradata.
the class LegacyNifiRestClient method startProcessGroupAndParentInputPorts.
public void startProcessGroupAndParentInputPorts(ProcessGroupDTO entity) {
// 1 startAll
try {
startAll(entity.getId(), entity.getParentGroupId());
} catch (NifiClientRuntimeException e) {
log.error("Error trying to mark connection ports Running for {}", entity.getName());
}
Set<PortDTO> ports = null;
try {
ports = getPortsForProcessGroup(entity.getParentGroupId());
} catch (NifiClientRuntimeException e) {
log.error("Error getPortsForProcessGroup {}", entity.getName());
}
if (ports != null && !ports.isEmpty()) {
Map<String, PortDTO> portsById = ports.stream().collect(Collectors.toMap(port -> port.getId(), port -> port));
ProcessGroupFlowDTO flow = getNiFiRestClient().processGroups().flow(entity.getParentGroupId());
if (flow != null) {
List<PortDTO> matchingParentGroupPorts = flow.getFlow().getConnections().stream().map(connectionEntity -> connectionEntity.getComponent()).filter(connectionDTO -> connectionDTO.getDestination().getGroupId().equalsIgnoreCase(entity.getId())).filter(connectionDTO -> portsById.containsKey(connectionDTO.getSource().getId())).map(connectionDTO -> portsById.get(connectionDTO.getSource().getId())).collect(Collectors.toList());
for (PortDTO port : matchingParentGroupPorts) {
port.setState(NifiProcessUtil.PROCESS_STATE.RUNNING.name());
if (port.getType().equalsIgnoreCase(NifiConstants.NIFI_PORT_TYPE.INPUT_PORT.name())) {
try {
startInputPort(entity.getParentGroupId(), port.getId());
} catch (NifiClientRuntimeException e) {
log.error("Error starting Input Port {} for process group {}", port.getName(), entity.getName());
}
} else if (port.getType().equalsIgnoreCase(NifiConstants.NIFI_PORT_TYPE.OUTPUT_PORT.name())) {
try {
startOutputPort(entity.getParentGroupId(), port.getId());
} catch (NifiClientRuntimeException e) {
log.error("Error starting Output Port {} for process group {}", port.getName(), entity.getName());
}
}
}
}
}
}
Aggregations