public RemoteProcessGroupPortDTO createRemoteProcessGroupPortDto(final RemoteGroupPort port) { if (port == null) { return null; } final RemoteProcessGroupPortDTO dto = new RemoteProcessGroupPortDTO(); dto.setId(port.getIdentifier()); dto.setGroupId(port.getRemoteProcessGroup().getIdentifier()); dto.setTargetId(port.getTargetIdentifier()); dto.setName(port.getName()); dto.setComments(port.getComments()); dto.setTransmitting(port.isRunning()); dto.setTargetRunning(port.isTargetRunning()); dto.setConcurrentlySchedulableTaskCount(port.getMaxConcurrentTasks()); dto.setUseCompression(port.isUseCompression()); dto.setExists(port.getTargetExists()); dto.setVersionedComponentId(port.getVersionedComponentId().orElse(null)); final BatchSettingsDTO batchDTO = new BatchSettingsDTO(); batchDTO.setCount(port.getBatchCount()); batchDTO.setSize(port.getBatchSize()); batchDTO.setDuration(port.getBatchDuration()); dto.setBatchSettings(batchDTO); // determine if this port is currently connected to another component locally if (ConnectableType.REMOTE_OUTPUT_PORT.equals(port.getConnectableType())) { dto.setConnected(!port.getConnections().isEmpty()); } else { dto.setConnected(port.hasIncomingConnection()); } return dto; }
/** * 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(); } }
writeLock.lock(); try { if (requireNonNull(port).getTargetExists()) { throw new IllegalStateException("Cannot remove Remote Port " + port.getIdentifier() + " because it still exists on the Remote Instance"); if (!port.getConnections().isEmpty() || port.hasIncomingConnection()) { throw new IllegalStateException("Cannot remove Remote Port because it is connected to other components"); if (outputPorts.containsKey(port.getIdentifier())) { outputPorts.remove(port.getIdentifier()); } else { if (!inputPorts.containsKey(port.getIdentifier())) { throw new IllegalStateException("Cannot remove Remote Port because it does not belong to this Remote Process Group"); inputPorts.remove(port.getIdentifier());
private BatchSize mapBatchSettings(final RemoteGroupPort remotePort) { final BatchSize batchSize = new BatchSize(); batchSize.setCount(remotePort.getBatchCount()); batchSize.setDuration(remotePort.getBatchDuration()); batchSize.setSize(remotePort.getBatchSize()); return batchSize; } }
public VersionedRemoteGroupPort mapRemotePort(final RemoteGroupPort remotePort, final ComponentType componentType) { final VersionedRemoteGroupPort port = new InstantiatedVersionedRemoteGroupPort(remotePort.getIdentifier(), remotePort.getRemoteProcessGroup().getIdentifier()); port.setIdentifier(getId(remotePort.getVersionedComponentId(), remotePort.getIdentifier())); port.setGroupIdentifier(getGroupId(remotePort.getRemoteProcessGroup().getIdentifier())); port.setComments(remotePort.getComments()); port.setConcurrentlySchedulableTaskCount(remotePort.getMaxConcurrentTasks()); port.setRemoteGroupId(getGroupId(remotePort.getRemoteProcessGroup().getIdentifier())); port.setName(remotePort.getName()); port.setUseCompression(remotePort.isUseCompression()); port.setBatchSize(mapBatchSettings(remotePort)); port.setTargetId(remotePort.getTargetIdentifier()); port.setComponentType(componentType); return port; }
private void addRemoteGroupPort(final Element parentElement, final RemoteGroupPort port, final String elementName, final ScheduledStateLookup scheduledStateLookup) { final Document doc = parentElement.getOwnerDocument(); final Element element = doc.createElement(elementName); parentElement.appendChild(element); addTextElement(element, "id", port.getIdentifier()); addTextElement(element, "versionedComponentId", port.getVersionedComponentId()); addTextElement(element, "name", port.getName()); addPosition(element, port.getPosition()); addTextElement(element, "comments", port.getComments()); addTextElement(element, "scheduledState", scheduledStateLookup.getScheduledState(port).name()); addTextElement(element, "targetId", port.getTargetIdentifier()); addTextElement(element, "maxConcurrentTasks", port.getMaxConcurrentTasks()); addTextElement(element, "useCompression", String.valueOf(port.isUseCompression())); final Integer batchCount = port.getBatchCount(); if (batchCount != null && batchCount > 0) { addTextElement(element, "batchCount", batchCount); } final String batchSize = port.getBatchSize(); if (batchSize != null && batchSize.length() > 0) { addTextElement(element, "batchSize", batchSize); } final String batchDuration = port.getBatchDuration(); if (batchDuration != null && batchDuration.length() > 0) { addTextElement(element, "batchDuration", batchDuration); } parentElement.appendChild(element); }
final RemoteProcessGroup remoteGroup = remoteGroupPort.getRemoteProcessGroup(); dto.setGroupId(remoteGroup.getIdentifier()); dto.setRunning(remoteGroupPort.isTargetRunning()); dto.setTransmitting(remoteGroupPort.isRunning()); dto.setExists(remoteGroupPort.getTargetExists()); if (isAuthorized) { dto.setComments(remoteGroup.getComments());
private static List<PortStatus> getPortStatusList(RemoteProcessGroupStatus inputRemoteProcessGroupStatus, FlowController flowController, String rootGroupId, Function<RemoteProcessGroup, Set<RemoteGroupPort>> portFunction) { return portFunction.apply(flowController.getGroup(rootGroupId).getRemoteProcessGroup(inputRemoteProcessGroupStatus.getId())).stream().map(r -> { PortStatus portStatus = new PortStatus(); portStatus.setName(r.getName()); portStatus.setTargetExists(r.getTargetExists()); portStatus.setTargetRunning(r.isTargetRunning()); return portStatus; }).collect(Collectors.toList()); }
@Override public void verifyScheduleComponents(final String groupId, final ScheduledState state,final Set<String> componentIds) { final ProcessGroup group = locateProcessGroup(flowController, groupId); final Set<ProcessGroup> validGroups = new HashSet<>(); validGroups.add(group); validGroups.addAll(group.findAllProcessGroups()); for (final String componentId : componentIds) { final Connectable connectable = findConnectable(componentId, groupId, validGroups); if (connectable == null) { throw new ResourceNotFoundException("Unable to find component with id " + componentId); } if (connectable instanceof RemoteGroupPort) { final RemoteGroupPort remotePort = (RemoteGroupPort) connectable; if (ScheduledState.RUNNING.equals(state)) { remotePort.verifyCanStart(); } else { remotePort.verifyCanStop(); } continue; } // verify as appropriate if (ScheduledState.RUNNING.equals(state)) { group.verifyCanStart(connectable); } else { group.verifyCanStop(connectable); } } }
.filter(component -> component.getVersionedComponentId().isPresent()) .filter(component -> id.equals(component.getVersionedComponentId().get())) .findAny(); .filter(component -> connectableComponent.getName().equals(component.getName())) .findAny() .orElse(null); .filter(component -> component.getVersionedComponentId().isPresent()) .filter(component -> id.equals(component.getVersionedComponentId().get())) .findAny(); .filter(component -> connectableComponent.getName().equals(component.getName())) .findAny() .orElse(null);
@Override public boolean isRemoteGroupPortConnected(final String remoteProcessGroupId, final String remotePortId) { final RemoteProcessGroup rpg = remoteProcessGroupDAO.getRemoteProcessGroup(remoteProcessGroupId); RemoteGroupPort port = rpg.getInputPort(remotePortId); if (port != null) { return port.hasIncomingConnection(); } port = rpg.getOutputPort(remotePortId); if (port != null) { return !port.getConnections().isEmpty(); } throw new ResourceNotFoundException("Could not find Port with ID " + remotePortId + " as a child of RemoteProcessGroup with ID " + remoteProcessGroupId); }
if (currentDestination.getConnectableType() == ConnectableType.REMOTE_INPUT_PORT) { RemoteGroupPort remotePort = (RemoteGroupPort) currentDestination; if (!proposedDestination.getGroupId().equals(remotePort.getRemoteProcessGroup().getIdentifier())) { isDifferentRemoteProcessGroup = true; if (!remoteInputPort.getTargetExists()) { throw new IllegalArgumentException("The specified remote input port does not exist."); } else {
dto.setGroupId(remoteGroupPort.getProcessGroupIdentifier()); if (Result.Approved.equals(remoteGroupPort.checkAuthorization(authorizer, RequestAction.READ, user).getResult())) { dto.setComponentName(remoteGroupPort.getName()); } else { dto.setComponentName(dto.getComponentId());
@Override public void startTransmitting(final RemoteGroupPort port) { writeLock.lock(); try { if (!inputPorts.containsValue(port) && !outputPorts.containsValue(port)) { throw new IllegalArgumentException("Port does not belong to this Remote Process Group"); } port.verifyCanStart(); scheduler.startPort(port); transmitting.set(true); } finally { writeLock.unlock(); } }
validationErrors.add(String.format("Concurrent tasks for port '%s' must be a positive integer.", remoteGroupPort.getName())); 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())); 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())); 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()));
private void applyVersionedComponentIds(final ProcessGroup processGroup, final Function<String, String> lookup) { processGroup.setVersionedComponentId(lookup.apply(processGroup.getIdentifier())); processGroup.getConnections() .forEach(component -> component.setVersionedComponentId(lookup.apply(component.getIdentifier()))); processGroup.getProcessors() .forEach(component -> component.setVersionedComponentId(lookup.apply(component.getIdentifier()))); processGroup.getInputPorts() .forEach(component -> component.setVersionedComponentId(lookup.apply(component.getIdentifier()))); processGroup.getOutputPorts() .forEach(component -> component.setVersionedComponentId(lookup.apply(component.getIdentifier()))); processGroup.getLabels() .forEach(component -> component.setVersionedComponentId(lookup.apply(component.getIdentifier()))); processGroup.getFunnels() .forEach(component -> component.setVersionedComponentId(lookup.apply(component.getIdentifier()))); processGroup.getControllerServices(false) .forEach(component -> component.setVersionedComponentId(lookup.apply(component.getIdentifier()))); processGroup.getRemoteProcessGroups() .forEach(rpg -> { rpg.setVersionedComponentId(lookup.apply(rpg.getIdentifier())); rpg.getInputPorts().forEach(port -> port.setVersionedComponentId(lookup.apply(port.getIdentifier()))); rpg.getOutputPorts().forEach(port -> port.setVersionedComponentId(lookup.apply(port.getIdentifier()))); }); for (final ProcessGroup childGroup : processGroup.getProcessGroups()) { if (childGroup.getVersionControlInformation() == null) { applyVersionedComponentIds(childGroup, lookup); } else if (!childGroup.getVersionedComponentId().isPresent()) { childGroup.setVersionedComponentId(lookup.apply(childGroup.getIdentifier())); } } }
if (sourceConnectable == null) { throw new IllegalArgumentException("The specified source for the connection does not exist"); } else if (!sourceConnectable.getTargetExists()) { throw new IllegalArgumentException("The specified remote output port does not exist."); if (destinationConnectable == null) { throw new IllegalArgumentException("The specified destination for the connection does not exist"); } else if (!destinationConnectable.getTargetExists()) { throw new IllegalArgumentException("The specified remote input port does not exist.");
for (final Connection connection : port.getConnections()) { connection.verifyCanDelete(); final Set<Connection> copy = new HashSet<>(port.getConnections()); for (final Connection connection : copy) { removeConnection(connection);
processGroup.findAllRemoteProcessGroups().stream() .flatMap(rpg -> Stream.concat(rpg.getInputPorts().stream(), rpg.getOutputPorts().stream())) .map(component -> revisionManager.getRevision(component.getIdentifier())) .forEach(revisions::add);
if (port.hasIncomingConnection()) { addRemoteGroupPort(element, port, "inputPort", scheduledStateLookup); if (!port.getConnections().isEmpty()) { addRemoteGroupPort(element, port, "outputPort", scheduledStateLookup);