@Test public void testDisabledValidationErrors() { final ModifiesClasspathNoAnnotationProcessor processor = new ModifiesClasspathNoAnnotationProcessor(); final StandardProcessorNode procNode = createProcessorNode(processor); final Map<String, String> properties = new HashMap<>(); properties.put(ModifiesClasspathNoAnnotationProcessor.CLASSPATH_RESOURCE.getName(), ""); procNode.setProperties(properties); Assert.assertTrue(procNode.getValidationErrors().size() > 0); procNode.disable(); Assert.assertFalse(procNode.getValidationErrors().size() > 0); }
@Override public Collection<ValidationResult> getValidationErrors() { final List<ValidationResult> results = new ArrayList<>(); try { if (getScheduledState() == ScheduledState.STOPPED) { final ValidationContext validationContext = this.getValidationContextFactory() .newValidationContext(getProperties(), getAnnotationData(), getProcessGroup().getIdentifier(), getIdentifier()); final Collection<ValidationResult> validationResults; try (final NarCloseable narCloseable = NarCloseable.withComponentNarLoader(getProcessor().getClass(), processor.getIdentifier())) { validationResults = getProcessor().validate(validationContext); } for (final ValidationResult result : validationResults) { if (!result.isValid()) { results.add(result); } } for (final Relationship relationship : getUndefinedRelationships()) { if (!isAutoTerminated(relationship)) { final ValidationResult error = new ValidationResult.Builder() .explanation("Relationship '" + relationship.getName() + "' is not connected to any component and is not auto-terminated") .subject("Relationship " + relationship.getName()).valid(false).build(); results.add(error); } } switch (getInputRequirement()) { case INPUT_ALLOWED: break; case INPUT_FORBIDDEN: { final int incomingConnCount = getIncomingNonLoopConnections().size(); if (incomingConnCount != 0) { results.add(new ValidationResult.Builder().explanation( "Processor does not allow upstream connections but currently has " + incomingConnCount) .subject("Upstream Connections").valid(false).build()); } break; } case INPUT_REQUIRED: { if (getIncomingNonLoopConnections().isEmpty()) { results.add(new ValidationResult.Builder() .explanation("Processor requires an upstream connection but currently has none") .subject("Upstream Connections").valid(false).build()); } break; } } } } catch (final Throwable t) { results.add(new ValidationResult.Builder().explanation("Failed to run validation due to " + t.toString()) .valid(false).build()); } return results; }
StandardProcessorNode extends ProcessorNode implements Connectable { @Override public Collection<ValidationResult> getValidationErrors() { final List<ValidationResult> results = new ArrayList<>(); try { if (getScheduledState() == ScheduledState.STOPPED) { final ValidationContext validationContext = this.getValidationContextFactory() .newValidationContext(getProperties(), getAnnotationData(), getProcessGroup().getIdentifier(), getIdentifier()); final Collection<ValidationResult> validationResults; try (final NarCloseable narCloseable = NarCloseable.withComponentNarLoader(getProcessor().getClass(), processor.getIdentifier())) { validationResults = getProcessor().validate(validationContext); } for (final ValidationResult result : validationResults) { if (!result.isValid()) { results.add(result); } } for (final Relationship relationship : getUndefinedRelationships()) { if (!isAutoTerminated(relationship)) { final ValidationResult error = new ValidationResult.Builder() .explanation("Relationship '" + relationship.getName() + "' is not connected to any component and is not auto-terminated") .subject("Relationship " + relationship.getName()).valid(false).build(); results.add(error); } } switch (getInputRequirement()) { case INPUT_ALLOWED: break; case INPUT_FORBIDDEN: { final int incomingConnCount = getIncomingNonLoopConnections().size(); if (incomingConnCount != 0) { results.add(new ValidationResult.Builder().explanation( "Processor does not allow upstream connections but currently has " + incomingConnCount) .subject("Upstream Connections").valid(false).build()); } break; } case INPUT_REQUIRED: { if (getIncomingNonLoopConnections().isEmpty()) { results.add(new ValidationResult.Builder() .explanation("Processor requires an upstream connection but currently has none") .subject("Upstream Connections").valid(false).build()); } break; } } } } catch (final Throwable t) { results.add(new ValidationResult.Builder().explanation("Failed to run validation due to " + t.toString()) .valid(false).build()); } return results; } }
StandardProcessorNode extends ProcessorNode implements Connectable { @Override public Collection<ValidationResult> getValidationErrors() { final List<ValidationResult> results = new ArrayList<>(); try { if (getScheduledState() == ScheduledState.STOPPED) { final ValidationContext validationContext = this.getValidationContextFactory() .newValidationContext(getProperties(), getAnnotationData(), getProcessGroup().getIdentifier(), getIdentifier()); final Collection<ValidationResult> validationResults; try (final NarCloseable narCloseable = NarCloseable.withComponentNarLoader(getProcessor().getClass(), processor.getIdentifier())) { validationResults = getProcessor().validate(validationContext); } for (final ValidationResult result : validationResults) { if (!result.isValid()) { results.add(result); } } for (final Relationship relationship : getUndefinedRelationships()) { if (!isAutoTerminated(relationship)) { final ValidationResult error = new ValidationResult.Builder() .explanation("Relationship '" + relationship.getName() + "' is not connected to any component and is not auto-terminated") .subject("Relationship " + relationship.getName()).valid(false).build(); results.add(error); } } switch (getInputRequirement()) { case INPUT_ALLOWED: break; case INPUT_FORBIDDEN: { final int incomingConnCount = getIncomingNonLoopConnections().size(); if (incomingConnCount != 0) { results.add(new ValidationResult.Builder().explanation( "Processor does not allow upstream connections but currently has " + incomingConnCount) .subject("Upstream Connections").valid(false).build()); } break; } case INPUT_REQUIRED: { if (getIncomingNonLoopConnections().isEmpty()) { results.add(new ValidationResult.Builder() .explanation("Processor requires an upstream connection but currently has none") .subject("Upstream Connections").valid(false).build()); } break; } } } } catch (final Throwable t) { results.add(new ValidationResult.Builder().explanation("Failed to run validation due to " + t.toString()) .valid(false).build()); } return results; } StandardProcessorNode(final Processor processor, final String uuid,
                                 final ValidationContextFactory validationContextFactory, final ProcessScheduler scheduler,
                                 final ControllerServiceProvider controllerServiceProvider, final NiFiProperties nifiProperties,
                                 final VariableRegistry variableRegistry, final ComponentLog logger);  StandardProcessorNode(final Processor processor, final String uuid,
                                 final ValidationContextFactory validationContextFactory, final ProcessScheduler scheduler,
                                 final ControllerServiceProvider controllerServiceProvider,
                                 final String componentType, final String componentCanonicalClass, final NiFiProperties nifiProperties,
                                 final VariableRegistry variableRegistry, final ComponentLog logger); }
