use of org.apache.nifi.groups.RemoteProcessGroup in project nifi by apache.
the class SnippetAuditor method updateSnippetAdvice.
/**
* Audits a bulk move.
*
* @param proceedingJoinPoint join point
* @param snippetDTO dto
* @param snippetDAO dao
* @return snippet
* @throws Throwable ex
*/
@Around("within(org.apache.nifi.web.dao.SnippetDAO+) && " + "execution(org.apache.nifi.controller.Snippet updateSnippetComponents(org.apache.nifi.web.api.dto.SnippetDTO)) && " + "args(snippetDTO) && " + "target(snippetDAO)")
public Snippet updateSnippetAdvice(ProceedingJoinPoint proceedingJoinPoint, SnippetDTO snippetDTO, SnippetDAO snippetDAO) throws Throwable {
// get the snippet before removing it
Snippet snippet = snippetDAO.getSnippet(snippetDTO.getId());
final String previousGroupId = snippet.getParentGroupId();
// perform the underlying operation
snippet = (Snippet) proceedingJoinPoint.proceed();
// if this snippet is linked and its parent group id has changed
final String groupId = snippetDTO.getParentGroupId();
if (!previousGroupId.equals(groupId)) {
// create move audit records for all items in this snippet
final Collection<Action> actions = new ArrayList<>();
for (String id : snippet.getProcessors().keySet()) {
final ProcessorNode processor = processorDAO.getProcessor(id);
final Action action = processorAuditor.generateAuditRecord(processor, Operation.Move, createMoveDetails(previousGroupId, groupId, logger));
if (action != null) {
actions.add(action);
}
}
for (String id : snippet.getFunnels().keySet()) {
final Funnel funnel = funnelDAO.getFunnel(id);
final Action action = funnelAuditor.generateAuditRecord(funnel, Operation.Move, createMoveDetails(previousGroupId, groupId, logger));
if (action != null) {
actions.add(action);
}
}
for (String id : snippet.getInputPorts().keySet()) {
final Port port = inputPortDAO.getPort(id);
final Action action = portAuditor.generateAuditRecord(port, Operation.Move, createMoveDetails(previousGroupId, groupId, logger));
if (action != null) {
actions.add(action);
}
}
for (String id : snippet.getOutputPorts().keySet()) {
final Port port = outputPortDAO.getPort(id);
final Action action = portAuditor.generateAuditRecord(port, Operation.Move, createMoveDetails(previousGroupId, groupId, logger));
if (action != null) {
actions.add(action);
}
}
for (String id : snippet.getRemoteProcessGroups().keySet()) {
final RemoteProcessGroup remoteProcessGroup = remoteProcessGroupDAO.getRemoteProcessGroup(id);
final Action action = remoteProcessGroupAuditor.generateAuditRecord(remoteProcessGroup, Operation.Move, createMoveDetails(previousGroupId, groupId, logger));
if (action != null) {
actions.add(action);
}
}
for (String id : snippet.getProcessGroups().keySet()) {
final ProcessGroupDAO processGroupDAO = getProcessGroupDAO();
final ProcessGroup processGroup = processGroupDAO.getProcessGroup(id);
final Action action = processGroupAuditor.generateAuditRecord(processGroup, Operation.Move, createMoveDetails(previousGroupId, groupId, logger));
if (action != null) {
actions.add(action);
}
}
for (String id : snippet.getConnections().keySet()) {
final Connection connection = connectionDAO.getConnection(id);
final Action action = relationshipAuditor.generateAuditRecordForConnection(connection, Operation.Move, createMoveDetails(previousGroupId, groupId, logger));
if (action != null) {
actions.add(action);
}
}
// save the actions
if (CollectionUtils.isNotEmpty(actions)) {
saveActions(actions, logger);
}
}
return snippet;
}
use of org.apache.nifi.groups.RemoteProcessGroup 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.groups.RemoteProcessGroup in project nifi by apache.
the class TestRemoteProcessGroupAuditor method testConfigureProxyPasswordClear.
@Test
public void testConfigureProxyPasswordClear() throws Throwable {
final RemoteProcessGroup existingRPG = defaultRemoteProcessGroup();
when(existingRPG.getProxyPassword()).thenReturn("proxy-password");
final RemoteProcessGroupDTO inputRPGDTO = defaultInput();
inputRPGDTO.setProxyPassword(null);
final Collection<Action> actions = updateProcessGroupConfiguration(inputRPGDTO, existingRPG);
assertEquals(1, actions.size());
final Action action = actions.iterator().next();
assertEquals(Operation.Configure, action.getOperation());
assertConfigureDetails(action.getActionDetails(), "Proxy Password", SENSITIVE_VALUE_MASK, "");
}
use of org.apache.nifi.groups.RemoteProcessGroup in project nifi by apache.
the class TestRemoteProcessGroupAuditor method testConfigureProxyPort.
@Test
public void testConfigureProxyPort() throws Throwable {
final RemoteProcessGroup existingRPG = defaultRemoteProcessGroup();
final RemoteProcessGroupDTO inputRPGDTO = defaultInput();
inputRPGDTO.setProxyPort(3128);
final Collection<Action> actions = updateProcessGroupConfiguration(inputRPGDTO, existingRPG);
assertEquals(1, actions.size());
final Action action = actions.iterator().next();
assertEquals(Operation.Configure, action.getOperation());
assertConfigureDetails(action.getActionDetails(), "Proxy Port", existingRPG.getProxyPort(), inputRPGDTO.getProxyPort());
}
use of org.apache.nifi.groups.RemoteProcessGroup in project nifi by apache.
the class TestRemoteProcessGroupAuditor method testConfigureTransportProtocol.
@Test
public void testConfigureTransportProtocol() throws Throwable {
final RemoteProcessGroup existingRPG = defaultRemoteProcessGroup();
when(existingRPG.getTransportProtocol()).thenReturn(SiteToSiteTransportProtocol.RAW);
final RemoteProcessGroupDTO inputRPGDTO = defaultInput();
inputRPGDTO.setTransportProtocol("HTTP");
final Collection<Action> actions = updateProcessGroupConfiguration(inputRPGDTO, existingRPG);
assertEquals(1, actions.size());
final Action action = actions.iterator().next();
assertEquals(Operation.Configure, action.getOperation());
assertConfigureDetails(action.getActionDetails(), "Transport Protocol", existingRPG.getTransportProtocol().name(), inputRPGDTO.getTransportProtocol());
}
Aggregations