@Override public void verifyCanStop(Connectable connectable) { final ScheduledState state = connectable.getScheduledState(); if (state == ScheduledState.DISABLED) { throw new IllegalStateException("Cannot stop component with id " + connectable + " because it is currently disabled."); } }
private <T extends Connectable & Triggerable> ScheduledState getScheduledState(final T component, final FlowController flowController) { final ScheduledState componentState = component.getScheduledState(); if (componentState == ScheduledState.STOPPED) { if (flowController.isStartAfterInitialization(component)) { return ScheduledState.RUNNING; } } return componentState; }
@Override public void verifyCanStart(Connectable connectable) { readLock.lock(); try { if (connectable.getScheduledState() == ScheduledState.STOPPED) { if (scheduler.getActiveThreadCount(connectable) > 0) { throw new IllegalStateException("Cannot start component with id" + connectable.getIdentifier() + " because it is currently stopping"); } connectable.verifyCanStart(); } } finally { readLock.unlock(); } }
private synchronized void startConnectable(final Connectable connectable) { if (connectable.getScheduledState() == ScheduledState.DISABLED) { throw new IllegalStateException(connectable.getIdentifier() + " is disabled, so it cannot be started"); } final LifecycleState lifecycleState = getLifecycleState(requireNonNull(connectable), true); if (lifecycleState.isScheduled()) { return; } final int activeThreads = lifecycleState.getActiveThreadCount(); if (activeThreads > 0) { throw new IllegalStateException("Port cannot be scheduled to run until its last " + activeThreads + " threads finish"); } lifecycleState.clearTerminationFlag(); getSchedulingAgent(connectable).schedule(connectable, lifecycleState); lifecycleState.setScheduled(true); }
LOG.info("Starting {} processors/ports/funnels", startConnectablesAfterInitialization.size() + startRemoteGroupPortsAfterInitialization.size()); for (final Connectable connectable : startConnectablesAfterInitialization) { if (connectable.getScheduledState() == ScheduledState.DISABLED) { continue;
private DelayProcessingReason getDelayReason(final Worker worker) { final Connectable connectable = worker.getConnectable(); if (ScheduledState.RUNNING != connectable.getScheduledState()) { return DelayProcessingReason.NOT_RUNNING;
try { try (final AutoCloseable ncl = NarCloseable.withComponentNarLoader(flowController.getExtensionManager(), connectable.getRunnableComponent().getClass(), connectable.getIdentifier())) { boolean shouldRun = connectable.getScheduledState() == ScheduledState.RUNNING; while (shouldRun) { connectable.onTrigger(processContext, activeSessionFactory); if (connectable.getScheduledState() != ScheduledState.RUNNING) { break;
private AffectedComponentEntity createAffectedComponentEntity(final Connectable connectable) { final AffectedComponentEntity entity = new AffectedComponentEntity(); entity.setRevision(dtoFactory.createRevisionDTO(revisionManager.getRevision(connectable.getIdentifier()))); entity.setId(connectable.getIdentifier()); final Authorizable authorizable = getAuthorizable(connectable); final PermissionsDTO permissionsDto = dtoFactory.createPermissionsDto(authorizable); entity.setPermissions(permissionsDto); final AffectedComponentDTO dto = new AffectedComponentDTO(); dto.setId(connectable.getIdentifier()); dto.setReferenceType(connectable.getConnectableType().name()); dto.setState(connectable.getScheduledState().name()); final String groupId = connectable instanceof RemoteGroupPort ? ((RemoteGroupPort) connectable).getRemoteProcessGroup().getIdentifier() : connectable.getProcessGroupIdentifier(); dto.setProcessGroupId(groupId); entity.setComponent(dto); return entity; }