nifi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pvill...@apache.org
Subject nifi git commit: NIFI-1682 Adding AttributeRollingWindow processor
Date Mon, 06 Mar 2017 18:43:16 GMT
Repository: nifi
Updated Branches:
  refs/heads/master 16bde02ed -> b7f946e84


NIFI-1682 Adding AttributeRollingWindow processor

Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com>

This closes #1328.


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/b7f946e8
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/b7f946e8
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/b7f946e8

Branch: refs/heads/master
Commit: b7f946e8472271597db165beec69e50ae139b420
Parents: 16bde02
Author: jpercivall <JPercivall@apache.org>
Authored: Mon Dec 12 22:51:36 2016 -0500
Committer: Pierre Villard <pierre.villard.fr@gmail.com>
Committed: Mon Mar 6 19:42:25 2017 +0100

----------------------------------------------------------------------
 nifi-assembly/pom.xml                           |   5 +
 .../nifi-stateful-analysis-nar/pom.xml          |  40 ++
 .../src/main/resources/META-INF/LICENSE         | 233 ++++++++++++
 .../src/main/resources/META-INF/NOTICE          |  27 ++
 .../nifi-stateful-analysis-processors/pom.xml   |  68 ++++
 .../analysis/AttributeRollingWindow.java        | 376 +++++++++++++++++++
 .../org.apache.nifi.processor.Processor         |  15 +
 .../analysis/TestAttributeRollingWindow.java    | 266 +++++++++++++
 .../nifi-stateful-analysis-bundle/pom.xml       |  37 ++
 nifi-nar-bundles/pom.xml                        |   1 +
 pom.xml                                         |   6 +
 11 files changed, 1074 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/b7f946e8/nifi-assembly/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-assembly/pom.xml b/nifi-assembly/pom.xml
index a4421ae..3e5104f 100755
--- a/nifi-assembly/pom.xml
+++ b/nifi-assembly/pom.xml
@@ -438,6 +438,11 @@ language governing permissions and limitations under the License. -->
             <artifactId>nifi-gcp-nar</artifactId>
             <type>nar</type>
         </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-stateful-analysis-nar</artifactId>
+            <type>nar</type>
+        </dependency>
     </dependencies>
     <profiles>
         <profile>

