org.apache.nifi.connectable.ConnectableType Java Examples
The following examples show how to use
org.apache.nifi.connectable.ConnectableType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NiFiRegistryFlowMapperTest.java From nifi with Apache License 2.0 | 6 votes |
private Connection prepareConnection(final ProcessorNode sourceProcessorNode, final ProcessorNode destProcessorNode, final ProcessGroup processGroup) { final Connection connection = mock(Connection.class); when(connection.getIdentifier()).thenReturn(UUID.randomUUID().toString()); when(connection.getProcessGroup()).thenReturn(processGroup); when(connection.getBendPoints()).thenReturn(Lists.newArrayList(new Position(counter++, counter++))); when(connection.getRelationships()).thenReturn(Lists.newArrayList()); final FlowFileQueue flowFileQueue = mock(FlowFileQueue.class); when(connection.getFlowFileQueue()).thenReturn(flowFileQueue); when(flowFileQueue.getPriorities()).thenReturn(Collections.emptyList()); when(flowFileQueue.getLoadBalanceStrategy()).thenReturn(LoadBalanceStrategy.DO_NOT_LOAD_BALANCE); when(flowFileQueue.getLoadBalanceCompression()).thenReturn(LoadBalanceCompression.DO_NOT_COMPRESS); when(sourceProcessorNode.getConnectableType()).thenReturn(ConnectableType.PROCESSOR); when(connection.getSource()).thenReturn(sourceProcessorNode); when(destProcessorNode.getConnectableType()).thenReturn(ConnectableType.PROCESSOR); when(connection.getDestination()).thenReturn(destProcessorNode); return connection; }
Example #2
Source File: StandardRemoteGroupPort.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override public boolean isValid() { if (!targetExists.get()) { return false; } if (getConnectableType() == ConnectableType.REMOTE_OUTPUT_PORT && getConnections(Relationship.ANONYMOUS).isEmpty()) { // if it's an output port, ensure that there is an outbound connection return false; } final boolean groupValid = remoteGroup.validate().stream() .allMatch(result -> result.isValid()); return groupValid; }
Example #3
Source File: StandardRemoteGroupPort.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override public Collection<ValidationResult> getValidationErrors() { final Collection<ValidationResult> validationErrors = new ArrayList<>(); if (getScheduledState() == ScheduledState.STOPPED) { ValidationResult error = null; if (!targetExists.get()) { error = new ValidationResult.Builder() .explanation(String.format("Remote instance indicates that port '%s' no longer exists.", getName())) .subject(String.format("Remote port '%s'", getName())) .valid(false) .build(); } else if (getConnectableType() == ConnectableType.REMOTE_OUTPUT_PORT && getConnections(Relationship.ANONYMOUS).isEmpty()) { error = new ValidationResult.Builder() .explanation(String.format("Port '%s' has no outbound connections", getName())) .subject(String.format("Remote port '%s'", getName())) .valid(false) .build(); } if (error != null) { validationErrors.add(error); } } return validationErrors; }
Example #4
Source File: StandardRemoteGroupPort.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override public void verifyCanStart() { super.verifyCanStart(); if (getConnectableType() == ConnectableType.REMOTE_INPUT_PORT && getIncomingConnections().isEmpty()) { throw new IllegalStateException("Port " + getName() + " has no incoming connections"); } final Optional<ValidationResult> resultOption = remoteGroup.validate().stream() .filter(result -> !result.isValid()) .findFirst(); if (resultOption.isPresent()) { throw new IllegalStateException("Remote Process Group is not valid: " + resultOption.get().toString()); } }
Example #5
Source File: ConnectableTask.java From nifi with Apache License 2.0 | 6 votes |
/** * Make sure processor has work to do. This means that it meets one of these criteria: * <ol> * <li>It is a Funnel and has incoming FlowFiles from other components, and and at least one outgoing connection.</li> * <li>It is a 'source' component, meaning:<ul> * <li>It is annotated with @TriggerWhenEmpty</li> * <li>It has no incoming connections</li> * <li>All incoming connections are self-loops</li> * </ul></li> * <li>It has data in incoming connections to process</li> * </ol> * @return true if there is work to do, otherwise false */ private boolean isWorkToDo() { boolean hasNonLoopConnection = Connectables.hasNonLoopConnection(connectable); if (connectable.getConnectableType() == ConnectableType.FUNNEL) { // Handle Funnel as a special case because it will never be a 'source' component, // and also its outgoing connections can not be terminated. // Incoming FlowFiles from other components, and at least one outgoing connection are required. return connectable.hasIncomingConnection() && hasNonLoopConnection && !connectable.getConnections().isEmpty() && Connectables.flowFilesQueued(connectable); } final boolean isSourceComponent = connectable.isTriggerWhenEmpty() // No input connections || !connectable.hasIncomingConnection() // Every incoming connection loops back to itself, no inputs from other components || !hasNonLoopConnection; // If it is not a 'source' component, it requires a FlowFile to process. return isSourceComponent || Connectables.flowFilesQueued(connectable); }
Example #6
Source File: AbstractPort.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override public void setName(final String name) { if (this.name.get().equals(name)) { return; } final ProcessGroup parentGroup = this.processGroup.get(); if (getConnectableType() == ConnectableType.INPUT_PORT) { if (parentGroup.getInputPortByName(name) != null) { throw new IllegalStateException("The requested new port name is not available"); } } else if (getConnectableType() == ConnectableType.OUTPUT_PORT) { if (parentGroup.getOutputPortByName(name) != null) { throw new IllegalStateException("The requested new port name is not available"); } } this.name.set(name); }
Example #7
Source File: SnippetAuditor.java From nifi with Apache License 2.0 | 6 votes |
/** * Determines the type of component the specified connectable is. */ private Component determineConnectableType(ConnectableDTO connectable) { Component component = Component.Controller; final String connectableType = connectable.getType(); if (ConnectableType.PROCESSOR.name().equals(connectableType)) { component = Component.Processor; } else if (ConnectableType.INPUT_PORT.name().equals(connectableType)) { component = Component.InputPort; } else if (ConnectableType.OUTPUT_PORT.name().equals(connectableType)) { component = Component.OutputPort; } else if (ConnectableType.FUNNEL.name().equals(connectableType)) { component = Component.Funnel; } else { component = Component.RemoteProcessGroup; } return component; }
Example #8
Source File: TestStandardPublicPort.java From nifi with Apache License 2.0 | 6 votes |
private PublicPort createPublicPort(NiFiProperties nifiProperties) { final BulletinRepository bulletinRepository = mock(BulletinRepository.class); final ProcessScheduler processScheduler = null; final Authorizer authorizer = mock(Authorizer.class); doAnswer(invocation -> { final AuthorizationRequest request = invocation.getArgument(0); if ("[email protected]".equals(request.getIdentity())) { return AuthorizationResult.approved(); } else if ("[email protected]".equals(request.getIdentity())) { return AuthorizationResult.approved(); } return AuthorizationResult.denied(); }).when(authorizer).authorize(any(AuthorizationRequest.class)); final ProcessGroup processGroup = mock(ProcessGroup.class); doReturn("process-group-id").when(processGroup).getIdentifier(); final StandardPublicPort port = new StandardPublicPort("id", "name", TransferDirection.SEND, ConnectableType.INPUT_PORT, authorizer, bulletinRepository, processScheduler, true, nifiProperties.getBoredYieldDuration(), IdentityMappingUtil.getIdentityMappings(nifiProperties)); port.setProcessGroup(processGroup); return port; }
Example #9
Source File: DtoFactory.java From localization_nifi with Apache License 2.0 | 6 votes |
public RemoteProcessGroupPortDTO createRemoteProcessGroupPortDto(final RemoteGroupPort port) { if (port == null) { return null; } final RemoteProcessGroupPortDTO dto = new RemoteProcessGroupPortDTO(); dto.setId(port.getIdentifier()); dto.setName(port.getName()); dto.setComments(port.getComments()); dto.setTransmitting(port.isRunning()); dto.setTargetRunning(port.isTargetRunning()); dto.setConcurrentlySchedulableTaskCount(port.getMaxConcurrentTasks()); dto.setUseCompression(port.isUseCompression()); dto.setExists(port.getTargetExists()); // determine if this port is currently connected to another component locally if (ConnectableType.REMOTE_OUTPUT_PORT.equals(port.getConnectableType())) { dto.setConnected(!port.getConnections().isEmpty()); } else { dto.setConnected(port.hasIncomingConnection()); } return dto; }
Example #10
Source File: StandardRemoteGroupPort.java From nifi with Apache License 2.0 | 6 votes |
@Override public void verifyCanStart() { super.verifyCanStart(); if (getConnectableType() == ConnectableType.REMOTE_INPUT_PORT && getIncomingConnections().isEmpty()) { throw new IllegalStateException("Port " + getName() + " has no incoming connections"); } final Optional<ValidationResult> resultOption = remoteGroup.validate().stream() .filter(result -> !result.isValid()) .findFirst(); if (resultOption.isPresent()) { throw new IllegalStateException("Remote Process Group is not valid: " + resultOption.get().toString()); } }
Example #11
Source File: AbstractPort.java From nifi with Apache License 2.0 | 6 votes |
@Override public void setName(final String name) { if (this.name.get().equals(name)) { return; } final ProcessGroup parentGroup = this.processGroup.get(); if (getConnectableType() == ConnectableType.INPUT_PORT) { if (parentGroup.getInputPortByName(name) != null) { throw new IllegalStateException("A port with the same name already exists."); } } else if (getConnectableType() == ConnectableType.OUTPUT_PORT) { if (parentGroup.getOutputPortByName(name) != null) { throw new IllegalStateException("A port with the same name already exists."); } } this.name.set(name); }
Example #12
Source File: AbstractPort.java From nifi with Apache License 2.0 | 6 votes |
public AbstractPort(final String id, final String name, final ConnectableType type, final ProcessScheduler scheduler) { this.id = requireNonNull(id); this.name = new AtomicReference<>(requireNonNull(name)); position = new AtomicReference<>(new Position(0D, 0D)); outgoingConnections = new HashSet<>(); incomingConnections = new ArrayList<>(); comments = new AtomicReference<>(); lossTolerant = new AtomicBoolean(false); concurrentTaskCount = new AtomicInteger(1); processScheduler = scheduler; final List<Relationship> relationshipList = new ArrayList<>(); relationshipList.add(PORT_RELATIONSHIP); relationships = Collections.unmodifiableList(relationshipList); this.type = type; penalizationPeriod = new AtomicReference<>("30 sec"); yieldPeriod = new AtomicReference<>("1 sec"); yieldExpiration = new AtomicLong(0L); schedulingPeriod = new AtomicReference<>("0 millis"); schedulingNanos = new AtomicLong(MINIMUM_SCHEDULING_NANOS); scheduledState = new AtomicReference<>(ScheduledState.STOPPED); }
Example #13
Source File: NiFiRegConnectionSchemaFunction.java From nifi-minifi with Apache License 2.0 | 6 votes |
@Override public ConnectionSchema apply(final VersionedConnection versionedConnection) { Map<String, Object> map = new HashMap<>(); map.put(ID_KEY, versionedConnection.getIdentifier()); map.put(NAME_KEY, versionedConnection.getName()); map.put(ConnectionSchema.SOURCE_ID_KEY, versionedConnection.getSource().getId()); Set<String> selectedRelationships = nullToEmpty(versionedConnection.getSelectedRelationships()); map.put(ConnectionSchema.SOURCE_RELATIONSHIP_NAMES_KEY, selectedRelationships.stream().sorted().collect(Collectors.toList())); map.put(ConnectionSchema.DESTINATION_ID_KEY, versionedConnection.getDestination().getId()); map.put(ConnectionSchema.MAX_WORK_QUEUE_SIZE_KEY, versionedConnection.getBackPressureObjectThreshold()); map.put(ConnectionSchema.MAX_WORK_QUEUE_DATA_SIZE_KEY, versionedConnection.getBackPressureDataSizeThreshold()); map.put(ConnectionSchema.FLOWFILE_EXPIRATION__KEY, versionedConnection.getFlowFileExpiration()); List<String> queuePrioritizers = nullToEmpty(versionedConnection.getPrioritizers()); if (queuePrioritizers.size() > 0) { map.put(ConnectionSchema.QUEUE_PRIORITIZER_CLASS_KEY, queuePrioritizers.get(0)); } ConnectionSchema connectionSchema = new ConnectionSchema(map); if (ConnectableType.FUNNEL.name().equals(versionedConnection.getSource().getType())) { connectionSchema.addValidationIssue("Connection " + versionedConnection.getName() + " has type " + ConnectableType.FUNNEL.name() + " which is not supported by MiNiFi"); } if (queuePrioritizers.size() > 1) { connectionSchema.addValidationIssue(ConnectionSchema.QUEUE_PRIORITIZER_CLASS_KEY, CONNECTIONS_KEY, " has more than one queue prioritizer"); } return connectionSchema; }
Example #14
Source File: ConnectionSchemaFunction.java From nifi-minifi with Apache License 2.0 | 6 votes |
@Override public ConnectionSchema apply(ConnectionDTO connectionDTO) { Map<String, Object> map = new HashMap<>(); map.put(ID_KEY, connectionDTO.getId()); map.put(NAME_KEY, connectionDTO.getName()); map.put(ConnectionSchema.SOURCE_ID_KEY, connectionDTO.getSource().getId()); Set<String> selectedRelationships = nullToEmpty(connectionDTO.getSelectedRelationships()); map.put(ConnectionSchema.SOURCE_RELATIONSHIP_NAMES_KEY, selectedRelationships.stream().sorted().collect(Collectors.toList())); map.put(ConnectionSchema.DESTINATION_ID_KEY, connectionDTO.getDestination().getId()); map.put(ConnectionSchema.MAX_WORK_QUEUE_SIZE_KEY, connectionDTO.getBackPressureObjectThreshold()); map.put(ConnectionSchema.MAX_WORK_QUEUE_DATA_SIZE_KEY, connectionDTO.getBackPressureDataSizeThreshold()); map.put(ConnectionSchema.FLOWFILE_EXPIRATION__KEY, connectionDTO.getFlowFileExpiration()); List<String> queuePrioritizers = nullToEmpty(connectionDTO.getPrioritizers()); if (queuePrioritizers.size() > 0) { map.put(ConnectionSchema.QUEUE_PRIORITIZER_CLASS_KEY, queuePrioritizers.get(0)); } ConnectionSchema connectionSchema = new ConnectionSchema(map); if (ConnectableType.FUNNEL.name().equals(connectionDTO.getSource().getType())) { connectionSchema.addValidationIssue("Connection " + connectionDTO.getName() + " has type " + ConnectableType.FUNNEL.name() + " which is not supported by MiNiFi"); } if (queuePrioritizers.size() > 1) { connectionSchema.addValidationIssue(ConnectionSchema.QUEUE_PRIORITIZER_CLASS_KEY, CONNECTIONS_KEY, " has more than one queue prioritizer"); } return connectionSchema; }
Example #15
Source File: StandardProcessGroupDAO.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override public void scheduleComponents(final String groupId, final ScheduledState state, final Set<String> componentIds) { final ProcessGroup group = locateProcessGroup(flowController, groupId); for (final String componentId : componentIds) { final Connectable connectable = group.findLocalConnectable(componentId); if (ScheduledState.RUNNING.equals(state)) { if (ConnectableType.PROCESSOR.equals(connectable.getConnectableType())) { connectable.getProcessGroup().startProcessor((ProcessorNode) connectable); } else if (ConnectableType.INPUT_PORT.equals(connectable.getConnectableType())) { connectable.getProcessGroup().startInputPort((Port) connectable); } else if (ConnectableType.OUTPUT_PORT.equals(connectable.getConnectableType())) { connectable.getProcessGroup().startOutputPort((Port) connectable); } } else { if (ConnectableType.PROCESSOR.equals(connectable.getConnectableType())) { connectable.getProcessGroup().stopProcessor((ProcessorNode) connectable); } else if (ConnectableType.INPUT_PORT.equals(connectable.getConnectableType())) { connectable.getProcessGroup().stopInputPort((Port) connectable); } else if (ConnectableType.OUTPUT_PORT.equals(connectable.getConnectableType())) { connectable.getProcessGroup().stopOutputPort((Port) connectable); } } } }
Example #16
Source File: StandardRemoteProcessGroup.java From localization_nifi with Apache License 2.0 | 6 votes |
/** * Adds an InputPort to this ProcessGroup that is described by the given * DTO. * * @param descriptor port descriptor * * @throws IllegalStateException if an Input Port already exists with the ID * given by the ID of the DTO. */ private void addInputPort(final RemoteProcessGroupPortDescriptor descriptor) { writeLock.lock(); try { if (inputPorts.containsKey(descriptor.getId())) { throw new IllegalStateException("Input Port with ID " + descriptor.getId() + " already exists"); } final StandardRemoteGroupPort port = new StandardRemoteGroupPort(descriptor.getId(), descriptor.getName(), getProcessGroup(), this, TransferDirection.SEND, ConnectableType.REMOTE_INPUT_PORT, sslContext, scheduler, nifiProperties); if (descriptor.getConcurrentlySchedulableTaskCount() != null) { port.setMaxConcurrentTasks(descriptor.getConcurrentlySchedulableTaskCount()); } if (descriptor.getUseCompression() != null) { port.setUseCompression(descriptor.getUseCompression()); } inputPorts.put(descriptor.getId(), port); } finally { writeLock.unlock(); } }
Example #17
Source File: StandardRemoteGroupPort.java From nifi with Apache License 2.0 | 6 votes |
@Override public Collection<ValidationResult> getValidationErrors() { final Collection<ValidationResult> validationErrors = new ArrayList<>(); if (getScheduledState() == ScheduledState.STOPPED) { ValidationResult error = null; if (!targetExists.get()) { error = new ValidationResult.Builder() .explanation(String.format("Remote instance indicates that port '%s' no longer exists.", getName())) .subject(String.format("Remote port '%s'", getName())) .valid(false) .build(); } else if (getConnectableType() == ConnectableType.REMOTE_OUTPUT_PORT && getConnections(Relationship.ANONYMOUS).isEmpty()) { error = new ValidationResult.Builder() .explanation(String.format("Port '%s' has no outbound connections", getName())) .subject(String.format("Remote port '%s'", getName())) .valid(false) .build(); } if (error != null) { validationErrors.add(error); } } return validationErrors; }
Example #18
Source File: StandardRemoteProcessGroup.java From localization_nifi with Apache License 2.0 | 6 votes |
/** * Adds an Output Port to this Remote Process Group that is described by * this DTO. * * @param descriptor * * @throws IllegalStateException if an Output Port already exists with the * ID given by dto.getId() */ private void addOutputPort(final RemoteProcessGroupPortDescriptor descriptor) { writeLock.lock(); try { if (outputPorts.containsKey(requireNonNull(descriptor).getId())) { throw new IllegalStateException("Output Port with ID " + descriptor.getId() + " already exists"); } final StandardRemoteGroupPort port = new StandardRemoteGroupPort(descriptor.getId(), descriptor.getName(), getProcessGroup(), this, TransferDirection.RECEIVE, ConnectableType.REMOTE_OUTPUT_PORT, sslContext, scheduler, nifiProperties); outputPorts.put(descriptor.getId(), port); if (descriptor.getConcurrentlySchedulableTaskCount() != null) { port.setMaxConcurrentTasks(descriptor.getConcurrentlySchedulableTaskCount()); } if (descriptor.getUseCompression() != null) { port.setUseCompression(descriptor.getUseCompression()); } } finally { writeLock.unlock(); } }
Example #19
Source File: TestStandardRootGroupPort.java From localization_nifi with Apache License 2.0 | 6 votes |
private RootGroupPort createRootGroupPort(NiFiProperties nifiProperties) { final BulletinRepository bulletinRepository = mock(BulletinRepository.class); final ProcessScheduler processScheduler = null; final Authorizer authorizer = mock(Authorizer.class); doAnswer(invocation -> { final AuthorizationRequest request = invocation.getArgumentAt(0, AuthorizationRequest.class); if ("[email protected]".equals(request.getIdentity())) { return AuthorizationResult.approved(); } return AuthorizationResult.denied(); }).when(authorizer).authorize(any(AuthorizationRequest.class)); final ProcessGroup processGroup = mock(ProcessGroup.class); doReturn("process-group-id").when(processGroup).getIdentifier(); return new StandardRootGroupPort("id", "name", processGroup, TransferDirection.SEND, ConnectableType.INPUT_PORT, authorizer, bulletinRepository, processScheduler, true, nifiProperties); }
Example #20
Source File: StandardPublicPort.java From nifi with Apache License 2.0 | 5 votes |
public StandardPublicPort(final String id, final String name, final TransferDirection direction, final ConnectableType type, final Authorizer authorizer, final BulletinRepository bulletinRepository, final ProcessScheduler scheduler, final boolean secure, final String yieldPeriod, final List<IdentityMapping> identityMappings) { super(id, name, type, scheduler); setScheduldingPeriod(MINIMUM_SCHEDULING_NANOS + " nanos"); this.authorizer = authorizer; this.secure = secure; this.identityMappings = identityMappings; this.bulletinRepository = bulletinRepository; this.scheduler = scheduler; this.direction = direction; setYieldPeriod(yieldPeriod); eventReporter = new EventReporter() { private static final long serialVersionUID = 1L; @Override public void reportEvent(final Severity severity, final String category, final String message) { final String groupId = StandardPublicPort.this.getProcessGroup().getIdentifier(); final String groupName = StandardPublicPort.this.getProcessGroup().getName(); final String sourceId = StandardPublicPort.this.getIdentifier(); final String sourceName = StandardPublicPort.this.getName(); final ComponentType componentType = direction == TransferDirection.RECEIVE ? ComponentType.INPUT_PORT : ComponentType.OUTPUT_PORT; bulletinRepository.addBulletin(BulletinFactory.createBulletin(groupId, groupName, sourceId, componentType, sourceName, category, severity.name(), message)); } }; relationships = direction == TransferDirection.RECEIVE ? Collections.singleton(AbstractPort.PORT_RELATIONSHIP) : Collections.emptySet(); }
Example #21
Source File: StandardFlowManager.java From nifi with Apache License 2.0 | 5 votes |
public Port createPublicInputPort(String id, String name) { id = requireNonNull(id).intern(); name = requireNonNull(name).intern(); verifyPortIdDoesNotExist(id); return new StandardPublicPort(id, name, TransferDirection.RECEIVE, ConnectableType.INPUT_PORT, authorizer, bulletinRepository, processScheduler, isSiteToSiteSecure, nifiProperties.getBoredYieldDuration(), IdentityMappingUtil.getIdentityMappings(nifiProperties)); }
Example #22
Source File: StandardConnectionDAO.java From nifi with Apache License 2.0 | 5 votes |
private void verifyUpdate(final Connection connection, final ConnectionDTO connectionDTO) { // determine what the request is attempting if (isAnyNotNull(connectionDTO.getBackPressureDataSizeThreshold(), connectionDTO.getBackPressureObjectThreshold(), connectionDTO.getDestination(), connectionDTO.getFlowFileExpiration(), connectionDTO.getName(), connectionDTO.getPosition(), connectionDTO.getPrioritizers(), connectionDTO.getSelectedRelationships())) { // validate the incoming request final List<String> validationErrors = validateProposedConfiguration(connection.getProcessGroup().getIdentifier(), connectionDTO); // ensure there was no validation errors if (!validationErrors.isEmpty()) { throw new ValidationException(validationErrors); } // If destination is changing, ensure that current destination is not running. This check is done here, rather than // in the Connection object itself because the Connection object itself does not know which updates are to occur and // we don't want to prevent updating things like the connection name or backpressure just because the destination is running final Connectable destination = connection.getDestination(); if (destination != null && destination.isRunning() && destination.getConnectableType() != ConnectableType.FUNNEL && destination.getConnectableType() != ConnectableType.INPUT_PORT) { throw new ValidationException(Collections.singletonList("Cannot change the destination of connection because the current destination is running")); } // verify that this connection supports modification connection.verifyCanUpdate(); } }
Example #23
Source File: ConnectableTypeParameter.java From nifi with Apache License 2.0 | 5 votes |
public ConnectableTypeParameter(String rawConnectionType) { try { type = ConnectableType.valueOf(rawConnectionType.toUpperCase()); } catch (IllegalArgumentException pe) { throw new IllegalArgumentException(String.format(INVALID_CONNECTABLE_TYPE_MESSAGE, rawConnectionType)); } }
Example #24
Source File: StandardRemoteGroupPort.java From nifi with Apache License 2.0 | 5 votes |
public StandardRemoteGroupPort(final String id, final String targetId, final String name, final RemoteProcessGroup remoteGroup, final TransferDirection direction, final ConnectableType type, final SSLContext sslContext, final ProcessScheduler scheduler, final NiFiProperties nifiProperties) { // remote group port id needs to be unique but cannot just be the id of the port // in the remote group instance. this supports referencing the same remote // instance more than once. super(id, name, type, scheduler); this.targetId = targetId; this.remoteGroup = remoteGroup; this.transferDirection = direction; this.sslContext = sslContext; setScheduldingPeriod(MINIMUM_SCHEDULING_NANOS + " nanos"); }
Example #25
Source File: StandardFlowManager.java From nifi with Apache License 2.0 | 5 votes |
public Port createPublicOutputPort(String id, String name) { id = requireNonNull(id).intern(); name = requireNonNull(name).intern(); verifyPortIdDoesNotExist(id); return new StandardPublicPort(id, name, TransferDirection.SEND, ConnectableType.OUTPUT_PORT, authorizer, bulletinRepository, processScheduler, isSiteToSiteSecure, nifiProperties.getBoredYieldDuration(), IdentityMappingUtil.getIdentityMappings(nifiProperties)); }
Example #26
Source File: RepositoryContext.java From nifi with Apache License 2.0 | 5 votes |
private boolean isTriggerWhenAnyDestinationAvailable() { if (connectable.getConnectableType() != ConnectableType.PROCESSOR) { return false; } final ProcessorNode procNode = (ProcessorNode) connectable; return procNode.isTriggerWhenAnyDestinationAvailable(); }
Example #27
Source File: StandardRemoteProcessGroup.java From nifi with Apache License 2.0 | 5 votes |
/** * Adds an Output Port to this Remote Process Group that is described by * this DTO. * * @param descriptor the RPG port descriptor * @throws IllegalStateException if an Output Port already exists with the * ID given by dto.getId() */ private StandardRemoteGroupPort addOutputPort(final RemoteProcessGroupPortDescriptor descriptor) { writeLock.lock(); try { if (outputPorts.containsKey(requireNonNull(descriptor).getId())) { throw new IllegalStateException("Output Port with ID " + descriptor.getId() + " already exists"); } final StandardRemoteGroupPort port = new StandardRemoteGroupPort(descriptor.getId(), descriptor.getTargetId(), descriptor.getName(), this, TransferDirection.RECEIVE, ConnectableType.REMOTE_OUTPUT_PORT, sslContext, scheduler, nifiProperties); port.setProcessGroup(getProcessGroup()); outputPorts.put(descriptor.getId(), port); if (descriptor.getConcurrentlySchedulableTaskCount() != null) { port.setMaxConcurrentTasks(descriptor.getConcurrentlySchedulableTaskCount()); } if (descriptor.getUseCompression() != null) { port.setUseCompression(descriptor.getUseCompression()); } if (descriptor.getBatchCount() != null && descriptor.getBatchCount() > 0) { port.setBatchCount(descriptor.getBatchCount()); } if (!StringUtils.isBlank(descriptor.getBatchSize())) { port.setBatchSize(descriptor.getBatchSize()); } if (!StringUtils.isBlank(descriptor.getBatchDuration())) { port.setBatchDuration(descriptor.getBatchDuration()); } port.setVersionedComponentId(descriptor.getVersionedComponentId()); return port; } finally { writeLock.unlock(); } }
Example #28
Source File: ProcessContext.java From localization_nifi with Apache License 2.0 | 5 votes |
private boolean isTriggerWhenAnyDestinationAvailable() { if (connectable.getConnectableType() != ConnectableType.PROCESSOR) { return false; } final ProcessorNode procNode = (ProcessorNode) connectable; return procNode.isTriggerWhenAnyDestinationAvailable(); }
Example #29
Source File: TestStandardRemoteGroupPort.java From nifi with Apache License 2.0 | 5 votes |
private void setupMock(final SiteToSiteTransportProtocol protocol, final TransferDirection direction, final SiteToSiteClientConfig siteToSiteClientConfig) throws Exception { processGroup = null; remoteGroup = mock(RemoteProcessGroup.class); scheduler = null; siteToSiteClient = mock(SiteToSiteClient.class); this.transaction = mock(Transaction.class); eventReporter = mock(EventReporter.class); final ConnectableType connectableType; switch (direction) { case SEND: connectableType = ConnectableType.REMOTE_INPUT_PORT; break; case RECEIVE: connectableType = ConnectableType.OUTPUT_PORT; break; default: connectableType = null; break; } port = spy(new StandardRemoteGroupPort(ID, ID, NAME, remoteGroup, direction, connectableType, null, scheduler, new StandardNiFiProperties())); doReturn(true).when(remoteGroup).isTransmitting(); doReturn(protocol).when(remoteGroup).getTransportProtocol(); doReturn(REMOTE_CLUSTER_URL).when(remoteGroup).getTargetUri(); doReturn(siteToSiteClient).when(port).getSiteToSiteClient(); doReturn(transaction).when(siteToSiteClient).createTransaction(eq(direction)); doReturn(siteToSiteClientConfig).when(siteToSiteClient).getConfig(); doReturn(eventReporter).when(remoteGroup).getEventReporter(); }
Example #30
Source File: StandardRemoteProcessGroup.java From nifi with Apache License 2.0 | 5 votes |
/** * Adds an InputPort to this ProcessGroup that is described by the given * DTO. * * @param descriptor port descriptor * @throws IllegalStateException if an Input Port already exists with the ID * given by the ID of the DTO. */ private StandardRemoteGroupPort addInputPort(final RemoteProcessGroupPortDescriptor descriptor) { writeLock.lock(); try { if (inputPorts.containsKey(descriptor.getId())) { throw new IllegalStateException("Input Port with ID " + descriptor.getId() + " already exists"); } // We need to generate the port's UUID deterministically because we need // all nodes in a cluster to use the same UUID. However, we want the ID to be // unique for each Remote Group Port, so that if we have multiple RPG's pointing // to the same target, we have unique ID's for each of those ports. final StandardRemoteGroupPort port = new StandardRemoteGroupPort(descriptor.getId(), descriptor.getTargetId(), descriptor.getName(), this, TransferDirection.SEND, ConnectableType.REMOTE_INPUT_PORT, sslContext, scheduler, nifiProperties); port.setProcessGroup(getProcessGroup()); if (descriptor.getConcurrentlySchedulableTaskCount() != null) { port.setMaxConcurrentTasks(descriptor.getConcurrentlySchedulableTaskCount()); } if (descriptor.getUseCompression() != null) { port.setUseCompression(descriptor.getUseCompression()); } if (descriptor.getBatchCount() != null && descriptor.getBatchCount() > 0) { port.setBatchCount(descriptor.getBatchCount()); } if (!StringUtils.isBlank(descriptor.getBatchSize())) { port.setBatchSize(descriptor.getBatchSize()); } if (!StringUtils.isBlank(descriptor.getBatchDuration())) { port.setBatchDuration(descriptor.getBatchDuration()); } port.setVersionedComponentId(descriptor.getVersionedComponentId()); inputPorts.put(descriptor.getId(), port); return port; } finally { writeLock.unlock(); } }