Search in sources :

Example 1 with NifiComponentNotFoundException

use of com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException in project kylo by Teradata.

the class NifiConnectionOrderVisitor method fetchProcessGroupForNameAndIdentifier.

private ProcessGroupDTO fetchProcessGroupForNameAndIdentifier(String groupId) {
    // fetch it
    ProcessGroupDTO processGroupEntity = null;
    try {
        try {
            log.debug("fetchProcessGroup {} ", groupId);
            processGroupEntity = getGroup(groupId);
        } catch (NifiComponentNotFoundException e) {
            log.debug("Unable to find the process group " + groupId);
        }
    } catch (Exception e) {
        log.error("Exception fetching the process group " + groupId);
    }
    return processGroupEntity;
}
Also used : NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException) RemoteProcessGroupDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupDTO) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO) NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException)

Example 2 with NifiComponentNotFoundException

use of com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException in project kylo by Teradata.

the class NifiConnectionOrderVisitor method visitProcessGroup.

@Override
public void visitProcessGroup(NifiVisitableProcessGroup processGroup) {
    log.debug(" Visit Process Group: {}, ({}) ", processGroup.getDto().getName(), processGroup.getDto().getId());
    NifiVisitableProcessGroup group = visitedProcessGroups.get(processGroup.getDto().getId());
    if (group == null) {
        group = processGroup;
    }
    this.currentProcessGroup = group;
    if (processGroup.getParentProcessGroup() == null) {
        try {
            ProcessGroupDTO parent = fetchProcessGroupForNameAndIdentifier(processGroup.getDto().getParentGroupId());
            if (parent != null) {
                group.setParentProcessGroup(parent);
            }
        } catch (NifiComponentNotFoundException e) {
        // cant find the parent
        }
    }
    group.accept(this);
    this.visitedProcessGroups.put(group.getDto().getId(), group);
}
Also used : NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException) NifiVisitableProcessGroup(com.thinkbiganalytics.nifi.rest.model.visitor.NifiVisitableProcessGroup) RemoteProcessGroupDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupDTO) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO)

Example 3 with NifiComponentNotFoundException

use of com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException in project kylo by Teradata.

the class NifiConnectionOrderVisitor method searchConnectionMatchingSource.

private ConnectionDTO searchConnectionMatchingSource(String parentGroupId, String destinationId) {
    // search up to find the connection that matches this dest id
    try {
        ProcessGroupDTO parent = null;
        try {
            log.debug("fetch ProcessGroup for searchConnectionMatchingSource {} ", parentGroupId);
            parent = getGroup(parentGroupId);
        } catch (NifiComponentNotFoundException e) {
            log.debug("Exception searching Connection matching the source. Parent Group ID: " + parentGroupId + ", and destinationId of  " + destinationId);
        }
        if (parent != null) {
            // processGroup.getDto().setParent(parentParent.getProcessGroup());
            // get Contents of this parent
            NifiVisitableProcessGroup visitableProcessGroup = new NifiVisitableProcessGroup(parent);
            ConnectionDTO conn = visitableProcessGroup.getConnectionMatchingSourceId(destinationId);
            if (conn != null) {
                return conn;
            }
            if (conn == null && parent.getParentGroupId() != null) {
                return searchConnectionMatchingSource(parent.getParentGroupId(), destinationId);
            }
        }
    } catch (Exception e) {
        log.error("Exception searching Connection matching the source.  Parent Group ID: " + parentGroupId + ", and destinationId of  " + destinationId);
    }
    return null;
}
Also used : NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException) NifiVisitableProcessGroup(com.thinkbiganalytics.nifi.rest.model.visitor.NifiVisitableProcessGroup) ConnectionDTO(org.apache.nifi.web.api.dto.ConnectionDTO) RemoteProcessGroupDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupDTO) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO) NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException)

Example 4 with NifiComponentNotFoundException

use of com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException in project kylo by Teradata.

the class NiFiProcessGroupsRestClientV1 method instantiateTemplate.

