org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO Java Examples

The following examples show how to use org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestRemoteProcessGroupAuditor.java    From nifi with Apache License 2.0 6 votes vote down vote up
@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");

}
 
Example #2
Source File: TestRemoteProcessGroupAuditor.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Test
public void testConfigurePortCompression() throws Throwable {

    final RemoteGroupPort existingRPGPort = defaultRemoteGroupPort();
    when(existingRPGPort.getName()).thenReturn("input-port-1");

    final RemoteProcessGroupPortDTO inputRPGPortDTO = defaultRemoteProcessGroupPortDTO();
    inputRPGPortDTO.setUseCompression(true);

    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.Compressed", "false", "true");

}
 
Example #3
Source File: FlowController.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Converts a set of ports into a set of remote process group ports.
 *
 * @param ports ports
 * @return group descriptors
 */
private Set<RemoteProcessGroupPortDescriptor> convertRemotePort(final Set<RemoteProcessGroupPortDTO> ports) {
    Set<RemoteProcessGroupPortDescriptor> remotePorts = null;
    if (ports != null) {
        remotePorts = new LinkedHashSet<>(ports.size());
        for (final RemoteProcessGroupPortDTO port : ports) {
            final StandardRemoteProcessGroupPortDescriptor descriptor = new StandardRemoteProcessGroupPortDescriptor();
            descriptor.setId(port.getId());
            descriptor.setName(port.getName());
            descriptor.setComments(port.getComments());
            descriptor.setTargetRunning(port.isTargetRunning());
            descriptor.setConnected(port.isConnected());
            descriptor.setConcurrentlySchedulableTaskCount(port.getConcurrentlySchedulableTaskCount());
            descriptor.setTransmitting(port.isTransmitting());
            descriptor.setUseCompression(port.getUseCompression());
            remotePorts.add(descriptor);
        }
    }
    return remotePorts;
}
 
Example #4
Source File: StandardRemoteProcessGroupDAO.java    From nifi with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param port Port instance to be updated.
 * @param remoteProcessGroupPortDto DTO containing updated remote process group port settings.
 * @param remoteProcessGroup If remoteProcessGroupPortDto has updated isTransmitting input,
 *                           this method will start or stop the port in this remoteProcessGroup as necessary.
 */
private void updatePort(RemoteGroupPort port, RemoteProcessGroupPortDTO remoteProcessGroupPortDto, RemoteProcessGroup remoteProcessGroup) {
    if (isNotNull(remoteProcessGroupPortDto.getConcurrentlySchedulableTaskCount())) {
        port.setMaxConcurrentTasks(remoteProcessGroupPortDto.getConcurrentlySchedulableTaskCount());
    }
    if (isNotNull(remoteProcessGroupPortDto.getUseCompression())) {
        port.setUseCompression(remoteProcessGroupPortDto.getUseCompression());
    }

    final BatchSettingsDTO batchSettingsDTO = remoteProcessGroupPortDto.getBatchSettings();
    if (isNotNull(batchSettingsDTO)) {
        port.setBatchCount(batchSettingsDTO.getCount());
        port.setBatchSize(batchSettingsDTO.getSize());
        port.setBatchDuration(batchSettingsDTO.getDuration());
    }

    final Boolean isTransmitting = remoteProcessGroupPortDto.isTransmitting();
    if (isNotNull(isTransmitting)) {
        // start or stop as necessary
        if (!port.isRunning() && isTransmitting) {
            remoteProcessGroup.startTransmitting(port);
        } else if (port.isRunning() && !isTransmitting) {
            remoteProcessGroup.stopTransmitting(port);
        }
    }
}
 
