public RemoteProcessGroupPortDTO copy(final RemoteProcessGroupPortDTO original) { final RemoteProcessGroupPortDTO copy = new RemoteProcessGroupPortDTO(); copy.setId(original.getId()); copy.setTargetId(original.getTargetId()); copy.setGroupId(original.getGroupId()); copy.setName(original.getName()); copy.setComments(original.getComments()); copy.setConnected(original.isConnected()); copy.setTargetRunning(original.isTargetRunning()); copy.setTransmitting(original.isTransmitting()); copy.setConcurrentlySchedulableTaskCount(original.getConcurrentlySchedulableTaskCount()); copy.setUseCompression(original.getUseCompression()); copy.setExists(original.getExists()); copy.setVersionedComponentId(original.getVersionedComponentId()); final BatchSettingsDTO batchOrg = original.getBatchSettings(); if (batchOrg != null) { final BatchSettingsDTO batchCopy = new BatchSettingsDTO(); batchCopy.setCount(batchOrg.getCount()); batchCopy.setSize(batchOrg.getSize()); batchCopy.setDuration(batchOrg.getDuration()); copy.setBatchSettings(batchCopy); } return copy; }
/** * 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(); } }
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());
@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); } }
public AffectedComponentEntity createAffectedComponentEntity(final RemoteProcessGroupPortDTO remotePortDto, final String referenceType, final RemoteProcessGroupEntity rpgEntity) { if (remotePortDto == null) { return null; } final AffectedComponentEntity component = new AffectedComponentEntity(); component.setId(remotePortDto.getId()); component.setPermissions(rpgEntity.getPermissions()); component.setRevision(rpgEntity.getRevision()); component.setUri(rpgEntity.getUri()); final AffectedComponentDTO componentDto = new AffectedComponentDTO(); componentDto.setId(remotePortDto.getId()); componentDto.setName(remotePortDto.getName()); componentDto.setProcessGroupId(remotePortDto.getGroupId()); componentDto.setReferenceType(referenceType); componentDto.setState(remotePortDto.isTransmitting() ? "Running" : "Stopped"); component.setComponent(componentDto); return component; }
if (contents != null && contents.getInputPorts() != null) { for (final RemoteProcessGroupPortDTO remotePort : contents.getInputPorts()) { remotePort.setGroupId(cp.getId()); final String originalId = remotePort.getId(); if (remotePort.getTargetId() == null) { remotePort.setTargetId(originalId); remotePort.setId(generateId(remotePort.getId(), idGenerationSeed, isCopy)); remotePort.setGroupId(cp.getId()); final String originalId = remotePort.getId(); if (remotePort.getTargetId() == null) { remotePort.setTargetId(originalId); remotePort.setId(generateId(remotePort.getId(), idGenerationSeed, isCopy)); connectableMap.put(remoteGroupDTO.getId() + "-" + originalId, dtoFactory.createConnectableDto(remotePort, ConnectableType.REMOTE_OUTPUT_PORT));
public ConnectableDTO createConnectableDto(final RemoteProcessGroupPortDTO remoteGroupPort, final ConnectableType type) { final ConnectableDTO connectable = new ConnectableDTO(); connectable.setGroupId(remoteGroupPort.getGroupId()); connectable.setId(remoteGroupPort.getId()); connectable.setName(remoteGroupPort.getName()); connectable.setType(type.name()); connectable.setVersionedComponentId(connectable.getVersionedComponentId()); return connectable; }
if (!portId.equals(requestRemoteProcessGroupPort.getId())) { throw new IllegalArgumentException(String.format("The remote process group port id (%s) in the request body does not equal the " + "remote process group port id of the requested resource (%s).", requestRemoteProcessGroupPort.getId(), portId)); if (!id.equals(requestRemoteProcessGroupPort.getGroupId())) { throw new IllegalArgumentException(String.format("The remote process group id (%s) in the request body does not equal the " + "remote process group id of the requested resource (%s).", requestRemoteProcessGroupPort.getGroupId(), id));
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();
@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); } }
/** * * @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); } } }
@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); }
if (!portId.equals(requestRemoteProcessGroupPort.getId())) { throw new IllegalArgumentException(String.format("The remote process group port id (%s) in the request body does not equal the " + "remote process group port id of the requested resource (%s).", requestRemoteProcessGroupPort.getId(), portId)); if (!id.equals(requestRemoteProcessGroupPort.getGroupId())) { throw new IllegalArgumentException(String.format("The remote process group id (%s) in the request body does not equal the " + "remote process group id of the requested resource (%s).", requestRemoteProcessGroupPort.getGroupId(), id));
@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); }
/** * 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); }
/** * 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); }
@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; }
.filter(remoteGroup -> remoteGroup.getContents() != null && remoteGroup.getContents().getInputPorts() != null) .flatMap(remoteGroup -> remoteGroup.getContents().getInputPorts().stream()) .map(remoteInputPort -> remoteInputPort.getId()) .forEach(id -> identifiers.add(id)); snippet.getRemoteProcessGroups().stream() .filter(remoteGroup -> remoteGroup.getContents() != null && remoteGroup.getContents().getOutputPorts() != null) .flatMap(remoteGroup -> remoteGroup.getContents().getOutputPorts().stream()) .map(remoteOutputPort -> remoteOutputPort.getId()) .forEach(id -> identifiers.add(id)); snippet.getLabels().stream()
@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; }