Search in sources :

Example 31 with RemoteProcessGroup

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;
}
Also used : Funnel(org.apache.nifi.connectable.Funnel) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) FlowChangeAction(org.apache.nifi.action.FlowChangeAction) Action(org.apache.nifi.action.Action) ProcessorNode(org.apache.nifi.controller.ProcessorNode) ProcessGroupDAO(org.apache.nifi.web.dao.ProcessGroupDAO) RemoteProcessGroupDAO(org.apache.nifi.web.dao.RemoteProcessGroupDAO) Port(org.apache.nifi.connectable.Port) ArrayList(java.util.ArrayList) ProcessGroup(org.apache.nifi.groups.ProcessGroup) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) Connection(org.apache.nifi.connectable.Connection) Snippet(org.apache.nifi.controller.Snippet) Around(org.aspectj.lang.annotation.Around)

Example 32 with RemoteProcessGroup

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);
}
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 33 with RemoteProcessGroup

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, "");
}
Also used : RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) Action(org.apache.nifi.action.Action) RemoteProcessGroupDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupDTO) Test(org.junit.Test)

Example 34 with RemoteProcessGroup

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());
}
Also used : RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) Action(org.apache.nifi.action.Action) RemoteProcessGroupDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupDTO) Test(org.junit.Test)

Example 35 with RemoteProcessGroup

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());
}
Also used : RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) Action(org.apache.nifi.action.Action) RemoteProcessGroupDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupDTO) Test(org.junit.Test)

Aggregations

RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)74 ProcessGroup (org.apache.nifi.groups.ProcessGroup)32 RemoteGroupPort (org.apache.nifi.remote.RemoteGroupPort)31 Action (org.apache.nifi.action.Action)27 RemoteProcessGroupDTO (org.apache.nifi.web.api.dto.RemoteProcessGroupDTO)26 ArrayList (java.util.ArrayList)20 Connection (org.apache.nifi.connectable.Connection)20 Port (org.apache.nifi.connectable.Port)19 Test (org.junit.Test)18 HashSet (java.util.HashSet)16 RootGroupPort (org.apache.nifi.remote.RootGroupPort)16 Funnel (org.apache.nifi.connectable.Funnel)15 Connectable (org.apache.nifi.connectable.Connectable)14 ProcessorNode (org.apache.nifi.controller.ProcessorNode)14 Label (org.apache.nifi.controller.label.Label)13 ControllerServiceNode (org.apache.nifi.controller.service.ControllerServiceNode)13 Collection (java.util.Collection)11 HashMap (java.util.HashMap)10 Snippet (org.apache.nifi.controller.Snippet)10 ProcessGroupStatus (org.apache.nifi.controller.status.ProcessGroupStatus)10