Example #5
Source File: StandardRemoteProcessGroupDAO.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public RemoteGroupPort updateRemoteProcessGroupOutputPort(String remoteProcessGroupId, RemoteProcessGroupPortDTO remoteProcessGroupPortDto) {
    final RemoteProcessGroup remoteProcessGroup = locateRemoteProcessGroup(remoteProcessGroupId);
    final RemoteGroupPort port = remoteProcessGroup.getOutputPort(remoteProcessGroupPortDto.getId());

    if (port == null) {
        throw new ResourceNotFoundException(
                String.format("Unable to find remote process group output port with id '%s'.", remoteProcessGroupId));
    }

    // verify the update
    verifyUpdatePort(port, remoteProcessGroupPortDto);

    // perform the update
    updatePort(port, remoteProcessGroupPortDto, remoteProcessGroup);
    remoteProcessGroup.getProcessGroup().onComponentModified();

    return port;
}
 
Example #6
Source File: StandardRemoteProcessGroupDAO.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Verified the specified remote port can be updated, if necessary.
 */
private void verifyUpdatePort(RemoteGroupPort port, RemoteProcessGroupPortDTO remoteProcessGroupPortDto) {
    // see if the remote process group can start/stop transmitting
    if (isNotNull(remoteProcessGroupPortDto.isTransmitting())) {
        if (!port.isRunning() && remoteProcessGroupPortDto.isTransmitting()) {
            port.verifyCanStart();
        } else if (port.isRunning() && !remoteProcessGroupPortDto.isTransmitting()) {
            port.verifyCanStop();
        }
    }

    // validate the proposed configuration
    final List<String> requestValidation = validateProposedRemoteProcessGroupPortConfiguration(port, remoteProcessGroupPortDto);
    // ensure there was no validation errors
    if (!requestValidation.isEmpty()) {
        throw new ValidationException(requestValidation);
    }


    // verify update when appropriate
    if (isAnyNotNull(remoteProcessGroupPortDto.getConcurrentlySchedulableTaskCount(), remoteProcessGroupPortDto.getUseCompression())) {
        port.verifyCanUpdate();
    }
}
 
Example #7
Source File: TestRemoteProcessGroupAuditor.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Test
public void testConfigurePortConcurrency() throws Throwable {

    final RemoteGroupPort existingRPGPort = defaultRemoteGroupPort();
    when(existingRPGPort.getName()).thenReturn("input-port-1");

    final RemoteProcessGroupPortDTO inputRPGPortDTO = defaultRemoteProcessGroupPortDTO();
    inputRPGPortDTO.setConcurrentlySchedulableTaskCount(2);

    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.Concurrent Tasks", "1", "2");

}
 
Example #8
Source File: StandardRemoteProcessGroupDAO.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public RemoteGroupPort updateRemoteProcessGroupInputPort(String remoteProcessGroupId, RemoteProcessGroupPortDTO remoteProcessGroupPortDto) {
    final RemoteProcessGroup remoteProcessGroup = locateRemoteProcessGroup(remoteProcessGroupId);
    final RemoteGroupPort port = remoteProcessGroup.getInputPort(remoteProcessGroupPortDto.getId());

    if (port == null) {
        throw new ResourceNotFoundException(
                String.format("Unable to find remote process group input port with id '%s'.", remoteProcessGroupPortDto.getId()));
    }

    // verify the update
    verifyUpdatePort(port, remoteProcessGroupPortDto);

    // perform the update
    updatePort(port, remoteProcessGroupPortDto, remoteProcessGroup);

    remoteProcessGroup.getProcessGroup().onComponentModified();
    return port;
}
 
Example #9
Source File: TestRemoteProcessGroupAuditor.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Test
public void testEnablePort() throws Throwable {

    final RemoteGroupPort existingRPGPort = defaultRemoteGroupPort();
    when(existingRPGPort.getName()).thenReturn("input-port-1");
    when(existingRPGPort.isRunning()).thenReturn(false);

    final RemoteProcessGroupPortDTO inputRPGPortDTO = defaultRemoteProcessGroupPortDTO();
    inputRPGPortDTO.setTransmitting(true);

    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", "disabled", "enabled");

}
 
