Github user jskora commented on a diff in the pull request: https://github.com/apache/nifi/pull/458#discussion_r65487473 --- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/DebugFlow.java --- @@ -0,0 +1,414 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.processors.standard; + +import org.apache.nifi.annotation.behavior.EventDriven; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.flowfile.attributes.CoreAttributes; +import org.apache.nifi.logging.ProcessorLog; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.processor.AbstractProcessor; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +@EventDriven() +@Tags({"test", "debug", "processor", "utility", "flow", "flowfile"}) +@CapabilityDescription("This processor aids in the testing and debugging of the flowfile framework by allowing " + + "a developer or flow manager to force various responses to a flowfile. In response to a receiving a flowfile " + + "it can route to the success or failure relationships, rollback, rollback and yield, rollback with penalty, " + + "or throw an exception. In addition, if using a timer based scheduling strategy, upon being triggered without " + + "a flowfile, it can be configured to throw an exception, when triggered without a flowfile.\n" + + "\n" + + "The 'iterations' properties, such as \"Success iterations\", configure how many times each response should occur " + + "in succession before moving on to the next response within the group of flowfile responses or no flowfile" + + "responses.\n" + + "\n" + + "The order of responses when a flow file is received are:" + + " 1. transfer flowfile to success relationship.\n" + + " 2. transfer flowfile to failure relationship.\n" + + " 3. rollback the flowfile without penalty.\n" + + " 4. rollback the flowfile and yield the context.\n" + + " 5. rollback the flowfile with penalty.\n" + + " 6. throw an exception.\n" + + "\n" + + "The order of responses when no flow file is received are:" + + " 1. yield the context.\n" + + " 2. throw an exception.\n" + + " 3. do nothing and return.\n" + + "\n" + + "By default, the processor is configured to perform each response one time. After processing the list of " + + "responses it will resume from the top of the list.\n" + + "\n" + + "To suppress any response, it's value can be set to zero (0) and no responses of that type will occur during " + + "processing.") +public class DebugFlow extends AbstractProcessor { + + private Set<Relationship> relationships = null; + + static final Relationship REL_SUCCESS = new Relationship.Builder() + .name("success") + .description("Flowfiles processed successfully.") + .build(); + static final Relationship REL_FAILURE = new Relationship.Builder() + .name("failure") + .description("Flowfiles that failed to process.") + .build(); + + private List<PropertyDescriptor> propertyDescriptors = null; + + static final PropertyDescriptor FF_SUCCESS_ITERATIONS = new PropertyDescriptor.Builder() + .name("Success Iterations") + .description("Number of flowfiles to forward to success relationship.") + .required(true) + .defaultValue("1") + .addValidator(StandardValidators.NON_NEGATIVE_INTEGER_VALIDATOR) + .build(); + static final PropertyDescriptor FF_FAILURE_ITERATIONS = new PropertyDescriptor.Builder() + .name("Failure Iterations") + .description("Number of flowfiles to forward to failure relationship.") + .required(true) + .defaultValue("0") + .addValidator(StandardValidators.NON_NEGATIVE_INTEGER_VALIDATOR) + .build(); + static final PropertyDescriptor FF_ROLLBACK_ITERATIONS = new PropertyDescriptor.Builder() + .name("Rollback Iterations") + .description("Number of flowfiles to roll back (without penalty).") + .required(true) + .defaultValue("0") + .addValidator(StandardValidators.NON_NEGATIVE_INTEGER_VALIDATOR) + .build(); + static final PropertyDescriptor FF_ROLLBACK_YIELD_ITERATIONS = new PropertyDescriptor.Builder() + .name("Rollback Yield Iterations") + .description("Number of flowfiles to roll back and yield.") + .required(true) + .defaultValue("0") + .addValidator(StandardValidators.NON_NEGATIVE_INTEGER_VALIDATOR) + .build(); + static final PropertyDescriptor FF_ROLLBACK_PENALTY_ITERATIONS = new PropertyDescriptor.Builder() + .name("Rollback Penalty Iterations") + .description("Number of flowfiles to roll back with penalty.") + .required(true) + .defaultValue("0") + .addValidator(StandardValidators.NON_NEGATIVE_INTEGER_VALIDATOR) + .build(); + static final PropertyDescriptor FF_EXCEPTION_ITERATIONS = new PropertyDescriptor.Builder() + .name("Exception Iterations") + .description("Number of flowfiles to throw NPE exception.") + .required(true) + .defaultValue("0") + .addValidator(StandardValidators.NON_NEGATIVE_INTEGER_VALIDATOR) + .build(); + + static final PropertyDescriptor NO_FF_EXCEPTION_ITERATIONS = new PropertyDescriptor.Builder() + .name("No Flowfile Exception Iterations") + .description("Number of times to throw NPE exception if no flowfile.") + .required(true) + .defaultValue("0") + .addValidator(StandardValidators.NON_NEGATIVE_INTEGER_VALIDATOR) + .build(); + static final PropertyDescriptor NO_FF_YIELD_ITERATIONS = new PropertyDescriptor.Builder() + .name("No Flowfile Yield Iterations") + .description("Number of times to yield if no flowfile.") + .required(true) + .defaultValue("0") + .addValidator(StandardValidators.NON_NEGATIVE_INTEGER_VALIDATOR) + .build(); + static final PropertyDescriptor NO_FF_SKIP_ITERATIONS = new PropertyDescriptor.Builder() + .name("No Flowfile Skip Iterations") + .description("Number of times to skip onTrigger if no flowfile.") + .required(true) + .defaultValue("1") + .addValidator(StandardValidators.NON_NEGATIVE_INTEGER_VALIDATOR) + .build(); + + Integer FF_SUCCESS_MAX = 0; + private Integer FF_FAILURE_MAX = 0; + private Integer FF_ROLLBACK_MAX = 0; + private Integer FF_YIELD_MAX = 0; + private Integer FF_PENALTY_MAX = 0; + private Integer FF_EXCEPTION_MAX = 0; + + private Integer NO_FF_EXCEPTION_MAX = 0; + private Integer NO_FF_YIELD_MAX = 0; + private Integer NO_FF_SKIP_MAX = 0; + + private Integer FF_SUCCESS_CURR = 0; --- End diff -- I will fix the names and looking into cleaning up the concurrency problems.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---