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);
}
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);
}
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;
}
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");
}
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");
}
Aggregations