Example #10
Source File: TestRemoteProcessGroupAuditor.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Test
public void testConfigurePortConcurrency() throws Throwable {

    final RemoteGroupPort existingRPGPort = defaultRemoteGroupPort();
    when(existingRPGPort.getName()).thenReturn("input-port-1");

    final RemoteProcessGroupPortDTO inputRPGPortDTO = defaultRemoteProcessGroupPortDTO();
    inputRPGPortDTO.setConcurrentlySchedulableTaskCount(2);

    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.Concurrent Tasks", "1", "2");

}
 
Example #11
Source File: TestRemoteProcessGroupAuditor.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Test
public void testConfigurePortCompression() throws Throwable {

    final RemoteGroupPort existingRPGPort = defaultRemoteGroupPort();
    when(existingRPGPort.getName()).thenReturn("input-port-1");

    final RemoteProcessGroupPortDTO inputRPGPortDTO = defaultRemoteProcessGroupPortDTO();
    inputRPGPortDTO.setUseCompression(true);

    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.Compressed", "false", "true");

}
 
Example #12
Source File: RemoteInputPortSchemaTest.java    From nifi-minifi with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() {
    dto = new RemoteProcessGroupPortDTO();
    dto.setId(testId);
    dto.setName(testName);
    dto.setComments(testComment);
    dto.setConcurrentlySchedulableTaskCount(testMaxConcurrentTasks);
    dto.setUseCompression(testUseCompression);

    map = new HashMap<>();
    map.put(CommonPropertyKeys.ID_KEY, testId);
    map.put(CommonPropertyKeys.NAME_KEY, testName);
    map.put(CommonPropertyKeys.COMMENT_KEY, testComment);
    map.put(CommonPropertyKeys.MAX_CONCURRENT_TASKS_KEY, testMaxConcurrentTasks);
    map.put(CommonPropertyKeys.USE_COMPRESSION_KEY, testUseCompression);
}
 
Example #13
Source File: TestStandardRemoteProcessGroupDAO.java    From nifi with Apache License 2.0 6 votes vote down vote up
private void validate(final StandardRemoteProcessGroupDAO dao, final RemoteProcessGroupPortDTO dto, final String ... errMessageKeywords) {
    try {
        dao.verifyUpdateInputPort(dto.getGroupId(), dto);
        if (errMessageKeywords.length > 0) {
            fail("Validation should fail with keywords: " + Arrays.asList(errMessageKeywords));
        }
    } catch (ValidationException e) {
        if (errMessageKeywords.length == 0) {
            fail("Validation should pass, but failed with: " + e);
        }
        final List<String> validationErrors = e.getValidationErrors();
        assertEquals("Validation should return one validationErrors", 1, validationErrors.size());
        final String validationError = validationErrors.get(0);
        for (String errMessageKeyword : errMessageKeywords) {
            assertTrue("validation error message should contain " + errMessageKeyword + ", but was: " + validationError,
                    validationError.contains(errMessageKeyword));
        }
    }
}
 
Example #14
Source File: StandardRemoteProcessGroupDAO.java    From nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Verified the specified remote port can be updated, if necessary.
 */
private void verifyUpdatePort(RemoteGroupPort port, RemoteProcessGroupPortDTO remoteProcessGroupPortDto) {
    // see if the remote process group can start/stop transmitting
    if (isNotNull(remoteProcessGroupPortDto.isTransmitting())) {
        if (!port.isRunning() && remoteProcessGroupPortDto.isTransmitting()) {
            port.verifyCanStart();
        } else if (port.isRunning() && !remoteProcessGroupPortDto.isTransmitting()) {
            port.verifyCanStop();
        }
    }

    // validate the proposed configuration
    final List<String> requestValidation = validateProposedRemoteProcessGroupPortConfiguration(port, remoteProcessGroupPortDto);
    // ensure there was no validation errors
    if (!requestValidation.isEmpty()) {
        throw new ValidationException(requestValidation);
    }


    // verify update when appropriate
    if (isAnyNotNull(remoteProcessGroupPortDto.getConcurrentlySchedulableTaskCount(),
            remoteProcessGroupPortDto.getUseCompression(),
            remoteProcessGroupPortDto.getBatchSettings())) {
        port.verifyCanUpdate();
    }
}
 
