Search in sources :

Example 1 with RootGroupPort

use of org.apache.nifi.remote.RootGroupPort in project nifi by apache.

the class StandardNiFiServiceFacade method getSiteToSiteDetails.

@Override
public ControllerDTO getSiteToSiteDetails() {
    final NiFiUser user = NiFiUserUtils.getNiFiUser();
    if (user == null) {
        throw new WebApplicationException(new Throwable("Unable to access details for current user."));
    }
    // serialize the input ports this NiFi has access to
    final Set<PortDTO> inputPortDtos = new LinkedHashSet<>();
    final Set<RootGroupPort> inputPorts = controllerFacade.getInputPorts();
    for (final RootGroupPort inputPort : inputPorts) {
        if (isUserAuthorized(user, inputPort)) {
            final PortDTO dto = new PortDTO();
            dto.setId(inputPort.getIdentifier());
            dto.setName(inputPort.getName());
            dto.setComments(inputPort.getComments());
            dto.setState(inputPort.getScheduledState().toString());
            inputPortDtos.add(dto);
        }
    }
    // serialize the output ports this NiFi has access to
    final Set<PortDTO> outputPortDtos = new LinkedHashSet<>();
    for (final RootGroupPort outputPort : controllerFacade.getOutputPorts()) {
        if (isUserAuthorized(user, outputPort)) {
            final PortDTO dto = new PortDTO();
            dto.setId(outputPort.getIdentifier());
            dto.setName(outputPort.getName());
            dto.setComments(outputPort.getComments());
            dto.setState(outputPort.getScheduledState().toString());
            outputPortDtos.add(dto);
        }
    }
    // get the root group
    final ProcessGroup rootGroup = processGroupDAO.getProcessGroup(controllerFacade.getRootGroupId());
    final ProcessGroupCounts counts = rootGroup.getCounts();
    // create the controller dto
    final ControllerDTO controllerDTO = new ControllerDTO();
    controllerDTO.setId(controllerFacade.getRootGroupId());
    controllerDTO.setInstanceId(controllerFacade.getInstanceId());
    controllerDTO.setName(controllerFacade.getName());
    controllerDTO.setComments(controllerFacade.getComments());
    controllerDTO.setInputPorts(inputPortDtos);
    controllerDTO.setOutputPorts(outputPortDtos);
    controllerDTO.setInputPortCount(inputPortDtos.size());
    controllerDTO.setOutputPortCount(outputPortDtos.size());
    controllerDTO.setRunningCount(counts.getRunningCount());
    controllerDTO.setStoppedCount(counts.getStoppedCount());
    controllerDTO.setInvalidCount(counts.getInvalidCount());
    controllerDTO.setDisabledCount(counts.getDisabledCount());
    // determine the site to site configuration
    controllerDTO.setRemoteSiteListeningPort(controllerFacade.getRemoteSiteListeningPort());
    controllerDTO.setRemoteSiteHttpListeningPort(controllerFacade.getRemoteSiteListeningHttpPort());
    controllerDTO.setSiteToSiteSecure(controllerFacade.isRemoteSiteCommsSecure());
    return controllerDTO;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ProcessGroupCounts(org.apache.nifi.groups.ProcessGroupCounts) NiFiUser(org.apache.nifi.authorization.user.NiFiUser) WebApplicationException(javax.ws.rs.WebApplicationException) RootGroupPort(org.apache.nifi.remote.RootGroupPort) RemoteProcessGroupPortDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO) PortDTO(org.apache.nifi.web.api.dto.PortDTO) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup) InstantiatedVersionedProcessGroup(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedProcessGroup) ControllerDTO(org.apache.nifi.web.api.dto.ControllerDTO)

Example 2 with RootGroupPort

use of org.apache.nifi.remote.RootGroupPort in project nifi by apache.

the class ControllerFacade method getOutputPorts.

/**
 * Gets the output ports on the root group.
 *
 * @return output ports
 */
public Set<RootGroupPort> getOutputPorts() {
    final Set<RootGroupPort> outputPorts = new HashSet<>();
    ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId());
    for (final Port port : rootGroup.getOutputPorts()) {
        if (port instanceof RootGroupPort) {
            outputPorts.add((RootGroupPort) port);
        }
    }
    return outputPorts;
}
Also used : RootGroupPort(org.apache.nifi.remote.RootGroupPort) RootGroupPort(org.apache.nifi.remote.RootGroupPort) Port(org.apache.nifi.connectable.Port) RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup) HashSet(java.util.HashSet)

