Search in sources :

Example 1 with RemoteProcessGroupPortDTO

use of org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO in project nifi by apache.

the class StandardNiFiServiceFacade method updateRemoteProcessGroupOutputPort.

@Override
public RemoteProcessGroupPortEntity updateRemoteProcessGroupOutputPort(final Revision revision, final String remoteProcessGroupId, final RemoteProcessGroupPortDTO remoteProcessGroupPortDTO) {
    final RemoteProcessGroup remoteProcessGroupNode = remoteProcessGroupDAO.getRemoteProcessGroup(remoteProcessGroupPortDTO.getGroupId());
    final RevisionUpdate<RemoteProcessGroupPortDTO> snapshot = updateComponent(revision, remoteProcessGroupNode, () -> remoteProcessGroupDAO.updateRemoteProcessGroupOutputPort(remoteProcessGroupId, remoteProcessGroupPortDTO), remoteGroupPort -> dtoFactory.createRemoteProcessGroupPortDto(remoteGroupPort));
    final PermissionsDTO permissions = dtoFactory.createPermissionsDto(remoteProcessGroupNode);
    final RevisionDTO updatedRevision = dtoFactory.createRevisionDTO(snapshot.getLastModification());
    return entityFactory.createRemoteProcessGroupPortEntity(snapshot.getComponent(), updatedRevision, permissions);
}
Also used : RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) PermissionsDTO(org.apache.nifi.web.api.dto.PermissionsDTO) RemoteProcessGroupPortDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO) RevisionDTO(org.apache.nifi.web.api.dto.RevisionDTO)

Example 2 with RemoteProcessGroupPortDTO

use of org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO in project nifi by apache.

the class StandardNiFiServiceFacade method updateRemoteProcessGroupInputPort.

@Override
public RemoteProcessGroupPortEntity updateRemoteProcessGroupInputPort(final Revision revision, final String remoteProcessGroupId, final RemoteProcessGroupPortDTO remoteProcessGroupPortDTO) {
    final RemoteProcessGroup remoteProcessGroupNode = remoteProcessGroupDAO.getRemoteProcessGroup(remoteProcessGroupPortDTO.getGroupId());
    final RevisionUpdate<RemoteProcessGroupPortDTO> snapshot = updateComponent(revision, remoteProcessGroupNode, () -> remoteProcessGroupDAO.updateRemoteProcessGroupInputPort(remoteProcessGroupId, remoteProcessGroupPortDTO), remoteGroupPort -> dtoFactory.createRemoteProcessGroupPortDto(remoteGroupPort));
    final PermissionsDTO permissions = dtoFactory.createPermissionsDto(remoteProcessGroupNode);
    final RevisionDTO updatedRevision = dtoFactory.createRevisionDTO(snapshot.getLastModification());
    return entityFactory.createRemoteProcessGroupPortEntity(snapshot.getComponent(), updatedRevision, permissions);
}
Also used : RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) PermissionsDTO(org.apache.nifi.web.api.dto.PermissionsDTO) RemoteProcessGroupPortDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO) RevisionDTO(org.apache.nifi.web.api.dto.RevisionDTO)

Example 3 with RemoteProcessGroupPortDTO

use of org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO 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 4 with RemoteProcessGroupPortDTO

use of org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO 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 5 with RemoteProcessGroupPortDTO

use of org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO 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

RemoteProcessGroupPortDTO (org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO)19 Test (org.junit.Test)7 HashMap (java.util.HashMap)6 RemoteGroupPort (org.apache.nifi.remote.RemoteGroupPort)6 Action (org.apache.nifi.action.Action)5 RemoteProcessGroupContentsDTO (org.apache.nifi.web.api.dto.RemoteProcessGroupContentsDTO)5 RemoteProcessGroupDTO (org.apache.nifi.web.api.dto.RemoteProcessGroupDTO)5 HashSet (java.util.HashSet)4 RevisionDTO (org.apache.nifi.web.api.dto.RevisionDTO)4 Map (java.util.Map)3 Set (java.util.Set)3 RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)3 BatchSettingsDTO (org.apache.nifi.web.api.dto.BatchSettingsDTO)3 ConnectableDTO (org.apache.nifi.web.api.dto.ConnectableDTO)3 ConnectionDTO (org.apache.nifi.web.api.dto.ConnectionDTO)3 PortDTO (org.apache.nifi.web.api.dto.PortDTO)3 ProcessGroupDTO (org.apache.nifi.web.api.dto.ProcessGroupDTO)3 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 ArrayList (java.util.ArrayList)2