Example #15
Source File: TestRemoteProcessGroupAuditor.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@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");

}
 
Example #16
Source File: TestRemoteProcessGroupAuditor.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Test
public void testEnablePort() throws Throwable {

    final RemoteGroupPort existingRPGPort = defaultRemoteGroupPort();
    when(existingRPGPort.getName()).thenReturn("input-port-1");
    when(existingRPGPort.isRunning()).thenReturn(false);

    final RemoteProcessGroupPortDTO inputRPGPortDTO = defaultRemoteProcessGroupPortDTO();
    inputRPGPortDTO.setTransmitting(true);

    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", "disabled", "enabled");

}
 
Example #17
Source File: StandardRemoteProcessGroupDAO.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
public RemoteGroupPort updateRemoteProcessGroupInputPort(String remoteProcessGroupId, RemoteProcessGroupPortDTO remoteProcessGroupPortDto) {
    final RemoteProcessGroup remoteProcessGroup = locateRemoteProcessGroup(remoteProcessGroupId);
    final RemoteGroupPort port = remoteProcessGroup.getInputPort(remoteProcessGroupPortDto.getId());

    if (port == null) {
        throw new ResourceNotFoundException(
                String.format("Unable to find remote process group input port with id '%s'.", remoteProcessGroupPortDto.getId()));
    }

    // verify the update
    verifyUpdatePort(port, remoteProcessGroupPortDto);

    // perform the update
    if (isNotNull(remoteProcessGroupPortDto.getConcurrentlySchedulableTaskCount())) {
        port.setMaxConcurrentTasks(remoteProcessGroupPortDto.getConcurrentlySchedulableTaskCount());
    }
    if (isNotNull(remoteProcessGroupPortDto.getUseCompression())) {
        port.setUseCompression(remoteProcessGroupPortDto.getUseCompression());
    }

    final Boolean isTransmitting = remoteProcessGroupPortDto.isTransmitting();
    if (isNotNull(isTransmitting)) {
        // start or stop as necessary
        if (!port.isRunning() && isTransmitting) {
            remoteProcessGroup.startTransmitting(port);
        } else if (port.isRunning() && !isTransmitting) {
            remoteProcessGroup.stopTransmitting(port);
        }
    }

    return port;
}
 
Example #18
Source File: StandardFlowSnippet.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Converts a set of ports into a set of remote process group ports.
 *
 * @param ports ports
 * @return group descriptors
 */
private Set<RemoteProcessGroupPortDescriptor> convertRemotePort(final Set<RemoteProcessGroupPortDTO> ports) {
    Set<RemoteProcessGroupPortDescriptor> remotePorts = null;
    if (ports != null) {
        remotePorts = new LinkedHashSet<>(ports.size());
        for (final RemoteProcessGroupPortDTO port : ports) {
            final StandardRemoteProcessGroupPortDescriptor descriptor = new StandardRemoteProcessGroupPortDescriptor();
            descriptor.setId(port.getId());
            descriptor.setVersionedComponentId(port.getVersionedComponentId());
            descriptor.setTargetId(port.getTargetId());
            descriptor.setName(port.getName());
            descriptor.setComments(port.getComments());
            descriptor.setTargetRunning(port.isTargetRunning());
            descriptor.setConnected(port.isConnected());
            descriptor.setConcurrentlySchedulableTaskCount(port.getConcurrentlySchedulableTaskCount());
            descriptor.setTransmitting(port.isTransmitting());
            descriptor.setUseCompression(port.getUseCompression());
            final BatchSettingsDTO batchSettings = port.getBatchSettings();
            if (batchSettings != null) {
                descriptor.setBatchCount(batchSettings.getCount());
                descriptor.setBatchSize(batchSettings.getSize());
                descriptor.setBatchDuration(batchSettings.getDuration());
            }
            remotePorts.add(descriptor);
        }
    }
    return remotePorts;
}
 
