You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by jo...@apache.org on 2015/08/15 19:13:34 UTC
[45/51] [partial] nifi git commit: NIFI-850 removed nifi parent,
updated nifi pom, moved all nifi subdirs up one level, fixed readme.
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/processor/Relationship.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/Relationship.java b/nifi-api/src/main/java/org/apache/nifi/processor/Relationship.java
new file mode 100644
index 0000000..d9f13be
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/Relationship.java
@@ -0,0 +1,126 @@
+/*
+ * 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.processor;
+
+/**
+ * An immutable object for holding information about a type of relationship.
+ *
+ */
+public final class Relationship implements Comparable<Relationship> {
+
+ public static final Relationship SELF = new Relationship.Builder().build();
+ public static final Relationship ANONYMOUS = new Relationship.Builder().name("").build();
+
+ /**
+ * The proper name of the relationship. Determines the relationship
+ * 'identity'
+ */
+ private final String name;
+ /**
+ * A user displayable description of the purpose of this relationship.
+ */
+ private final String description;
+
+ /**
+ * The hash code, which is computed in the constructor because it is hashed
+ * very frequently and the hash code is constant
+ */
+ private final int hashCode;
+
+ protected Relationship(final Builder builder) {
+ this.name = builder.name == null ? null : builder.name.intern();
+ this.description = builder.description;
+ this.hashCode = 301 + this.name.hashCode(); // compute only once, since it gets called a bunch and will never change
+ }
+
+ @Override
+ public int compareTo(final Relationship o) {
+ if (o == null) {
+ return -1;
+ }
+ final String thisName = getName();
+ final String thatName = o.getName();
+ if (thisName == null && thatName == null) {
+ return 0;
+ }
+ if (thisName == null) {
+ return 1;
+ }
+ if (thatName == null) {
+ return -1;
+ }
+
+ return thisName.compareTo(thatName);
+ }
+
+ public static final class Builder {
+
+ private String name = "";
+ private String description = "";
+
+ public Builder name(final String name) {
+ if (null != name) {
+ this.name = name;
+ }
+ return this;
+ }
+
+ public Builder description(final String description) {
+ if (null != description) {
+ this.description = description;
+ }
+ return this;
+ }
+
+ public Relationship build() {
+ return new Relationship(this);
+ }
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+
+ @Override
+ public boolean equals(final Object other) {
+ if (other == null) {
+ return false;
+ }
+ if (!(other instanceof Relationship)) {
+ return false;
+ }
+ if (this == other) {
+ return true;
+ }
+ Relationship desc = (Relationship) other;
+ return this.name.equals(desc.name);
+ }
+
+ @Override
+ public int hashCode() {
+ return hashCode;
+ }
+
+ @Override
+ public String toString() {
+ return this.name;
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/processor/SchedulingContext.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/SchedulingContext.java b/nifi-api/src/main/java/org/apache/nifi/processor/SchedulingContext.java
new file mode 100644
index 0000000..0cfc0be
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/SchedulingContext.java
@@ -0,0 +1,70 @@
+/*
+ * 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.processor;
+
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.PropertyValue;
+import org.apache.nifi.controller.ControllerServiceLookup;
+
+public interface SchedulingContext extends ProcessContext {
+
+ /**
+ * <p>
+ * Indicates to the framework that the Controller Service with the given
+ * identifier will be used by this Processor. This will prevent any Data
+ * Flow Manager from disabling the Controller Service while this Processor
+ * is still running.
+ * </p>
+ *
+ * <p>
+ * Generally, a Controller Service is accessed by indicating in a
+ * {@link PropertyDescriptor} that the PropertyDescriptor identifies a
+ * Controller Service via the
+ * {@link PropertyDescriptor.Builder#identifiesControllerService(Class) identifiesControllerService(Class)}
+ * method and then calling
+ * {@link ProcessContext#getProperty(PropertyDescriptor)}.{@link PropertyValue#asControllerService(Class) asControllerService(Class)}.
+ * In this case, it is not necessary to lease the Controller Service, as the
+ * Framework will handle this.
+ * </p>
+ *
+ * <p>
+ * There are, however, cases in which a Controller Service must be accessed
+ * in a different way, via the {@link ControllerServiceLookup} (accessed via
+ * {@link ProcessContext#getControllerServiceLookup()}). In this case, the
+ * Controller Service that is obtained from the ControllerServiceLookup can
+ * be disabled by a Data Flow Manager while it is still in use by a
+ * Processor, causing IllegalStateException to be thrown whenever the
+ * Processor attempts to interact with the service. This method provides a
+ * mechanism by which a Processor is able to indicate that the Controller
+ * Service with the given identifier should not be disabled while this
+ * Processor is running.
+ * </p>
+ *
+ * <p>
+ * For any Controller Service that is leased by calling this method, the
+ * lease will automatically be terminated, allowing the Controller Service
+ * to be disabled, whenever the Processor is stopped.
+ * </p>
+ *
+ * @param identifier
+ *
+ * @throws IllegalArgumentException if no Controller Service exists with the
+ * given identifier
+ */
+ void leaseControllerService(String identifier);
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/processor/annotation/CapabilityDescription.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/annotation/CapabilityDescription.java b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/CapabilityDescription.java
new file mode 100644
index 0000000..f966f89
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/CapabilityDescription.java
@@ -0,0 +1,42 @@
+/*
+ * 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.processor.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation that may be placed on a processor allowing for a description to be
+ * provided. This description can be provided to a user in logs, UI, etc.
+ *
+ * @deprecated This Annotation has been replaced by the
+ * {@link org.apache.nifi.annotation.documentation.CapabilityDescription}
+ * annotation.
+ */
+@Documented
+@Target({ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Deprecated
+public @interface CapabilityDescription {
+
+ String value();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/processor/annotation/EventDriven.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/annotation/EventDriven.java b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/EventDriven.java
new file mode 100644
index 0000000..0f412ca
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/EventDriven.java
@@ -0,0 +1,51 @@
+/*
+ * 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.processor.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * <p>
+ * Annotation that may be placed on a Processor that indicates to the framework
+ * that the Processor is eligible to be scheduled to run based on the occurrence
+ * of an "Event" (e.g., when a FlowFile is enqueued in an incoming Connection),
+ * rather than being triggered periodically.
+ * </p>
+ *
+ * <p>
+ * This Annotation should not be used in conjunction with
+ * {@link TriggerSerially} or {@link TriggerWhenEmpty}. If this Annotation is
+ * used with either of these other Annotations, the Processor will not be
+ * eligible to be scheduled in Event-Driven mode.
+ * </p>
+ *
+ * @deprecated This Annotation has been replaced by the
+ * {@link org.apache.nifi.annotation.behavior.EventDriven} annotation.
+ */
+@Documented
+@Target({ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Deprecated
+public @interface EventDriven {
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnAdded.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnAdded.java b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnAdded.java
new file mode 100644
index 0000000..ff0b75f
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnAdded.java
@@ -0,0 +1,43 @@
+/*
+ * 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.processor.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Marker annotation a processor implementation can use to indicate a method
+ * should be called whenever the processor is added to the graph. This method
+ * will be called once for the entire life of a processor instance.
+ *
+ * If any method annotated with this annotation throws, the processor will not
+ * be added to the graph.
+ *
+ * @deprecated This Annotation has been replaced by the
+ * {@link org.apache.nifi.annotation.lifecycle.OnAdded} annotation.
+ */
+@Documented
+@Target({ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Deprecated
+public @interface OnAdded {
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnRemoved.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnRemoved.java b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnRemoved.java
new file mode 100644
index 0000000..740e9f8
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnRemoved.java
@@ -0,0 +1,44 @@
+/*
+ * 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.processor.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Marker annotation a processor implementation can use to indicate a method
+ * should be called whenever the processor is removed from the graph. This
+ * method will be called once for the entire life of a processor instance unless
+ * an invocation of this method throws any Throwable.
+ *
+ * If any method annotated with this annotation throws, the processor will not
+ * be removed from the graph.
+ *
+ * @deprecated This Annotation has been replaced by the
+ * {@link org.apache.nifi.annotation.lifecycle.OnRemoved} annotation.
+ */
+@Documented
+@Target({ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Deprecated
+public @interface OnRemoved {
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnScheduled.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnScheduled.java b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnScheduled.java
new file mode 100644
index 0000000..3815de2
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnScheduled.java
@@ -0,0 +1,46 @@
+/*
+ * 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.processor.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Marker annotation a processor implementation can use to indicate a method
+ * should be called whenever the processor is scheduled for processing. This
+ * will be called before any 'onTrigger' calls and will be called once each time
+ * a processor instance is scheduled to run. Methods using this annotation must
+ * take either 0 arguments or a single argument of type
+ * {@link nifi.processor.SchedulingContext SchedulingContext}.
+ *
+ * If any method annotated with this annotation throws, the processor will not
+ * be scheduled to run.
+ *
+ * @deprecated This Annotation has been replaced by the
+ * {@link org.apache.nifi.annotation.lifecycle.OnScheduled} annotation.
+ */
+@Documented
+@Target({ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Deprecated
+public @interface OnScheduled {
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnShutdown.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnShutdown.java b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnShutdown.java
new file mode 100644
index 0000000..930a9df
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnShutdown.java
@@ -0,0 +1,40 @@
+/*
+ * 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.processor.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Marker annotation a processor implementation can use to indicate a method
+ * should be called whenever the flow is being shutdown. This will be called at
+ * most once for each processor instance in a process lifetime.
+ *
+ * @deprecated This Annotation has been replaced by the
+ * {@link org.apache.nifi.annotation.lifecycle.OnShutdown} annotation.
+ */
+@Documented
+@Target({ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Deprecated
+public @interface OnShutdown {
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnStopped.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnStopped.java b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnStopped.java
new file mode 100644
index 0000000..4fbaf95
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnStopped.java
@@ -0,0 +1,58 @@
+/*
+ * 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.processor.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * <p>
+ * Marker annotation a processor implementation can use to indicate a method
+ * should be called whenever the processor is no longer scheduled to run.
+ * Methods marked with this annotation will be invoked each time the processor
+ * is stopped and will be invoked only after the last thread has returned from
+ * the <code>onTrigger</code> method.
+ * </p>
+ *
+ * <p>
+ * This means that the thread executing in this method will be the only thread
+ * executing in any part of the Processor. However, since other threads may
+ * later execute other parts of the code, member variables must still be
+ * protected appropriately. However, access to multiple variables need not be
+ * atomic.
+ * </p>
+ *
+ * <p>
+ * To indicate that a method should be called immediately when a processor is no
+ * longer scheduled to run, see the {@link OnUnscheduled} annotation.
+ * </p>
+ *
+ * @deprecated This Annotation has been replaced by the
+ * {@link org.apache.nifi.annotation.lifecycle.OnStopped} annotation.
+ */
+@Documented
+@Target({ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Deprecated
+public @interface OnStopped {
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnUnscheduled.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnUnscheduled.java b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnUnscheduled.java
new file mode 100644
index 0000000..7b4c1f6
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/OnUnscheduled.java
@@ -0,0 +1,48 @@
+/*
+ * 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.processor.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * <p>
+ * Marker annotation a processor implementation can use to indicate a method
+ * should be called whenever the processor is no longer scheduled to run.
+ * Methods marked with this annotation will be invoked each time the framework
+ * is notified to stop scheduling the processor. This method is invoked as other
+ * threads are potentially running. To invoke a method after all threads have
+ * finished processing, see the {@link OnStopped} annotation.
+ * </p>
+ *
+ * If any method annotated with this annotation throws, the processor will not
+ * be scheduled to run.
+ *
+ * @deprecated This Annotation has been replaced by the
+ * {@link org.apache.nifi.annotation.lifecycle.OnUnscheduled} annotation.
+ */
+@Documented
+@Target({ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Deprecated
+public @interface OnUnscheduled {
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/processor/annotation/SideEffectFree.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/annotation/SideEffectFree.java b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/SideEffectFree.java
new file mode 100644
index 0000000..6c65caa
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/SideEffectFree.java
@@ -0,0 +1,47 @@
+/*
+ * 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.processor.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Marker annotation a processor implementation can use to indicate that its
+ * operations on flow files can be safely repeated across process sessions. If a
+ * processor has this annotation and it allows the framework to manage session
+ * commit and rollback then the framework may elect to cascade a
+ * <code>ProcessSession</code> given to this processor's onTrigger method to the
+ * onTrigger method of another processor. It can do this knowing that if
+ * something fails along a series of processors using this same session that it
+ * can all be safely rolled back without any ill effects on external services
+ * which could not be rolled back and thus all the processes could be safely
+ * repeated (implied idempotent behavior).
+ *
+ * @deprecated This Annotation has been replaced by the
+ * {@link org.apache.nifi.annotation.behavior.SideEffectFree} annotation.
+ */
+@Documented
+@Target({ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Deprecated
+public @interface SideEffectFree {
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/processor/annotation/SupportsBatching.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/annotation/SupportsBatching.java b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/SupportsBatching.java
new file mode 100644
index 0000000..5b3d1aa
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/SupportsBatching.java
@@ -0,0 +1,53 @@
+/*
+ * 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.processor.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Marker annotation a Processor implementation can use to indicate that users
+ * should be able to supply a Batch Duration for the Processor. If a Processor
+ * uses this annotation, it is allowing the Framework to batch
+ * {@link nifi.processor.ProcessSession ProcessSession}s' commits, as well as
+ * allowing the Framework to return the same ProcessSession multiple times from
+ * subsequent calls to
+ * {@link nifi.processor.ProcessSessionFactory ProcessSessionFactory}.{@link nifi.processor.ProcessSessionFactory#createSession() createSession()}.
+ *
+ * When this Annotation is used, it is important to note that calls to
+ * {@link nifi.processor.ProcessSession#commit() ProcessSession.commit()} may
+ * not provide a guarantee that the data has been safely stored in NiFi's
+ * Content Repository or FlowFile Repository. Therefore, it is not appropriate,
+ * for instance, to use this annotation if the Processor will call
+ * ProcessSession.commit() to ensure data is persisted before deleting the data
+ * from a remote source.
+ *
+ * @deprecated This Annotation has been replaced by the
+ * {@link org.apache.nifi.annotation.behavior.SupportsBatching} annotation.
+ */
+@Documented
+@Target({ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Deprecated
+public @interface SupportsBatching {
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/processor/annotation/Tags.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/annotation/Tags.java b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/Tags.java
new file mode 100644
index 0000000..81428d7
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/Tags.java
@@ -0,0 +1,43 @@
+/*
+ * 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.processor.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation that can be applied to a {@link Processor} in order to associate
+ * tags with the processor. These tags do not affect the {@link Processor} in
+ * any way but serve as additional documentation and can be used to sort/filter
+ * Processors.
+ *
+ * @deprecated This Annotation has been replaced by the
+ * {@link org.apache.nifi.annotation.documentation.Tags} annotation.
+ */
+@Documented
+@Target({ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Deprecated
+public @interface Tags {
+
+ public String[] value();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/processor/annotation/TriggerSerially.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/annotation/TriggerSerially.java b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/TriggerSerially.java
new file mode 100644
index 0000000..6e80cef
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/TriggerSerially.java
@@ -0,0 +1,41 @@
+/*
+ * 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.processor.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Marker annotation a processor implementation can use to indicate that the
+ * processor is not thread safe for concurrent execution of its onTrigger()
+ * method. By default processors are assumed to be thread safe for concurrent
+ * execution.
+ *
+ * @deprecated This Annotation has been replaced by the
+ * {@link org.apache.nifi.annotation.behavior.TriggerSerially} annotation.
+ */
+@Documented
+@Target({ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Deprecated
+public @interface TriggerSerially {
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/processor/annotation/TriggerWhenAnyDestinationAvailable.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/annotation/TriggerWhenAnyDestinationAvailable.java b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/TriggerWhenAnyDestinationAvailable.java
new file mode 100644
index 0000000..6e01f6c
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/TriggerWhenAnyDestinationAvailable.java
@@ -0,0 +1,43 @@
+/*
+ * 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.processor.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Marker annotation a processor implementation can use to indicate that the
+ * processor is to be triggered if any of its destinations has available space
+ * for incoming FlowFiles. By default processors are triggered only when all
+ * destinations report that they have available space.
+ *
+ * @deprecated This Annotation has been replaced by the
+ * {@link org.apache.nifi.annotation.behavior.TriggerWhenAnyDestinationAvailable}
+ * annotation.
+ */
+@Documented
+@Target({ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Deprecated
+public @interface TriggerWhenAnyDestinationAvailable {
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/processor/annotation/TriggerWhenEmpty.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/annotation/TriggerWhenEmpty.java b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/TriggerWhenEmpty.java
new file mode 100644
index 0000000..d068a9e
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/annotation/TriggerWhenEmpty.java
@@ -0,0 +1,43 @@
+/*
+ * 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.processor.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Marker annotation a processor implementation can use to indicate that the
+ * processor should still be triggered even when it has no data in its work
+ * queue. By default, processors which have no non-self incoming edges will be
+ * triggered even if there is no work in its queue. However, processors that
+ * have non-self incoming edges will only be triggered if they have work in
+ * their queue or they present this annotation.
+ *
+ * @deprecated This Annotation has been replaced by the
+ * {@link org.apache.nifi.annotation.behavior.TriggerWhenEmpty} annotation.
+ */
+@Documented
+@Target({ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+@Deprecated
+public @interface TriggerWhenEmpty {
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/processor/exception/FlowFileAccessException.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/exception/FlowFileAccessException.java b/nifi-api/src/main/java/org/apache/nifi/processor/exception/FlowFileAccessException.java
new file mode 100644
index 0000000..c7e9c22
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/exception/FlowFileAccessException.java
@@ -0,0 +1,36 @@
+/*
+ * 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.processor.exception;
+
+/**
+ * Indicates an issue occurred while accessing the content of a FlowFile, such
+ * as an IOException.
+ *
+ */
+public class FlowFileAccessException extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public FlowFileAccessException(final String message) {
+ super(message);
+ }
+
+ public FlowFileAccessException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/processor/exception/FlowFileHandlingException.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/exception/FlowFileHandlingException.java b/nifi-api/src/main/java/org/apache/nifi/processor/exception/FlowFileHandlingException.java
new file mode 100644
index 0000000..d5bf62d
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/exception/FlowFileHandlingException.java
@@ -0,0 +1,38 @@
+/*
+ * 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.processor.exception;
+
+/**
+ * Thrown when a flow file is referenced that is not part of the appropriate
+ * session or is not properly accounted for by a transfer or removal within a
+ * session. In any event this exception indicates a logic or programming error
+ * within the processor interacting with the offending session.
+ *
+ */
+public class FlowFileHandlingException extends ProcessException {
+
+ private static final long serialVersionUID = 1L;
+
+ public FlowFileHandlingException(final String message) {
+ super(message);
+ }
+
+ public FlowFileHandlingException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/processor/exception/MissingFlowFileException.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/exception/MissingFlowFileException.java b/nifi-api/src/main/java/org/apache/nifi/processor/exception/MissingFlowFileException.java
new file mode 100644
index 0000000..700afd5
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/exception/MissingFlowFileException.java
@@ -0,0 +1,36 @@
+/*
+ * 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.processor.exception;
+
+/**
+ * Thrown to indicate that the content for some FlowFile could not be found.
+ * This indicates that the data is gone and likely cannot be restored and any
+ * information about the FlowFile should be discarded entirely. This likely
+ * indicates some influence from an external process outside the control of the
+ * framework and it is not something any processor or the framework can recover
+ * so it must discard the object.
+ *
+ */
+public class MissingFlowFileException extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public MissingFlowFileException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/processor/exception/ProcessException.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/exception/ProcessException.java b/nifi-api/src/main/java/org/apache/nifi/processor/exception/ProcessException.java
new file mode 100644
index 0000000..f162b14
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/exception/ProcessException.java
@@ -0,0 +1,43 @@
+/*
+ * 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.processor.exception;
+
+/**
+ * Indicates an issue occurred in user code while processing a FlowFile.
+ *
+ */
+public class ProcessException extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public ProcessException() {
+ super();
+ }
+
+ public ProcessException(final String message) {
+ super(message);
+ }
+
+ public ProcessException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+ public ProcessException(final Throwable cause) {
+ super(cause);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/processor/io/InputStreamCallback.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/io/InputStreamCallback.java b/nifi-api/src/main/java/org/apache/nifi/processor/io/InputStreamCallback.java
new file mode 100644
index 0000000..6873f2e
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/io/InputStreamCallback.java
@@ -0,0 +1,37 @@
+/*
+ * 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.processor.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ *
+ */
+public interface InputStreamCallback {
+
+ /**
+ * Provides a managed input stream for use. The input stream is
+ * automatically opened and closed though it is ok to close the stream
+ * manually.
+ *
+ * @param in the stream to read bytes from
+ * @throws IOException if issues reading from the underlying stream
+ */
+ void process(InputStream in) throws IOException;
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/processor/io/OutputStreamCallback.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/io/OutputStreamCallback.java b/nifi-api/src/main/java/org/apache/nifi/processor/io/OutputStreamCallback.java
new file mode 100644
index 0000000..86fe1a7
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/io/OutputStreamCallback.java
@@ -0,0 +1,38 @@
+/*
+ * 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.processor.io;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ *
+ */
+public interface OutputStreamCallback {
+
+ /**
+ * Provides a managed output stream for use. The input stream is
+ * automatically opened and closed though it is ok to close the stream
+ * manually - and quite important if any streams wrapping these streams open
+ * resources which should be cleared.
+ *
+ * @param out the stream to write bytes to
+ * @throws IOException if issues writing to output stream
+ */
+ void process(OutputStream out) throws IOException;
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/processor/io/StreamCallback.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/processor/io/StreamCallback.java b/nifi-api/src/main/java/org/apache/nifi/processor/io/StreamCallback.java
new file mode 100644
index 0000000..54f0e3b
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/processor/io/StreamCallback.java
@@ -0,0 +1,37 @@
+/*
+ * 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.processor.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public interface StreamCallback {
+
+ /**
+ * Provides a managed output stream for use. The input stream is
+ * automatically opened and closed though it is ok to close the stream
+ * manually - and quite important if any streams wrapping these streams open
+ * resources which should be cleared.
+ *
+ * @param in the stream to read bytes from
+ * @param out the stream to write bytes to
+ * @throws IOException if issues occur reading or writing the underlying streams
+ */
+ void process(InputStream in, OutputStream out) throws IOException;
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventBuilder.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventBuilder.java b/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventBuilder.java
new file mode 100644
index 0000000..0ffccd5
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventBuilder.java
@@ -0,0 +1,308 @@
+/*
+ * 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.provenance;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.processor.Processor;
+import org.apache.nifi.processor.Relationship;
+
+public interface ProvenanceEventBuilder {
+
+ /**
+ * Sets the type of {@link ProvenanceEventRecord}
+ *
+ * @param eventType of the event
+ * @return the builder
+ */
+ ProvenanceEventBuilder setEventType(ProvenanceEventType eventType);
+
+ /**
+ * Populates the values of the Event being built from the values in the
+ * given event
+ *
+ * @param event the event from which to populate the Builders values
+ * @return the builder
+ */
+ ProvenanceEventBuilder fromEvent(ProvenanceEventRecord event);
+
+ /**
+ * Sets the date and time at which the FlowFile entered the flow
+ *
+ * @param entryDate of the flow file
+ * @return the builder
+ */
+ ProvenanceEventBuilder setFlowFileEntryDate(long entryDate);
+
+ /**
+ * Sets the Lineage Identifiers. This is a set of all FlowFile UUID's that
+ * were involved in making this event occur.
+ *
+ * @param lineageIdentifiers of the flowfiles in this event
+ * @return the builder
+ */
+ ProvenanceEventBuilder setLineageIdentifiers(Set<String> lineageIdentifiers);
+
+ /**
+ * Sets the Content Claim that the FlowFile was previously associated with
+ * before this event occurred.
+ *
+ * @param container for previous content
+ * @param section for previous content
+ * @param identifier for previous content
+ * @param offset for previous content
+ * @param size for previous content
+ * @return the builder
+ */
+ ProvenanceEventBuilder setPreviousContentClaim(String container, String section, String identifier, Long offset, long size);
+
+ /**
+ * Sets the Content Claim that the FlowFile is associated with as a result
+ * of this event
+ *
+ * @param container for resulting content
+ * @param section for resulting content
+ * @param identifier for resulting content
+ * @param offset for resulting content
+ * @param size for resulting content
+ * @return the builder
+ */
+ ProvenanceEventBuilder setCurrentContentClaim(String container, String section, String identifier, Long offset, long size);
+
+ /**
+ * Sets the identifier of the FlowFile Queue from which the FlowFile was
+ * pulled
+ *
+ * @param identifier of the source queue
+ * @return the builder
+ */
+ ProvenanceEventBuilder setSourceQueueIdentifier(String identifier);
+
+ /**
+ * Sets the attributes that existed on the FlowFile before this event
+ * occurred and any attributes that were added or updated as a result of
+ * this event.
+ *
+ * @param previousAttributes Map of all attributes before the event occurred
+ * @param updatedAttributes Map containing all attributes that were added or
+ * updated. If any entry has a value of <code>null</code>, that attribute is
+ * considered removed
+ *
+ * @return the builder
+ */
+ ProvenanceEventBuilder setAttributes(Map<String, String> previousAttributes, Map<String, String> updatedAttributes);
+
+ /**
+ * Sets the UUID to associate with the FlowFile
+ *
+ * @param uuid of the flowfile
+ * @return the builder
+ */
+ ProvenanceEventBuilder setFlowFileUUID(String uuid);
+
+ /**
+ * Sets the time at which the Provenance Event took place
+ *
+ * @param eventTime time of the event
+ * @return the builder
+ */
+ ProvenanceEventBuilder setEventTime(long eventTime);
+
+ /**
+ * Sets the amount of time that was required in order to perform the
+ * function referred to by this event
+ *
+ * @param millis of the event
+ * @return the builder
+ */
+ ProvenanceEventBuilder setEventDuration(long millis);
+
+ /**
+ * Sets the time at which the FlowFile's lineage began
+ *
+ * @param startDate start date of the event
+ * @return the builder
+ */
+ ProvenanceEventBuilder setLineageStartDate(long startDate);
+
+ /**
+ * Sets the unique identifier of the NiFi Component (such as a
+ * {@link Processor}) that is generating the Event
+ *
+ * @param componentId that produced the event
+ * @return the builder
+ */
+ ProvenanceEventBuilder setComponentId(String componentId);
+
+ /**
+ * Sets the type of the Component that is generating the Event. For
+ * {@link Processor}s, this is the Simple Class Name of the Processor.
+ *
+ * @param componentType of the component that made the event
+ * @return the builder
+ */
+ ProvenanceEventBuilder setComponentType(String componentType);
+
+ /**
+ * Sets the identifier that is used by the remote system to refer to the
+ * FlowFile for which this Event is being created.
+ *
+ * This is valid only for Event Types {@link ProvenanceEventType#RECEIVE}
+ * and {@link ProvenanceEventType#SEND} and will be ignored for any other
+ * event types.
+ *
+ * @param sourceSystemFlowFileIdentifier identifier the remote system used
+ * @return the builder
+ */
+ ProvenanceEventBuilder setSourceSystemFlowFileIdentifier(String sourceSystemFlowFileIdentifier);
+
+ /**
+ * Sets the Transit URI that is used for the Event. This is a URI that
+ * provides information about the System and Protocol information over which
+ * the transfer occurred. The intent of this field is such that both the
+ * sender and the receiver can publish the events to an external
+ * Enterprise-wide system that is then able to correlate the SEND and
+ * RECEIVE events.
+ *
+ * This is valid only for Event Types {@link ProvenanceEventType#RECEIVE}
+ * and {@link ProvenanceEventType#SEND} and will be ignored for any other
+ * event types.
+ *
+ * @param transitUri of the event
+ * @return the builder
+ */
+ ProvenanceEventBuilder setTransitUri(String transitUri);
+
+ /**
+ * Adds the given FlowFile as a parent for Events of type {@link ProvenanceEventType#SPAWN},
+ * {@link ProvenanceEventType#FORK}, {@link ProvenanceEventType#JOIN}, and
+ * {@link ProvenanceEventType#CLONE}
+ *
+ * This is valid only for {@link ProvenanceEventType#SPAWN},
+ * {@link ProvenanceEventType#FORK}, {@link ProvenanceEventType#JOIN}, and
+ * {@link ProvenanceEventType#CLONE} events and will be ignored for any
+ * other event types.
+ *
+ * @param parent flowfile that this event is derived from
+ * @return the builder
+ */
+ ProvenanceEventBuilder addParentFlowFile(FlowFile parent);
+
+ /**
+ * Removes the given FlowFile as a parent for Events of type {@link ProvenanceEventType#SPAWN},
+ * {@link ProvenanceEventType#FORK}, {@link ProvenanceEventType#JOIN}, and
+ * {@link ProvenanceEventType#CLONE}
+ *
+ * This is valid only for {@link ProvenanceEventType#SPAWN},
+ * {@link ProvenanceEventType#FORK}, {@link ProvenanceEventType#JOIN}, and
+ * {@link ProvenanceEventType#CLONE} events and will be ignored for any
+ * other event types.
+ *
+ * @param parent previous parent of this event
+ * @return the builder
+ */
+ ProvenanceEventBuilder removeParentFlowFile(FlowFile parent);
+
+ /**
+ * Adds the given FlowFile as a child for Events of type {@link ProvenanceEventType#SPAWN},
+ * {@link ProvenanceEventType#FORK}, {@link ProvenanceEventType#JOIN}, and
+ * {@link ProvenanceEventType#CLONE}
+ *
+ * This is valid only for {@link ProvenanceEventType#SPAWN},
+ * {@link ProvenanceEventType#FORK}, {@link ProvenanceEventType#JOIN}, and
+ * {@link ProvenanceEventType#CLONE} events and will be ignored for any
+ * other event types.
+ *
+ * @param child the child to add
+ * @return the builder
+ */
+ ProvenanceEventBuilder addChildFlowFile(FlowFile child);
+
+ /**
+ * Removes the given FlowFile as a child for Events of type {@link ProvenanceEventType#SPAWN},
+ * {@link ProvenanceEventType#FORK}, {@link ProvenanceEventType#JOIN}, and
+ * {@link ProvenanceEventType#CLONE}
+ *
+ * This is valid only for {@link ProvenanceEventType#SPAWN},
+ * {@link ProvenanceEventType#FORK}, {@link ProvenanceEventType#JOIN}, and
+ * {@link ProvenanceEventType#CLONE} events and will be ignored for any
+ * other event types.
+ *
+ * @param child to remove
+ * @return the builder
+ */
+ ProvenanceEventBuilder removeChildFlowFile(FlowFile child);
+
+ /**
+ * Associates the given identifier with the FlowFile for which this Event is
+ * created. This provides a linkage between the given FlowFile and alternate
+ * identifier. This information can be useful if published to an external,
+ * enterprise-wide Provenance tracking system that is able to associate the
+ * data between different processes or services.
+ *
+ * This is valid only for {@link ProvenanceEventType#ADDINFO} events and
+ * will be ignored for any other event types.
+ *
+ * @param alternateIdentifierUri another identifier of the flowfile this event is for
+ * @return the builder
+ */
+ ProvenanceEventBuilder setAlternateIdentifierUri(String alternateIdentifierUri);
+
+ /**
+ * Sets the details for this event. This is a free-form String that can
+ * contain any information that is relevant to this event.
+ *
+ * @param details a description of the event
+ * @return the builder
+ */
+ ProvenanceEventBuilder setDetails(String details);
+
+ /**
+ * Sets the to which the FlowFile was routed for
+ * {@link ProvenanceEventType#ROUTE} events. This is valid only for
+ * {@link ProvenanceEventType#ROUTE} events and will be ignored for any
+ * other event types.
+ *
+ * @param relationship to which flowfiles in this event were routed
+ * @return the builder
+ */
+ ProvenanceEventBuilder setRelationship(Relationship relationship);
+
+ /**
+ * Populates the builder with as much information as it can from the given
+ * FlowFile
+ *
+ * @param flowFile to source attributes for this event from
+ * @return the builder
+ */
+ ProvenanceEventBuilder fromFlowFile(FlowFile flowFile);
+
+ /**
+ * Builds the Provenance Event. It is possible that calling
+ * {@link ProvenanceEventRecord#getEventId()} on the
+ * {@link ProvenanceEventRecord} that is returned will yield
+ * <code>-1</code>. This is because the implementation of the Event may
+ * depend on the {@link ProvevenanceEventRepository} to generate the unique
+ * identifier.
+ *
+ * @return the event
+ */
+ ProvenanceEventRecord build();
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRecord.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRecord.java b/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRecord.java
new file mode 100644
index 0000000..dc251b3
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRecord.java
@@ -0,0 +1,235 @@
+/*
+ * 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.provenance;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Describes an event that happened to a FlowFile.
+ */
+public interface ProvenanceEventRecord {
+
+ /**
+ * @return a unique ID for this Provenance Event. Depending on the
+ * implementation, the Event ID may be set to -1 until the event has been
+ * added to the {@link ProvenanceEventRepository}
+ */
+ long getEventId();
+
+ /**
+ * @return the time at which this Provenance Event was created, as the
+ * number of milliseconds since epoch
+ */
+ long getEventTime();
+
+ /**
+ * @return the EntryDate of the FlowFile to which this Event is associated
+ */
+ long getFlowFileEntryDate();
+
+ /**
+ * @return the time at which the lineage began
+ */
+ long getLineageStartDate();
+
+ /**
+ * @return the set of all lineage identifiers that are associated with the
+ * FlowFile for which this Event was created
+ */
+ Set<String> getLineageIdentifiers();
+
+ /**
+ * @return the size of the FlowFile to which this Event is associated
+ */
+ long getFileSize();
+
+ /**
+ * @return the previous size of the FlowFile to which this Event is
+ * associated, if the FlowFile previously had content and its size was
+ * known; otherwise, returns <code>null</code>
+ */
+ Long getPreviousFileSize();
+
+ /**
+ * @return the amount of time in milliseconds that elapsed while performing
+ * this event. If not populated, the value -1 will be returned
+ */
+ long getEventDuration();
+
+ /**
+ * @return the type of this Provenance Event
+ */
+ ProvenanceEventType getEventType();
+
+ /**
+ * @return all FlowFile attributes that were associated with the FlowFile at
+ * the time that this ProvenanceEvent was created
+ */
+ Map<String, String> getAttributes();
+
+ /**
+ * @return all FlowFile attributes that existed on the FlowFile before this
+ * event occurred
+ */
+ Map<String, String> getPreviousAttributes();
+
+ /**
+ * @return all FlowFile attributes that were updated as a result of this
+ * event
+ */
+ Map<String, String> getUpdatedAttributes();
+
+ /**
+ * @return the ID of the Processor/component that created this Provenance
+ * Event
+ */
+ String getComponentId();
+
+ /**
+ * @return the fully-qualified Class Name of the Processor/component that
+ * created this Provenance Event
+ */
+ String getComponentType();
+
+ /**
+ * @return a URI that provides information about the System and Protocol
+ * information over which the transfer occurred. The intent of this field is
+ * such that both the sender and the receiver can publish the events to an
+ * external Enterprise-wide system that is then able to correlate the SEND
+ * and RECEIVE events.
+ */
+ String getTransitUri();
+
+ /**
+ * Since the receiving system will usually refer to the data using a
+ * different identifier than the source system, this information is used to
+ * correlate the receive system's FlowFile with the sending system's data
+ *
+ * @return the UUID that the Source System used to refer to this data; this
+ * is applicable only when the {@link ProvenanceEventType} is of type
+ * {@link ProvenanceEventType#RECEIVE RECEIVE}
+ */
+ String getSourceSystemFlowFileIdentifier();
+
+ /**
+ * @return the UUID of the FlowFile with which this Event is associated
+ */
+ String getFlowFileUuid();
+
+ /**
+ * @return the UUID's of all Parent FlowFiles. This is applicable only when
+ * the {@link ProvenanceEventType} is of type
+ * {@link ProvenanceEventType#SPAWN SPAWN}
+ */
+ List<String> getParentUuids();
+
+ /**
+ * @return the UUID's of all Child FlowFiles. This is applicable only when
+ * the {@link ProvenanceEventType} is of type
+ * {@link ProvenanceEventType#SPAWN SPAWN}
+ */
+ List<String> getChildUuids();
+
+ /**
+ * @return the Alternate Identifier associated with the FlowFile with which
+ * this Event is associated. This is applicable only when the
+ * {@link ProvenanceEventType} is of type
+ * {@link ProvenanceEventType#ADDINFO}
+ */
+ String getAlternateIdentifierUri();
+
+ /**
+ * @return the details for this record, if any were supplied. Otherwise,
+ * returns <code>null</code>
+ */
+ String getDetails();
+
+ /**
+ * @return the relationship to which this record was routed if the event
+ * type is {@link ProvenanceEventType#ROUTE}. The relationship is applicable
+ * only to this type
+ */
+ String getRelationship();
+
+ /**
+ * @return the identifier of the queue from which the FlowFile was taken, if
+ * any. If the FlowFile is created as a result of this event (in this case,
+ * the Event Type is one of null null null null null null null null {@link ProvenanceEventType#CREATE}, {@link ProvenanceEventType#RECEIVE},
+ * {@link ProvenanceEventType#FORK}, {@link ProvenanceEventType#JOIN}, or
+ * {@link ProvenanceEventType#CLONE}), or if the queue identifier is
+ * unknown, then this method will return <code>null</code>
+ *
+ */
+ String getSourceQueueIdentifier();
+
+ /**
+ * @return the Section for the Content Claim that this Event refers to, if
+ * any; otherwise, returns <code>null</code>
+ *
+ */
+ String getContentClaimSection();
+
+ /**
+ * @return the Section for the Content Claim that the FlowFile previously
+ * referenced, if any; otherwise, returns <code>null</code>
+ *
+ */
+ String getPreviousContentClaimSection();
+
+ /**
+ * @return the Container for the Content Claim that this Event refers to, if
+ * any; otherwise, returns <code>null</code>
+ *
+ */
+ String getContentClaimContainer();
+
+ /**
+ * @return the Container for the Content Claim that the FlowFile previously
+ * referenced, if any; otherwise, returns <code>null</code>
+ */
+ String getPreviousContentClaimContainer();
+
+ /**
+ * @return the Identifier for the Content Claim that this Event refers to,
+ * if any; otherwise, returns <code>null</code>
+ *
+ */
+ String getContentClaimIdentifier();
+
+ /**
+ * @return the Identifier for the Content Claim that the FlowFile previously
+ * referenced, if any; otherwise, returns <code>null</code>
+ *
+ */
+ String getPreviousContentClaimIdentifier();
+
+ /**
+ * @return the offset into the Content Claim at which the FlowFile's content
+ * begins, if any; otherwise, returns <code>null</code>
+ *
+ */
+ Long getContentClaimOffset();
+
+ /**
+ * @return the offset into the Content Claim at which the FlowFile's
+ * previous content began, if any; otherwise, returns <code>null</code>
+ *
+ */
+ Long getPreviousContentClaimOffset();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRepository.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRepository.java b/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRepository.java
new file mode 100644
index 0000000..25563b7
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRepository.java
@@ -0,0 +1,180 @@
+/*
+ * 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.provenance;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.nifi.events.EventReporter;
+import org.apache.nifi.provenance.lineage.ComputeLineageSubmission;
+import org.apache.nifi.provenance.search.Query;
+import org.apache.nifi.provenance.search.QuerySubmission;
+import org.apache.nifi.provenance.search.SearchableField;
+
+/**
+ * This Repository houses Provenance Events. The repository is responsible for
+ * managing the life-cycle of the events, providing access to the events that it
+ * has stored, and providing query capabilities against the events.
+ *
+ */
+public interface ProvenanceEventRepository {
+
+ /**
+ * Performs any initialization needed. This should be called only by the
+ * framework.
+ *
+ * @param eventReporter to report to
+ * @throws java.io.IOException if unable to initialize
+ */
+ void initialize(EventReporter eventReporter) throws IOException;
+
+ /**
+ * Returns a {@link ProvenanceEventBuilder} that is capable of building
+ * {@link ProvenanceEventRecord}s
+ *
+ * @return builder
+ */
+ ProvenanceEventBuilder eventBuilder();
+
+ /**
+ * Adds the given event to the repository and returns a new event for which
+ * the event id has been populated. Depending on the implementation, the
+ * returned event may or may not be the same event given
+ *
+ * @param event to register
+ */
+ void registerEvent(ProvenanceEventRecord event);
+
+ /**
+ * Adds the given events to the repository.
+ *
+ * <p>
+ * This interface makes no assumptions about whether or not the registration
+ * of the Collection are atomic. This detail is implementation-specific.
+ * </p>
+ *
+ * @param events to register
+ */
+ void registerEvents(Iterable<ProvenanceEventRecord> events);
+
+ /**
+ * Returns a List of all <code>ProvenanceEventRecord</code>s in the
+ * repository starting with the given ID. The first ID in the repository
+ * will always be 0 or higher.
+ *
+ * @param firstRecordId id of the first record to retrieve
+ * @param maxRecords maximum number of records to retrieve
+ * @return records
+ * @throws java.io.IOException if error reading from repository
+ */
+ List<ProvenanceEventRecord> getEvents(long firstRecordId, final int maxRecords) throws IOException;
+
+ /**
+ * @return the largest ID of any event that is queryable in the repository.
+ * If no queryable events exists, returns null
+ */
+ Long getMaxEventId();
+
+ /**
+ * Submits an asynchronous request to process the given query, returning an
+ * identifier that can be used to fetch the results at a later time
+ *
+ * @param query to submit
+ * @return an identifier that can be used to fetch the results at a later
+ * time
+ */
+ QuerySubmission submitQuery(Query query);
+
+ /**
+ * @param queryIdentifier of the query
+ *
+ * @return the QueryResult associated with the given identifier, if the
+ * query has finished processing. If the query has not yet finished running,
+ * returns <code>null</code>
+ */
+ QuerySubmission retrieveQuerySubmission(String queryIdentifier);
+
+ /**
+ * Submits a Lineage Computation to be completed and returns the
+ * AsynchronousLineageResult that indicates the status of the request and
+ * the results, if the computation is complete.
+ *
+ * @param flowFileUuid the UUID of the FlowFile for which the Lineage should
+ * be calculated
+ * @return a {@link ComputeLineageSubmission} object that can be used to
+ * check if the computing is complete and if so get the results
+ */
+ ComputeLineageSubmission submitLineageComputation(String flowFileUuid);
+
+ /**
+ * @param lineageIdentifier identifier of lineage to compute
+ * @return the {@link ComputeLineageSubmission} associated with the given
+ * identifier
+ */
+ ComputeLineageSubmission retrieveLineageSubmission(String lineageIdentifier);
+
+ /**
+ * @param id to lookup
+ * @return the Provenance Event Record with the given ID, if it exists, or
+ * {@code null} otherwise
+ * @throws IOException if failure while retrieving event
+ */
+ ProvenanceEventRecord getEvent(long id) throws IOException;
+
+ /**
+ * Submits a request to expand the parents of the event with the given id
+ *
+ * @param eventId the one-up id of the Event to expand
+ * @return a submission which can be checked for status
+ *
+ * @throws IllegalArgumentException if the given identifier identifies a
+ * Provenance Event that has a Type that is not expandable or if the
+ * identifier cannot be found
+ */
+ ComputeLineageSubmission submitExpandParents(long eventId);
+
+ /**
+ * Submits a request to expand the children of the event with the given id
+ *
+ * @param eventId the one-up id of the Event
+ * @return a submission which can be checked for status
+ *
+ * @throws IllegalArgumentException if the given identifier identifies a
+ * Provenance Event that has a Type that is not expandable or if the
+ * identifier cannot be found
+ */
+ ComputeLineageSubmission submitExpandChildren(long eventId);
+
+ /**
+ * Closes the repository, freeing any resources
+ *
+ * @throws IOException if failure closing repository
+ */
+ void close() throws IOException;
+
+ /**
+ * @return a list of all fields that can be searched via the
+ * {@link #submitQuery(nifi.provenance.search.Query)} method
+ */
+ List<SearchableField> getSearchableFields();
+
+ /**
+ * @return a list of all FlowFile attributes that can be searched via the
+ * {@link #submitQuery(nifi.provenance.search.Query)} method
+ */
+ List<SearchableField> getSearchableAttributes();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa998847/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventType.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventType.java b/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventType.java
new file mode 100644
index 0000000..f2638fe
--- /dev/null
+++ b/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventType.java
@@ -0,0 +1,92 @@
+/*
+ * 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.provenance;
+
+public enum ProvenanceEventType {
+
+ /**
+ * A CREATE event is used when a FlowFile is generated from data that was
+ * not received from a remote system or external process
+ */
+ CREATE,
+ /**
+ * Indicates a provenance event for receiving data from an external process
+ */
+ RECEIVE,
+ /**
+ * Indicates a provenance event for sending data to an external process
+ */
+ SEND,
+ /**
+ * Indicates a provenance event for the conclusion of an object's life for
+ * some reason other than object expiration
+ */
+ DROP,
+ /**
+ * Indicates a provenance event for the conclusion of an object's life due
+ * to the fact that the object could not be processed in a timely manner
+ */
+ EXPIRE,
+ /**
+ * FORK is used to indicate that one or more FlowFile was derived from a
+ * parent FlowFile.
+ */
+ FORK,
+ /**
+ * JOIN is used to indicate that a single FlowFile is derived from joining
+ * together multiple parent FlowFiles.
+ */
+ JOIN,
+ /**
+ * CLONE is used to indicate that a FlowFile is an exact duplicate of its
+ * parent FlowFile.
+ */
+ CLONE,
+ /**
+ * CONTENT_MODIFIED is used to indicate that a FlowFile's content was
+ * modified in some way. When using this Event Type, it is advisable to
+ * provide details about how the content is modified.
+ */
+ CONTENT_MODIFIED,
+ /**
+ * ATTRIBUTES_MODIFIED is used to indicate that a FlowFile's attributes were
+ * modified in some way. This event is not needed when another event is
+ * reported at the same time, as the other event will already contain all
+ * FlowFile attributes.
+ */
+ ATTRIBUTES_MODIFIED,
+ /**
+ * ROUTE is used to show that a FlowFile was routed to a specified
+ * {@link nifi.processor.Relationship Relationship} and should provide
+ * information about why the FlowFile was routed to this relationship.
+ */
+ ROUTE,
+ /**
+ * Indicates a provenance event for adding additional information such as a
+ * new linkage to a new URI or UUID
+ */
+ ADDINFO,
+ /**
+ * Indicates a provenance event for replaying a FlowFile. The UUID of the
+ * event will indicate the UUID of the original FlowFile that is being
+ * replayed. The event will contain exactly one Parent UUID that is also the
+ * UUID of the FlowFile that is being replayed and exactly one Child UUID
+ * that is the UUID of the a newly created FlowFile that will be re-queued
+ * for processing.
+ */
+ REPLAY
+}