StandardProcessorNode extends ProcessorNode implements Connectable { @Override public Collection<ValidationResult> getValidationErrors() { final List<ValidationResult> results = new ArrayList<>(); try { if (getScheduledState() == ScheduledState.STOPPED) { final ValidationContext validationContext = this.getValidationContextFactory() .newValidationContext(getProperties(), getAnnotationData(), getProcessGroup().getIdentifier(), getIdentifier()); final Collection<ValidationResult> validationResults; try (final NarCloseable narCloseable = NarCloseable.withComponentNarLoader(getProcessor().getClass(), processor.getIdentifier())) { validationResults = getProcessor().validate(validationContext); } for (final ValidationResult result : validationResults) { if (!result.isValid()) { results.add(result); } } for (final Relationship relationship : getUndefinedRelationships()) { if (!isAutoTerminated(relationship)) { final ValidationResult error = new ValidationResult.Builder() .explanation("Relationship '" + relationship.getName() + "' is not connected to any component and is not auto-terminated") .subject("Relationship " + relationship.getName()).valid(false).build(); results.add(error); } } switch (getInputRequirement()) { case INPUT_ALLOWED: break; case INPUT_FORBIDDEN: { final int incomingConnCount = getIncomingNonLoopConnections().size(); if (incomingConnCount != 0) { results.add(new ValidationResult.Builder().explanation( "Processor does not allow upstream connections but currently has " + incomingConnCount) .subject("Upstream Connections").valid(false).build()); } break; } case INPUT_REQUIRED: { if (getIncomingNonLoopConnections().isEmpty()) { results.add(new ValidationResult.Builder() .explanation("Processor requires an upstream connection but currently has none") .subject("Upstream Connections").valid(false).build()); } break; } } } } catch (final Throwable t) { results.add(new ValidationResult.Builder().explanation("Failed to run validation due to " + t.toString()) .valid(false).build()); } return results; } StandardProcessorNode(final Processor processor, final String uuid,
                                 final ValidationContextFactory validationContextFactory, final ProcessScheduler scheduler,
                                 final ControllerServiceProvider controllerServiceProvider, final NiFiProperties nifiProperties,
                                 final VariableRegistry variableRegistry, final ComponentLog logger);  StandardProcessorNode(final Processor processor, final String uuid,
                                 final ValidationContextFactory validationContextFactory, final ProcessScheduler scheduler,
                                 final ControllerServiceProvider controllerServiceProvider,
                                 final String componentType, final String componentCanonicalClass, final NiFiProperties nifiProperties,
                                 final VariableRegistry variableRegistry, final ComponentLog logger); @Override String getComments(); @Override Authorizable getParentAuthorizable(); @Override Resource getResource(); @Override boolean isRestricted(); @Override void setComments(final String comments); @Override Position getPosition(); @Override void setPosition(final Position position); @Override Map<String, String> getStyle(); @Override void setStyle(final Map<String, String> style); @Override String getIdentifier(); @Override boolean isLossTolerant(); @Override boolean isIsolated(); @Override boolean isTriggerWhenEmpty(); @Override boolean isSideEffectFree(); @Override boolean isHighThroughputSupported(); @Override boolean isTriggerWhenAnyDestinationAvailable(); @Override void setLossTolerant(final boolean lossTolerant); @Override boolean isAutoTerminated(final Relationship relationship); @Override void setAutoTerminatedRelationships(final Set<Relationship> terminate); @Override Set<Relationship> getAutoTerminatedRelationships(); String getProcessorDescription(); @Override void setName(final String name); @Override long getSchedulingPeriod(final TimeUnit timeUnit); @Override boolean isEventDrivenSupported(); @Override void setSchedulingStrategy(final SchedulingStrategy schedulingStrategy); @Override SchedulingStrategy getSchedulingStrategy(); @Override String getSchedulingPeriod(); @Override void setScheduldingPeriod(final String schedulingPeriod); @Override void setExecutionNode(final ExecutionNode executionNode); @Override ExecutionNode getExecutionNode(); @Override long getRunDuration(final TimeUnit timeUnit); @Override void setRunDuration(final long duration, final TimeUnit timeUnit); @Override long getYieldPeriod(final TimeUnit timeUnit); @Override String getYieldPeriod(); @Override void setYieldPeriod(final String yieldPeriod); @Override void yield(); @Override void yield(final long period, final TimeUnit timeUnit); @Override long getYieldExpiration(); @Override long getPenalizationPeriod(final TimeUnit timeUnit); @Override String getPenalizationPeriod(); @Override void setPenalizationPeriod(final String penalizationPeriod); @Override void setMaxConcurrentTasks(final int taskCount); @Override boolean isTriggeredSerially(); @Override int getMaxConcurrentTasks(); @Override LogLevel getBulletinLevel(); @Override void setBulletinLevel(final LogLevel level); @Override Set<Connection> getConnections(); @Override List<Connection> getIncomingConnections(); @Override Set<Connection> getConnections(final Relationship relationship); @Override void addConnection(final Connection connection); @Override boolean hasIncomingConnection(); @Override void updateConnection(final Connection connection); @Override void removeConnection(final Connection connection); @Override Relationship getRelationship(final String relationshipName); @Override Processor getProcessor(); Set<Connectable> getDestinations(); Set<Connectable> getDestinations(final Relationship relationship); Set<Relationship> getUndefinedRelationships(); @Override boolean isRunning(); @Override int getActiveThreadCount(); @Override boolean isValid(); @Override Collection<ValidationResult> getValidationErrors(); @Override Requirement getInputRequirement(); @Override boolean equals(final Object other); @Override int hashCode(); @Override Collection<Relationship> getRelationships(); @Override String toString(); @Override ProcessGroup getProcessGroup(); @Override void setProcessGroup(final ProcessGroup group); @Override void onTrigger(final ProcessContext context, final ProcessSessionFactory sessionFactory); @Override ConnectableType getConnectableType(); @Override void setAnnotationData(final String data); @Override Collection<ValidationResult> validate(final ValidationContext validationContext); @Override void verifyCanDelete(); @Override void verifyCanDelete(final boolean ignoreConnections); @Override void verifyCanStart(); @Override void verifyCanStart(final Set<ControllerServiceNode> ignoredReferences); @Override void verifyCanStop(); @Override void verifyCanUpdate(); @Override void verifyCanEnable(); @Override void verifyCanDisable(); @Override void verifyCanClearState(); @Override void verifyModifiable(); @Override void start(final ScheduledExecutorService taskScheduler,
            final long administrativeYieldMillis, final T processContext, final SchedulingAgentCallback schedulingAgentCallback); @Override void stop(final ScheduledExecutorService scheduler,
        final T processContext, final SchedulingAgent schedulingAgent, final ScheduleState scheduleState); @Override String getProcessGroupIdentifier(); }