Example #19
Source File: StandardRemoteProcessGroupDAO.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Validates the proposed configuration for the specified remote port.
 */
private List<String> validateProposedRemoteProcessGroupPortConfiguration(RemoteGroupPort remoteGroupPort, RemoteProcessGroupPortDTO remoteProcessGroupPortDTO) {
    final List<String> validationErrors = new ArrayList<>();

    // ensure the proposed port configuration is valid
    if (isNotNull(remoteProcessGroupPortDTO.getConcurrentlySchedulableTaskCount()) && remoteProcessGroupPortDTO.getConcurrentlySchedulableTaskCount() <= 0) {
        validationErrors.add(String.format("Concurrent tasks for port '%s' must be a positive integer.", remoteGroupPort.getName()));
    }

    return validationErrors;
}
 
Example #20
Source File: StandardRemoteProcessGroupDAO.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void verifyUpdateOutputPort(String remoteProcessGroupId, RemoteProcessGroupPortDTO remoteProcessGroupPortDto) {
    final RemoteProcessGroup remoteProcessGroup = locateRemoteProcessGroup(remoteProcessGroupId);
    final RemoteGroupPort port = remoteProcessGroup.getOutputPort(remoteProcessGroupPortDto.getId());

    if (port == null) {
        throw new ResourceNotFoundException(
                String.format("Unable to find remote process group output port with id '%s'.", remoteProcessGroupPortDto.getId()));
    }

    verifyUpdatePort(port, remoteProcessGroupPortDto);
}
 
Example #21
Source File: StandardRemoteProcessGroupDAO.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
public RemoteGroupPort updateRemoteProcessGroupOutputPort(String remoteProcessGroupId, RemoteProcessGroupPortDTO remoteProcessGroupPortDto) {
    final RemoteProcessGroup remoteProcessGroup = locateRemoteProcessGroup(remoteProcessGroupId);
    final RemoteGroupPort port = remoteProcessGroup.getOutputPort(remoteProcessGroupPortDto.getId());

    if (port == null) {
        throw new ResourceNotFoundException(
                String.format("Unable to find remote process group output port with id '%s'.", remoteProcessGroupId));
    }

    // verify the update
    verifyUpdatePort(port, remoteProcessGroupPortDto);

    // perform the update
    if (isNotNull(remoteProcessGroupPortDto.getConcurrentlySchedulableTaskCount())) {
        port.setMaxConcurrentTasks(remoteProcessGroupPortDto.getConcurrentlySchedulableTaskCount());
    }
    if (isNotNull(remoteProcessGroupPortDto.getUseCompression())) {
        port.setUseCompression(remoteProcessGroupPortDto.getUseCompression());
    }

    final Boolean isTransmitting = remoteProcessGroupPortDto.isTransmitting();
    if (isNotNull(isTransmitting)) {
        // start or stop as necessary
        if (!port.isRunning() && isTransmitting) {
            remoteProcessGroup.startTransmitting(port);
        } else if (port.isRunning() && !isTransmitting) {
            remoteProcessGroup.stopTransmitting(port);
        }
    }

    return port;
}
 
Example #22
Source File: TestRemoteProcessGroupAuditor.java    From nifi with Apache License 2.0 5 votes vote down vote up
@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");
}
 
Example #23
Source File: RemoteProcessGroupAuditor.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Audits the update of remote process group output 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 updateRemoteProcessGroupOutputPort(java.lang.String, org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO)) && "
        + "args(remoteProcessGroupId, remoteProcessGroupPortDto) && "
        + "target(remoteProcessGroupDAO)")
