This is an automated email from the ASF dual-hosted git repository.
mattyb149 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new 7b6a51aa9f NIFI-11728 Removed RethinkDB Processors
7b6a51aa9f is described below
commit 7b6a51aa9fb1b1b8d0669831432dd706daf0797f
Author: exceptionfactory <[email protected]>
AuthorDate: Mon Jun 19 17:14:21 2023 -0500
NIFI-11728 Removed RethinkDB Processors
Signed-off-by: Matt Burgess <[email protected]>
This closes #7410
---
nifi-assembly/NOTICE | 6 -
nifi-assembly/pom.xml | 6 -
.../nifi-rethinkdb-nar/pom.xml | 44 ---
.../src/main/resources/META-INF/LICENSE | 209 ------------
.../src/main/resources/META-INF/NOTICE | 31 --
.../nifi-rethinkdb-processors/pom.xml | 63 ----
.../rethinkdb/AbstractRethinkDBProcessor.java | 211 ------------
.../nifi/processors/rethinkdb/DeleteRethinkDB.java | 216 -------------
.../nifi/processors/rethinkdb/GetRethinkDB.java | 186 -----------
.../nifi/processors/rethinkdb/PutRethinkDB.java | 225 -------------
.../services/org.apache.nifi.processor.Processor | 17 -
.../processors/rethinkdb/TestDeleteRethinkDB.java | 252 ---------------
.../processors/rethinkdb/TestGetRethinkDB.java | 261 ---------------
.../processors/rethinkdb/TestPutRethinkDB.java | 360 ---------------------
nifi-nar-bundles/nifi-rethinkdb-bundle/pom.xml | 42 ---
nifi-nar-bundles/pom.xml | 1 -
16 files changed, 2130 deletions(-)
diff --git a/nifi-assembly/NOTICE b/nifi-assembly/NOTICE
index 5fa6e2fe36..02b7c13102 100644
--- a/nifi-assembly/NOTICE
+++ b/nifi-assembly/NOTICE
@@ -1388,12 +1388,6 @@ The following binary components are provided under the
Apache Software License v
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
- (ASLv2) RethinkDB Java Driver
- The following NOTICE information applies:
- RethinkDB Language Drivers
-
- Copyright 2010-2012 RethinkDB
-
(ASLv2) Neo4j Java Driver
Neo4j
Copyright © 2002-2018 Neo4j Sweden AB (referred to in this notice as
"Neo4j")
diff --git a/nifi-assembly/pom.xml b/nifi-assembly/pom.xml
index be338304b1..49cc8a1a66 100644
--- a/nifi-assembly/pom.xml
+++ b/nifi-assembly/pom.xml
@@ -450,12 +450,6 @@ language governing permissions and limitations under the
License. -->
<version>2.0.0-SNAPSHOT</version>
<type>nar</type>
</dependency>
- <dependency>
- <groupId>org.apache.nifi</groupId>
- <artifactId>nifi-rethinkdb-nar</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- <type>nar</type>
- </dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-prometheus-nar</artifactId>
diff --git a/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-nar/pom.xml
b/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-nar/pom.xml
deleted file mode 100644
index 0148fe98c8..0000000000
--- a/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-nar/pom.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<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
https://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.nifi</groupId>
- <artifactId>nifi-rethinkdb-bundle</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>nifi-rethinkdb-nar</artifactId>
- <packaging>nar</packaging>
- <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>
- <version>2.0.0-SNAPSHOT</version>
- <type>nar</type>
- </dependency>
- <dependency>
- <groupId>org.apache.nifi</groupId>
- <artifactId>nifi-rethinkdb-processors</artifactId>
- </dependency>
- </dependencies>
-</project>
diff --git
a/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-nar/src/main/resources/META-INF/LICENSE
b/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-nar/src/main/resources/META-INF/LICENSE
deleted file mode 100644
index 44893cdb29..0000000000
---
a/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-nar/src/main/resources/META-INF/LICENSE
+++ /dev/null
@@ -1,209 +0,0 @@
-
- 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.
diff --git
a/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-nar/src/main/resources/META-INF/NOTICE
b/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-nar/src/main/resources/META-INF/NOTICE
deleted file mode 100644
index 4f8ec932a4..0000000000
---
a/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-nar/src/main/resources/META-INF/NOTICE
+++ /dev/null
@@ -1,31 +0,0 @@
-nifi-rethinkdb-nar
-Copyright 2016-2020 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) RethinkDB Java Driver
- The following NOTICE information applies:
- RethinkDB Language Drivers
-
- Copyright 2010-2012 RethinkDB
-
- (ASLv2) Apache Commons IO
- The following NOTICE information applies:
- Apache Commons IO
- Copyright 2002-2016 The Apache Software Foundation
-
- (ASLv2) Apache Commons Lang
- The following NOTICE information applies:
- Apache Commons Lang
- Copyright 2001-2015 The Apache Software Foundation
-
- (ASLv2) Google GSON
- The following NOTICE information applies:
- Copyright 2008 Google Inc.
diff --git
a/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/pom.xml
b/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/pom.xml
deleted file mode 100644
index e18f2164c5..0000000000
--- a/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/pom.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<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
https://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.nifi</groupId>
- <artifactId>nifi-rethinkdb-bundle</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>nifi-rethinkdb-processors</artifactId>
- <packaging>jar</packaging>
-
- <dependencies>
- <dependency>
- <groupId>com.rethinkdb</groupId>
- <artifactId>rethinkdb-driver</artifactId>
- <version>2.3.3</version>
- </dependency>
- <dependency>
- <groupId>org.apache.nifi</groupId>
- <artifactId>nifi-api</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.nifi</groupId>
- <artifactId>nifi-utils</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.nifi</groupId>
- <artifactId>nifi-mock</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
diff --git
a/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/src/main/java/org/apache/nifi/processors/rethinkdb/AbstractRethinkDBProcessor.java
b/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/src/main/java/org/apache/nifi/processors/rethinkdb/AbstractRethinkDBProcessor.java
deleted file mode 100644
index 4f69a2bf34..0000000000
---
a/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/src/main/java/org/apache/nifi/processors/rethinkdb/AbstractRethinkDBProcessor.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * 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.rethinkdb;
-
-import org.apache.nifi.annotation.lifecycle.OnScheduled;
-import org.apache.nifi.annotation.lifecycle.OnStopped;
-import org.apache.nifi.components.AllowableValue;
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.expression.AttributeExpression.ResultType;
-import org.apache.nifi.expression.ExpressionLanguageScope;
-import org.apache.nifi.processor.AbstractProcessor;
-import org.apache.nifi.processor.ProcessContext;
-import org.apache.nifi.processor.Relationship;
-import org.apache.nifi.processor.util.StandardValidators;
-import com.rethinkdb.RethinkDB;
-import com.rethinkdb.gen.ast.Table;
-import com.rethinkdb.net.Connection;
-
-/**
- * Abstract base class for RethinkDB processors
- */
-abstract class AbstractRethinkDBProcessor extends AbstractProcessor {
-
- protected static final PropertyDescriptor CHARSET = new
PropertyDescriptor.Builder()
- .name("rethinkdb-charset")
- .displayName("Character Set")
- .description("Specifies the character set of the document data.")
- .required(true)
- .defaultValue("UTF-8")
-
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
- .addValidator(StandardValidators.CHARACTER_SET_VALIDATOR)
- .build();
-
- public static final PropertyDescriptor DB_NAME = new
PropertyDescriptor.Builder()
- .name("rethinkdb-dbname")
- .displayName("DB Name")
- .description("RethinkDB database to connect to")
- .required(true)
- .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
- .build();
-
- public static final PropertyDescriptor DB_HOST = new
PropertyDescriptor.Builder()
- .name("rethinkdb-host")
- .displayName("Hostname")
- .description("RethinkDB hostname")
- .required(true)
- .defaultValue("localhost")
- .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
- .build();
-
- public static final PropertyDescriptor DB_PORT = new
PropertyDescriptor.Builder()
- .name("rethinkdb-port")
- .displayName("DB Port")
- .description("RethinkDB database port to connect to")
- .required(true)
- .defaultValue("28015")
- .addValidator(StandardValidators.PORT_VALIDATOR)
- .build();
-
- public static final PropertyDescriptor USERNAME = new
PropertyDescriptor.Builder()
- .name("rethinkdb-username")
- .displayName("Username")
- .description("Username for accessing RethinkDB")
- .required(false)
- .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
- .build();
-
- public static final PropertyDescriptor PASSWORD = new
PropertyDescriptor.Builder()
- .name("rethinkdb-password")
- .displayName("Password")
- .description("Password for user")
- .required(false)
- .sensitive(true)
- .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
- .build();
-
- public static final PropertyDescriptor TABLE_NAME = new
PropertyDescriptor.Builder()
- .name("rethinkdb-table")
- .displayName("Table name")
- .description("RethinkDB table to connect to")
- .required(true)
- .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
- .build();
-
- protected static final PropertyDescriptor MAX_DOCUMENTS_SIZE = new
PropertyDescriptor.Builder()
- .name("rethinkdb-max-document-size")
- .displayName("Max size of documents")
- .description("Maximum size of documents allowed to be posted in
one batch")
- .defaultValue("1 MB")
- .required(true)
- .addValidator(StandardValidators.DATA_SIZE_VALIDATOR)
- .build();
-
- public static final PropertyDescriptor RETHINKDB_DOCUMENT_ID = new
PropertyDescriptor.Builder()
- .displayName("Document Identifier")
- .name("rethinkdb-document-identifier")
- .description("A FlowFile attribute, or attribute expression
used " +
- "for determining RethinkDB key for the Flow File content")
- .required(true)
-
.addValidator(StandardValidators.createAttributeExpressionLanguageValidator(ResultType.STRING,
true))
-
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
- .build();
-
- public static AllowableValue DURABILITY_SOFT = new AllowableValue("soft",
"Soft", "Don't save changes to disk before ack");
-
- public static AllowableValue DURABILITY_HARD = new AllowableValue("hard",
"Hard", "Save change to disk before ack");
-
- protected static final PropertyDescriptor DURABILITY = new
PropertyDescriptor.Builder()
- .name("rethinkdb-durability")
- .displayName("Durablity of documents")
- .description("Durability of documents being inserted")
- .required(true)
- .defaultValue("hard")
- .allowableValues(DURABILITY_HARD, DURABILITY_SOFT)
-
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
- .build();
-
- static final Relationship REL_SUCCESS = new
Relationship.Builder().name("success")
- .description("Sucessful FlowFiles are routed to this
relationship").build();
-
- static final Relationship REL_FAILURE = new
Relationship.Builder().name("failure")
- .description("Failed FlowFiles are routed to this
relationship").build();
-
- static final Relationship REL_NOT_FOUND = new
Relationship.Builder().name("not_found")
- .description("Document not found are routed to this
relationship").build();
-
- public static final String RESULT_ERROR_KEY = "errors";
- public static final String RESULT_DELETED_KEY = "deleted";
- public static final String RESULT_GENERATED_KEYS_KEY = "generated_keys";
- public static final String RESULT_INSERTED_KEY = "inserted";
- public static final String RESULT_REPLACED_KEY = "replaced";
- public static final String RESULT_SKIPPED_KEY = "skipped";
- public static final String RESULT_UNCHANGED_KEY = "unchanged";
- public static final String RESULT_FIRST_ERROR_KEY = "first_error";
- public static final String RESULT_WARNINGS_KEY = "warnings";
-
- public static final String DURABILITY_OPTION_KEY = "durability";
-
- public static final String RETHINKDB_ERROR_MESSAGE =
"rethinkdb.error.message";
- public static final String DOCUMENT_ID_EMPTY_MESSAGE = "Document Id cannot
be empty";
-
- protected Connection rethinkDbConnection;
- protected String databaseName;
- protected String tableName;
- protected String username;
- protected String password;
- protected String hostname;
- protected Integer port;
- protected long maxDocumentsSize;
-
- /**
- * Helper method to help testability
- * @return RethinkDB instance
- */
- protected RethinkDB getRethinkDB() {
- return RethinkDB.r;
- }
-
- /**
- * @return the rdbTable
- */
- protected Table getRdbTable() {
- return getRethinkDB().db(databaseName).table(tableName);
- }
-
- @OnScheduled
- public void onScheduled(final ProcessContext context) {
- hostname = context.getProperty(DB_HOST).getValue();
- port = context.getProperty(DB_PORT).asInteger();
- username = context.getProperty(USERNAME).getValue();
- password = context.getProperty(PASSWORD).getValue();
- databaseName = context.getProperty(DB_NAME).getValue();
- tableName = context.getProperty(TABLE_NAME).getValue();
-
- try {
- rethinkDbConnection = makeConnection();
- } catch(Exception e) {
- getLogger().error("Error while getting connection " +
e.getLocalizedMessage(),e);
- throw new RuntimeException("Error while getting connection" +
e.getLocalizedMessage(),e);
- }
- getLogger().info("RethinkDB connection created for host {} port {} and
db {}",
- new Object[] {hostname, port,databaseName});
- }
-
- protected Connection makeConnection() {
- return getRethinkDB().connection().hostname(hostname)
- .port(port).user(username,
- password).connect();
- }
-
- @OnStopped
- public void close() {
- getLogger().info("Closing connection");
- if ( rethinkDbConnection != null )
- rethinkDbConnection.close();
- }
-}
\ No newline at end of file
diff --git
a/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/src/main/java/org/apache/nifi/processors/rethinkdb/DeleteRethinkDB.java
b/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/src/main/java/org/apache/nifi/processors/rethinkdb/DeleteRethinkDB.java
deleted file mode 100644
index 0140da96c9..0000000000
---
a/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/src/main/java/org/apache/nifi/processors/rethinkdb/DeleteRethinkDB.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * 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.rethinkdb;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.nifi.annotation.behavior.EventDriven;
-import org.apache.nifi.annotation.behavior.InputRequirement;
-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.SeeAlso;
-import org.apache.nifi.annotation.documentation.Tags;
-import org.apache.nifi.annotation.lifecycle.OnScheduled;
-import org.apache.nifi.annotation.lifecycle.OnStopped;
-import org.apache.nifi.components.AllowableValue;
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.expression.ExpressionLanguageScope;
-import org.apache.nifi.flowfile.FlowFile;
-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 com.google.gson.Gson;
-
-import java.io.ByteArrayInputStream;
-import java.nio.charset.Charset;
-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;
-
-@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED)
-@EventDriven
-@Tags({"rethinkdb", "delete", "remove"})
-@CapabilityDescription("Processor to remove a JSON document from RethinkDB
(https://www.rethinkdb.com/) using the document id.")
-@WritesAttributes({
- @WritesAttribute(attribute = DeleteRethinkDB.RETHINKDB_ERROR_MESSAGE,
description = "RethinkDB error message"),
- @WritesAttribute(attribute =
DeleteRethinkDB.RETHINKDB_DELETE_RESULT_ERROR_KEY, description = "Error count
while delete documents"),
- @WritesAttribute(attribute =
DeleteRethinkDB.RETHINKDB_DELETE_RESULT_DELETED_KEY, description = "Number of
documents deleted"),
- @WritesAttribute(attribute =
DeleteRethinkDB.RETHINKDB_DELETE_RESULT_INSERTED_KEY, description = "Number of
documents inserted"),
- @WritesAttribute(attribute =
DeleteRethinkDB.RETHINKDB_DELETE_RESULT_REPLACED_KEY, description = "Number of
documents replaced"),
- @WritesAttribute(attribute =
DeleteRethinkDB.RETHINKDB_DELETE_RESULT_SKIPPED_KEY, description = "Number of
documents skipped"),
- @WritesAttribute(attribute =
DeleteRethinkDB.RETHINKDB_DELETE_RESULT_UNCHANGED_KEY, description = "Number of
documents unchanged since they already existed"),
- })
-@SeeAlso({PutRethinkDB.class,GetRethinkDB.class})
-public class DeleteRethinkDB extends AbstractRethinkDBProcessor {
-
- public static AllowableValue RETURN_CHANGES_TRUE = new
AllowableValue("true", "True", "Return changed document");
- public static AllowableValue RETURN_CHANGES_FALSE = new
AllowableValue("false", "False", "Do not return changed document");
-
- protected static final PropertyDescriptor RETURN_CHANGES = new
PropertyDescriptor.Builder()
- .name("rethinkdb-return-result")
- .displayName("Return deleted value")
- .description("Return old value which were deleted")
- .required(true)
- .defaultValue(RETURN_CHANGES_TRUE.getValue())
- .allowableValues(RETURN_CHANGES_TRUE, RETURN_CHANGES_FALSE)
-
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
- .build();
-
- private static final Set<Relationship> relationships;
- private static final List<PropertyDescriptor> propertyDescriptors;
-
- public static final String RETHINKDB_DELETE_RESULT_ERROR_KEY =
"rethinkdb.delete.errors";
- public static final String RETHINKDB_DELETE_RESULT_DELETED_KEY =
"rethinkdb.delete.deleted";
- public static final String RETHINKDB_DELETE_RESULT_INSERTED_KEY =
"rethinkdb.delete.inserted";
- public static final String RETHINKDB_DELETE_RESULT_REPLACED_KEY =
"rethinkdb.delete.replaced";
- public static final String RETHINKDB_DELETE_RESULT_SKIPPED_KEY =
"rethinkdb.delete.skipped";
- public static final String RETHINKDB_DELETE_RESULT_UNCHANGED_KEY =
"rethinkdb.delete.unchanged";
-
- public static final String RESULT_CHANGES_KEY = "changes";
- public static final String RETURN_CHANGES_OPTION_KEY = "return_changes";
-
- protected Gson gson = new Gson();
-
- static {
- final Set<Relationship> tempRelationships = new HashSet<>();
- tempRelationships.add(REL_SUCCESS);
- tempRelationships.add(REL_FAILURE);
- tempRelationships.add(REL_NOT_FOUND);
- relationships = Collections.unmodifiableSet(tempRelationships);
-
- final List<PropertyDescriptor> tempDescriptors = new ArrayList<>();
- tempDescriptors.add(DB_NAME);
- tempDescriptors.add(DB_HOST);
- tempDescriptors.add(DB_PORT);
- tempDescriptors.add(USERNAME);
- tempDescriptors.add(PASSWORD);
- tempDescriptors.add(TABLE_NAME);
- tempDescriptors.add(CHARSET);
- tempDescriptors.add(RETHINKDB_DOCUMENT_ID);
- tempDescriptors.add(RETURN_CHANGES);
- tempDescriptors.add(DURABILITY);
- propertyDescriptors = Collections.unmodifiableList(tempDescriptors);
- }
-
- @Override
- public Set<Relationship> getRelationships() {
- return relationships;
- }
-
- @Override
- public final List<PropertyDescriptor> getSupportedPropertyDescriptors() {
- return propertyDescriptors;
- }
-
- @OnScheduled
- public void onScheduled(final ProcessContext context) {
- super.onScheduled(context);
- }
-
- @Override
- public void onTrigger(final ProcessContext context, final ProcessSession
session) throws ProcessException {
- FlowFile flowFile = session.get();
- if (flowFile == null) {
- return;
- }
-
- Charset charset =
Charset.forName(context.getProperty(CHARSET).evaluateAttributeExpressions(flowFile).getValue());
- String id =
context.getProperty(RETHINKDB_DOCUMENT_ID).evaluateAttributeExpressions(flowFile).getValue();
- String durablity =
context.getProperty(DURABILITY).evaluateAttributeExpressions(flowFile).getValue();
- Boolean returnChanges =
context.getProperty(RETURN_CHANGES).evaluateAttributeExpressions(flowFile).asBoolean();
-
- if ( StringUtils.isEmpty(id) ) {
- getLogger().error(DOCUMENT_ID_EMPTY_MESSAGE);
- flowFile = session.putAttribute(flowFile, RETHINKDB_ERROR_MESSAGE,
DOCUMENT_ID_EMPTY_MESSAGE);
- session.transfer(flowFile, REL_FAILURE);
- return;
- }
-
- try {
- long startTimeMillis = System.currentTimeMillis();
- Map<String,Object> result = deleteDocument(id, durablity,
returnChanges);
- final long endTimeMillis = System.currentTimeMillis();
-
- getLogger().debug("Json document {} deleted Result: {}", new
Object[] {id, result});
-
- flowFile = populateAttributes(session, flowFile, result);
-
- Long deletedCount =
((Long)result.get(RESULT_DELETED_KEY)).longValue();
-
- if ( deletedCount == 0L ) {
- getLogger().debug("Deleted count should be 1 but was " +
deletedCount + " for document with id '" + id + "'");
-
- flowFile = populateAttributes(session, flowFile, result);
-
- flowFile = session.putAttribute(flowFile,
RETHINKDB_ERROR_MESSAGE, "Deleted count should be 1 but was " + deletedCount +
" for document with id '" + id + "'");
- session.transfer(flowFile, REL_NOT_FOUND);
- return;
- }
-
- if ( returnChanges ) {
- String json =
gson.toJson(((List)result.get(RESULT_CHANGES_KEY)).get(0));
-
- byte [] documentBytes = json.getBytes(charset);
-
- ByteArrayInputStream bais = new
ByteArrayInputStream(documentBytes);
- session.importFrom(bais, flowFile);
-
- session.getProvenanceReporter().modifyContent(flowFile,
- new
StringBuilder("rethinkdb://").append(databaseName).append("/").append(tableName).append("/").append(id).toString(),
- (endTimeMillis - startTimeMillis));
- }
-
- session.transfer(flowFile, REL_SUCCESS);
-
-
- } catch (Exception exception) {
- getLogger().error("Failed to delete document from RethinkDB due to
error {}",
- new Object[]{exception.getLocalizedMessage()}, exception);
- flowFile = session.putAttribute(flowFile, RETHINKDB_ERROR_MESSAGE,
exception.getMessage());
- session.transfer(flowFile, REL_FAILURE);
- context.yield();
- }
- }
-
- private FlowFile populateAttributes(final ProcessSession session, FlowFile
flowFile,
- Map<String, Object> result) {
- Map<String,String> resultAttributes = new HashMap<>();
- resultAttributes.put(RETHINKDB_DELETE_RESULT_ERROR_KEY,
String.valueOf(result.get(RESULT_ERROR_KEY)));
- resultAttributes.put(RETHINKDB_DELETE_RESULT_DELETED_KEY,
String.valueOf(result.get(RESULT_DELETED_KEY)));
- resultAttributes.put(RETHINKDB_DELETE_RESULT_INSERTED_KEY,
String.valueOf(result.get(RESULT_INSERTED_KEY)));
- resultAttributes.put(RETHINKDB_DELETE_RESULT_REPLACED_KEY,
String.valueOf(result.get(RESULT_REPLACED_KEY)));
- resultAttributes.put(RETHINKDB_DELETE_RESULT_SKIPPED_KEY,
String.valueOf(result.get(RESULT_SKIPPED_KEY)));
- resultAttributes.put(RETHINKDB_DELETE_RESULT_UNCHANGED_KEY,
String.valueOf(result.get(RESULT_UNCHANGED_KEY)));
- flowFile = session.putAllAttributes(flowFile, resultAttributes);
- return flowFile;
- }
-
- protected Map<String,Object> deleteDocument(String id, String durablity,
Boolean returnChanges) {
- return
getRdbTable().get(id).delete().optArg(DURABILITY_OPTION_KEY,durablity).optArg(RETURN_CHANGES_OPTION_KEY,
returnChanges).run(rethinkDbConnection);
- }
-
- @OnStopped
- public void close() {
- super.close();
- }
-}
\ No newline at end of file
diff --git
a/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/src/main/java/org/apache/nifi/processors/rethinkdb/GetRethinkDB.java
b/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/src/main/java/org/apache/nifi/processors/rethinkdb/GetRethinkDB.java
deleted file mode 100644
index 27d8a6f511..0000000000
---
a/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/src/main/java/org/apache/nifi/processors/rethinkdb/GetRethinkDB.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * 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.rethinkdb;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.nifi.annotation.behavior.EventDriven;
-import org.apache.nifi.annotation.behavior.InputRequirement;
-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.SeeAlso;
-import org.apache.nifi.annotation.documentation.Tags;
-import org.apache.nifi.annotation.lifecycle.OnScheduled;
-import org.apache.nifi.annotation.lifecycle.OnStopped;
-import org.apache.nifi.components.AllowableValue;
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.expression.ExpressionLanguageScope;
-import org.apache.nifi.flowfile.FlowFile;
-import org.apache.nifi.processor.DataUnit;
-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 com.google.gson.Gson;
-
-import java.io.ByteArrayInputStream;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED)
-@EventDriven
-@Tags({"rethinkdb", "get", "read", "fetch"})
-@CapabilityDescription("Processor to get a JSON document from RethinkDB
(https://www.rethinkdb.com/) using the document id. The FlowFile will contain
the retrieved document")
-@WritesAttributes({
- @WritesAttribute(attribute = GetRethinkDB.RETHINKDB_ERROR_MESSAGE,
description = "RethinkDB error message"),
- })
-@SeeAlso({PutRethinkDB.class,DeleteRethinkDB.class})
-public class GetRethinkDB extends AbstractRethinkDBProcessor {
-
- public static AllowableValue READ_MODE_SINGLE = new
AllowableValue("single", "Single", "Read values from memory from primary
replica (Default)");
- public static AllowableValue READ_MODE_MAJORITY = new
AllowableValue("majority", "Majority", "Read values committed to disk on
majority of replicas");
- public static AllowableValue READ_MODE_OUTDATED = new
AllowableValue("outdated", "Outdated", "Read values from memory from an
arbitrary replica ");
-
- protected static final PropertyDescriptor READ_MODE = new
PropertyDescriptor.Builder()
- .name("rethinkdb-read-mode")
- .displayName("Read Mode")
- .description("Read mode used for consistency")
- .required(true)
- .defaultValue(READ_MODE_SINGLE.getValue())
- .allowableValues(READ_MODE_SINGLE, READ_MODE_MAJORITY,
READ_MODE_OUTDATED)
-
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
- .build();
-
- protected String READ_MODE_KEY = "read_mode";
-
- private static final Set<Relationship> relationships;
- private static final List<PropertyDescriptor> propertyDescriptors;
-
- protected Gson gson = new Gson();
-
- static {
- final Set<Relationship> tempRelationships = new HashSet<>();
- tempRelationships.add(REL_SUCCESS);
- tempRelationships.add(REL_FAILURE);
- tempRelationships.add(REL_NOT_FOUND);
- relationships = Collections.unmodifiableSet(tempRelationships);
-
- final List<PropertyDescriptor> tempDescriptors = new ArrayList<>();
- tempDescriptors.add(DB_NAME);
- tempDescriptors.add(DB_HOST);
- tempDescriptors.add(DB_PORT);
- tempDescriptors.add(USERNAME);
- tempDescriptors.add(PASSWORD);
- tempDescriptors.add(TABLE_NAME);
- tempDescriptors.add(CHARSET);
- tempDescriptors.add(RETHINKDB_DOCUMENT_ID);
- tempDescriptors.add(READ_MODE);
- tempDescriptors.add(MAX_DOCUMENTS_SIZE);
- propertyDescriptors = Collections.unmodifiableList(tempDescriptors);
- }
-
- @Override
- public Set<Relationship> getRelationships() {
- return relationships;
- }
-
- @Override
- public final List<PropertyDescriptor> getSupportedPropertyDescriptors() {
- return propertyDescriptors;
- }
-
- @OnScheduled
- public void onScheduled(final ProcessContext context) {
- maxDocumentsSize =
context.getProperty(MAX_DOCUMENTS_SIZE).asDataSize(DataUnit.B).longValue();
- super.onScheduled(context);
- }
-
- @Override
- public void onTrigger(final ProcessContext context, final ProcessSession
session) throws ProcessException {
- FlowFile flowFile = session.get();
- if (flowFile == null) {
- return;
- }
-
- Charset charset =
Charset.forName(context.getProperty(CHARSET).evaluateAttributeExpressions(flowFile).getValue());
- String id =
context.getProperty(RETHINKDB_DOCUMENT_ID).evaluateAttributeExpressions(flowFile).getValue();
- String readMode =
context.getProperty(READ_MODE).evaluateAttributeExpressions(flowFile).getValue();
-
- if ( StringUtils.isEmpty(id) ) {
- getLogger().error(DOCUMENT_ID_EMPTY_MESSAGE);
- flowFile = session.putAttribute(flowFile, RETHINKDB_ERROR_MESSAGE,
DOCUMENT_ID_EMPTY_MESSAGE);
- session.transfer(flowFile, REL_FAILURE);
- return;
- }
-
- try {
- long startTimeMillis = System.currentTimeMillis();
- Map<String,Object> document = getDocument(id, readMode);
-
- if ( document == null ) {
- getLogger().debug("Document with id '" + id + "' not found");
- flowFile = session.putAttribute(flowFile,
RETHINKDB_ERROR_MESSAGE, "Document with id '" + id + "' not found");
- session.transfer(flowFile, REL_NOT_FOUND);
- return;
- }
-
- String json = gson.toJson(document);
-
- byte [] documentBytes = json.getBytes(charset);
-
- if ( documentBytes.length > maxDocumentsSize ) {
- getLogger().error("Document too big with size " +
documentBytes.length + " and max limit is " + maxDocumentsSize );
- flowFile = session.putAttribute(flowFile,
RETHINKDB_ERROR_MESSAGE, "Document too big size " + documentBytes.length + "
bytes");
- session.transfer(flowFile, REL_FAILURE);
- return;
- }
-
- ByteArrayInputStream bais = new
ByteArrayInputStream(documentBytes);
- session.importFrom(bais, flowFile);
- final long endTimeMillis = System.currentTimeMillis();
-
- getLogger().debug("Json document {} retrieved Result: {}", new
Object[] {id, document});
-
- session.transfer(flowFile, REL_SUCCESS);
- session.getProvenanceReporter().fetch(flowFile,
- new
StringBuilder("rethinkdb://").append(databaseName).append("/").append(tableName).append("/").append(id).toString(),
- (endTimeMillis - startTimeMillis));
-
- } catch (Exception exception) {
- getLogger().error("Failed to get document from RethinkDB due to
error {}",
- new Object[]{exception.getLocalizedMessage()}, exception);
- flowFile = session.putAttribute(flowFile, RETHINKDB_ERROR_MESSAGE,
exception.getMessage() + "");
- session.transfer(flowFile, REL_FAILURE);
- context.yield();
- }
- }
-
- protected Map<String,Object> getDocument(String id, String readMode) {
- return
getRdbTable().optArg(READ_MODE_KEY,readMode).get(id).run(rethinkDbConnection);
- }
-
- @OnStopped
- public void close() {
- super.close();
- }
-}
\ No newline at end of file
diff --git
a/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/src/main/java/org/apache/nifi/processors/rethinkdb/PutRethinkDB.java
b/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/src/main/java/org/apache/nifi/processors/rethinkdb/PutRethinkDB.java
deleted file mode 100644
index 4d3e84d3f7..0000000000
---
a/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/src/main/java/org/apache/nifi/processors/rethinkdb/PutRethinkDB.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * 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.rethinkdb;
-
-import org.apache.nifi.annotation.behavior.EventDriven;
-import org.apache.nifi.annotation.behavior.InputRequirement;
-import org.apache.nifi.annotation.behavior.SupportsBatching;
-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.SeeAlso;
-import org.apache.nifi.annotation.documentation.Tags;
-import org.apache.nifi.annotation.lifecycle.OnScheduled;
-import org.apache.nifi.annotation.lifecycle.OnStopped;
-import org.apache.nifi.components.AllowableValue;
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.expression.ExpressionLanguageScope;
-import org.apache.nifi.flowfile.FlowFile;
-import org.apache.nifi.processor.DataUnit;
-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.json.simple.parser.JSONParser;
-import com.rethinkdb.gen.ast.Insert;
-import java.io.ByteArrayOutputStream;
-import java.nio.charset.Charset;
-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;
-
-@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED)
-@EventDriven
-@SupportsBatching
-@Tags({"rethinkdb", "stream","insert", "update", "write", "put"})
-@CapabilityDescription("Processor to write the JSON content of a FlowFile to
RethinkDB (https://www.rethinkdb.com/). The flow file should contain either
JSON Object an array of JSON documents")
-@WritesAttributes({
- @WritesAttribute(attribute = PutRethinkDB.RETHINKDB_ERROR_MESSAGE,
description = "RethinkDB error message"),
- @WritesAttribute(attribute =
PutRethinkDB.RETHINKDB_INSERT_RESULT_ERROR_KEY, description = "Error count
while inserting documents"),
- @WritesAttribute(attribute =
PutRethinkDB.RETHINKDB_INSERT_RESULT_DELETED_KEY, description = "Number of
documents deleted"),
- @WritesAttribute(attribute =
PutRethinkDB.RETHINKDB_INSERT_RESULT_GENERATED_KEYS_KEY, description = "Keys
generated on inserting documents"),
- @WritesAttribute(attribute =
PutRethinkDB.RETHINKDB_INSERT_RESULT_INSERTED_KEY, description = "Number of
documents inserted"),
- @WritesAttribute(attribute =
PutRethinkDB.RETHINKDB_INSERT_RESULT_REPLACED_KEY, description = "Number of
documents replaced"),
- @WritesAttribute(attribute =
PutRethinkDB.RETHINKDB_INSERT_RESULT_SKIPPED_KEY, description = "Number of
documents skipped because they already existed"),
- @WritesAttribute(attribute =
PutRethinkDB.RETHINKDB_INSERT_RESULT_UNCHANGED_KEY, description = "Number of
documents unchanged since they already existed"),
- @WritesAttribute(attribute =
PutRethinkDB.RETHINKDB_INSERT_RESULT_FIRST_ERROR_KEY, description = "First
error while inserting documents"),
- @WritesAttribute(attribute =
PutRethinkDB.RETHINKDB_INSERT_RESULT_WARNINGS_KEY, description = "Warning
message in case of large number of ids being returned on insertion")
- })
-@SeeAlso({GetRethinkDB.class,DeleteRethinkDB.class})
-public class PutRethinkDB extends AbstractRethinkDBProcessor {
-
- public static AllowableValue CONFLICT_STRATEGY_UPDATE = new
AllowableValue("update", "Update", "Update the document having same id with new
values");
- public static AllowableValue CONFLICT_STRATEGY_REPLACE = new
AllowableValue("replace", "Replace", "Replace the document with having same id
new document");
- public static AllowableValue CONFLICT_STRATEGY_ERROR = new
AllowableValue("error", "Error", "Return error if the document with same id
exists");
-
- protected static final PropertyDescriptor CONFLICT_STRATEGY = new
PropertyDescriptor.Builder()
- .name("rethinkdb-conflict-strategy")
- .displayName("Conflict strategy")
- .description("Conflict strategy to be used in case of inserting
existing document.")
- .required(true)
- .defaultValue(CONFLICT_STRATEGY_UPDATE.getValue())
- .allowableValues(CONFLICT_STRATEGY_UPDATE,
CONFLICT_STRATEGY_REPLACE, CONFLICT_STRATEGY_ERROR)
-
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
- .build();
-
- private static final Set<Relationship> relationships;
- private static final List<PropertyDescriptor> propertyDescriptors;
-
- public static final String RETHINKDB_INSERT_RESULT =
"rethinkdb.insert.result";
- public static final String RETHINKDB_INSERT_RESULT_ERROR_KEY =
"rethinkdb.insert.errors";
- public static final String RETHINKDB_INSERT_RESULT_DELETED_KEY =
"rethinkdb.insert.deleted";
- public static final String RETHINKDB_INSERT_RESULT_GENERATED_KEYS_KEY =
"rethinkdb.insert.generated_keys";
- public static final String RETHINKDB_INSERT_RESULT_INSERTED_KEY =
"rethinkdb.insert.inserted";
- public static final String RETHINKDB_INSERT_RESULT_REPLACED_KEY =
"rethinkdb.insert.replaced";
- public static final String RETHINKDB_INSERT_RESULT_SKIPPED_KEY =
"rethinkdb.insert.skipped";
- public static final String RETHINKDB_INSERT_RESULT_UNCHANGED_KEY =
"rethinkdb.insert.unchanged";
- public static final String RETHINKDB_INSERT_RESULT_FIRST_ERROR_KEY =
"rethinkdb.insert.first_error";
- public static final String RETHINKDB_INSERT_RESULT_WARNINGS_KEY =
"rethinkdb.insert.warnings";
-
- public final String CONFLICT_OPTION_KEY = "conflict";
-
- static {
- final Set<Relationship> tempRelationships = new HashSet<>();
- tempRelationships.add(REL_SUCCESS);
- tempRelationships.add(REL_FAILURE);
- relationships = Collections.unmodifiableSet(tempRelationships);
-
- final List<PropertyDescriptor> tempDescriptors = new ArrayList<>();
- tempDescriptors.add(DB_NAME);
- tempDescriptors.add(DB_HOST);
- tempDescriptors.add(DB_PORT);
- tempDescriptors.add(USERNAME);
- tempDescriptors.add(PASSWORD);
- tempDescriptors.add(TABLE_NAME);
- tempDescriptors.add(CHARSET);
- tempDescriptors.add(CONFLICT_STRATEGY);
- tempDescriptors.add(DURABILITY);
- tempDescriptors.add(MAX_DOCUMENTS_SIZE);
- propertyDescriptors = Collections.unmodifiableList(tempDescriptors);
- }
-
- @Override
- public Set<Relationship> getRelationships() {
- return relationships;
- }
-
- @Override
- public final List<PropertyDescriptor> getSupportedPropertyDescriptors() {
- return propertyDescriptors;
- }
-
- @OnScheduled
- public void onScheduled(final ProcessContext context) {
- maxDocumentsSize =
context.getProperty(MAX_DOCUMENTS_SIZE).asDataSize(DataUnit.B).longValue();
- super.onScheduled(context);
- }
-
- @Override
- public void onTrigger(final ProcessContext context, final ProcessSession
session) throws ProcessException {
- FlowFile flowFile = session.get();
- if (flowFile == null) {
- return;
- }
-
- if ( flowFile.getSize() == 0) {
- getLogger().error("Empty message");
- flowFile = session.putAttribute(flowFile, RETHINKDB_ERROR_MESSAGE,
"Empty message size " + flowFile.getSize());
- session.transfer(flowFile, REL_FAILURE);
- return;
- }
-
- if ( flowFile.getSize() > maxDocumentsSize) {
- getLogger().error("Message size exceeded {} max allowed is {}",
new Object[] { flowFile.getSize(), maxDocumentsSize});
- flowFile = session.putAttribute(flowFile, RETHINKDB_ERROR_MESSAGE,
"Max message size exceeded " + flowFile.getSize());
- session.transfer(flowFile, REL_FAILURE);
- return;
- }
-
- Charset charset =
Charset.forName(context.getProperty(CHARSET).evaluateAttributeExpressions(flowFile).getValue());
- String conflictStrategy =
context.getProperty(CONFLICT_STRATEGY).evaluateAttributeExpressions(flowFile).getValue();
- String durability =
context.getProperty(DURABILITY).evaluateAttributeExpressions(flowFile).getValue();
-
- try {
- long startTimeMillis = System.currentTimeMillis();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- session.exportTo(flowFile, baos);
- String documents = new String(baos.toByteArray(), charset);
- JSONParser parser = new JSONParser();
- Object jsonDocuments = parser.parse(documents);
-
- Insert insert = getRdbTable().insert(jsonDocuments)
- .optArg(CONFLICT_OPTION_KEY, conflictStrategy)
- .optArg(DURABILITY_OPTION_KEY, durability);
-
- HashMap<String,Object> result = runInsert(insert);
- final long endTimeMillis = System.currentTimeMillis();
- getLogger().debug("Json documents {} inserted Result: {}", new
Object[] {documents, result});
- flowFile = populateAttributes(session, flowFile, result);
-
- if ( (Long)result.get(RESULT_ERROR_KEY) != 0 ) {
- getLogger().error("There were errors while inserting data
documents {} result {}",
- new Object [] {documents, result});
- session.transfer(flowFile, REL_FAILURE);
- } else {
- session.transfer(flowFile, REL_SUCCESS);
- session.getProvenanceReporter().send(flowFile,
- new
StringBuilder("rethinkdb://").append(databaseName).append("/").append(tableName).toString(),
- (endTimeMillis - startTimeMillis));
- }
- } catch (Exception exception) {
- getLogger().error("Failed to insert into RethinkDB due to {}",
- new Object[]{exception.getLocalizedMessage()}, exception);
- flowFile = session.putAttribute(flowFile, RETHINKDB_ERROR_MESSAGE,
String.valueOf(exception.getMessage()));
- session.transfer(flowFile, REL_FAILURE);
- context.yield();
- }
- }
-
- private FlowFile populateAttributes(final ProcessSession session, FlowFile
flowFile,
- HashMap<String, Object> result) {
- Map<String,String> resultAttributes = new HashMap<>();
- resultAttributes.put(RETHINKDB_INSERT_RESULT, result.toString());
- resultAttributes.put(RETHINKDB_INSERT_RESULT_ERROR_KEY,
String.valueOf(result.get(RESULT_ERROR_KEY)));
- resultAttributes.put(RETHINKDB_INSERT_RESULT_DELETED_KEY,
String.valueOf(result.get(RESULT_DELETED_KEY)));
- resultAttributes.put(RETHINKDB_INSERT_RESULT_GENERATED_KEYS_KEY,
String.valueOf(result.get(RESULT_GENERATED_KEYS_KEY)));
- resultAttributes.put(RETHINKDB_INSERT_RESULT_INSERTED_KEY,
String.valueOf(result.get(RESULT_INSERTED_KEY)));
- resultAttributes.put(RETHINKDB_INSERT_RESULT_REPLACED_KEY,
String.valueOf(result.get(RESULT_REPLACED_KEY)));
- resultAttributes.put(RETHINKDB_INSERT_RESULT_SKIPPED_KEY,
String.valueOf(result.get(RESULT_SKIPPED_KEY)));
- resultAttributes.put(RETHINKDB_INSERT_RESULT_UNCHANGED_KEY,
String.valueOf(result.get(RESULT_UNCHANGED_KEY)));
- resultAttributes.put(RETHINKDB_INSERT_RESULT_FIRST_ERROR_KEY,
String.valueOf(result.get(RESULT_FIRST_ERROR_KEY)));
- resultAttributes.put(RETHINKDB_INSERT_RESULT_WARNINGS_KEY,
String.valueOf(result.get(RESULT_WARNINGS_KEY)));
- flowFile = session.putAllAttributes(flowFile, resultAttributes);
- return flowFile;
- }
-
- protected HashMap<String,Object> runInsert(Insert insert) {
- return insert.run(rethinkDbConnection);
- }
-
- /**
- * Shutdown client connection
- */
- @OnStopped
- public void close() {
- super.close();
- }
-}
\ No newline at end of file
diff --git
a/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor
b/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor
deleted file mode 100644
index 0db3a569ac..0000000000
---
a/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/src/main/resources/META-INF/services/org.apache.nifi.processor.Processor
+++ /dev/null
@@ -1,17 +0,0 @@
-# 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.rethinkdb.PutRethinkDB
-org.apache.nifi.processors.rethinkdb.GetRethinkDB
-org.apache.nifi.processors.rethinkdb.DeleteRethinkDB
diff --git
a/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/src/test/java/org/apache/nifi/processors/rethinkdb/TestDeleteRethinkDB.java
b/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/src/test/java/org/apache/nifi/processors/rethinkdb/TestDeleteRethinkDB.java
deleted file mode 100644
index b6fef76d04..0000000000
---
a/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/src/test/java/org/apache/nifi/processors/rethinkdb/TestDeleteRethinkDB.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * 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.rethinkdb;
-
-import com.google.gson.Gson;
-import com.rethinkdb.net.Connection;
-import org.apache.nifi.util.MockFlowFile;
-import org.apache.nifi.util.TestRunner;
-import org.apache.nifi.util.TestRunners;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-public class TestDeleteRethinkDB {
- private static final String DOCUMENT_ID = "id1";
- private TestRunner runner;
- private AbstractRethinkDBProcessor mockDeleteRethinkDB;
- private Map<String,Object> document = new HashMap<>();
-
- @BeforeEach
- public void setUp() throws Exception {
- mockDeleteRethinkDB = new DeleteRethinkDB() {
- @Override
- protected Connection makeConnection() {
- return null;
- }
-
- @Override
- protected Map<String, Object> deleteDocument(String id, String
durablity, Boolean returnChanges) {
- return document;
- }
-
- };
-
- document.put(DeleteRethinkDB.RESULT_DELETED_KEY, 1L);
- document.put(DeleteRethinkDB.RESULT_ERROR_KEY, 0L);
- document.put(DeleteRethinkDB.RESULT_CHANGES_KEY, Arrays.asList(
- "[{new_val=null, old_val={id=1, value=one}}]"));
- document.put(DeleteRethinkDB.RESULT_INSERTED_KEY, 0L);
- document.put(DeleteRethinkDB.RESULT_REPLACED_KEY, 0L);
- document.put(DeleteRethinkDB.RESULT_SKIPPED_KEY, 0L);
- document.put(DeleteRethinkDB.RESULT_UNCHANGED_KEY, 0L);
- document.put(DeleteRethinkDB.RESULT_FIRST_ERROR_KEY, "");
-
- runner = TestRunners.newTestRunner(mockDeleteRethinkDB);
- runner.setProperty(AbstractRethinkDBProcessor.DB_NAME, "test");
- runner.setProperty(AbstractRethinkDBProcessor.DB_HOST, "host1");
- runner.setProperty(AbstractRethinkDBProcessor.DB_PORT, "1234");
- runner.setProperty(AbstractRethinkDBProcessor.USERNAME, "u1");
- runner.setProperty(AbstractRethinkDBProcessor.PASSWORD, "p1");
- runner.setProperty(AbstractRethinkDBProcessor.TABLE_NAME, "t1");
- runner.setProperty(AbstractRethinkDBProcessor.CHARSET, "UTF-8");
- runner.setProperty(AbstractRethinkDBProcessor.DURABILITY, "soft");
- runner.setProperty(AbstractRethinkDBProcessor.RETHINKDB_DOCUMENT_ID,
"${rethinkdb.id}");
- runner.assertValid();
- }
-
- @AfterEach
- public void tearDown() throws Exception {
- runner = null;
- }
-
- @Test
- public void testDefaultValid() {
- runner.assertValid();
- }
-
- @Test
- public void testBlankHost() {
- runner.setProperty(AbstractRethinkDBProcessor.DB_HOST, "");
- runner.assertNotValid();
- }
-
- @Test
- public void testEmptyPort() {
- runner.setProperty(AbstractRethinkDBProcessor.DB_PORT, "");
- runner.assertNotValid();
- }
-
- @Test
- public void testEmptyDBName() {
- runner.setProperty(AbstractRethinkDBProcessor.DB_NAME, "");
- runner.assertNotValid();
- }
-
- @Test
- public void testEmptyUsername() {
- runner.setProperty(AbstractRethinkDBProcessor.USERNAME, "");
- runner.assertNotValid();
- }
-
- @Test
- public void testEmptyPassword() {
- runner.setProperty(AbstractRethinkDBProcessor.PASSWORD, "p1");
- runner.assertValid();
- }
-
- @Test
- public void testCharsetUTF8() {
- runner.setProperty(AbstractRethinkDBProcessor.CHARSET, "UTF-8");
- runner.assertValid();
- }
-
- @Test
- public void testCharsetBlank() {
- runner.setProperty(AbstractRethinkDBProcessor.CHARSET, "");
- runner.assertNotValid();
- }
- @Test
- public void testZeroMaxDocumentSize() {
- runner.setProperty(AbstractRethinkDBProcessor.MAX_DOCUMENTS_SIZE, "0");
- runner.assertNotValid();
- }
-
- @Test
- public void testBlankDurability() {
- runner.setProperty(DeleteRethinkDB.DURABILITY, "");
- runner.assertNotValid();
- }
-
- @Test
- public void testNotFound() {
- runner.assertValid();
- document.put(DeleteRethinkDB.RESULT_DELETED_KEY, 0L);
-
- HashMap<String,String> props = new HashMap<>();
- props.put("rethinkdb.id", DOCUMENT_ID);
-
- runner.enqueue(new byte[]{}, props);
-
- runner.run(1,true,true);
-
-
runner.assertAllFlowFilesTransferred(AbstractRethinkDBProcessor.REL_NOT_FOUND,
1);
- List<MockFlowFile> flowFiles =
runner.getFlowFilesForRelationship(AbstractRethinkDBProcessor.REL_NOT_FOUND);
-
assertNotNull(flowFiles.get(0).getAttribute(AbstractRethinkDBProcessor.RETHINKDB_ERROR_MESSAGE));
-
flowFiles.get(0).assertAttributeEquals(AbstractRethinkDBProcessor.RETHINKDB_ERROR_MESSAGE,
- "Deleted count should be 1 but was 0 for document with id
'id1'");
- }
-
- @Test
- public void testBlankId() {
- runner.assertValid();
- runner.setProperty(AbstractRethinkDBProcessor.RETHINKDB_DOCUMENT_ID,
"${rethinkdb.id}");
-
- Map<String,String> props = new HashMap<>();
-
- runner.enqueue(new byte[]{},props);
- runner.run(1,true,true);
-
runner.assertAllFlowFilesTransferred(AbstractRethinkDBProcessor.REL_FAILURE, 1);
- List<MockFlowFile> flowFiles =
runner.getFlowFilesForRelationship(AbstractRethinkDBProcessor.REL_FAILURE);
-
assertNotNull(flowFiles.get(0).getAttribute(AbstractRethinkDBProcessor.RETHINKDB_ERROR_MESSAGE));
-
flowFiles.get(0).assertAttributeEquals(AbstractRethinkDBProcessor.RETHINKDB_ERROR_MESSAGE,AbstractRethinkDBProcessor.DOCUMENT_ID_EMPTY_MESSAGE);
- }
-
- @Test
- public void testNullId() {
- runner.assertValid();
- runner.setProperty(AbstractRethinkDBProcessor.RETHINKDB_DOCUMENT_ID,
"${rethinkdb.id}");
-
- Map<String,String> props = new HashMap<>();
- props.put("rethinkdb.id", null);
-
- runner.enqueue(new byte[]{},props);
- runner.run(1,true,true);
-
runner.assertAllFlowFilesTransferred(AbstractRethinkDBProcessor.REL_FAILURE, 1);
- List<MockFlowFile> flowFiles =
runner.getFlowFilesForRelationship(AbstractRethinkDBProcessor.REL_FAILURE);
-
assertNotNull(flowFiles.get(0).getAttribute(AbstractRethinkDBProcessor.RETHINKDB_ERROR_MESSAGE));
-
flowFiles.get(0).assertAttributeEquals(AbstractRethinkDBProcessor.RETHINKDB_ERROR_MESSAGE,AbstractRethinkDBProcessor.DOCUMENT_ID_EMPTY_MESSAGE);
- }
-
- @Test
- public void testValidSingleDelete() {
- runner.assertValid();
-
- HashMap<String,String> props = new HashMap<>();
- props.put("rethinkdb.id", DOCUMENT_ID);
-
- runner.enqueue(new byte[]{}, props);
-
- runner.run(1,true,true);
-
runner.assertAllFlowFilesTransferred(AbstractRethinkDBProcessor.REL_SUCCESS, 1);
- Gson gson = new Gson();
-
- String json =
gson.toJson(((List)document.get(DeleteRethinkDB.RESULT_CHANGES_KEY)).get(0));
-
- List<MockFlowFile> flowFiles =
runner.getFlowFilesForRelationship(AbstractRethinkDBProcessor.REL_SUCCESS);
- flowFiles.get(0).assertContentEquals(json);
-
assertNull(flowFiles.get(0).getAttribute(AbstractRethinkDBProcessor.RETHINKDB_ERROR_MESSAGE));
- }
-
- @Test
- public void testGetThrowsException() {
- mockDeleteRethinkDB = new DeleteRethinkDB() {
- @Override
- protected Connection makeConnection() {
- return null;
- }
-
- @Override
- protected Map<String,Object> deleteDocument(String id, String
durablity, Boolean returnChanges) {
- throw new RuntimeException("testException");
- }
- };
-
- runner = TestRunners.newTestRunner(mockDeleteRethinkDB);
- runner.setProperty(AbstractRethinkDBProcessor.DB_NAME, "test");
- runner.setProperty(AbstractRethinkDBProcessor.DB_HOST, "host1");
- runner.setProperty(AbstractRethinkDBProcessor.DB_PORT, "1234");
- runner.setProperty(AbstractRethinkDBProcessor.USERNAME, "u1");
- runner.setProperty(AbstractRethinkDBProcessor.PASSWORD, "p1");
- runner.setProperty(AbstractRethinkDBProcessor.TABLE_NAME, "t1");
- runner.setProperty(AbstractRethinkDBProcessor.CHARSET, "UTF-8");
-
- runner.setProperty(AbstractRethinkDBProcessor.RETHINKDB_DOCUMENT_ID,
DOCUMENT_ID);
-
- runner.assertValid();
-
- HashMap<String,String> props = new HashMap<>();
- props.put("rethinkdb.id", DOCUMENT_ID);
-
- runner.enqueue(new byte[]{}, props);
-
- runner.run(1,true,true);
-
runner.assertAllFlowFilesTransferred(AbstractRethinkDBProcessor.REL_FAILURE, 1);
-
- List<MockFlowFile> flowFiles =
runner.getFlowFilesForRelationship(AbstractRethinkDBProcessor.REL_FAILURE);
-
assertNotNull(flowFiles.get(0).getAttribute(AbstractRethinkDBProcessor.RETHINKDB_ERROR_MESSAGE));
-
flowFiles.get(0).assertAttributeEquals(AbstractRethinkDBProcessor.RETHINKDB_ERROR_MESSAGE,"testException");
- }
-}
\ No newline at end of file
diff --git
a/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/src/test/java/org/apache/nifi/processors/rethinkdb/TestGetRethinkDB.java
b/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/src/test/java/org/apache/nifi/processors/rethinkdb/TestGetRethinkDB.java
deleted file mode 100644
index ece46e3e91..0000000000
---
a/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/src/test/java/org/apache/nifi/processors/rethinkdb/TestGetRethinkDB.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * 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.rethinkdb;
-
-import com.google.gson.Gson;
-import com.rethinkdb.net.Connection;
-import org.apache.nifi.util.MockFlowFile;
-import org.apache.nifi.util.TestRunner;
-import org.apache.nifi.util.TestRunners;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-public class TestGetRethinkDB {
- private static final String DOCUMENT_ID = "id1";
- private TestRunner runner;
- private AbstractRethinkDBProcessor mockGetRethinkDB;
- private Map<String,Object> document;
-
- @BeforeEach
- public void setUp() throws Exception {
- mockGetRethinkDB = new GetRethinkDB() {
- @Override
- protected Connection makeConnection() {
- return null;
- }
-
- @Override
- protected Map<String,Object> getDocument(String id, String
readMode) {
- return document;
- }
- };
- runner = TestRunners.newTestRunner(mockGetRethinkDB);
- runner.setProperty(GetRethinkDB.DB_NAME, "test");
- runner.setProperty(GetRethinkDB.DB_HOST, "host1");
- runner.setProperty(GetRethinkDB.DB_PORT, "1234");
- runner.setProperty(GetRethinkDB.USERNAME, "u1");
- runner.setProperty(GetRethinkDB.PASSWORD, "p1");
- runner.setProperty(GetRethinkDB.TABLE_NAME, "t1");
- runner.setProperty(GetRethinkDB.CHARSET, "UTF-8");
- runner.setProperty(GetRethinkDB.READ_MODE, "single");
- runner.setProperty(GetRethinkDB.RETHINKDB_DOCUMENT_ID,
"${rethinkdb.id}");
- runner.setProperty(GetRethinkDB.MAX_DOCUMENTS_SIZE, "1 KB");
- runner.assertValid();
- }
-
- @AfterEach
- public void tearDown() throws Exception {
- runner = null;
- }
-
- @Test
- public void testDefaultValid() {
- runner.assertValid();
- }
-
- @Test
- public void testBlankHost() {
- runner.setProperty(GetRethinkDB.DB_HOST, "");
- runner.assertNotValid();
- }
-
- @Test
- public void testEmptyPort() {
- runner.setProperty(GetRethinkDB.DB_PORT, "");
- runner.assertNotValid();
- }
-
- @Test
- public void testEmptyDBName() {
- runner.setProperty(GetRethinkDB.DB_NAME, "");
- runner.assertNotValid();
- }
-
- @Test
- public void testEmptyUsername() {
- runner.setProperty(GetRethinkDB.USERNAME, "");
- runner.assertNotValid();
- }
-
- @Test
- public void testEmptyPassword() {
- runner.setProperty(GetRethinkDB.PASSWORD, "p1");
- runner.assertValid();
- }
-
- @Test
- public void testCharsetUTF8() {
- runner.setProperty(GetRethinkDB.CHARSET, "UTF-8");
- runner.assertValid();
- }
-
- @Test
- public void testCharsetBlank() {
- runner.setProperty(GetRethinkDB.CHARSET, "");
- runner.assertNotValid();
- }
- @Test
- public void testZeroMaxDocumentSize() {
- runner.setProperty(GetRethinkDB.MAX_DOCUMENTS_SIZE, "0");
- runner.assertNotValid();
- }
-
- @Test
- public void testBlankReadMode() {
- runner.setProperty(GetRethinkDB.READ_MODE, "");
- runner.assertNotValid();
- }
-
- @Test
- public void testSizeGreaterThanThreshold() {
- runner.setProperty(GetRethinkDB.MAX_DOCUMENTS_SIZE, "1 B");
- runner.assertValid();
- document = new HashMap<>();
- document.put("hello", "rethinkdb");
-
- HashMap<String,String> props = new HashMap<>();
- props.put("rethinkdb.id", DOCUMENT_ID);
-
- runner.enqueue(new byte[]{}, props);
- runner.run(1,true,true);
-
runner.assertAllFlowFilesTransferred(AbstractRethinkDBProcessor.REL_FAILURE, 1);
- List<MockFlowFile> flowFiles =
runner.getFlowFilesForRelationship(AbstractRethinkDBProcessor.REL_FAILURE);
-
assertNotNull(flowFiles.get(0).getAttribute(AbstractRethinkDBProcessor.RETHINKDB_ERROR_MESSAGE));
- }
-
- @Test
- public void testNotFound() {
- runner.setProperty(AbstractRethinkDBProcessor.MAX_DOCUMENTS_SIZE, "1
B");
- runner.assertValid();
-
- HashMap<String,String> props = new HashMap<>();
- props.put("rethinkdb.id", DOCUMENT_ID);
-
- runner.enqueue(new byte[]{}, props);
-
- runner.run(1,true,true);
-
-
runner.assertAllFlowFilesTransferred(AbstractRethinkDBProcessor.REL_NOT_FOUND,
1);
- List<MockFlowFile> flowFiles =
runner.getFlowFilesForRelationship(AbstractRethinkDBProcessor.REL_NOT_FOUND);
-
assertNotNull(flowFiles.get(0).getAttribute(AbstractRethinkDBProcessor.RETHINKDB_ERROR_MESSAGE));
-
flowFiles.get(0).assertAttributeEquals(AbstractRethinkDBProcessor.RETHINKDB_ERROR_MESSAGE,"Document
with id '" + DOCUMENT_ID + "' not found");
- }
-
- @Test
- public void testBlankId() {
- runner.setProperty(AbstractRethinkDBProcessor.MAX_DOCUMENTS_SIZE, "1
B");
- runner.assertValid();
- runner.setProperty(GetRethinkDB.RETHINKDB_DOCUMENT_ID,
"${rethinkdb.id}");
- Map<String,String> props = new HashMap<>();
-
- runner.enqueue(new byte[]{},props);
- runner.run(1,true,true);
-
runner.assertAllFlowFilesTransferred(AbstractRethinkDBProcessor.REL_FAILURE, 1);
- List<MockFlowFile> flowFiles =
runner.getFlowFilesForRelationship(AbstractRethinkDBProcessor.REL_FAILURE);
-
assertNotNull(flowFiles.get(0).getAttribute(AbstractRethinkDBProcessor.RETHINKDB_ERROR_MESSAGE));
-
flowFiles.get(0).assertAttributeEquals(AbstractRethinkDBProcessor.RETHINKDB_ERROR_MESSAGE,GetRethinkDB.DOCUMENT_ID_EMPTY_MESSAGE);
- }
-
- @Test
- public void testNullId() {
- runner.setProperty(AbstractRethinkDBProcessor.MAX_DOCUMENTS_SIZE, "1
B");
- runner.assertValid();
- runner.setProperty(GetRethinkDB.RETHINKDB_DOCUMENT_ID,
"${rethinkdb.id}");
- Map<String,String> props = new HashMap<>();
- props.put("rethinkdb.id", null);
- runner.enqueue(new byte[]{},props);
- runner.run(1,true,true);
-
runner.assertAllFlowFilesTransferred(AbstractRethinkDBProcessor.REL_FAILURE, 1);
- List<MockFlowFile> flowFiles =
runner.getFlowFilesForRelationship(AbstractRethinkDBProcessor.REL_FAILURE);
-
assertNotNull(flowFiles.get(0).getAttribute(AbstractRethinkDBProcessor.RETHINKDB_ERROR_MESSAGE));
-
flowFiles.get(0).assertAttributeEquals(AbstractRethinkDBProcessor.RETHINKDB_ERROR_MESSAGE,GetRethinkDB.DOCUMENT_ID_EMPTY_MESSAGE);
- }
-
- @Test
- public void testValidSingleMessage() {
- runner.setProperty(AbstractRethinkDBProcessor.MAX_DOCUMENTS_SIZE, "1
MB");
- runner.assertValid();
- document = new HashMap<>();
- document.put("hello", "rethinkdb");
-
- HashMap<String,String> props = new HashMap<>();
- props.put("rethinkdb.id", DOCUMENT_ID);
-
- runner.enqueue(new byte[]{}, props);
-
- runner.run(1,true,true);
-
runner.assertAllFlowFilesTransferred(AbstractRethinkDBProcessor.REL_SUCCESS, 1);
- Gson gson = new Gson();
-
- String json = gson.toJson(document);
-
- List<MockFlowFile> flowFiles =
runner.getFlowFilesForRelationship(AbstractRethinkDBProcessor.REL_SUCCESS);
- flowFiles.get(0).assertContentEquals(json.toString());
-
assertNull(flowFiles.get(0).getAttribute(AbstractRethinkDBProcessor.RETHINKDB_ERROR_MESSAGE));
-
- }
-
- @Test
- public void testGetThrowsException() {
- mockGetRethinkDB = new GetRethinkDB() {
- @Override
- protected Connection makeConnection() {
- return null;
- }
-
- @Override
- protected Map<String,Object> getDocument(String id, String
readMode) {
- throw new RuntimeException("testException");
- }
- };
-
- runner = TestRunners.newTestRunner(mockGetRethinkDB);
- runner.setProperty(AbstractRethinkDBProcessor.DB_NAME, "test");
- runner.setProperty(AbstractRethinkDBProcessor.DB_HOST, "host1");
- runner.setProperty(AbstractRethinkDBProcessor.DB_PORT, "1234");
- runner.setProperty(AbstractRethinkDBProcessor.USERNAME, "u1");
- runner.setProperty(AbstractRethinkDBProcessor.PASSWORD, "p1");
- runner.setProperty(AbstractRethinkDBProcessor.TABLE_NAME, "t1");
- runner.setProperty(AbstractRethinkDBProcessor.CHARSET, "UTF-8");
- runner.setProperty(GetRethinkDB.READ_MODE, "single");
-
- runner.setProperty(AbstractRethinkDBProcessor.MAX_DOCUMENTS_SIZE, "1
KB");
- runner.setProperty(GetRethinkDB.RETHINKDB_DOCUMENT_ID, DOCUMENT_ID);
-
- runner.assertValid();
-
- HashMap<String,String> props = new HashMap<>();
- props.put("rethinkdb.id", DOCUMENT_ID);
-
- runner.enqueue(new byte[]{}, props);
-
- runner.run(1,true,true);
- runner.assertAllFlowFilesTransferred(PutRethinkDB.REL_FAILURE, 1);
-
- List<MockFlowFile> flowFiles =
runner.getFlowFilesForRelationship(AbstractRethinkDBProcessor.REL_FAILURE);
-
assertNotNull(flowFiles.get(0).getAttribute(AbstractRethinkDBProcessor.RETHINKDB_ERROR_MESSAGE));
-
flowFiles.get(0).assertAttributeEquals(AbstractRethinkDBProcessor.RETHINKDB_ERROR_MESSAGE,"testException");
- }
-}
\ No newline at end of file
diff --git
a/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/src/test/java/org/apache/nifi/processors/rethinkdb/TestPutRethinkDB.java
b/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/src/test/java/org/apache/nifi/processors/rethinkdb/TestPutRethinkDB.java
deleted file mode 100644
index c783366680..0000000000
---
a/nifi-nar-bundles/nifi-rethinkdb-bundle/nifi-rethinkdb-processors/src/test/java/org/apache/nifi/processors/rethinkdb/TestPutRethinkDB.java
+++ /dev/null
@@ -1,360 +0,0 @@
-/*
- * 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.rethinkdb;
-
-import com.rethinkdb.gen.ast.Insert;
-import com.rethinkdb.net.Connection;
-import net.minidev.json.JSONObject;
-import org.apache.nifi.util.MockFlowFile;
-import org.apache.nifi.util.TestRunner;
-import org.apache.nifi.util.TestRunners;
-import org.json.simple.JSONArray;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import java.util.HashMap;
-import java.util.List;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-public class TestPutRethinkDB {
- private TestRunner runner;
- private PutRethinkDB mockPutRethinkDB;
- protected HashMap<String,Object> result = new HashMap<>();
-
- @BeforeEach
- public void setUp() throws Exception {
- result.put(PutRethinkDB.RESULT_DELETED_KEY, 0L);
- result.put(PutRethinkDB.RESULT_ERROR_KEY, 0L);
- result.put(PutRethinkDB.RESULT_GENERATED_KEYS_KEY,
- "[\"4056b236-1d8a-492a-b67f-8cf99e363cc6\"]");
- result.put(PutRethinkDB.RESULT_INSERTED_KEY, 1L);
- result.put(PutRethinkDB.RESULT_REPLACED_KEY, 0L);
- result.put(PutRethinkDB.RESULT_SKIPPED_KEY, 0L);
- result.put(PutRethinkDB.RESULT_UNCHANGED_KEY, 0L);
- result.put(PutRethinkDB.RESULT_FIRST_ERROR_KEY, "");
- result.put(PutRethinkDB.RESULT_WARNINGS_KEY, "");
- mockPutRethinkDB = new PutRethinkDB() {
- @Override
- protected Connection makeConnection() {
- return null;
- }
- @Override
- protected HashMap<String, Object> runInsert(Insert insert) {
- return result;
- }
- };
- runner = TestRunners.newTestRunner(mockPutRethinkDB);
- runner.setProperty(PutRethinkDB.DB_NAME, "test");
- runner.setProperty(PutRethinkDB.DB_HOST, "host1");
- runner.setProperty(PutRethinkDB.DB_PORT, "1234");
- runner.setProperty(PutRethinkDB.USERNAME, "u1");
- runner.setProperty(PutRethinkDB.PASSWORD, "p1");
- runner.setProperty(PutRethinkDB.TABLE_NAME, "t1");
- runner.setProperty(PutRethinkDB.CHARSET, "UTF-8");
- runner.setProperty(PutRethinkDB.CONFLICT_STRATEGY,
PutRethinkDB.CONFLICT_STRATEGY_UPDATE);
- runner.setProperty(PutRethinkDB.DURABILITY,
PutRethinkDB.DURABILITY_HARD);
- runner.setProperty(PutRethinkDB.MAX_DOCUMENTS_SIZE, "1 KB");
- runner.assertValid();
- }
-
- @AfterEach
- public void tearDown() throws Exception {
- runner = null;
- }
-
- @Test
- public void testDefaultValid() {
- runner.assertValid();
- }
-
- @Test
- public void testBlankHost() {
- runner.setProperty(PutRethinkDB.DB_HOST, "");
- runner.assertNotValid();
- }
-
- @Test
- public void testEmptyPort() {
- runner.setProperty(PutRethinkDB.DB_PORT, "");
- runner.assertNotValid();
- }
-
- @Test
- public void testEmptyDBName() {
- runner.setProperty(PutRethinkDB.DB_NAME, "");
- runner.assertNotValid();
- }
-
- @Test
- public void testEmptyUsername() {
- runner.setProperty(PutRethinkDB.USERNAME, "");
- runner.assertNotValid();
- }
-
- @Test
- public void testEmptyPassword() {
- runner.setProperty(PutRethinkDB.PASSWORD, "p1");
- runner.assertValid();
- }
-
- @Test
- public void testCharsetUTF8() {
- runner.setProperty(PutRethinkDB.CHARSET, "UTF-8");
- runner.assertValid();
- }
-
- @Test
- public void testCharsetBlank() {
- runner.setProperty(PutRethinkDB.CHARSET, "");
- runner.assertNotValid();
- }
- @Test
- public void testZeroMaxDocumentSize() {
- runner.setProperty(PutRethinkDB.MAX_DOCUMENTS_SIZE, "0");
- runner.assertNotValid();
- }
-
- @Test
- public void testBlankConflictStrategy() {
- runner.setProperty(PutRethinkDB.CONFLICT_STRATEGY, "");
- runner.assertNotValid();
- }
-
- @Test
- public void testBlankDurability() {
- runner.setProperty(PutRethinkDB.DURABILITY, "");
- runner.assertNotValid();
- }
-
- @Test
- public void testSizeGreaterThanThreshold() {
- runner.setProperty(PutRethinkDB.MAX_DOCUMENTS_SIZE, "1 B");
- runner.assertValid();
- byte [] bytes = new byte[2];
- for (int i = 0; i < bytes.length; i++) {
- bytes[i] = 'a';
- }
- runner.enqueue(bytes);
- runner.run(1);
- runner.assertAllFlowFilesTransferred(PutRethinkDB.REL_FAILURE, 1);
- List<MockFlowFile> flowFiles =
runner.getFlowFilesForRelationship(PutRethinkDB.REL_FAILURE);
-
assertNotNull(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_ERROR_MESSAGE));
- }
-
- @Test
- public void testValidSingleMessage() {
- runner.setProperty(PutRethinkDB.MAX_DOCUMENTS_SIZE, "1 MB");
- runner.assertValid();
- result.remove(PutRethinkDB.RESULT_FIRST_ERROR_KEY);
- result.remove(PutRethinkDB.RESULT_WARNINGS_KEY);
- JSONObject message = new JSONObject();
- message.put("hello", "rethinkdb");
- byte [] bytes = message.toJSONString().getBytes();
-
- runner.enqueue(bytes);
- runner.run(1,true,true);
- runner.assertAllFlowFilesTransferred(PutRethinkDB.REL_SUCCESS, 1);
-
- List<MockFlowFile> flowFiles =
runner.getFlowFilesForRelationship(PutRethinkDB.REL_SUCCESS);
-
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_DELETED_KEY),
"0");
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_ERROR_KEY),"0");
-
assertNotNull(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_GENERATED_KEYS_KEY));
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_INSERTED_KEY),"1");
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_REPLACED_KEY),"0");
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_SKIPPED_KEY),"0");
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_UNCHANGED_KEY),"0");
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_FIRST_ERROR_KEY),"null");
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_FIRST_ERROR_KEY),"null");
- }
-
- @Test
- public void testInsertThrowsException() {
- mockPutRethinkDB = new PutRethinkDB() {
- @Override
- protected Connection makeConnection() {
- return null;
- }
- @Override
- protected HashMap<String, Object> runInsert(Insert insert) {
- throw new RuntimeException("testException");
- }
- };
- runner = TestRunners.newTestRunner(mockPutRethinkDB);
- runner.setProperty(PutRethinkDB.DB_NAME, "test");
- runner.setProperty(PutRethinkDB.DB_HOST, "host1");
- runner.setProperty(PutRethinkDB.DB_PORT, "1234");
- runner.setProperty(PutRethinkDB.USERNAME, "u1");
- runner.setProperty(PutRethinkDB.PASSWORD, "p1");
- runner.setProperty(PutRethinkDB.TABLE_NAME, "t1");
- runner.setProperty(PutRethinkDB.CHARSET, "UTF-8");
- runner.setProperty(PutRethinkDB.CONFLICT_STRATEGY,
PutRethinkDB.CONFLICT_STRATEGY_UPDATE);
- runner.setProperty(PutRethinkDB.DURABILITY,
PutRethinkDB.DURABILITY_HARD);
- runner.setProperty(PutRethinkDB.MAX_DOCUMENTS_SIZE, "1 KB");
- runner.assertValid();
-
- JSONObject message = new JSONObject();
- message.put("hello", "rethinkdb");
- byte [] bytes = message.toJSONString().getBytes();
- runner.enqueue(bytes);
- runner.run(1,true,true);
- runner.assertAllFlowFilesTransferred(PutRethinkDB.REL_FAILURE, 1);
-
- List<MockFlowFile> flowFiles =
runner.getFlowFilesForRelationship(PutRethinkDB.REL_FAILURE);
-
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_DELETED_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_ERROR_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_GENERATED_KEYS_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_INSERTED_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_REPLACED_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_SKIPPED_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_UNCHANGED_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_FIRST_ERROR_KEY),null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_ERROR_MESSAGE),"testException");
- }
-
- @Test
- public void testMakeConnectionThrowsException() {
- mockPutRethinkDB = new PutRethinkDB() {
- @Override
- protected Connection makeConnection() {
- throw new RuntimeException("testException");
- }
- };
- runner = TestRunners.newTestRunner(mockPutRethinkDB);
- runner.setProperty(PutRethinkDB.DB_NAME, "test");
- runner.setProperty(PutRethinkDB.DB_HOST, "host1");
- runner.setProperty(PutRethinkDB.DB_PORT, "1234");
- runner.setProperty(PutRethinkDB.USERNAME, "u1");
- runner.setProperty(PutRethinkDB.PASSWORD, "p1");
- runner.setProperty(PutRethinkDB.TABLE_NAME, "t1");
- runner.setProperty(PutRethinkDB.CHARSET, "UTF-8");
- runner.setProperty(PutRethinkDB.CONFLICT_STRATEGY,
PutRethinkDB.CONFLICT_STRATEGY_UPDATE);
- runner.setProperty(PutRethinkDB.DURABILITY,
PutRethinkDB.DURABILITY_HARD);
- runner.setProperty(PutRethinkDB.MAX_DOCUMENTS_SIZE, "1 KB");
- runner.assertValid();
- JSONObject message = new JSONObject();
- message.put("hello", "rethinkdb");
-
- byte [] bytes = message.toJSONString().getBytes();
- runner.enqueue(bytes);
- assertThrows(AssertionError.class, () -> runner.run(1,true,true));
- }
-
- @Test
- public void testMessageError() {
- runner.setProperty(PutRethinkDB.MAX_DOCUMENTS_SIZE, "1 MB");
- runner.assertValid();
- result.put(PutRethinkDB.RESULT_FIRST_ERROR_KEY,"Error occured");
- result.put(PutRethinkDB.RESULT_ERROR_KEY,1L);
- result.put(PutRethinkDB.RESULT_INSERTED_KEY,0L);
- result.remove(PutRethinkDB.RESULT_WARNINGS_KEY);
- JSONObject message = new JSONObject();
- message.put("hello", "rethinkdb");
- byte [] bytes = message.toJSONString().getBytes();
- runner.enqueue(bytes);
- runner.run(1,true,true);
- runner.assertAllFlowFilesTransferred(PutRethinkDB.REL_FAILURE, 1);
-
- List<MockFlowFile> flowFiles =
runner.getFlowFilesForRelationship(PutRethinkDB.REL_FAILURE);
-
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_DELETED_KEY),
"0");
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_ERROR_KEY),"1");
-
assertNotNull(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_GENERATED_KEYS_KEY));
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_INSERTED_KEY),"0");
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_REPLACED_KEY),"0");
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_SKIPPED_KEY),"0");
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_UNCHANGED_KEY),"0");
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_FIRST_ERROR_KEY),"Error
occured");
- }
-
- @Test
- public void testValidArrayMessage() {
- runner.setProperty(PutRethinkDB.MAX_DOCUMENTS_SIZE, "1 MB");
- runner.assertValid();
- result.remove(PutRethinkDB.RESULT_FIRST_ERROR_KEY);
- result.remove(PutRethinkDB.RESULT_WARNINGS_KEY);
- result.put(PutRethinkDB.RESULT_INSERTED_KEY,2L);
- JSONObject message1 = new JSONObject();
- message1.put("hello", "rethinkdb");
- JSONObject message2 = new JSONObject();
- message2.put("hello2", "rethinkdb2");
- JSONArray array = new JSONArray();
- array.add(message1);
- array.add(message2);
- byte [] bytes = array.toJSONString().getBytes();
-
- runner.enqueue(bytes);
- runner.run(1,true,true);
-
- runner.assertAllFlowFilesTransferred(PutRethinkDB.REL_SUCCESS, 1);
- List<MockFlowFile> flowFiles =
runner.getFlowFilesForRelationship(PutRethinkDB.REL_SUCCESS);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_DELETED_KEY),
"0");
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_ERROR_KEY),"0");
-
assertNotNull(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_GENERATED_KEYS_KEY));
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_INSERTED_KEY),"2");
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_REPLACED_KEY),"0");
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_SKIPPED_KEY),"0");
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_UNCHANGED_KEY),"0");
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_FIRST_ERROR_KEY),"null");
- }
- @Test
- public void testInvalidSingleMessage() {
- byte [] bytes = "bad json".getBytes();
-
- runner.enqueue(bytes);
- runner.run(1,true,true);
- runner.assertAllFlowFilesTransferred(PutRethinkDB.REL_FAILURE, 1);
-
- List<MockFlowFile> flowFiles =
runner.getFlowFilesForRelationship(PutRethinkDB.REL_FAILURE);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_DELETED_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_ERROR_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_GENERATED_KEYS_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_INSERTED_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_REPLACED_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_SKIPPED_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_UNCHANGED_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_FIRST_ERROR_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_FIRST_ERROR_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_ERROR_MESSAGE),
"null");
- }
-
- @Test
- public void testInvalidEmptySingleMessage() {
- byte [] bytes = "".getBytes();
- runner.enqueue(bytes);
- runner.run(1,true,true);
- runner.assertAllFlowFilesTransferred(PutRethinkDB.REL_FAILURE, 1);
-
- List<MockFlowFile> flowFiles =
runner.getFlowFilesForRelationship(PutRethinkDB.REL_FAILURE);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_DELETED_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_ERROR_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_GENERATED_KEYS_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_INSERTED_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_REPLACED_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_SKIPPED_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_UNCHANGED_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_FIRST_ERROR_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_INSERT_RESULT_FIRST_ERROR_KEY),
null);
-
assertEquals(flowFiles.get(0).getAttribute(PutRethinkDB.RETHINKDB_ERROR_MESSAGE),
"Empty message size 0");
- }
-
-}
\ No newline at end of file
diff --git a/nifi-nar-bundles/nifi-rethinkdb-bundle/pom.xml
b/nifi-nar-bundles/nifi-rethinkdb-bundle/pom.xml
deleted file mode 100644
index 2a1d4de14e..0000000000
--- a/nifi-nar-bundles/nifi-rethinkdb-bundle/pom.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<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
https://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.nifi</groupId>
- <artifactId>nifi-nar-bundles</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>nifi-rethinkdb-bundle</artifactId>
- <packaging>pom</packaging>
-
- <modules>
- <module>nifi-rethinkdb-processors</module>
- <module>nifi-rethinkdb-nar</module>
- </modules>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.apache.nifi</groupId>
- <artifactId>nifi-rethinkdb-processors</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
-</project>
diff --git a/nifi-nar-bundles/pom.xml b/nifi-nar-bundles/pom.xml
index 63621e6ab8..e2fb465167 100755
--- a/nifi-nar-bundles/pom.xml
+++ b/nifi-nar-bundles/pom.xml
@@ -73,7 +73,6 @@
<module>nifi-snmp-bundle</module>
<module>nifi-datadog-bundle</module>
<module>nifi-windows-event-log-bundle</module>
- <module>nifi-rethinkdb-bundle</module>
<module>nifi-influxdb-bundle</module>
<module>nifi-graph-bundle</module>
<module>nifi-email-bundle</module>