http://git-wip-us.apache.org/repos/asf/nifi/blob/b7f946e8/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-nar/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-nar/pom.xml b/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-nar/pom.xml
new file mode 100644
index 0000000..b228466
--- /dev/null
+++ b/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-nar/pom.xml
@@ -0,0 +1,40 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <!--
+      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.
+    -->
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.nifi</groupId>
+        <artifactId>nifi-stateful-analysis-bundle</artifactId>
+        <version>1.2.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>nifi-stateful-analysis-nar</artifactId>
+    <packaging>nar</packaging>
+    <description>NiFi NAR for doing stateful analysis</description>
+    <properties>
+        <maven.javadoc.skip>true</maven.javadoc.skip>
+        <source.skip>true</source.skip>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-standard-services-api-nar</artifactId>
+            <type>nar</type>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-stateful-analysis-processors</artifactId>
+        </dependency>
+    </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/nifi/blob/b7f946e8/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-nar/src/main/resources/META-INF/LICENSE
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-nar/src/main/resources/META-INF/LICENSE b/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-nar/src/main/resources/META-INF/LICENSE
new file mode 100644
index 0000000..f57bcde
--- /dev/null
+++ b/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-nar/src/main/resources/META-INF/LICENSE
@@ -0,0 +1,233 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.
+
+APACHE NIFI SUBCOMPONENTS:
+
+The Apache NiFi project contains subcomponents with separate copyright
+notices and license terms. Your use of the source code for the these
+subcomponents is subject to the terms and conditions of the following
+licenses.
+
+
+  The binary distribution of this product bundles 'Bouncy Castle JDK 1.5'
+  under an MIT style license.
+
+    Copyright (c) 2000 - 2015 The Legion of the Bouncy Castle Inc. (http://www.bouncycastle.org)
+
+    Permission is hereby granted, free of charge, to any person obtaining a copy
+    of this software and associated documentation files (the "Software"), to deal
+    in the Software without restriction, including without limitation the rights
+    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+    copies of the Software, and to permit persons to whom the Software is
+    furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice shall be included in
+    all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+    THE SOFTWARE.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/nifi/blob/b7f946e8/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-nar/src/main/resources/META-INF/NOTICE
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-nar/src/main/resources/META-INF/NOTICE b/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-nar/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000..ac6e828
--- /dev/null
+++ b/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-nar/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,27 @@
+nifi-stateful-analysis-nar
+Copyright 2014-2016 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+******************
+Apache Software License v2
+******************
+
+The following binary components are provided under the Apache Software License v2
+
+  (ASLv2) Apache Commons Lang
+    The following NOTICE information applies:
+      Apache Commons Lang
+      Copyright 2001-2015 The Apache Software Foundation
+
+      This product includes software from the Spring Framework,
+      under the Apache License 2.0 (see: StringUtils.containsWhitespace())
+
+  (ASLv2) Apache Commons IO
+    The following NOTICE information applies:
+      Apache Commons IO
+      Copyright 2002-2016 The Apache Software Foundation
+
+      This product includes software developed at
+      The Apache Software Foundation (http://www.apache.org/).
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/nifi/blob/b7f946e8/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-processors/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-processors/pom.xml b/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-processors/pom.xml
new file mode 100644
index 0000000..cab3160
--- /dev/null
+++ b/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-processors/pom.xml
@@ -0,0 +1,68 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <!--
+      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.
+    -->
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.nifi</groupId>
+        <artifactId>nifi-stateful-analysis-bundle</artifactId>
+        <version>1.2.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>nifi-stateful-analysis-processors</artifactId>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <!-- NiFi dependencies -->
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-processor-utils</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-utils</artifactId>
+        </dependency>
+
+        <!-- External dependencies -->
+
+        <!-- Test dependencies -->
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-mock</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.11</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+</project>

http://git-wip-us.apache.org/repos/asf/nifi/blob/b7f946e8/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-processors/src/main/java/org/apache/nifi/processors/stateful/analysis/AttributeRollingWindow.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-processors/src/main/java/org/apache/nifi/processors/stateful/analysis/AttributeRollingWindow.java b/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-processors/src/main/java/org/apache/nifi/processors/stateful/analysis/AttributeRollingWindow.java
new file mode 100644
index 0000000..d7f839a
--- /dev/null
+++ b/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-processors/src/main/java/org/apache/nifi/processors/stateful/analysis/AttributeRollingWindow.java
@@ -0,0 +1,376 @@
+/*
+ * 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.stateful.analysis;
+
+import org.apache.nifi.annotation.behavior.InputRequirement;
+import org.apache.nifi.annotation.behavior.Stateful;
+import org.apache.nifi.annotation.behavior.TriggerSerially;
+import org.apache.nifi.annotation.behavior.WritesAttribute;
+import org.apache.nifi.annotation.behavior.WritesAttributes;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnScheduled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.state.Scope;
+import org.apache.nifi.components.state.StateManager;
+import org.apache.nifi.components.state.StateMap;
+import org.apache.nifi.flowfile.FlowFile;
+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.io.IOException;
+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;
+import java.util.concurrent.TimeUnit;
+
+import static org.apache.nifi.processors.stateful.analysis.AttributeRollingWindow.ROLLING_WINDOW_COUNT_KEY;
+import static org.apache.nifi.processors.stateful.analysis.AttributeRollingWindow.ROLLING_WINDOW_MEAN_KEY;
+import static org.apache.nifi.processors.stateful.analysis.AttributeRollingWindow.ROLLING_WINDOW_VALUE_KEY;
+
+@TriggerSerially
+@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED)
+@Tags({"Attribute Expression Language", "state", "data science", "rolling", "window"})
+@CapabilityDescription("Track a Rolling Window based on evaluating an Expression Language expression on each FlowFile and add that value to the processor's state. Each FlowFile will be emitted " +
+        "with the count of FlowFiles and total aggregate value of values processed in the current time window.")
+@WritesAttributes({
+        @WritesAttribute(attribute = ROLLING_WINDOW_VALUE_KEY, description = "The rolling window value (sum of all the values stored)."),
+        @WritesAttribute(attribute = ROLLING_WINDOW_COUNT_KEY, description = "The count of the number of FlowFiles seen in the rolling window."),
+        @WritesAttribute(attribute = ROLLING_WINDOW_MEAN_KEY, description = "The mean of the FlowFiles seen in the rolling window.")
+})
+@Stateful(scopes = {Scope.LOCAL}, description = "Store the values backing the rolling window. This includes storing the individual values and their time-stamps or the batches of values and their " +
+        "counts.")
+public class AttributeRollingWindow extends AbstractProcessor {
+
+    public static final String COUNT_KEY = "count";
+    public static final String ROLLING_WINDOW_VALUE_KEY = "rolling_window_value";
+    public static final String ROLLING_WINDOW_COUNT_KEY = "rolling_window_count";
+    public static final String ROLLING_WINDOW_MEAN_KEY = "rolling_window_mean";
+
+    public static final String CURRENT_MICRO_BATCH_STATE_TS_KEY = "start_curr_batch_ts";
+    public static final String BATCH_APPEND_KEY = "_batch";
+    public static final String COUNT_APPEND_KEY = "_count";
+    public static final int COUNT_APPEND_KEY_LENGTH = 6;
+
+    static final PropertyDescriptor VALUE_TO_TRACK = new PropertyDescriptor.Builder()
+            .displayName("Value to track")
+            .name("Value to track")
+            .description("The expression on which to evaluate each FlowFile. The result of the expression will be added to the rolling window value.")
+            .expressionLanguageSupported(true)
+            .addValidator(StandardValidators.ATTRIBUTE_EXPRESSION_LANGUAGE_VALIDATOR)
+            .required(true)
+            .build();
+    static final PropertyDescriptor TIME_WINDOW = new PropertyDescriptor.Builder()
+            .displayName("Time window")
+            .name("Time window")
+            .description("The time window on which to calculate the rolling window.")
+            .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR)
+            .required(true)
+            .build();
+    static final PropertyDescriptor SUB_WINDOW_LENGTH = new PropertyDescriptor.Builder()
+            .displayName("Sub-window length")
+            .name("Sub-window length")
+            .description("When set, values will be batched into sub-windows of the set length. This allows for much larger length total windows to be set but sacrifices some precision. If this is " +
+                    "not set (or is 0) then each value is stored in state with the timestamp of when it was received. After the length of time stated in " + TIME_WINDOW.getDisplayName() +
+                    " elaspes the value will be removed. If this is set, values will be batched together every X amount of time (where X is the time period set for this property) and removed " +
+                    "all at once.")
+            .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR)
+            .required(false)
+            .build();
+
+
+    private final Set<Relationship> relationships;
+    private final List<PropertyDescriptor> properties;
+    private Long timeWindow;
+    private Long microBatchTime;
+    private static final Scope SCOPE = Scope.LOCAL;
+
+    // relationships
+    public static final Relationship REL_SUCCESS = new Relationship.Builder()
+            .description("All FlowFiles are successfully processed are routed here")
+            .name("success")
+            .build();
+    public static final Relationship REL_FAILED_SET_STATE = new Relationship.Builder()
+            .name("set state fail")
+            .description("When state fails to save when processing a FlowFile, the FlowFile is routed here.")
+            .build();
+    public static final Relationship REL_FAILURE = new Relationship.Builder()
+            .name("failure")
+            .description("When a FlowFile fails for a reason other than failing to set state it is routed here.")
+            .build();
+
+    {
+        final Set<Relationship> relationshipSet = new HashSet<>();
+        relationshipSet.add(REL_SUCCESS);
+        relationshipSet.add(REL_FAILED_SET_STATE);
+        relationshipSet.add(REL_FAILURE);
+        relationships = Collections.unmodifiableSet(relationshipSet);
+
+        final List<PropertyDescriptor> properties = new ArrayList<>();
+        properties.add(VALUE_TO_TRACK);
+        properties.add(TIME_WINDOW);
+        properties.add(SUB_WINDOW_LENGTH);
+        this.properties = Collections.unmodifiableList(properties);
+    }
+
+    @Override
+    public Set<Relationship> getRelationships() {
+        return relationships;
+    }
+
+    @Override
+    protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
+        return properties;
+    }
+
+    @OnScheduled
+    public void onScheduled(final ProcessContext context) throws IOException {
+        timeWindow = context.getProperty(TIME_WINDOW).asTimePeriod(TimeUnit.MILLISECONDS);
+        microBatchTime = context.getProperty(SUB_WINDOW_LENGTH).asTimePeriod(TimeUnit.MILLISECONDS);
+
+        if(microBatchTime == null || microBatchTime == 0) {
+            StateManager stateManager = context.getStateManager();
+            StateMap state = stateManager.getState(SCOPE);
+            HashMap<String, String> tempMap = new HashMap<>();
+            tempMap.putAll(state.toMap());
+            if (!tempMap.containsKey(COUNT_KEY)) {
+                tempMap.put(COUNT_KEY, "0");
+                context.getStateManager().setState(tempMap, SCOPE);
+            }
+        }
+    }
+
+    @Override
+    public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException {
+        FlowFile flowFile = session.get();
+        if (flowFile == null) {
+            return;
+        }
+
+        try {
+            Long currTime = System.currentTimeMillis();
+            if(microBatchTime == null){
+                noMicroBatch(context, session, flowFile, currTime);
+            } else{
+                microBatch(context, session, flowFile, currTime);
+            }
+
+        } catch (Exception e) {
+            getLogger().error("Ran into an error while processing {}.", new Object[] { flowFile}, e);
+            session.transfer(flowFile, REL_FAILURE);
+        }
+    }
+
+    private void noMicroBatch(ProcessContext context, ProcessSession session, FlowFile flowFile, Long currTime) {
+        final StateManager stateManager = context.getStateManager();
+
+        Map<String, String> state = null;
+        try {
+            state = new HashMap<>(stateManager.getState(SCOPE).toMap());
+        } catch (IOException e) {
+            getLogger().error("Failed to get the initial state when processing {}; transferring FlowFile back to its incoming queue", new Object[]{flowFile}, e);
+            session.transfer(flowFile);
+            context.yield();
+            return;
+        }
+
+        Long count = Long.valueOf(state.get(COUNT_KEY));
+        count ++;
+
+        Set<String> keysToRemove = new HashSet<>();
+
+        for(String key: state.keySet()){
+            if(!key.equals(COUNT_KEY)){
+                Long timeStamp = Long.decode(key);
+
+                if(currTime - timeStamp > timeWindow) {
+                    keysToRemove.add(key);
+                    count --;
+
+                }
+            }
+        }
+        String countString = String.valueOf(count);
+
+        for(String key: keysToRemove){
+            state.remove(key);
+        }
+
+        Double aggregateValue = 0.0D;
+
+        for(Map.Entry<String,String> entry: state.entrySet()){
+            if(!entry.getKey().equals(COUNT_KEY)){
+                aggregateValue += Double.valueOf(entry.getValue());
+            }
+        }
+
+
+        final Double currentFlowFileValue = context.getProperty(VALUE_TO_TRACK).evaluateAttributeExpressions(flowFile).asDouble();
+
+        aggregateValue += currentFlowFileValue;
+
+        state.put(String.valueOf(currTime), String.valueOf(currentFlowFileValue));
+
+        state.put(COUNT_KEY, countString);
+        try {
+            stateManager.setState(state, SCOPE);
+        } catch (IOException e) {
+            getLogger().error("Failed to set the state after successfully processing {} due a failure when setting the state. Transferring to '{}'",
+                    new Object[]{flowFile, REL_FAILED_SET_STATE.getName()}, e);
+
+            session.transfer(flowFile, REL_FAILED_SET_STATE);
+            context.yield();
+            return;
+        }
+
+        Double mean = aggregateValue / count;
+
+        Map<String, String> attributesToAdd = new HashMap<>();
+        attributesToAdd.put(ROLLING_WINDOW_VALUE_KEY, String.valueOf(aggregateValue));
+        attributesToAdd.put(ROLLING_WINDOW_COUNT_KEY, String.valueOf(count));
+        attributesToAdd.put(ROLLING_WINDOW_MEAN_KEY, String.valueOf(mean));
+
+        flowFile = session.putAllAttributes(flowFile, attributesToAdd);
+
+        session.transfer(flowFile, REL_SUCCESS);
+    }
+
+    private void microBatch(ProcessContext context, ProcessSession session, FlowFile flowFile, Long currTime) {
+        final StateManager stateManager = context.getStateManager();
+
+        Map<String, String> state = null;
+        try {
+            state = new HashMap<>(stateManager.getState(SCOPE).toMap());
+        } catch (IOException e) {
+            getLogger().error("Failed to get the initial state when processing {}; transferring FlowFile back to its incoming queue", new Object[]{flowFile}, e);
+            session.transfer(flowFile);
+            context.yield();
+            return;
+        }
+
+        String currBatchStart = state.get(CURRENT_MICRO_BATCH_STATE_TS_KEY);
+        boolean newBatch = false;
+        if(currBatchStart != null){
+            if (currTime - Long.valueOf(currBatchStart) > microBatchTime) {
+                newBatch = true;
+                currBatchStart = String.valueOf(currTime);
+                state.put(CURRENT_MICRO_BATCH_STATE_TS_KEY, currBatchStart);
+            }
+        } else {
+            newBatch = true;
+            currBatchStart = String.valueOf(currTime);
+            state.put(CURRENT_MICRO_BATCH_STATE_TS_KEY, currBatchStart);
+        }
+
+        Long count = 0L;
+        count += 1;
+
+        Set<String> keysToRemove = new HashSet<>();
+
+        for(String key: state.keySet()){
+            String timeStampString;
+            if (key.endsWith(BATCH_APPEND_KEY)) {
+                timeStampString = key.substring(0, key.length() - COUNT_APPEND_KEY_LENGTH);
+                Long timeStamp = Long.decode(timeStampString);
+
+                if (currTime - timeStamp  > timeWindow) {
+                    keysToRemove.add(key);
+                }
+            } else if(key.endsWith(COUNT_APPEND_KEY)) {
+                timeStampString = key.substring(0, key.length() - COUNT_APPEND_KEY_LENGTH);
+                Long timeStamp = Long.decode(timeStampString);
+
+                if (currTime - timeStamp > timeWindow) {
+                    keysToRemove.add(key);
+                } else {
+                    count += Long.valueOf(state.get(key));
+                }
+            }
+        }
+
+        for(String key:keysToRemove){
+            state.remove(key);
+        }
+        keysToRemove.clear();
+
+        Double aggregateValue = 0.0D;
+        Double currentBatchValue =  0.0D;
+        Long currentBatchCount = 0L;
+
+        for(Map.Entry<String,String> entry: state.entrySet()){
+            String key = entry.getKey();
+            if (key.endsWith(BATCH_APPEND_KEY)) {
+                String timeStampString = key.substring(0, key.length() - COUNT_APPEND_KEY_LENGTH);
+
+                Double batchValue = Double.valueOf(entry.getValue());
+                Long batchCount = Long.valueOf(state.get(timeStampString+COUNT_APPEND_KEY));
+                if (!newBatch && timeStampString.equals(currBatchStart)) {
+
+                    final Double currentFlowFileValue = context.getProperty(VALUE_TO_TRACK).evaluateAttributeExpressions(flowFile).asDouble();
+                    batchCount++;
+
+                    batchValue += currentFlowFileValue;
+                    currentBatchValue = batchValue;
+                    currentBatchCount = batchCount;
+                }
+
+                aggregateValue += batchValue;
+
+            }
+        }
+
+        if(newBatch) {
+            final Double currentFlowFileValue = context.getProperty(VALUE_TO_TRACK).evaluateAttributeExpressions(flowFile).asDouble();
+
+            currentBatchValue += currentFlowFileValue;
+            currentBatchCount = 1L;
+
+            aggregateValue += currentBatchValue;
+        }
+
+        state.put(currBatchStart + BATCH_APPEND_KEY, String.valueOf(currentBatchValue));
+        state.put(currBatchStart + COUNT_APPEND_KEY, String.valueOf(currentBatchCount));
+
+        try {
+            stateManager.setState(state, SCOPE);
+        } catch (IOException e) {
+            getLogger().error("Failed to get the initial state when processing {}; transferring FlowFile back to its incoming queue", new Object[]{flowFile}, e);
+            session.transfer(flowFile);
+            context.yield();
+            return;
+        }
+
+        Double mean = aggregateValue / count;
+
+        Map<String, String> attributesToAdd = new HashMap<>();
+        attributesToAdd.put(ROLLING_WINDOW_VALUE_KEY, String.valueOf(aggregateValue));
+        attributesToAdd.put(ROLLING_WINDOW_COUNT_KEY, String.valueOf(count));
+        attributesToAdd.put(ROLLING_WINDOW_MEAN_KEY, String.valueOf(mean));
+
+        flowFile = session.putAllAttributes(flowFile, attributesToAdd);
+
+        session.transfer(flowFile, REL_SUCCESS);
+    }
+}

http://git-wip-us.apache.org/repos/asf/nifi/blob/b7f946e8/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-processors/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-processors/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor b/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-processors/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor
new file mode 100644
index 0000000..1cb250f
--- /dev/null
+++ b/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-processors/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor
@@ -0,0 +1,15 @@
+# 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.
+org.apache.nifi.processors.stateful.analysis.AttributeRollingWindow

http://git-wip-us.apache.org/repos/asf/nifi/blob/b7f946e8/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-processors/src/test/java/org/apache/nifi/processors/stateful/analysis/TestAttributeRollingWindow.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-processors/src/test/java/org/apache/nifi/processors/stateful/analysis/TestAttributeRollingWindow.java b/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-processors/src/test/java/org/apache/nifi/processors/stateful/analysis/TestAttributeRollingWindow.java
new file mode 100644
index 0000000..8e28996
--- /dev/null
+++ b/nifi-nar-bundles/nifi-stateful-analysis-bundle/nifi-stateful-analysis-processors/src/test/java/org/apache/nifi/processors/stateful/analysis/TestAttributeRollingWindow.java
@@ -0,0 +1,266 @@
+/*
+ * 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.stateful.analysis;
+
+import org.apache.nifi.components.state.Scope;
+import org.apache.nifi.processor.ProcessSessionFactory;
+import org.apache.nifi.state.MockStateManager;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.apache.nifi.processors.stateful.analysis.AttributeRollingWindow.REL_FAILED_SET_STATE;
+import static org.apache.nifi.processors.stateful.analysis.AttributeRollingWindow.ROLLING_WINDOW_COUNT_KEY;
+import static org.apache.nifi.processors.stateful.analysis.AttributeRollingWindow.ROLLING_WINDOW_MEAN_KEY;
+import static org.apache.nifi.processors.stateful.analysis.AttributeRollingWindow.ROLLING_WINDOW_VALUE_KEY;
+
+public class TestAttributeRollingWindow {
+
+    @Test
+    public void testFailureDueToBadAttribute() throws InterruptedException {
+        final TestRunner runner = TestRunners.newTestRunner(AttributeRollingWindow.class);
+
+        runner.setProperty(AttributeRollingWindow.VALUE_TO_TRACK, "${value}");
+        runner.setProperty(AttributeRollingWindow.TIME_WINDOW, "3 sec");
+
+
+        final Map<String, String> attributes = new HashMap<>();
+        attributes.put("value", "bad");
+
+
+        runner.enqueue("1".getBytes(), attributes);
+        runner.run(1);
+
+        runner.assertAllFlowFilesTransferred(AttributeRollingWindow.REL_FAILURE);
+    }
+
+    @Test
+    public void testStateFailures() throws InterruptedException, IOException {
+        final TestRunner runner = TestRunners.newTestRunner(AttributeRollingWindow.class);
+        MockStateManager mockStateManager = runner.getStateManager();
+        final AttributeRollingWindow processor = (AttributeRollingWindow) runner.getProcessor();
+        final ProcessSessionFactory processSessionFactory = runner.getProcessSessionFactory();
+
+        runner.setProperty(AttributeRollingWindow.VALUE_TO_TRACK, "${value}");
+        runner.setProperty(AttributeRollingWindow.TIME_WINDOW, "3 sec");
+
+        processor.onScheduled(runner.getProcessContext());
+
+        final Map<String, String> attributes = new HashMap<>();
+        attributes.put("value", "1");
+
+        mockStateManager.setFailOnStateGet(Scope.LOCAL, true);
+
+        runner.enqueue(new byte[0],attributes);
+        processor.onTrigger(runner.getProcessContext(), processSessionFactory.createSession());
+
+        runner.assertQueueNotEmpty();
+
+        mockStateManager.setFailOnStateGet(Scope.LOCAL, false);
+        mockStateManager.setFailOnStateSet(Scope.LOCAL, true);
+
+        processor.onTrigger(runner.getProcessContext(), processSessionFactory.createSession());
+
+        runner.assertQueueEmpty();
+
+        runner.assertAllFlowFilesTransferred(AttributeRollingWindow.REL_FAILED_SET_STATE, 1);
+        MockFlowFile mockFlowFile = runner.getFlowFilesForRelationship(REL_FAILED_SET_STATE).get(0);
+        mockFlowFile.assertAttributeNotExists(ROLLING_WINDOW_VALUE_KEY);
+        mockFlowFile.assertAttributeNotExists(ROLLING_WINDOW_COUNT_KEY);
+        mockFlowFile.assertAttributeNotExists(ROLLING_WINDOW_MEAN_KEY);
+    }
+
+
+    @Test
+    public void testBasic() throws InterruptedException {
+        final TestRunner runner = TestRunners.newTestRunner(AttributeRollingWindow.class);
+
+        runner.setProperty(AttributeRollingWindow.VALUE_TO_TRACK, "${value}");
+        runner.setProperty(AttributeRollingWindow.TIME_WINDOW, "300 ms");
+
+
+        final Map<String, String> attributes = new HashMap<>();
+        attributes.put("value", "1");
+
+
+        runner.enqueue("1".getBytes(), attributes);
+        runner.run(1);
+        runner.assertAllFlowFilesTransferred(AttributeRollingWindow.REL_SUCCESS, 1);
+        MockFlowFile flowFile = runner.getFlowFilesForRelationship(AttributeRollingWindow.REL_SUCCESS).get(0);
+        runner.clearTransferState();
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_VALUE_KEY, "1.0");
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_COUNT_KEY, "1");
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_MEAN_KEY, "1.0");
+
+        runner.enqueue("2".getBytes(), attributes);
+        runner.run(1);
+        runner.assertAllFlowFilesTransferred(AttributeRollingWindow.REL_SUCCESS, 1);
+         flowFile = runner.getFlowFilesForRelationship(AttributeRollingWindow.REL_SUCCESS).get(0);
+        runner.clearTransferState();
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_VALUE_KEY, "2.0");
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_COUNT_KEY, "2");
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_MEAN_KEY, "1.0");
+
+        Thread.sleep(500L);
+
+        runner.enqueue("2".getBytes(), attributes);
+        runner.run(1);
+        runner.assertAllFlowFilesTransferred(AttributeRollingWindow.REL_SUCCESS, 1);
+        flowFile = runner.getFlowFilesForRelationship(AttributeRollingWindow.REL_SUCCESS).get(0);
+        runner.clearTransferState();
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_VALUE_KEY, "1.0");
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_COUNT_KEY, "1");
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_MEAN_KEY, "1.0");
+
+    }
+
+
+    @Test
+    public void testVerifyCount() throws InterruptedException {
+        final TestRunner runner = TestRunners.newTestRunner(AttributeRollingWindow.class);
+
+        runner.setProperty(AttributeRollingWindow.VALUE_TO_TRACK, "${value}");
+        runner.setProperty(AttributeRollingWindow.TIME_WINDOW, "10 sec");
+
+        MockFlowFile flowFile;
+
+        final Map<String, String> attributes = new HashMap<>();
+        attributes.put("value", "1");
+        for(int i = 1; i<61; i++){
+            runner.enqueue(String.valueOf(i).getBytes(), attributes);
+
+            runner.run();
+
+            flowFile = runner.getFlowFilesForRelationship(AttributeRollingWindow.REL_SUCCESS).get(0);
+            runner.clearTransferState();
+            Double value = (double) i;
+            Double mean = value / i;
+
+            flowFile.assertAttributeEquals(ROLLING_WINDOW_VALUE_KEY, String.valueOf(value));
+            flowFile.assertAttributeEquals(ROLLING_WINDOW_COUNT_KEY, String.valueOf(i));
+            flowFile.assertAttributeEquals(ROLLING_WINDOW_MEAN_KEY, String.valueOf(mean));
+            Thread.sleep(10L);
+        }
+
+
+
+        runner.setProperty(AttributeRollingWindow.VALUE_TO_TRACK, "${value}");
+        runner.setProperty(AttributeRollingWindow.SUB_WINDOW_LENGTH, "500 ms");
+        runner.setProperty(AttributeRollingWindow.TIME_WINDOW, "10 sec");
+
+        for(int i = 1; i<10; i++){
+            runner.enqueue(String.valueOf(i).getBytes(), attributes);
+
+            runner.run();
+
+            flowFile = runner.getFlowFilesForRelationship(AttributeRollingWindow.REL_SUCCESS).get(0);
+            runner.clearTransferState();
+            Double value = (double) i;
+            Double mean = value / i;
+
+            flowFile.assertAttributeEquals(ROLLING_WINDOW_VALUE_KEY, String.valueOf(Double.valueOf(i)));
+            flowFile.assertAttributeEquals(ROLLING_WINDOW_COUNT_KEY, String.valueOf(i));
+            flowFile.assertAttributeEquals(ROLLING_WINDOW_MEAN_KEY, String.valueOf(mean));
+
+            Thread.sleep(10L);
+        }
+
+    }
+
+
+    @Test
+    public void testMicroBatching() throws InterruptedException {
+        final TestRunner runner = TestRunners.newTestRunner(AttributeRollingWindow.class);
+
+        runner.setProperty(AttributeRollingWindow.VALUE_TO_TRACK, "${value}");
+        runner.setProperty(AttributeRollingWindow.SUB_WINDOW_LENGTH, "500 ms");
+        runner.setProperty(AttributeRollingWindow.TIME_WINDOW, "1 sec");
+
+
+        final Map<String, String> attributes = new HashMap<>();
+        attributes.put("value", "2");
+
+        runner.enqueue("1".getBytes(), attributes);
+        runner.run(1);
+        runner.assertAllFlowFilesTransferred(AttributeRollingWindow.REL_SUCCESS, 1);
+        MockFlowFile flowFile = runner.getFlowFilesForRelationship(AttributeRollingWindow.REL_SUCCESS).get(0);
+        runner.clearTransferState();
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_VALUE_KEY, "2.0");
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_COUNT_KEY, "1");
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_MEAN_KEY, "2.0");
+
+        Thread.sleep(200L);
+
+        runner.enqueue("2".getBytes(), attributes);
+        runner.run(1);
+        runner.assertAllFlowFilesTransferred(AttributeRollingWindow.REL_SUCCESS, 1);
+        flowFile = runner.getFlowFilesForRelationship(AttributeRollingWindow.REL_SUCCESS).get(0);
+        runner.clearTransferState();
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_VALUE_KEY, "4.0");
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_COUNT_KEY, "2");
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_MEAN_KEY, "2.0");
+
+
+        Thread.sleep(300L);
+
+        runner.enqueue("2".getBytes(), attributes);
+        runner.run(1);
+        runner.assertAllFlowFilesTransferred(AttributeRollingWindow.REL_SUCCESS, 1);
+        flowFile = runner.getFlowFilesForRelationship(AttributeRollingWindow.REL_SUCCESS).get(0);
+        runner.clearTransferState();
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_VALUE_KEY, "6.0");
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_COUNT_KEY, "3");
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_MEAN_KEY, "2.0");
+
+        Thread.sleep(200L);
+        runner.enqueue("2".getBytes(), attributes);
+        runner.run(1);
+        runner.assertAllFlowFilesTransferred(AttributeRollingWindow.REL_SUCCESS, 1);
+        flowFile = runner.getFlowFilesForRelationship(AttributeRollingWindow.REL_SUCCESS).get(0);
+        runner.clearTransferState();
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_VALUE_KEY, "8.0");
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_COUNT_KEY, "4");
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_MEAN_KEY, "2.0");
+
+        Thread.sleep(300L);
+
+        runner.enqueue("2".getBytes(), attributes);
+        runner.run(1);
+        runner.assertAllFlowFilesTransferred(AttributeRollingWindow.REL_SUCCESS, 1);
+        flowFile = runner.getFlowFilesForRelationship(AttributeRollingWindow.REL_SUCCESS).get(0);
+        runner.clearTransferState();
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_VALUE_KEY, "6.0");
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_COUNT_KEY, "3");
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_MEAN_KEY, "2.0");
+
+        runner.enqueue("2".getBytes(), attributes);
+        runner.run(1);
+        runner.assertAllFlowFilesTransferred(AttributeRollingWindow.REL_SUCCESS, 1);
+        flowFile = runner.getFlowFilesForRelationship(AttributeRollingWindow.REL_SUCCESS).get(0);
+        runner.clearTransferState();
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_VALUE_KEY, "8.0");
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_COUNT_KEY, "4");
+        flowFile.assertAttributeEquals(ROLLING_WINDOW_MEAN_KEY, "2.0");
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/nifi/blob/b7f946e8/nifi-nar-bundles/nifi-stateful-analysis-bundle/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-stateful-analysis-bundle/pom.xml b/nifi-nar-bundles/nifi-stateful-analysis-bundle/pom.xml
new file mode 100644
index 0000000..8bb9ca2
--- /dev/null
+++ b/nifi-nar-bundles/nifi-stateful-analysis-bundle/pom.xml
@@ -0,0 +1,37 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <!--
+      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.
+    -->
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.nifi</groupId>
+        <artifactId>nifi-nar-bundles</artifactId>
+        <version>1.2.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>nifi-stateful-analysis-bundle</artifactId>
+    <packaging>pom</packaging>
+    <modules>
+        <module>nifi-stateful-analysis-processors</module>
+        <module>nifi-stateful-analysis-nar</module>
+    </modules>
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.apache.nifi</groupId>
+                <artifactId>nifi-stateful-analysis-processors</artifactId>
+                <version>1.2.0-SNAPSHOT</version>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+</project>

http://git-wip-us.apache.org/repos/asf/nifi/blob/b7f946e8/nifi-nar-bundles/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/pom.xml b/nifi-nar-bundles/pom.xml
index c1016e7..72cba43 100755
--- a/nifi-nar-bundles/pom.xml
+++ b/nifi-nar-bundles/pom.xml
@@ -76,6 +76,7 @@
         <module>nifi-tcp-bundle</module>
         <module>nifi-gcp-bundle</module>
         <module>nifi-registry-bundle</module>
+        <module>nifi-stateful-analysis-bundle</module>
   </modules>
     
   <dependencyManagement>

http://git-wip-us.apache.org/repos/asf/nifi/blob/b7f946e8/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index cec0e67..4ded11d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1308,6 +1308,12 @@ language governing permissions and limitations under the License. -->
             </dependency>
             <dependency>
                 <groupId>org.apache.nifi</groupId>
+                <artifactId>nifi-stateful-analysis-nar</artifactId>
+                <version>1.2.0-SNAPSHOT</version>
+                <type>nar</type>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.nifi</groupId>
                 <artifactId>nifi-properties</artifactId>
                 <version>1.2.0-SNAPSHOT</version>
             </dependency>


Mime
View raw message