public RemoteGroupPort auditUpdateProcessGroupOutputPortConfiguration(
        ProceedingJoinPoint proceedingJoinPoint, String remoteProcessGroupId,
        RemoteProcessGroupPortDTO remoteProcessGroupPortDto, RemoteProcessGroupDAO remoteProcessGroupDAO) throws Throwable {

    final RemoteProcessGroup remoteProcessGroup = remoteProcessGroupDAO.getRemoteProcessGroup(remoteProcessGroupId);
    final RemoteGroupPort remoteProcessGroupPort = remoteProcessGroup.getOutputPort(remoteProcessGroupPortDto.getId());

    return auditUpdateProcessGroupPortConfiguration(proceedingJoinPoint, remoteProcessGroupPortDto, remoteProcessGroup, remoteProcessGroupPort);
}
 
Example #24
Source File: StandardRemoteProcessGroupDAO.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void verifyUpdateInputPort(String remoteProcessGroupId, RemoteProcessGroupPortDTO remoteProcessGroupPortDto) {
    final RemoteProcessGroup remoteProcessGroup = locateRemoteProcessGroup(remoteProcessGroupId);
    final RemoteGroupPort port = remoteProcessGroup.getInputPort(remoteProcessGroupPortDto.getId());

    if (port == null) {
        throw new ResourceNotFoundException(
                String.format("Unable to find remote process group input port with id '%s'.", remoteProcessGroupPortDto.getId()));
    }

    verifyUpdatePort(port, remoteProcessGroupPortDto);
}
 
Example #25
Source File: RemoteProcessGroupAuditor.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Audits the update of remote process group output 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 updateRemoteProcessGroupOutputPort(java.lang.String, org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO)) && "
        + "args(remoteProcessGroupId, remoteProcessGroupPortDto) && "
        + "target(remoteProcessGroupDAO)")
public RemoteGroupPort auditUpdateProcessGroupOutputPortConfiguration(
        ProceedingJoinPoint proceedingJoinPoint, String remoteProcessGroupId,
        RemoteProcessGroupPortDTO remoteProcessGroupPortDto, RemoteProcessGroupDAO remoteProcessGroupDAO) throws Throwable {

    final RemoteProcessGroup remoteProcessGroup = remoteProcessGroupDAO.getRemoteProcessGroup(remoteProcessGroupId);
    final RemoteGroupPort remoteProcessGroupPort = remoteProcessGroup.getOutputPort(remoteProcessGroupPortDto.getId());

    return auditUpdateProcessGroupPortConfiguration(proceedingJoinPoint, remoteProcessGroupPortDto, remoteProcessGroup, remoteProcessGroupPort);
}
 
Example #26
Source File: RemotePortSchemaFunction.java    From nifi-minifi with Apache License 2.0 5 votes vote down vote up
@Override
public RemotePortSchema apply(RemoteProcessGroupPortDTO remoteProcessGroupPortDTO) {
    Map<String, Object> map = new HashMap<>();
    // If a targetId is specified, it takes precedence over the original id
    final String targetId = remoteProcessGroupPortDTO.getTargetId();
    map.put(ID_KEY, StringUtils.isNotBlank(targetId) ? targetId : remoteProcessGroupPortDTO.getId());
    map.put(NAME_KEY, remoteProcessGroupPortDTO.getName());

    map.put(CommonPropertyKeys.COMMENT_KEY, remoteProcessGroupPortDTO.getComments());
    map.put(CommonPropertyKeys.MAX_CONCURRENT_TASKS_KEY, remoteProcessGroupPortDTO.getConcurrentlySchedulableTaskCount());
    map.put(CommonPropertyKeys.USE_COMPRESSION_KEY, remoteProcessGroupPortDTO.getUseCompression());
    return new RemotePortSchema(map);
}
 
Example #27
Source File: StandardRemoteProcessGroupDAO.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Validates the proposed configuration for the specified remote port.
 */