StandardProcessorNode extends ProcessorNode implements Connectable { @Override public Collection<ValidationResult> getValidationErrors() { final List<ValidationResult> results = new ArrayList<>(); try { if (getScheduledState() == ScheduledState.STOPPED) { final ValidationContext validationContext = this.getValidationContextFactory() .newValidationContext(getProperties(), getAnnotationData(), getProcessGroup().getIdentifier(), getIdentifier()); final Collection<ValidationResult> validationResults; try (final NarCloseable narCloseable = NarCloseable.withComponentNarLoader(getProcessor().getClass(), processor.getIdentifier())) { validationResults = getProcessor().validate(validationContext); } for (final ValidationResult result : validationResults) { if (!result.isValid()) { results.add(result); } } for (final Relationship relationship : getUndefinedRelationships()) { if (!isAutoTerminated(relationship)) { final ValidationResult error = new ValidationResult.Builder() .explanation("Relationship '" + relationship.getName() + "' is not connected to any component and is not auto-terminated") .subject("Relationship " + relationship.getName()).valid(false).build(); results.add(error); } } switch (getInputRequirement()) { case INPUT_ALLOWED: break; case INPUT_FORBIDDEN: { final int incomingConnCount = getIncomingNonLoopConnections().size(); if (incomingConnCount != 0) { results.add(new ValidationResult.Builder().explanation( "Processor does not allow upstream connections but currently has " + incomingConnCount) .subject("Upstream Connections").valid(false).build()); } break; } case INPUT_REQUIRED: { if (getIncomingNonLoopConnections().isEmpty()) { results.add(new ValidationResult.Builder() .explanation("Processor requires an upstream connection but currently has none") .subject("Upstream Connections").valid(false).build()); } break; } } } } catch (final Throwable t) { results.add(new ValidationResult.Builder().explanation("Failed to run validation due to " + t.toString()) .valid(false).build()); } return results; } StandardProcessorNode(final Processor processor, final String uuid,
                                 final ValidationContextFactory validationContextFactory, final ProcessScheduler scheduler,
                                 final ControllerServiceProvider controllerServiceProvider, final NiFiProperties nifiProperties,
                                 final VariableRegistry variableRegistry, final ComponentLog logger);  StandardProcessorNode(final Processor processor, final String uuid,
                                 final ValidationContextFactory validationContextFactory, final ProcessScheduler scheduler,
                                 final ControllerServiceProvider controllerServiceProvider,
                                 final String componentType, final String componentCanonicalClass, final NiFiProperties nifiProperties,
                                 final VariableRegistry variableRegistry, final ComponentLog logger); @Override String getComments(); @Override Authorizable getParentAuthorizable(); @Override Resource getResource(); @Override boolean isRestricted(); @Override void setComments(final String comments); @Override Position getPosition(); @Override void setPosition(final Position position); @Override Map<String, String> getStyle(); @Override void setStyle(final Map<String, String> style); @Override String getIdentifier(); @Override boolean isLossTolerant(); @Override boolean isIsolated(); @Override boolean isTriggerWhenEmpty(); @Override boolean isSideEffectFree(); @Override boolean isHighThroughputSupported(); @Override boolean isTriggerWhenAnyDestinationAvailable(); @Override void setLossTolerant(final boolean lossTolerant); @Override boolean isAutoTerminated(final Relationship relationship); @Override void setAutoTerminatedRelationships(final Set<Relationship> terminate); @Override Set<Relationship> getAutoTerminatedRelationships(); String getProcessorDescription(); @Override void setName(final String name); @Override long getSchedulingPeriod(final TimeUnit timeUnit); @Override boolean isEventDrivenSupported(); @Override void setSchedulingStrategy(final SchedulingStrategy schedulingStrategy); @Override SchedulingStrategy getSchedulingStrategy(); @Override String getSchedulingPeriod(); @Override void setScheduldingPeriod(final String schedulingPeriod); @Override void setExecutionNode(final ExecutionNode executionNode); @Override ExecutionNode getExecutionNode(); @Override long getRunDuration(final TimeUnit timeUnit); @Override void setRunDuration(final long duration, final TimeUnit timeUnit); @Override long getYieldPeriod(final TimeUnit timeUnit); @Override String getYieldPeriod(); @Override void setYieldPeriod(final String yieldPeriod); @Override void yield(); @Override void yield(final long period, final TimeUnit timeUnit); @Override long getYieldExpiration(); @Override long getPenalizationPeriod(final TimeUnit timeUnit); @Override String getPenalizationPeriod(); @Override void setPenalizationPeriod(final String penalizationPeriod); @Override void setMaxConcurrentTasks(final int taskCount); @Override boolean isTriggeredSerially(); @Override int getMaxConcurrentTasks(); @Override LogLevel getBulletinLevel(); @Override void setBulletinLevel(final LogLevel level); @Override Set<Connection> getConnections(); @Override List<Connection> getIncomingConnections(); @Override Set<Connection> getConnections(final Relationship relationship); @Override void addConnection(final Connection connection); @Override boolean hasIncomingConnection(); @Override void updateConnection(final Connection connection); @Override void removeConnection(final Connection connection); @Override Relationship getRelationship(final String relationshipName); @Override Processor getProcessor(); Set<Connectable> getDestinations(); Set<Connectable> getDestinations(final Relationship relationship); Set<Relationship> getUndefinedRelationships(); @Override boolean isRunning(); @Override int getActiveThreadCount(); @Override boolean isValid(); @Override Collection<ValidationResult> getValidationErrors(); @Override Requirement getInputRequirement(); @Override boolean equals(final Object other); @Override int hashCode(); @Override Collection<Relationship> getRelationships(); @Override String toString(); @Override ProcessGroup getProcessGroup(); @Override void setProcessGroup(final ProcessGroup group); @Override void onTrigger(final ProcessContext context, final ProcessSessionFactory sessionFactory); @Override ConnectableType getConnectableType(); @Override void setAnnotationData(final String data); @Override Collection<ValidationResult> validate(final ValidationContext validationContext); @Override void verifyCanDelete(); @Override void verifyCanDelete(final boolean ignoreConnections); @Override void verifyCanStart(); @Override void verifyCanStart(final Set<ControllerServiceNode> ignoredReferences); @Override void verifyCanStop(); @Override void verifyCanUpdate(); @Override void verifyCanEnable(); @Override void verifyCanDisable(); @Override void verifyCanClearState(); @Override void verifyModifiable(); @Override void start(final ScheduledExecutorService taskScheduler,
            final long administrativeYieldMillis, final T processContext, final SchedulingAgentCallback schedulingAgentCallback); @Override void stop(final ScheduledExecutorService scheduler,
        final T processContext, final SchedulingAgent schedulingAgent, final ScheduleState scheduleState); @Override String getProcessGroupIdentifier(); static final String BULLETIN_OBSERVER_ID; static final TimeUnit DEFAULT_TIME_UNIT; static final String DEFAULT_YIELD_PERIOD; static final String DEFAULT_PENALIZATION_PERIOD; }