@Nonnull
@Override
public FlowSnippetDTO instantiateTemplate(@Nonnull final String processGroupId, @Nonnull final String templateId) {
    final InstantiateTemplateRequestEntity entity = new InstantiateTemplateRequestEntity();
    entity.setOriginX(10.0);
    entity.setOriginY(10.0);
    entity.setTemplateId(templateId);
    try {
        final FlowEntity flow = client.post(BASE_PATH + processGroupId + "/template-instance", entity, FlowEntity.class);
        return toFlowSnippet(flow.getFlow(), true);
    } catch (final NotFoundException e) {
        throw new NifiComponentNotFoundException(processGroupId, NifiConstants.NIFI_COMPONENT_TYPE.PROCESS_GROUP, e);
    } catch (final ClientErrorException e) {
        final String msg = e.getResponse().readEntity(String.class);
        throw new NifiComponentNotFoundException("Unable to create Template instance for templateId: " + templateId + " under Process Group " + processGroupId + ". " + msg);
    }
}
Also used : NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException) NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException) NotFoundException(javax.ws.rs.NotFoundException) ClientErrorException(javax.ws.rs.ClientErrorException) InstantiateTemplateRequestEntity(org.apache.nifi.web.api.entity.InstantiateTemplateRequestEntity) ProcessGroupFlowEntity(org.apache.nifi.web.api.entity.ProcessGroupFlowEntity) FlowEntity(org.apache.nifi.web.api.entity.FlowEntity) Nonnull(javax.annotation.Nonnull)

Example 5 with NifiComponentNotFoundException

use of com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException in project kylo by Teradata.

the class NiFiProcessGroupsRestClientV1 method schedule.

@Override
public void schedule(@Nonnull final String processGroupId, @Nonnull final String parentGroupId, @Nonnull final NiFiComponentState state) {
    final ScheduleComponentsEntity entity = new ScheduleComponentsEntity();
    entity.setId(processGroupId);
    entity.setState(state.toString());
    try {
        client.put("/flow/process-groups/" + processGroupId, entity, ScheduleComponentsEntity.class);
    } catch (final NotFoundException e) {
        throw new NifiComponentNotFoundException(processGroupId, NifiConstants.NIFI_COMPONENT_TYPE.PROCESS_GROUP, e);
    }
}
Also used : NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException) ScheduleComponentsEntity(org.apache.nifi.web.api.entity.ScheduleComponentsEntity) NifiComponentNotFoundException(com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException) NotFoundException(javax.ws.rs.NotFoundException)

Aggregations

NifiComponentNotFoundException (com.thinkbiganalytics.nifi.rest.client.NifiComponentNotFoundException)22 Nonnull (javax.annotation.Nonnull)10 NotFoundException (javax.ws.rs.NotFoundException)10 ProcessGroupDTO (org.apache.nifi.web.api.dto.ProcessGroupDTO)10 ConnectionDTO (org.apache.nifi.web.api.dto.ConnectionDTO)6 RevisionDTO (org.apache.nifi.web.api.dto.RevisionDTO)6 HashMap (java.util.HashMap)5 RemoteProcessGroupDTO (org.apache.nifi.web.api.dto.RemoteProcessGroupDTO)5 PortEntity (org.apache.nifi.web.api.entity.PortEntity)5 NifiClientRuntimeException (com.thinkbiganalytics.nifi.rest.client.NifiClientRuntimeException)4 NifiVisitableProcessGroup (com.thinkbiganalytics.nifi.rest.model.visitor.NifiVisitableProcessGroup)4 LegacyNifiRestClient (com.thinkbiganalytics.nifi.rest.client.LegacyNifiRestClient)3 NifiProperty (com.thinkbiganalytics.nifi.rest.model.NifiProperty)3 NifiConstants (com.thinkbiganalytics.nifi.rest.support.NifiConstants)3 ArrayList (java.util.ArrayList)3 Collections (java.util.Collections)3 Iterables (com.google.common.collect.Iterables)2 ReusableTemplateConnectionInfo (com.thinkbiganalytics.feedmgr.rest.model.ReusableTemplateConnectionInfo)2 NifiPropertyUtil (com.thinkbiganalytics.nifi.rest.support.NifiPropertyUtil)2 HashSet (java.util.HashSet)2