use of org.apache.nifi.remote.RemoteGroupPort in project nifi by apache.
the class StandardProcessGroupDAO method scheduleComponents.
@Override
public Future<Void> scheduleComponents(final String groupId, final ScheduledState state, final Set<String> componentIds) {
final ProcessGroup group = locateProcessGroup(flowController, groupId);
CompletableFuture<Void> future = CompletableFuture.completedFuture(null);
for (final String componentId : componentIds) {
final Connectable connectable = group.findLocalConnectable(componentId);
if (ScheduledState.RUNNING.equals(state)) {
switch(connectable.getConnectableType()) {
case PROCESSOR:
final CompletableFuture<?> processorFuture = connectable.getProcessGroup().startProcessor((ProcessorNode) connectable, true);
future = CompletableFuture.allOf(future, processorFuture);
break;
case INPUT_PORT:
connectable.getProcessGroup().startInputPort((Port) connectable);
break;
case OUTPUT_PORT:
connectable.getProcessGroup().startOutputPort((Port) connectable);
break;
case REMOTE_INPUT_PORT:
case REMOTE_OUTPUT_PORT:
final RemoteGroupPort remotePort = group.findRemoteGroupPort(componentId);
remotePort.getRemoteProcessGroup().startTransmitting(remotePort);
break;
}
} else {
switch(connectable.getConnectableType()) {
case PROCESSOR:
final CompletableFuture<?> processorFuture = connectable.getProcessGroup().stopProcessor((ProcessorNode) connectable);
future = CompletableFuture.allOf(future, processorFuture);
break;
case INPUT_PORT:
connectable.getProcessGroup().stopInputPort((Port) connectable);
break;
case OUTPUT_PORT:
connectable.getProcessGroup().stopOutputPort((Port) connectable);
break;
case REMOTE_INPUT_PORT:
case REMOTE_OUTPUT_PORT:
final RemoteGroupPort remotePort = group.findRemoteGroupPort(componentId);
remotePort.getRemoteProcessGroup().stopTransmitting(remotePort);
break;
}
}
}
return future;
}
use of org.apache.nifi.remote.RemoteGroupPort in project nifi by apache.
the class StandardRemoteProcessGroupDAO method updateRemoteProcessGroupInputPort.
@Override
public RemoteGroupPort updateRemoteProcessGroupInputPort(String remoteProcessGroupId, RemoteProcessGroupPortDTO remoteProcessGroupPortDto) {
final RemoteProcessGroup remoteProcessGroup = locateRemoteProcessGroup(remoteProcessGroupId);
final RemoteGroupPort port = remoteProcessGroup.getInputPort(remoteProcessGroupPortDto.getId());
if (port == null) {
throw new ResourceNotFoundException(String.format("Unable to find remote process group input port with id '%s'.", remoteProcessGroupPortDto.getId()));
}
// verify the update
verifyUpdatePort(port, remoteProcessGroupPortDto);
// perform the update
updatePort(port, remoteProcessGroupPortDto, remoteProcessGroup);
remoteProcessGroup.getProcessGroup().onComponentModified();
return port;
}
use of org.apache.nifi.remote.RemoteGroupPort in project nifi by apache.
the class FingerprintFactoryTest method testRemotePortFingerprint.
@Test
public void testRemotePortFingerprint() throws Exception {
// Fill out every configuration.
final RemoteProcessGroup groupComponent = mock(RemoteProcessGroup.class);
when(groupComponent.getName()).thenReturn("name");
when(groupComponent.getIdentifier()).thenReturn("id");
when(groupComponent.getPosition()).thenReturn(new Position(10.5, 20.3));
when(groupComponent.getTargetUri()).thenReturn("http://node1:8080/nifi");
when(groupComponent.getTransportProtocol()).thenReturn(SiteToSiteTransportProtocol.RAW);
when(groupComponent.getVersionedComponentId()).thenReturn(Optional.empty());
final RemoteGroupPort portComponent = mock(RemoteGroupPort.class);
when(groupComponent.getInputPorts()).thenReturn(Collections.singleton(portComponent));
when(portComponent.getName()).thenReturn("portName");
when(portComponent.getIdentifier()).thenReturn("portId");
when(portComponent.getPosition()).thenReturn(new Position(10.5, 20.3));
when(portComponent.getComments()).thenReturn("portComment");
when(portComponent.getScheduledState()).thenReturn(ScheduledState.RUNNING);
when(portComponent.getMaxConcurrentTasks()).thenReturn(3);
when(portComponent.isUseCompression()).thenReturn(true);
when(portComponent.getBatchCount()).thenReturn(1234);
when(portComponent.getBatchSize()).thenReturn("64KB");
when(portComponent.getBatchDuration()).thenReturn("10sec");
// Serializer doesn't serialize if a port doesn't have any connection.
when(portComponent.hasIncomingConnection()).thenReturn(true);
when(portComponent.getVersionedComponentId()).thenReturn(Optional.empty());
// Assert fingerprints with expected one.
final String expected = "portId" + "NO_VALUE" + "NO_VALUE" + "3" + "true" + "1234" + "64KB" + "10sec";
final Element rootElement = serializeElement(encryptor, RemoteProcessGroup.class, groupComponent, "addRemoteProcessGroup", IDENTITY_LOOKUP);
final Element componentElement = (Element) rootElement.getElementsByTagName("inputPort").item(0);
assertEquals(expected, fingerprint("addRemoteGroupPortFingerprint", Element.class, componentElement));
}
use of org.apache.nifi.remote.RemoteGroupPort in project nifi by apache.
the class RelationshipAuditor method determineConnectableType.
/**
* Determines the type of component the specified connectable is.
*/
private Component determineConnectableType(Connectable connectable) {
String sourceId = connectable.getIdentifier();
Component componentType = Component.Controller;
if (connectable instanceof ProcessorNode) {
componentType = Component.Processor;
} else if (connectable instanceof RemoteGroupPort) {
final RemoteGroupPort remoteGroupPort = (RemoteGroupPort) connectable;
if (TransferDirection.RECEIVE.equals(remoteGroupPort.getTransferDirection())) {
if (remoteGroupPort.getRemoteProcessGroup() == null) {
componentType = Component.InputPort;
} else {
componentType = Component.OutputPort;
}
} else {
if (remoteGroupPort.getRemoteProcessGroup() == null) {
componentType = Component.OutputPort;
} else {
componentType = Component.InputPort;
}
}
} else if (connectable instanceof Port) {
ProcessGroup processGroup = connectable.getProcessGroup();
if (processGroup.getInputPort(sourceId) != null) {
componentType = Component.InputPort;
} else if (processGroup.getOutputPort(sourceId) != null) {
componentType = Component.OutputPort;
}
} else if (connectable instanceof Funnel) {
componentType = Component.Funnel;
}
return componentType;
}
use of org.apache.nifi.remote.RemoteGroupPort in project nifi by apache.
the class RemoteProcessGroupAuditor method auditUpdateProcessGroupOutputPortConfiguration.
/**
* Audits the update of remote process group output port configuration.
*
* @param proceedingJoinPoint join point
* @param remoteProcessGroupPortDto dto
* @param remoteProcessGroupDAO dao
* @return group
* @throws Throwable ex
*/
@Around("within(org.apache.nifi.web.dao.RemoteProcessGroupDAO+) && " + "execution(org.apache.nifi.remote.RemoteGroupPort updateRemoteProcessGroupOutputPort(java.lang.String, org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO)) && " + "args(remoteProcessGroupId, remoteProcessGroupPortDto) && " + "target(remoteProcessGroupDAO)")
public RemoteGroupPort auditUpdateProcessGroupOutputPortConfiguration(ProceedingJoinPoint proceedingJoinPoint, String remoteProcessGroupId, RemoteProcessGroupPortDTO remoteProcessGroupPortDto, RemoteProcessGroupDAO remoteProcessGroupDAO) throws Throwable {
final RemoteProcessGroup remoteProcessGroup = remoteProcessGroupDAO.getRemoteProcessGroup(remoteProcessGroupId);
final RemoteGroupPort remoteProcessGroupPort = remoteProcessGroup.getOutputPort(remoteProcessGroupPortDto.getId());
return auditUpdateProcessGroupPortConfiguration(proceedingJoinPoint, remoteProcessGroupPortDto, remoteProcessGroup, remoteProcessGroupPort);
}
Aggregations