Example 3 with RootGroupPort

use of org.apache.nifi.remote.RootGroupPort in project nifi by apache.

the class ControllerFacade method getInputPorts.

/**
 * Gets the input ports on the root group.
 *
 * @return input ports
 */
public Set<RootGroupPort> getInputPorts() {
    final Set<RootGroupPort> inputPorts = new HashSet<>();
    ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId());
    for (final Port port : rootGroup.getInputPorts()) {
        if (port instanceof RootGroupPort) {
            inputPorts.add((RootGroupPort) port);
        }
    }
    return inputPorts;
}
Also used : RootGroupPort(org.apache.nifi.remote.RootGroupPort) RootGroupPort(org.apache.nifi.remote.RootGroupPort) Port(org.apache.nifi.connectable.Port) RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup) HashSet(java.util.HashSet)

Example 4 with RootGroupPort

use of org.apache.nifi.remote.RootGroupPort in project nifi by apache.

the class ControllerFacade method getResources.

public List<Resource> getResources() {
    final List<Resource> resources = new ArrayList<>();
    resources.add(ResourceFactory.getFlowResource());
    resources.add(ResourceFactory.getSystemResource());
    resources.add(ResourceFactory.getControllerResource());
    resources.add(ResourceFactory.getCountersResource());
    resources.add(ResourceFactory.getProvenanceResource());
    resources.add(ResourceFactory.getPoliciesResource());
    resources.add(ResourceFactory.getTenantResource());
    resources.add(ResourceFactory.getProxyResource());
    resources.add(ResourceFactory.getResourceResource());
    resources.add(ResourceFactory.getSiteToSiteResource());
    // restricted components
    resources.add(ResourceFactory.getRestrictedComponentsResource());
    Arrays.stream(RequiredPermission.values()).forEach(requiredPermission -> resources.add(ResourceFactory.getRestrictedComponentsResource(requiredPermission)));
    final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId());
    // include the root group
    final Resource rootResource = root.getResource();
    resources.add(rootResource);
    resources.add(ResourceFactory.getDataResource(rootResource));
    resources.add(ResourceFactory.getPolicyResource(rootResource));
    // add each processor
    for (final ProcessorNode processor : root.findAllProcessors()) {
        final Resource processorResource = processor.getResource();
        resources.add(processorResource);
        resources.add(ResourceFactory.getDataResource(processorResource));
        resources.add(ResourceFactory.getPolicyResource(processorResource));
    }
    // add each label
    for (final Label label : root.findAllLabels()) {
        final Resource labelResource = label.getResource();
        resources.add(labelResource);
        resources.add(ResourceFactory.getPolicyResource(labelResource));
    }
    // add each process group
    for (final ProcessGroup processGroup : root.findAllProcessGroups()) {
        final Resource processGroupResource = processGroup.getResource();
        resources.add(processGroupResource);
        resources.add(ResourceFactory.getDataResource(processGroupResource));
        resources.add(ResourceFactory.getPolicyResource(processGroupResource));
    }
    // add each remote process group
    for (final RemoteProcessGroup remoteProcessGroup : root.findAllRemoteProcessGroups()) {
        final Resource remoteProcessGroupResource = remoteProcessGroup.getResource();
        resources.add(remoteProcessGroupResource);
        resources.add(ResourceFactory.getDataResource(remoteProcessGroupResource));
        resources.add(ResourceFactory.getPolicyResource(remoteProcessGroupResource));
    }
    // add each input port
    for (final Port inputPort : root.findAllInputPorts()) {
        final Resource inputPortResource = inputPort.getResource();
        resources.add(inputPortResource);
        resources.add(ResourceFactory.getDataResource(inputPortResource));
        resources.add(ResourceFactory.getPolicyResource(inputPortResource));
        if (inputPort instanceof RootGroupPort) {
            resources.add(ResourceFactory.getDataTransferResource(inputPortResource));
        }
    }
    // add each output port
    for (final Port outputPort : root.findAllOutputPorts()) {
        final Resource outputPortResource = outputPort.getResource();
        resources.add(outputPortResource);
        resources.add(ResourceFactory.getDataResource(outputPortResource));
        resources.add(ResourceFactory.getPolicyResource(outputPortResource));
        if (outputPort instanceof RootGroupPort) {
            resources.add(ResourceFactory.getDataTransferResource(outputPortResource));
        }
    }
    // add each controller service
    final Consumer<ControllerServiceNode> csConsumer = controllerService -> {
        final Resource controllerServiceResource = controllerService.getResource();
        resources.add(controllerServiceResource);
        resources.add(ResourceFactory.getPolicyResource(controllerServiceResource));
    };
    flowController.getAllControllerServices().forEach(csConsumer);
    root.findAllControllerServices().forEach(csConsumer);
    // add each reporting task
    for (final ReportingTaskNode reportingTask : flowController.getAllReportingTasks()) {
        final Resource reportingTaskResource = reportingTask.getResource();
        resources.add(reportingTaskResource);
        resources.add(ResourceFactory.getPolicyResource(reportingTaskResource));
    }
    // add each template
    for (final Template template : root.findAllTemplates()) {
        final Resource templateResource = template.getResource();
        resources.add(templateResource);
        resources.add(ResourceFactory.getPolicyResource(templateResource));
    }
    return resources;
}
Also used : Bundle(org.apache.nifi.bundle.Bundle) Arrays(java.util.Arrays) SearchableFields(org.apache.nifi.provenance.SearchableFields) StringUtils(org.apache.commons.lang3.StringUtils) QueueSize(org.apache.nifi.controller.queue.QueueSize) ClassUtils(org.apache.commons.lang3.ClassUtils) ROOT_GROUP_ID_ALIAS(org.apache.nifi.controller.FlowController.ROOT_GROUP_ID_ALIAS) AuthorizationResult(org.apache.nifi.authorization.AuthorizationResult) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) Map(java.util.Map) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException) ProvenanceRepository(org.apache.nifi.provenance.ProvenanceRepository) RootGroupPort(org.apache.nifi.remote.RootGroupPort) Connectable(org.apache.nifi.connectable.Connectable) Connection(org.apache.nifi.connectable.Connection) ProcessorStatus(org.apache.nifi.controller.status.ProcessorStatus) FlowFilePrioritizer(org.apache.nifi.flowfile.FlowFilePrioritizer) ProcessGroupStatus(org.apache.nifi.controller.status.ProcessGroupStatus) Set(java.util.Set) FlowController(org.apache.nifi.controller.FlowController) VariableRegistry(org.apache.nifi.registry.VariableRegistry) AttributeDTO(org.apache.nifi.web.api.dto.provenance.AttributeDTO) ControllerService(org.apache.nifi.controller.ControllerService) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) WebApplicationException(javax.ws.rs.WebApplicationException) ExtensionManager(org.apache.nifi.nar.ExtensionManager) ConnectionStatus(org.apache.nifi.controller.status.ConnectionStatus) ComponentStatusRepository(org.apache.nifi.controller.status.history.ComponentStatusRepository) LineageRequestDTO(org.apache.nifi.web.api.dto.provenance.lineage.LineageRequestDTO) ProvenanceRequestDTO(org.apache.nifi.web.api.dto.provenance.ProvenanceRequestDTO) DtoFactory(org.apache.nifi.web.api.dto.DtoFactory) Resource(org.apache.nifi.authorization.Resource) Counter(org.apache.nifi.controller.Counter) ProvenanceEventDTO(org.apache.nifi.web.api.dto.provenance.ProvenanceEventDTO) AccessDeniedException(org.apache.nifi.authorization.AccessDeniedException) ControllerServiceEntity(org.apache.nifi.web.api.entity.ControllerServiceEntity) ConfigurableComponent(org.apache.nifi.components.ConfigurableComponent) CollectionUtils(org.apache.commons.collections4.CollectionUtils) TreeSet(java.util.TreeSet) LineageDTO(org.apache.nifi.web.api.dto.provenance.lineage.LineageDTO) ArrayList(java.util.ArrayList) ContentAvailability(org.apache.nifi.controller.ContentAvailability) NiFiUser(org.apache.nifi.authorization.user.NiFiUser) Relationship(org.apache.nifi.processor.Relationship) ProvenanceEventRecord(org.apache.nifi.provenance.ProvenanceEventRecord) ControllerServiceProvider(org.apache.nifi.controller.service.ControllerServiceProvider) ProcessGroupCounts(org.apache.nifi.groups.ProcessGroupCounts) ProvenanceDTO(org.apache.nifi.web.api.dto.provenance.ProvenanceDTO) Collator(java.text.Collator) DocumentedTypeDTO(org.apache.nifi.web.api.dto.DocumentedTypeDTO) ContentDirection(org.apache.nifi.controller.repository.claim.ContentDirection) RequestAction(org.apache.nifi.authorization.RequestAction) ProvenanceOptionsDTO(org.apache.nifi.web.api.dto.provenance.ProvenanceOptionsDTO) IOException(java.io.IOException) Authorizer(org.apache.nifi.authorization.Authorizer) NiFiProperties(org.apache.nifi.util.NiFiProperties) ReportingTask(org.apache.nifi.reporting.ReportingTask) CoreAttributes(org.apache.nifi.flowfile.attributes.CoreAttributes) NodeIdentifier(org.apache.nifi.cluster.protocol.NodeIdentifier) ProcessGroup(org.apache.nifi.groups.ProcessGroup) SortedSet(java.util.SortedSet) BundleCoordinate(org.apache.nifi.bundle.BundleCoordinate) Query(org.apache.nifi.provenance.search.Query) Date(java.util.Date) LoggerFactory(org.slf4j.LoggerFactory) Port(org.apache.nifi.connectable.Port) FlowService(org.apache.nifi.services.FlowService) BundleDTO(org.apache.nifi.web.api.dto.BundleDTO) ControllerStatusDTO(org.apache.nifi.web.api.dto.status.ControllerStatusDTO) Locale(java.util.Locale) SearchableField(org.apache.nifi.provenance.search.SearchableField) Template(org.apache.nifi.controller.Template) Label(org.apache.nifi.controller.label.Label) ProvenanceSearchableFieldDTO(org.apache.nifi.web.api.dto.provenance.ProvenanceSearchableFieldDTO) Authorizable(org.apache.nifi.authorization.resource.Authorizable) RequiredPermission(org.apache.nifi.components.RequiredPermission) TimeZone(java.util.TimeZone) Collection(java.util.Collection) BundleUtils(org.apache.nifi.util.BundleUtils) Collectors(java.util.stream.Collectors) ResourceFactory(org.apache.nifi.authorization.resource.ResourceFactory) Processor(org.apache.nifi.processor.Processor) SystemDiagnostics(org.apache.nifi.diagnostics.SystemDiagnostics) List(java.util.List) Result(org.apache.nifi.authorization.AuthorizationResult.Result) StatusHistoryDTO(org.apache.nifi.web.api.dto.status.StatusHistoryDTO) ProvenanceResultsDTO(org.apache.nifi.web.api.dto.provenance.ProvenanceResultsDTO) SearchTerms(org.apache.nifi.provenance.search.SearchTerms) ProcessorNode(org.apache.nifi.controller.ProcessorNode) ControllerServiceNode(org.apache.nifi.controller.service.ControllerServiceNode) HashMap(java.util.HashMap) Function(java.util.function.Function) HashSet(java.util.HashSet) QueryResult(org.apache.nifi.provenance.search.QueryResult) ReportingTaskNode(org.apache.nifi.controller.ReportingTaskNode) SearchTerm(org.apache.nifi.provenance.search.SearchTerm) QuerySubmission(org.apache.nifi.provenance.search.QuerySubmission) ContentNotFoundException(org.apache.nifi.controller.repository.ContentNotFoundException) Logger(org.slf4j.Logger) RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) ProcessorDiagnosticsDTO(org.apache.nifi.web.api.dto.diagnostics.ProcessorDiagnosticsDTO) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) RemoteProcessGroupStatus(org.apache.nifi.controller.status.RemoteProcessGroupStatus) NiFiCoreException(org.apache.nifi.web.NiFiCoreException) ComputeLineageSubmission(org.apache.nifi.provenance.lineage.ComputeLineageSubmission) FormatUtils(org.apache.nifi.util.FormatUtils) NiFiUserUtils(org.apache.nifi.authorization.user.NiFiUserUtils) PortStatus(org.apache.nifi.controller.status.PortStatus) SearchResultsDTO(org.apache.nifi.web.api.dto.search.SearchResultsDTO) BulletinRepository(org.apache.nifi.reporting.BulletinRepository) DownloadableContent(org.apache.nifi.web.DownloadableContent) LineageRequestType(org.apache.nifi.web.api.dto.provenance.lineage.LineageRequestDTO.LineageRequestType) Comparator(java.util.Comparator) Collections(java.util.Collections) InputStream(java.io.InputStream) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) RootGroupPort(org.apache.nifi.remote.RootGroupPort) RootGroupPort(org.apache.nifi.remote.RootGroupPort) Port(org.apache.nifi.connectable.Port) RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) Resource(org.apache.nifi.authorization.Resource) ArrayList(java.util.ArrayList) Label(org.apache.nifi.controller.label.Label) Template(org.apache.nifi.controller.Template) ProcessorNode(org.apache.nifi.controller.ProcessorNode) ControllerServiceNode(org.apache.nifi.controller.service.ControllerServiceNode) ReportingTaskNode(org.apache.nifi.controller.ReportingTaskNode) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup)

