Search in sources :

Example 11 with RemoteGroupPort

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

the class RemoteProcessGroupAuditor method auditUpdateProcessGroupInputPortConfiguration.

/**
 * Audits the update of remote process group input 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 updateRemoteProcessGroupInputPort(java.lang.String, org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO)) && " + "args(remoteProcessGroupId, remoteProcessGroupPortDto) && " + "target(remoteProcessGroupDAO)")
public RemoteGroupPort auditUpdateProcessGroupInputPortConfiguration(ProceedingJoinPoint proceedingJoinPoint, String remoteProcessGroupId, RemoteProcessGroupPortDTO remoteProcessGroupPortDto, RemoteProcessGroupDAO remoteProcessGroupDAO) throws Throwable {
    final RemoteProcessGroup remoteProcessGroup = remoteProcessGroupDAO.getRemoteProcessGroup(remoteProcessGroupId);
    final RemoteGroupPort remoteProcessGroupPort = remoteProcessGroup.getInputPort(remoteProcessGroupPortDto.getId());
    return auditUpdateProcessGroupPortConfiguration(proceedingJoinPoint, remoteProcessGroupPortDto, remoteProcessGroup, remoteProcessGroupPort);
}
Also used : RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) Around(org.aspectj.lang.annotation.Around)

Example 12 with RemoteGroupPort

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

the class TestStandardRemoteProcessGroupDAO method testVerifyUpdateInputPort.

@Test
public void testVerifyUpdateInputPort() {
    final StandardRemoteProcessGroupDAO dao = new StandardRemoteProcessGroupDAO();
    final String remoteProcessGroupId = "remote-process-group-id";
    final String remoteProcessGroupInputPortId = "remote-process-group-input-port-id";
    final FlowController flowController = mock(FlowController.class);
    final ProcessGroup processGroup = mock(ProcessGroup.class);
    final RemoteProcessGroup remoteProcessGroup = mock(RemoteProcessGroup.class);
    final RemoteGroupPort remoteGroupPort = mock(RemoteGroupPort.class);
    dao.setFlowController(flowController);
    when(flowController.getGroup(any())).thenReturn(processGroup);
    when(processGroup.findRemoteProcessGroup(eq(remoteProcessGroupId))).thenReturn(remoteProcessGroup);
    when(remoteProcessGroup.getInputPort(remoteProcessGroupInputPortId)).thenReturn(remoteGroupPort);
    when(remoteGroupPort.getName()).thenReturn("remote-group-port");
    final RemoteProcessGroupPortDTO dto = new RemoteProcessGroupPortDTO();
    dto.setGroupId(remoteProcessGroupId);
    dto.setId(remoteProcessGroupInputPortId);
    dto.setTargetId(remoteProcessGroupInputPortId);
    final BatchSettingsDTO batchSettings = new BatchSettingsDTO();
    dto.setBatchSettings(batchSettings);
    // Empty input values should pass validation.
    dao.verifyUpdateInputPort(remoteProcessGroupId, dto);
    // Concurrent tasks
    dto.setConcurrentlySchedulableTaskCount(0);
    validate(dao, dto, "Concurrent tasks", "positive integer");
    dto.setConcurrentlySchedulableTaskCount(2);
    validate(dao, dto);
    // Batch count
    batchSettings.setCount(-1);
    validate(dao, dto, "Batch count", "positive integer");
    batchSettings.setCount(0);
    validate(dao, dto);
    batchSettings.setCount(1000);
    validate(dao, dto);
    // Batch size
    batchSettings.setSize("AB");
    validate(dao, dto, "Batch size", "Data Size");
    batchSettings.setSize("10 days");
    validate(dao, dto, "Batch size", "Data Size");
    batchSettings.setSize("300MB");
    validate(dao, dto);
    // Batch duration
    batchSettings.setDuration("AB");
    validate(dao, dto, "Batch duration", "Time Unit");
    batchSettings.setDuration("10 KB");
    validate(dao, dto, "Batch duration", "Time Unit");
    batchSettings.setDuration("10 secs");
    validate(dao, dto);
}
Also used : BatchSettingsDTO(org.apache.nifi.web.api.dto.BatchSettingsDTO) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) ProcessGroup(org.apache.nifi.groups.ProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) FlowController(org.apache.nifi.controller.FlowController) RemoteProcessGroupPortDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO) Test(org.junit.Test)

Example 13 with RemoteGroupPort

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

the class TestRemoteProcessGroupAuditor method defaultRemoteGroupPort.

private RemoteGroupPort defaultRemoteGroupPort() {
    final RemoteGroupPort existingRPGPort = mock(RemoteGroupPort.class);
    when(existingRPGPort.isRunning()).thenReturn(false);
    when(existingRPGPort.getMaxConcurrentTasks()).thenReturn(1);
    when(existingRPGPort.isUseCompression()).thenReturn(false);
    return existingRPGPort;
}
Also used : RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort)

Example 14 with RemoteGroupPort

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

the class TestRemoteProcessGroupAuditor method testConfigurePortBatchSettings.

@Test
public void testConfigurePortBatchSettings() throws Throwable {
    final RemoteGroupPort existingRPGPort = defaultRemoteGroupPort();
    when(existingRPGPort.getName()).thenReturn("input-port-1");
    final RemoteProcessGroupPortDTO inputRPGPortDTO = defaultRemoteProcessGroupPortDTO();
    final BatchSettingsDTO batchSettingsDTO = new BatchSettingsDTO();
    batchSettingsDTO.setCount(1234);
    batchSettingsDTO.setSize("64KB");
    batchSettingsDTO.setDuration("10sec");
    inputRPGPortDTO.setBatchSettings(batchSettingsDTO);
    final Collection<Action> actions = updateProcessGroupInputPortConfiguration(inputRPGPortDTO, existingRPGPort);
    assertEquals(3, actions.size());
    final Iterator<Action> iterator = actions.iterator();
    Action action = iterator.next();
    assertEquals(Operation.Configure, action.getOperation());
    assertConfigureDetails(action.getActionDetails(), "input-port-1.Batch Count", "0", "1234");
    action = iterator.next();
    assertEquals(Operation.Configure, action.getOperation());
    assertConfigureDetails(action.getActionDetails(), "input-port-1.Batch Size", "", "64KB");
    action = iterator.next();
    assertEquals(Operation.Configure, action.getOperation());
    assertConfigureDetails(action.getActionDetails(), "input-port-1.Batch Duration", "", "10sec");
}
Also used : BatchSettingsDTO(org.apache.nifi.web.api.dto.BatchSettingsDTO) Action(org.apache.nifi.action.Action) RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) RemoteProcessGroupPortDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO) Test(org.junit.Test)

Example 15 with RemoteGroupPort

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

the class TestRemoteProcessGroupAuditor method testDisablePort.

@Test
public void testDisablePort() throws Throwable {
    final RemoteGroupPort existingRPGPort = defaultRemoteGroupPort();
    when(existingRPGPort.getName()).thenReturn("input-port-1");
    when(existingRPGPort.isRunning()).thenReturn(true);
    final RemoteProcessGroupPortDTO inputRPGPortDTO = defaultRemoteProcessGroupPortDTO();
    inputRPGPortDTO.setTransmitting(false);
    final Collection<Action> actions = updateProcessGroupInputPortConfiguration(inputRPGPortDTO, existingRPGPort);
    assertEquals(1, actions.size());
    final Action action = actions.iterator().next();
    assertEquals(Operation.Configure, action.getOperation());
    assertConfigureDetails(action.getActionDetails(), "input-port-1.Transmission", "enabled", "disabled");
}
Also used : Action(org.apache.nifi.action.Action) RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) RemoteProcessGroupPortDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO) Test(org.junit.Test)

Aggregations

RemoteGroupPort (org.apache.nifi.remote.RemoteGroupPort)41 RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)22 ProcessGroup (org.apache.nifi.groups.ProcessGroup)11 ArrayList (java.util.ArrayList)9 Connectable (org.apache.nifi.connectable.Connectable)9 Action (org.apache.nifi.action.Action)8 Port (org.apache.nifi.connectable.Port)8 Connection (org.apache.nifi.connectable.Connection)7 RootGroupPort (org.apache.nifi.remote.RootGroupPort)7 RemoteProcessGroupPortDTO (org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO)7 Test (org.junit.Test)7 HashSet (java.util.HashSet)6 Funnel (org.apache.nifi.connectable.Funnel)6 Authorizable (org.apache.nifi.authorization.resource.Authorizable)5 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)5 ResourceNotFoundException (org.apache.nifi.web.ResourceNotFoundException)5 Collection (java.util.Collection)4 Position (org.apache.nifi.connectable.Position)4 Element (org.w3c.dom.Element)4 IOException (java.io.IOException)3