private List<String> validateProposedRemoteProcessGroupPortConfiguration(RemoteGroupPort remoteGroupPort, RemoteProcessGroupPortDTO remoteProcessGroupPortDTO) {
    final List<String> validationErrors = new ArrayList<>();

    // ensure the proposed port configuration is valid
    if (isNotNull(remoteProcessGroupPortDTO.getConcurrentlySchedulableTaskCount()) && remoteProcessGroupPortDTO.getConcurrentlySchedulableTaskCount() <= 0) {
        validationErrors.add(String.format("Concurrent tasks for port '%s' must be a positive integer.", remoteGroupPort.getName()));
    }

    final BatchSettingsDTO batchSettingsDTO = remoteProcessGroupPortDTO.getBatchSettings();
    if (batchSettingsDTO != null) {
        final Integer batchCount = batchSettingsDTO.getCount();
        if (isNotNull(batchCount) && batchCount < 0) {
            validationErrors.add(String.format("Batch count for port '%s' must be a positive integer.", remoteGroupPort.getName()));
        }

        final String batchSize = batchSettingsDTO.getSize();
        if (isNotNull(batchSize) && batchSize.length() > 0
                && !DataUnit.DATA_SIZE_PATTERN.matcher(batchSize.trim().toUpperCase()).matches()) {
            validationErrors.add(String.format("Batch size for port '%s' must be of format <Data Size> <Data Unit>" +
                    " where <Data Size> is a non-negative integer and <Data Unit> is a supported Data"
                    + " Unit, such as: B, KB, MB, GB, TB", remoteGroupPort.getName()));
        }

        final String batchDuration = batchSettingsDTO.getDuration();
        if (isNotNull(batchDuration) && batchDuration.length() > 0
                && !FormatUtils.TIME_DURATION_PATTERN.matcher(batchDuration.trim().toLowerCase()).matches()) {
            validationErrors.add(String.format("Batch duration for port '%s' must be of format <duration> <TimeUnit>" +
                    " where <duration> is a non-negative integer and TimeUnit is a supported Time Unit, such "
                    + "as: nanos, millis, secs, mins, hrs, days", remoteGroupPort.getName()));
        }
    }

    return validationErrors;
}
 
Example #28
Source File: StandardRemoteProcessGroupDAO.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void verifyUpdateOutputPort(String remoteProcessGroupId, RemoteProcessGroupPortDTO remoteProcessGroupPortDto) {
    final RemoteProcessGroup remoteProcessGroup = locateRemoteProcessGroup(remoteProcessGroupId);
    final RemoteGroupPort port = remoteProcessGroup.getOutputPort(remoteProcessGroupPortDto.getId());

    if (port == null) {
        throw new ResourceNotFoundException(
                String.format("Unable to find remote process group output port with id '%s'.", remoteProcessGroupPortDto.getId()));
    }

    verifyUpdatePort(port, remoteProcessGroupPortDto);
}
 
Example #29
Source File: RemoteProcessGroupResource.java    From nifi with Apache License 2.0 5 votes vote down vote up
private RemoteProcessGroupPortDTO createPortDTOWithDesiredRunStatus(final String portId, final String groupId, final RemotePortRunStatusEntity entity) {
    final RemoteProcessGroupPortDTO dto = new RemoteProcessGroupPortDTO();
    dto.setId(portId);
    dto.setGroupId(groupId);
    dto.setTransmitting(shouldTransmit(entity));
    return dto;
}
 
Example #30
Source File: StandardRemoteProcessGroupDAO.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Override
public void verifyUpdateInputPort(String remoteProcessGroupId, RemoteProcessGroupPortDTO remoteProcessGroupPortDto) {
    final RemoteProcessGroup remoteProcessGroup = locateRemoteProcessGroup(remoteProcessGroupId);
    final RemoteGroupPort port = remoteProcessGroup.getInputPort(remoteProcessGroupPortDto.getId());

    if (port == null) {
        throw new ResourceNotFoundException(
                String.format("Unable to find remote process group input port with id '%s'.", remoteProcessGroupPortDto.getId()));
    }

    verifyUpdatePort(port, remoteProcessGroupPortDto);
}