@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(); } }
@Override public void verifyCanStart() { super.verifyCanStart(); if (getConnectableType() == ConnectableType.REMOTE_INPUT_PORT && getIncomingConnections().isEmpty()) { throw new IllegalStateException("Port " + getName() + " has no incoming connections"); } final Optional<ValidationResult> resultOption = remoteGroup.validate().stream() .filter(result -> !result.isValid()) .findFirst(); if (resultOption.isPresent()) { throw new IllegalStateException("Remote Process Group is not valid: " + resultOption.get().toString()); } }
@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); } } }
/** * 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(); } }
@Override public void verifyCanStart() { super.verifyCanStart(); if (getConnectableType() == ConnectableType.REMOTE_INPUT_PORT && getIncomingConnections().isEmpty()) { throw new IllegalStateException("Port " + getName() + " has no incoming connections"); } final Optional<ValidationResult> resultOption = remoteGroup.validate().stream() .filter(result -> !result.isValid()) .findFirst(); if (resultOption.isPresent()) { throw new IllegalStateException("Remote Process Group is not valid: " + resultOption.get().toString()); } }