Example 5 with RootGroupPort

use of org.apache.nifi.remote.RootGroupPort in project nifi by apache.

the class AbstractFlowFileServerProtocol method checkPortStatus.

protected void checkPortStatus(final Peer peer, String portId) throws HandshakeException {
    Port receivedPort = rootGroup.getInputPort(portId);
    if (receivedPort == null) {
        receivedPort = rootGroup.getOutputPort(portId);
    }
    if (receivedPort == null) {
        logger.debug("Responding with ResponseCode UNKNOWN_PORT for identifier {}", portId);
        throw new HandshakeException(ResponseCode.UNKNOWN_PORT, "Received unknown port identifier: " + portId);
    }
    if (!(receivedPort instanceof RootGroupPort)) {
        logger.debug("Responding with ResponseCode UNKNOWN_PORT for identifier {}", portId);
        throw new HandshakeException(ResponseCode.UNKNOWN_PORT, "Received port identifier " + portId + ", but this Port is not a RootGroupPort");
    }
    this.port = (RootGroupPort) receivedPort;
    final PortAuthorizationResult portAuthResult = this.port.checkUserAuthorization(peer.getCommunicationsSession().getUserDn());
    if (!portAuthResult.isAuthorized()) {
        logger.debug("Responding with ResponseCode UNAUTHORIZED: ", portAuthResult.getExplanation());
        throw new HandshakeException(ResponseCode.UNAUTHORIZED, portAuthResult.getExplanation());
    }
    if (!receivedPort.isValid()) {
        logger.debug("Responding with ResponseCode PORT_NOT_IN_VALID_STATE for {}", receivedPort);
        throw new HandshakeException(ResponseCode.PORT_NOT_IN_VALID_STATE, "Port is not valid");
    }
    if (!receivedPort.isRunning()) {
        logger.debug("Responding with ResponseCode PORT_NOT_IN_VALID_STATE for {}", receivedPort);
        throw new HandshakeException(ResponseCode.PORT_NOT_IN_VALID_STATE, "Port not running");
    }
    // we we will simply not service the request but the sender will timeout
    if (getVersionNegotiator().getVersion() > 1) {
        for (final Connection connection : port.getConnections()) {
            if (connection.getFlowFileQueue().isFull()) {
                logger.debug("Responding with ResponseCode PORTS_DESTINATION_FULL for {}", port);
                throw new HandshakeException(ResponseCode.PORTS_DESTINATION_FULL, "Received port identifier " + portId + ", but its destination is full");
            }
        }
    }
}
Also used : RootGroupPort(org.apache.nifi.remote.RootGroupPort) Port(org.apache.nifi.connectable.Port) RootGroupPort(org.apache.nifi.remote.RootGroupPort) Connection(org.apache.nifi.connectable.Connection) HandshakeException(org.apache.nifi.remote.exception.HandshakeException) PortAuthorizationResult(org.apache.nifi.remote.PortAuthorizationResult)

Aggregations

RootGroupPort (org.apache.nifi.remote.RootGroupPort)21 Port (org.apache.nifi.connectable.Port)13 ProcessGroup (org.apache.nifi.groups.ProcessGroup)11 RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)8 ArrayList (java.util.ArrayList)7 HashSet (java.util.HashSet)7 Connection (org.apache.nifi.connectable.Connection)7 RemoteGroupPort (org.apache.nifi.remote.RemoteGroupPort)7 PortAuthorizationResult (org.apache.nifi.remote.PortAuthorizationResult)6 NiFiUser (org.apache.nifi.authorization.user.NiFiUser)5 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)5 Peer (org.apache.nifi.remote.Peer)5 Connectable (org.apache.nifi.connectable.Connectable)4 Funnel (org.apache.nifi.connectable.Funnel)4 Position (org.apache.nifi.connectable.Position)4 HttpServerCommunicationsSession (org.apache.nifi.remote.io.http.HttpServerCommunicationsSession)4 BundleCoordinate (org.apache.nifi.bundle.BundleCoordinate)3 ScheduledState (org.apache.nifi.controller.ScheduledState)3 Label (org.apache.nifi.controller.label.Label)3 ControllerServiceNode (org.apache.nifi.controller.service.ControllerServiceNode)3