Search in sources :

Example 1 with PortDTO

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;
}
Also used : PortDTO(org.apache.nifi.web.api.dto.PortDTO) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO)

Example 2 with PortDTO

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;
}
Also used : PortDTO(org.apache.nifi.web.api.dto.PortDTO)

Example 3 with PortDTO

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);
}
Also used : PortDTO(org.apache.nifi.web.api.dto.PortDTO)

Example 4 with 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());
        }
    }
}
Also used : ProcessorDTO(org.apache.nifi.web.api.dto.ProcessorDTO) PortDTO(org.apache.nifi.web.api.dto.PortDTO)

Example 5 with PortDTO

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());
                    }
                }
            }
        }
    }
}
Also used : LoggerFactory(org.slf4j.LoggerFactory) ConnectionDTO(org.apache.nifi.web.api.dto.ConnectionDTO) NifiProcessUtil(com.thinkbiganalytics.nifi.rest.support.NifiProcessUtil) StringUtils(org.apache.commons.lang3.StringUtils) ClientErrorException(javax.ws.rs.ClientErrorException) NiFiPropertyDescriptorTransform(com.thinkbiganalytics.nifi.rest.model.NiFiPropertyDescriptorTransform) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO) PropertyDescriptorDTO(org.apache.nifi.web.api.dto.PropertyDescriptorDTO) ConfigurationPropertyReplacer(com.thinkbiganalytics.nifi.feedmgr.ConfigurationPropertyReplacer) NifiConnectionUtil(com.thinkbiganalytics.nifi.rest.support.NifiConnectionUtil) TemplateDTO(org.apache.nifi.web.api.dto.TemplateDTO) NifiPropertyUtil(com.thinkbiganalytics.nifi.rest.support.NifiPropertyUtil) AboutDTO(org.apache.nifi.web.api.dto.AboutDTO) Map(java.util.Map) BulletinDTO(org.apache.nifi.web.api.dto.BulletinDTO) NifiVisitableProcessGroup(com.thinkbiganalytics.nifi.rest.model.visitor.NifiVisitableProcessGroup) Function(com.google.common.base.Function) ControllerServiceDTO(org.apache.nifi.web.api.dto.ControllerServiceDTO) ReusableTemplateCreationCallback(com.thinkbiganalytics.nifi.feedmgr.ReusableTemplateCreationCallback) NifiProperty(com.thinkbiganalytics.nifi.rest.model.NifiProperty) Collection(java.util.Collection) Set(java.util.Set) Collectors(java.util.stream.Collectors) PortDTO(org.apache.nifi.web.api.dto.PortDTO) List(java.util.List) Predicate(com.google.common.base.Predicate) ProcessorDTO(org.apache.nifi.web.api.dto.ProcessorDTO) NifiProcessGroup(com.thinkbiganalytics.nifi.rest.model.NifiProcessGroup) FlowSnippetDTO(org.apache.nifi.web.api.dto.FlowSnippetDTO) RemoteProcessGroupDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupDTO) Iterables(com.google.common.collect.Iterables) NifiConnectionOrderVisitorCache(com.thinkbiganalytics.nifi.rest.visitor.NifiConnectionOrderVisitorCache) NiFiPropertyDescriptor(com.thinkbiganalytics.nifi.rest.model.NiFiPropertyDescriptor) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Lists(com.google.common.collect.Lists) NiFiObjectCache(com.thinkbiganalytics.nifi.rest.NiFiObjectCache) NifiFlowProcessGroup(com.thinkbiganalytics.nifi.rest.model.flow.NifiFlowProcessGroup) ProcessGroupFlowDTO(org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO) Nonnull(javax.annotation.Nonnull) TemplateInstanceCreator(com.thinkbiganalytics.nifi.feedmgr.TemplateInstanceCreator) NifiConstants(com.thinkbiganalytics.nifi.rest.support.NifiConstants) Nullable(javax.annotation.Nullable) DocumentedTypeDTO(org.apache.nifi.web.api.dto.DocumentedTypeDTO) Logger(org.slf4j.Logger) TemplateCreationHelper(com.thinkbiganalytics.nifi.feedmgr.TemplateCreationHelper) NifiEnvironmentProperties(com.thinkbiganalytics.nifi.feedmgr.NifiEnvironmentProperties) TimeUnit(java.util.concurrent.TimeUnit) SearchResultsDTO(org.apache.nifi.web.api.dto.search.SearchResultsDTO) Collections(java.util.Collections) ConnectableDTO(org.apache.nifi.web.api.dto.ConnectableDTO) ComponentSearchResultDTO(org.apache.nifi.web.api.dto.search.ComponentSearchResultDTO) ProcessGroupFlowDTO(org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO) PortDTO(org.apache.nifi.web.api.dto.PortDTO)

Aggregations

PortDTO (org.apache.nifi.web.api.dto.PortDTO)71 ProcessGroupDTO (org.apache.nifi.web.api.dto.ProcessGroupDTO)30 ConnectionDTO (org.apache.nifi.web.api.dto.ConnectionDTO)29 HashSet (java.util.HashSet)28 ArrayList (java.util.ArrayList)27 ProcessorDTO (org.apache.nifi.web.api.dto.ProcessorDTO)26 HashMap (java.util.HashMap)24 ConnectableDTO (org.apache.nifi.web.api.dto.ConnectableDTO)22 Map (java.util.Map)21 Set (java.util.Set)20 List (java.util.List)18 Collectors (java.util.stream.Collectors)18 TemplateDTO (org.apache.nifi.web.api.dto.TemplateDTO)18 RemoteProcessGroupDTO (org.apache.nifi.web.api.dto.RemoteProcessGroupDTO)17 Logger (org.slf4j.Logger)17 LoggerFactory (org.slf4j.LoggerFactory)17 RemoteProcessGroupPortDTO (org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO)15 Collection (java.util.Collection)14 Optional (java.util.Optional)14 PortEntity (org.apache.nifi.web.api.entity.PortEntity)14