mirror of https://github.com/apache/nifi.git
NIFI-11583 Removed GetIgniteCache and PutIgniteCache Processors
Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com> This closes #7285.
This commit is contained in:
parent
c8d3a69d64
commit
3833b51764
|
@ -1380,21 +1380,6 @@ The following binary components are provided under the Apache Software License v
|
||||||
This product includes software developed by
|
This product includes software developed by
|
||||||
The Groovy community (http://groovy.codehaus.org/).
|
The Groovy community (http://groovy.codehaus.org/).
|
||||||
|
|
||||||
(ASLv2) Apache Ignite
|
|
||||||
The following NOTICE information applies:
|
|
||||||
Apache Ignite
|
|
||||||
Copyright 2015 The Apache Software Foundation
|
|
||||||
|
|
||||||
This product includes software developed at
|
|
||||||
The Apache Software Foundation (http://www.apache.org/).
|
|
||||||
|
|
||||||
|
|
||||||
This software includes code from IntelliJ IDEA Community Edition
|
|
||||||
Copyright (C) JetBrains s.r.o.
|
|
||||||
https://www.jetbrains.com/idea/
|
|
||||||
Licensed under Apache License, Version 2.0.
|
|
||||||
http://search.maven.org/#artifactdetails%7Corg.jetbrains%7Cannotations%7C13.0%7Cjar
|
|
||||||
|
|
||||||
(ASLv2) Apache Geronimo JSR-107 JCache Spec API
|
(ASLv2) Apache Geronimo JSR-107 JCache Spec API
|
||||||
The following NOTICE information applies:
|
The following NOTICE information applies:
|
||||||
Apache Geronimo JSR-107 JCache Spec API
|
Apache Geronimo JSR-107 JCache Spec API
|
||||||
|
|
|
@ -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-ignite-bundle</artifactId>
|
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>nifi-ignite-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-ignite-processors</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
|
@ -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.
|
|
|
@ -1,57 +0,0 @@
|
||||||
nifi-ignite-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) Apache Ignite
|
|
||||||
The following NOTICE information applies:
|
|
||||||
Apache Ignite
|
|
||||||
Copyright 2015 The Apache Software Foundation
|
|
||||||
|
|
||||||
This product includes software developed at
|
|
||||||
The Apache Software Foundation (http://www.apache.org/).
|
|
||||||
|
|
||||||
|
|
||||||
This software includes code from IntelliJ IDEA Community Edition
|
|
||||||
Copyright (C) JetBrains s.r.o.
|
|
||||||
https://www.jetbrains.com/idea/
|
|
||||||
Licensed under Apache License, Version 2.0.
|
|
||||||
http://search.maven.org/#artifactdetails%7Corg.jetbrains%7Cannotations%7C13.0%7Cjar
|
|
||||||
|
|
||||||
(ASLv2) Apache Geronimo JSR-107 JCache Spec API
|
|
||||||
The following NOTICE information applies:
|
|
||||||
Apache Geronimo JSR-107 JCache Spec API
|
|
||||||
Copyright 2009-2014 The Apache Software Foundation
|
|
||||||
|
|
||||||
This product includes software developed at
|
|
||||||
The Apache Software Foundation (http://www.apache.org/).
|
|
||||||
|
|
||||||
(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-2011 The Apache Software Foundation
|
|
||||||
|
|
||||||
(ASLv2) Spring Framework
|
|
||||||
The following NOTICE information applies:
|
|
||||||
Spring Framework 5
|
|
||||||
Copyright (c) 2002-2021 Pivotal, Inc.
|
|
||||||
|
|
||||||
*****************
|
|
||||||
Public Domain
|
|
||||||
*****************
|
|
||||||
|
|
||||||
The following binary components are provided to the 'Public Domain'. See project link for details.
|
|
||||||
|
|
||||||
(Public Domain) AOP Alliance 1.0 (http://aopalliance.sourceforge.net/)
|
|
|
@ -1,85 +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-ignite-bundle</artifactId>
|
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>nifi-ignite-processors</artifactId>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.ignite</groupId>
|
|
||||||
<artifactId>ignite-core</artifactId>
|
|
||||||
<version>1.6.0</version>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>javax.cache</groupId>
|
|
||||||
<artifactId>cache-api</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.geronimo.specs</groupId>
|
|
||||||
<artifactId>geronimo-jcache_1.0_spec</artifactId>
|
|
||||||
<version>1.0-alpha-1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-lang3</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.ignite</groupId>
|
|
||||||
<artifactId>ignite-slf4j</artifactId>
|
|
||||||
<version>1.6.0</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.ignite</groupId>
|
|
||||||
<artifactId>ignite-spring</artifactId>
|
|
||||||
<version>1.6.0</version>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>commons-logging</groupId>
|
|
||||||
<artifactId>commons-logging</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.nifi</groupId>
|
|
||||||
<artifactId>nifi-api</artifactId>
|
|
||||||
</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.nifi</groupId>
|
|
||||||
<artifactId>nifi-mock</artifactId>
|
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
|
@ -1,117 +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.ignite;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.ignite.Ignite;
|
|
||||||
import org.apache.ignite.Ignition;
|
|
||||||
import org.apache.nifi.components.PropertyDescriptor;
|
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Base class for Ignite processors
|
|
||||||
*/
|
|
||||||
public abstract class AbstractIgniteProcessor extends AbstractProcessor {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ignite spring configuration file
|
|
||||||
*/
|
|
||||||
public static final PropertyDescriptor IGNITE_CONFIGURATION_FILE = new PropertyDescriptor.Builder()
|
|
||||||
.displayName("Ignite Spring Properties Xml File")
|
|
||||||
.name("ignite-spring-properties-xml-file")
|
|
||||||
.description("Ignite spring configuration file, <path>/<ignite-configuration>.xml. If the " +
|
|
||||||
"configuration file is not provided, default Ignite configuration " +
|
|
||||||
"configuration is used which binds to 127.0.0.1:47500..47509")
|
|
||||||
.required(false)
|
|
||||||
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Success relation
|
|
||||||
*/
|
|
||||||
public static final Relationship REL_SUCCESS = new Relationship.Builder().name("success")
|
|
||||||
.description("All FlowFiles that are written to Ignite cache are routed to this relationship").build();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Failure relation
|
|
||||||
*/
|
|
||||||
public static final Relationship REL_FAILURE = new Relationship.Builder().name("failure")
|
|
||||||
.description("All FlowFiles that cannot be written to Ignite cache are routed to this relationship").build();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The ignite instance
|
|
||||||
*/
|
|
||||||
private transient Ignite ignite;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get ignite instance
|
|
||||||
* @return ignite instance
|
|
||||||
*/
|
|
||||||
protected Ignite getIgnite() {
|
|
||||||
return ignite;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Close ignite instance
|
|
||||||
*/
|
|
||||||
public void closeIgnite() {
|
|
||||||
if (ignite != null) {
|
|
||||||
getLogger().info("Closing ignite client");
|
|
||||||
ignite.close();
|
|
||||||
ignite = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize ignite instance
|
|
||||||
* @param context process context
|
|
||||||
*/
|
|
||||||
public void initializeIgnite(ProcessContext context) {
|
|
||||||
|
|
||||||
if ( getIgnite() != null ) {
|
|
||||||
getLogger().info("Ignite already initialized");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
synchronized(Ignition.class) {
|
|
||||||
List<Ignite> grids = Ignition.allGrids();
|
|
||||||
|
|
||||||
if ( grids.size() == 1 ) {
|
|
||||||
getLogger().info("Ignite grid already available");
|
|
||||||
ignite = grids.get(0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Ignition.setClientMode(true);
|
|
||||||
|
|
||||||
String configuration = context.getProperty(IGNITE_CONFIGURATION_FILE).getValue();
|
|
||||||
getLogger().info("Initializing ignite with configuration {} ", new Object[] { configuration });
|
|
||||||
if ( StringUtils.isEmpty(configuration) ) {
|
|
||||||
ignite = Ignition.start();
|
|
||||||
} else {
|
|
||||||
ignite = Ignition.start(configuration);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,130 +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.ignite.cache;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.apache.ignite.IgniteCache;
|
|
||||||
import org.apache.nifi.annotation.lifecycle.OnShutdown;
|
|
||||||
import org.apache.nifi.components.PropertyDescriptor;
|
|
||||||
import org.apache.nifi.expression.ExpressionLanguageScope;
|
|
||||||
import org.apache.nifi.expression.AttributeExpression.ResultType;
|
|
||||||
import org.apache.nifi.processor.ProcessContext;
|
|
||||||
import org.apache.nifi.processor.Relationship;
|
|
||||||
import org.apache.nifi.processor.exception.ProcessException;
|
|
||||||
import org.apache.nifi.processor.util.StandardValidators;
|
|
||||||
import org.apache.nifi.processors.ignite.AbstractIgniteProcessor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Base class of Ignite cache based processor
|
|
||||||
*/
|
|
||||||
public abstract class AbstractIgniteCacheProcessor extends AbstractIgniteProcessor {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ignite cache name
|
|
||||||
*/
|
|
||||||
protected static final PropertyDescriptor CACHE_NAME = new PropertyDescriptor.Builder()
|
|
||||||
.displayName("Ignite Cache Name")
|
|
||||||
.name("ignite-cache-name")
|
|
||||||
.description("The name of the ignite cache")
|
|
||||||
.required(false)
|
|
||||||
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Ignite cache key attribute
|
|
||||||
*/
|
|
||||||
public static final PropertyDescriptor IGNITE_CACHE_ENTRY_KEY = new PropertyDescriptor.Builder()
|
|
||||||
.displayName("Ignite Cache Entry Identifier")
|
|
||||||
.name("ignite-cache-entry-identifier")
|
|
||||||
.description("A FlowFile attribute, or attribute expression used " +
|
|
||||||
"for determining Ignite cache key for the Flow File content")
|
|
||||||
.required(true)
|
|
||||||
.addValidator(StandardValidators.createAttributeExpressionLanguageValidator(ResultType.STRING, true))
|
|
||||||
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Relations
|
|
||||||
*/
|
|
||||||
protected static Set<Relationship> relationships;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ignite cache name
|
|
||||||
*/
|
|
||||||
private String cacheName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get ignite cache instance
|
|
||||||
* @return ignite cache instance
|
|
||||||
*/
|
|
||||||
protected IgniteCache<String, byte[]> getIgniteCache() {
|
|
||||||
if ( getIgnite() == null )
|
|
||||||
return null;
|
|
||||||
else
|
|
||||||
return getIgnite().getOrCreateCache(cacheName);
|
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
|
||||||
final Set<Relationship> rels = new HashSet<>();
|
|
||||||
rels.add(REL_SUCCESS);
|
|
||||||
rels.add(REL_FAILURE);
|
|
||||||
relationships = Collections.unmodifiableSet(rels);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<Relationship> getRelationships() {
|
|
||||||
return relationships;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize the ignite cache instance
|
|
||||||
* @param context process context
|
|
||||||
* @throws ProcessException if there is a problem while scheduling the processor
|
|
||||||
*/
|
|
||||||
public void initializeIgniteCache(ProcessContext context) throws ProcessException {
|
|
||||||
|
|
||||||
getLogger().info("Initializing Ignite cache");
|
|
||||||
|
|
||||||
try {
|
|
||||||
if ( getIgnite() == null ) {
|
|
||||||
getLogger().info("Initializing ignite as client");
|
|
||||||
super.initializeIgnite(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
cacheName = context.getProperty(CACHE_NAME).getValue();
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
getLogger().error("Failed to initialize ignite cache due to {}", new Object[] { e }, e);
|
|
||||||
throw new ProcessException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Close Ignite cache instance and calls base class closeIgnite
|
|
||||||
*/
|
|
||||||
@OnShutdown
|
|
||||||
public void closeIgniteCache() {
|
|
||||||
if (getIgniteCache() != null) {
|
|
||||||
getLogger().info("Closing ignite cache");
|
|
||||||
getIgniteCache().close();
|
|
||||||
}
|
|
||||||
super.closeIgnite();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,117 +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.ignite.cache;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
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.InputRequirement.Requirement;
|
|
||||||
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.components.PropertyDescriptor;
|
|
||||||
import org.apache.nifi.flowfile.FlowFile;
|
|
||||||
import org.apache.nifi.processor.ProcessContext;
|
|
||||||
import org.apache.nifi.processor.ProcessSession;
|
|
||||||
import org.apache.nifi.processor.exception.ProcessException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get cache processors which gets byte array for the key from Ignite cache and set the array
|
|
||||||
* as the FlowFile content.
|
|
||||||
*/
|
|
||||||
@EventDriven
|
|
||||||
@SupportsBatching
|
|
||||||
@Tags({ "Ignite", "get", "read", "cache", "key" })
|
|
||||||
@SeeAlso({PutIgniteCache.class})
|
|
||||||
@InputRequirement(Requirement.INPUT_REQUIRED)
|
|
||||||
@CapabilityDescription("Get the byte array from Ignite Cache and adds it as the content of a FlowFile." +
|
|
||||||
"The processor uses the value of FlowFile attribute (Ignite cache entry key) as the cache key lookup. " +
|
|
||||||
"If the entry corresponding to the key is not found in the cache an error message is associated with the FlowFile " +
|
|
||||||
"Note - The Ignite Kernel periodically outputs node performance statistics to the logs. This message " +
|
|
||||||
" can be turned off by setting the log level for logger 'org.apache.ignite' to WARN in the logback.xml configuration file.")
|
|
||||||
@WritesAttributes({
|
|
||||||
@WritesAttribute(attribute = GetIgniteCache.IGNITE_GET_FAILED_REASON_ATTRIBUTE_KEY, description = "The reason for getting entry from cache"),
|
|
||||||
})
|
|
||||||
public class GetIgniteCache extends AbstractIgniteCacheProcessor {
|
|
||||||
|
|
||||||
/** Flow file attribute keys and messages */
|
|
||||||
public static final String IGNITE_GET_FAILED_REASON_ATTRIBUTE_KEY = "ignite.cache.get.failed.reason";
|
|
||||||
public static final String IGNITE_GET_FAILED_MISSING_KEY_MESSAGE = "The FlowFile key attribute was missing";
|
|
||||||
public static final String IGNITE_GET_FAILED_MISSING_ENTRY_MESSAGE = "The cache byte array entry was null or zero length";
|
|
||||||
public static final String IGNITE_GET_FAILED_MESSAGE_PREFIX = "The cache request failed because of ";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Property descriptors
|
|
||||||
*/
|
|
||||||
protected static final List<PropertyDescriptor> descriptors =
|
|
||||||
Arrays.asList(IGNITE_CONFIGURATION_FILE, CACHE_NAME, IGNITE_CACHE_ENTRY_KEY);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<PropertyDescriptor> getSupportedPropertyDescriptors() {
|
|
||||||
return descriptors;
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnScheduled
|
|
||||||
public final void initialize(ProcessContext context) throws ProcessException {
|
|
||||||
super.initializeIgniteCache(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle flow file and gets the entry from the cache based on the key attribute
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
|
|
||||||
FlowFile flowFile = session.get();
|
|
||||||
|
|
||||||
if (flowFile == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String key = context.getProperty(IGNITE_CACHE_ENTRY_KEY).evaluateAttributeExpressions(flowFile).getValue();
|
|
||||||
if ( StringUtils.isEmpty(key) ) {
|
|
||||||
flowFile = session.putAttribute(flowFile, IGNITE_GET_FAILED_REASON_ATTRIBUTE_KEY, IGNITE_GET_FAILED_MISSING_KEY_MESSAGE);
|
|
||||||
session.transfer(flowFile, REL_FAILURE);
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
byte [] value = getIgniteCache().get(key);
|
|
||||||
if ( value == null || value.length == 0 ) {
|
|
||||||
flowFile = session.putAttribute(flowFile, IGNITE_GET_FAILED_REASON_ATTRIBUTE_KEY,
|
|
||||||
IGNITE_GET_FAILED_MISSING_ENTRY_MESSAGE);
|
|
||||||
session.transfer(flowFile, REL_FAILURE);
|
|
||||||
} else {
|
|
||||||
ByteArrayInputStream bais = new ByteArrayInputStream(value);
|
|
||||||
flowFile = session.importFrom(bais, flowFile);
|
|
||||||
session.transfer(flowFile,REL_SUCCESS);
|
|
||||||
}
|
|
||||||
} catch(Exception exception) {
|
|
||||||
flowFile = session.putAttribute(flowFile, IGNITE_GET_FAILED_REASON_ATTRIBUTE_KEY,
|
|
||||||
IGNITE_GET_FAILED_MESSAGE_PREFIX + exception);
|
|
||||||
getLogger().error("Failed to get value for key {} from IgniteDB due to {}", new Object[] { key, exception }, exception);
|
|
||||||
session.transfer(flowFile, REL_FAILURE);
|
|
||||||
context.yield();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,390 +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.ignite.cache;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.AbstractMap;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.ignite.IgniteDataStreamer;
|
|
||||||
import org.apache.ignite.lang.IgniteFuture;
|
|
||||||
import org.apache.nifi.annotation.behavior.EventDriven;
|
|
||||||
import org.apache.nifi.annotation.behavior.SystemResourceConsideration;
|
|
||||||
import org.apache.nifi.annotation.behavior.InputRequirement;
|
|
||||||
import org.apache.nifi.annotation.behavior.InputRequirement.Requirement;
|
|
||||||
import org.apache.nifi.annotation.behavior.SupportsBatching;
|
|
||||||
import org.apache.nifi.annotation.behavior.SystemResource;
|
|
||||||
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.OnShutdown;
|
|
||||||
import org.apache.nifi.annotation.lifecycle.OnStopped;
|
|
||||||
import org.apache.nifi.components.AllowableValue;
|
|
||||||
import org.apache.nifi.components.PropertyDescriptor;
|
|
||||||
import org.apache.nifi.flowfile.FlowFile;
|
|
||||||
import org.apache.nifi.processor.ProcessContext;
|
|
||||||
import org.apache.nifi.processor.ProcessSession;
|
|
||||||
import org.apache.nifi.processor.exception.ProcessException;
|
|
||||||
import org.apache.nifi.processor.io.InputStreamCallback;
|
|
||||||
import org.apache.nifi.processor.util.StandardValidators;
|
|
||||||
import org.apache.nifi.stream.io.StreamUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Put cache processors which pushes the flow file content into Ignite Cache using
|
|
||||||
* DataStreamer interface
|
|
||||||
*/
|
|
||||||
@EventDriven
|
|
||||||
@SupportsBatching
|
|
||||||
@Tags({ "Ignite", "insert", "update", "stream", "write", "put", "cache", "key" })
|
|
||||||
@InputRequirement(Requirement.INPUT_REQUIRED)
|
|
||||||
@CapabilityDescription("Stream the contents of a FlowFile to Ignite Cache using DataStreamer. " +
|
|
||||||
"The processor uses the value of FlowFile attribute (Ignite cache entry key) as the " +
|
|
||||||
"cache key and the byte array of the FlowFile as the value of the cache entry value. Both the string key and a " +
|
|
||||||
" non-empty byte array value are required otherwise the FlowFile is transferred to the failure relation. " +
|
|
||||||
"Note - The Ignite Kernel periodically outputs node performance statistics to the logs. This message " +
|
|
||||||
" can be turned off by setting the log level for logger 'org.apache.ignite' to WARN in the logback.xml configuration file.")
|
|
||||||
@WritesAttributes({
|
|
||||||
@WritesAttribute(attribute = PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, description = "The total number of FlowFile in the batch"),
|
|
||||||
@WritesAttribute(attribute = PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, description = "The item number of FlowFile in the batch"),
|
|
||||||
@WritesAttribute(attribute = PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_ITEM_NUMBER, description = "The successful FlowFile item number"),
|
|
||||||
@WritesAttribute(attribute = PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_COUNT, description = "The number of successful FlowFiles"),
|
|
||||||
@WritesAttribute(attribute = PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_ITEM_NUMBER, description = "The failed FlowFile item number"),
|
|
||||||
@WritesAttribute(attribute = PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_COUNT, description = "The total number of failed FlowFiles in the batch"),
|
|
||||||
@WritesAttribute(attribute = PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_REASON_ATTRIBUTE_KEY, description = "The failed reason attribute key")
|
|
||||||
})
|
|
||||||
@SeeAlso({GetIgniteCache.class})
|
|
||||||
@SystemResourceConsideration(resource = SystemResource.MEMORY)
|
|
||||||
public class PutIgniteCache extends AbstractIgniteCacheProcessor {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The batch size of flow files to be processed on invocation of onTrigger
|
|
||||||
*/
|
|
||||||
public static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder()
|
|
||||||
.displayName("Batch Size For Entries")
|
|
||||||
.name("batch-size-for-entries")
|
|
||||||
.description("Batch size for entries (1-500).")
|
|
||||||
.defaultValue("250")
|
|
||||||
.required(true)
|
|
||||||
.addValidator(StandardValidators.createLongValidator(1, 500, true))
|
|
||||||
.sensitive(false)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Data streamer's per node parallelism
|
|
||||||
*/
|
|
||||||
public static final PropertyDescriptor DATA_STREAMER_PER_NODE_PARALLEL_OPERATIONS = new PropertyDescriptor.Builder()
|
|
||||||
.displayName("Data Streamer Per Node Parallel Operations")
|
|
||||||
.name("data-streamer-per-node-parallel-operations")
|
|
||||||
.description("Data streamer per node parallelism")
|
|
||||||
.defaultValue("5")
|
|
||||||
.required(true)
|
|
||||||
.addValidator(StandardValidators.createLongValidator(1, 10, true))
|
|
||||||
.sensitive(false)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Data streamers per node buffer size
|
|
||||||
*/
|
|
||||||
public static final PropertyDescriptor DATA_STREAMER_PER_NODE_BUFFER_SIZE = new PropertyDescriptor.Builder()
|
|
||||||
.displayName("Data Streamer Per Node Buffer Size")
|
|
||||||
.name("data-streamer-per-node-buffer-size")
|
|
||||||
.description("Data streamer per node buffer size (1-500).")
|
|
||||||
.defaultValue("250")
|
|
||||||
.required(true)
|
|
||||||
.addValidator(StandardValidators.createLongValidator(1, 500, true))
|
|
||||||
.sensitive(false)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Data streamers auto flush frequency
|
|
||||||
*/
|
|
||||||
public static final PropertyDescriptor DATA_STREAMER_AUTO_FLUSH_FREQUENCY = new PropertyDescriptor.Builder()
|
|
||||||
.displayName("Data Streamer Auto Flush Frequency in millis")
|
|
||||||
.name("data-streamer-auto-flush-frequency-in-millis")
|
|
||||||
.description("Data streamer flush interval in millis seconds")
|
|
||||||
.defaultValue("10")
|
|
||||||
.required(true)
|
|
||||||
.addValidator(StandardValidators.createLongValidator(1, 100, true))
|
|
||||||
.sensitive(false)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Data streamers override values property
|
|
||||||
*/
|
|
||||||
public static final PropertyDescriptor DATA_STREAMER_ALLOW_OVERRIDE = new PropertyDescriptor.Builder()
|
|
||||||
.displayName("Data Streamer Allow Override")
|
|
||||||
.name("data-streamer-allow-override")
|
|
||||||
.description("Whether to override values already in the cache")
|
|
||||||
.defaultValue("false")
|
|
||||||
.required(true)
|
|
||||||
.allowableValues(new AllowableValue("true"), new AllowableValue("false"))
|
|
||||||
.sensitive(false)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
/** Flow file attribute keys and messages */
|
|
||||||
public static final String IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT = "ignite.cache.batch.flow.file.total.count";
|
|
||||||
public static final String IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER = "ignite.cache.batch.flow.file.item.number";
|
|
||||||
public static final String IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_COUNT = "ignite.cache.batch.flow.file.successful.count";
|
|
||||||
public static final String IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_ITEM_NUMBER = "ignite.cache.batch.flow.file.successful.number";
|
|
||||||
public static final String IGNITE_BATCH_FLOW_FILE_FAILED_COUNT = "ignite.cache.batch.flow.file.failed.count";
|
|
||||||
public static final String IGNITE_BATCH_FLOW_FILE_FAILED_ITEM_NUMBER = "ignite.cache.batch.flow.file.failed.number";
|
|
||||||
public static final String IGNITE_BATCH_FLOW_FILE_FAILED_FILE_SIZE = "ignite.cache.batch.flow.file.failed.size";
|
|
||||||
public static final String IGNITE_BATCH_FLOW_FILE_FAILED_REASON_ATTRIBUTE_KEY = "ignite.cache.batch.flow.file.failed.reason";
|
|
||||||
public static final String IGNITE_BATCH_FLOW_FILE_FAILED_MISSING_KEY_MESSAGE = "The FlowFile key attribute was missing";
|
|
||||||
public static final String IGNITE_BATCH_FLOW_FILE_FAILED_ZERO_SIZE_MESSAGE = "The FlowFile size was zero";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Property descriptors
|
|
||||||
*/
|
|
||||||
protected static final List<PropertyDescriptor> descriptors =
|
|
||||||
Arrays.asList(IGNITE_CONFIGURATION_FILE,CACHE_NAME,BATCH_SIZE,
|
|
||||||
IGNITE_CACHE_ENTRY_KEY,
|
|
||||||
DATA_STREAMER_PER_NODE_PARALLEL_OPERATIONS,
|
|
||||||
DATA_STREAMER_PER_NODE_BUFFER_SIZE,
|
|
||||||
DATA_STREAMER_AUTO_FLUSH_FREQUENCY,DATA_STREAMER_ALLOW_OVERRIDE);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Data streamer instance
|
|
||||||
*/
|
|
||||||
private transient IgniteDataStreamer<String, byte[]> igniteDataStreamer;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<PropertyDescriptor> getSupportedPropertyDescriptors() {
|
|
||||||
return descriptors;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Close data streamer and calls base classes close ignite cache
|
|
||||||
*/
|
|
||||||
@OnStopped
|
|
||||||
public final void closeIgniteDataStreamer() {
|
|
||||||
if (igniteDataStreamer != null) {
|
|
||||||
getLogger().info("Closing ignite data streamer");
|
|
||||||
igniteDataStreamer.flush();
|
|
||||||
igniteDataStreamer = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnShutdown
|
|
||||||
public final void closeIgniteDataStreamerAndCache() {
|
|
||||||
closeIgniteDataStreamer();
|
|
||||||
super.closeIgniteCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get data streamer
|
|
||||||
* @return data streamer instance
|
|
||||||
*/
|
|
||||||
protected IgniteDataStreamer<String, byte[]> getIgniteDataStreamer() {
|
|
||||||
return igniteDataStreamer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize ignite cache
|
|
||||||
*/
|
|
||||||
@OnScheduled
|
|
||||||
public final void initializeIgniteDataStreamer(ProcessContext context) throws ProcessException {
|
|
||||||
super.initializeIgniteCache(context);
|
|
||||||
|
|
||||||
if ( getIgniteDataStreamer() != null ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
getLogger().info("Creating Ignite Datastreamer");
|
|
||||||
try {
|
|
||||||
int perNodeParallelOperations = context.getProperty(DATA_STREAMER_PER_NODE_PARALLEL_OPERATIONS).asInteger();
|
|
||||||
int perNodeBufferSize = context.getProperty(DATA_STREAMER_PER_NODE_BUFFER_SIZE).asInteger();
|
|
||||||
int autoFlushFrequency = context.getProperty(DATA_STREAMER_AUTO_FLUSH_FREQUENCY).asInteger();
|
|
||||||
boolean allowOverride = context.getProperty(DATA_STREAMER_ALLOW_OVERRIDE).asBoolean();
|
|
||||||
|
|
||||||
igniteDataStreamer = getIgnite().dataStreamer(getIgniteCache().getName());
|
|
||||||
igniteDataStreamer.perNodeBufferSize(perNodeBufferSize);
|
|
||||||
igniteDataStreamer.perNodeParallelOperations(perNodeParallelOperations);
|
|
||||||
igniteDataStreamer.autoFlushFrequency(autoFlushFrequency);
|
|
||||||
igniteDataStreamer.allowOverwrite(allowOverride);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
getLogger().error("Failed to schedule PutIgnite due to {}", new Object[] { e }, e);
|
|
||||||
throw new ProcessException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle flow files
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
|
|
||||||
final int batchSize = context.getProperty(BATCH_SIZE).asInteger();
|
|
||||||
final List<FlowFile> flowFiles = session.get(batchSize);
|
|
||||||
|
|
||||||
if (flowFiles.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Map.Entry<String, byte[]>> cacheItems = new ArrayList<>();
|
|
||||||
List<FlowFile> successfulFlowFiles = new ArrayList<>();
|
|
||||||
List<FlowFile> failedFlowFiles = new ArrayList<>();
|
|
||||||
try {
|
|
||||||
for (int i = 0; i < flowFiles.size(); i++) {
|
|
||||||
FlowFile flowFile = null;
|
|
||||||
try {
|
|
||||||
flowFile = flowFiles.get(i);
|
|
||||||
|
|
||||||
String key = context.getProperty(IGNITE_CACHE_ENTRY_KEY).evaluateAttributeExpressions(flowFile).getValue();
|
|
||||||
|
|
||||||
if ( isFailedFlowFile(flowFile, key) ) {
|
|
||||||
failedFlowFiles.add(flowFile);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
final byte[] byteArray = new byte[(int) flowFile.getSize()];
|
|
||||||
session.read(flowFile, new InputStreamCallback() {
|
|
||||||
@Override
|
|
||||||
public void process(final InputStream in) throws IOException {
|
|
||||||
StreamUtils.fillBuffer(in, byteArray, true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
cacheItems.add(new AbstractMap.SimpleEntry<String,byte[]>(key, byteArray));
|
|
||||||
successfulFlowFiles.add(flowFile);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
getLogger().error("Failed to insert {} into IgniteDB due to {}", new Object[] { flowFile, e }, e);
|
|
||||||
session.transfer(flowFile, REL_FAILURE);
|
|
||||||
context.yield();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (!cacheItems.isEmpty()) {
|
|
||||||
IgniteFuture<?> futures = igniteDataStreamer.addData(cacheItems);
|
|
||||||
Object result = futures.get();
|
|
||||||
getLogger().debug("Result {} of addData", new Object [] {result});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!successfulFlowFiles.isEmpty()) {
|
|
||||||
successfulFlowFiles = updateSuccessfulFlowFileAttributes(flowFiles, successfulFlowFiles, session);
|
|
||||||
session.transfer(successfulFlowFiles, REL_SUCCESS);
|
|
||||||
for (FlowFile flowFile : successfulFlowFiles) {
|
|
||||||
String key = context.getProperty(IGNITE_CACHE_ENTRY_KEY).evaluateAttributeExpressions(flowFile).getValue();
|
|
||||||
session.getProvenanceReporter().send(flowFile, "ignite://cache/" + getIgniteCache().getName() + "/" + key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!failedFlowFiles.isEmpty()) {
|
|
||||||
failedFlowFiles = updateFailedFlowFileAttributes(flowFiles, failedFlowFiles, session, context);
|
|
||||||
session.transfer(failedFlowFiles, REL_FAILURE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if flow if corrupted (either flow file is empty or does not have a key attribute)
|
|
||||||
* @param flowFile the flow file to check
|
|
||||||
* @param key the cache key
|
|
||||||
* @return <code>true</code> if flow file is incomplete
|
|
||||||
*/
|
|
||||||
private boolean isFailedFlowFile(FlowFile flowFile, String key) {
|
|
||||||
if ( StringUtils.isEmpty(key) ) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return flowFile.getSize() == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add successful flow file attributes
|
|
||||||
* @param flowFiles all flow files
|
|
||||||
* @param successfulFlowFiles list of successful flow files
|
|
||||||
* @param session process session
|
|
||||||
* @return successful flow files with updated attributes
|
|
||||||
*/
|
|
||||||
protected List<FlowFile> updateSuccessfulFlowFileAttributes(
|
|
||||||
List<FlowFile> flowFiles,
|
|
||||||
List<FlowFile> successfulFlowFiles, ProcessSession session) {
|
|
||||||
|
|
||||||
int flowFileCount = flowFiles.size();
|
|
||||||
int flowFileSuccessful = successfulFlowFiles.size();
|
|
||||||
List<FlowFile> updatedSuccessfulFlowFiles = new ArrayList<>();
|
|
||||||
|
|
||||||
for (int i = 0; i < flowFileSuccessful; i++) {
|
|
||||||
FlowFile flowFile = successfulFlowFiles.get(i);
|
|
||||||
Map<String,String> attributes = new HashMap<>();
|
|
||||||
attributes.put(IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_ITEM_NUMBER, Integer.toString(i));
|
|
||||||
attributes.put(IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, Integer.toString(flowFileCount));
|
|
||||||
attributes.put(IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, Integer.toString(flowFiles.indexOf(flowFile)));
|
|
||||||
attributes.put(IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_COUNT, Integer.toString(flowFileSuccessful));
|
|
||||||
flowFile = session.putAllAttributes(flowFile, attributes);
|
|
||||||
updatedSuccessfulFlowFiles.add(flowFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
return updatedSuccessfulFlowFiles;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add failed flow file attributes
|
|
||||||
* @param flowFiles all flow files
|
|
||||||
* @param failedFlowFiles list of failed flow files
|
|
||||||
* @param session process session
|
|
||||||
* @param context the process context
|
|
||||||
* @return failed flow files with updated attributes
|
|
||||||
*/
|
|
||||||
protected List<FlowFile> updateFailedFlowFileAttributes(
|
|
||||||
List<FlowFile> flowFiles,
|
|
||||||
List<FlowFile> failedFlowFiles, ProcessSession session, ProcessContext context) {
|
|
||||||
|
|
||||||
int flowFileCount = flowFiles.size();
|
|
||||||
int flowFileFailed = failedFlowFiles.size();
|
|
||||||
List<FlowFile> updatedFailedFlowFiles = new ArrayList<>();
|
|
||||||
|
|
||||||
for (int i = 0; i < flowFileFailed; i++) {
|
|
||||||
FlowFile flowFile = failedFlowFiles.get(i);
|
|
||||||
|
|
||||||
Map<String,String> attributes = new HashMap<>();
|
|
||||||
attributes.put(IGNITE_BATCH_FLOW_FILE_FAILED_ITEM_NUMBER, Integer.toString(i));
|
|
||||||
attributes.put(IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, Integer.toString(flowFileCount));
|
|
||||||
attributes.put(IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, Integer.toString(flowFiles.indexOf(flowFile)));
|
|
||||||
attributes.put(IGNITE_BATCH_FLOW_FILE_FAILED_COUNT, Integer.toString(flowFileFailed));
|
|
||||||
|
|
||||||
String key = context.getProperty(IGNITE_CACHE_ENTRY_KEY).evaluateAttributeExpressions(flowFile).getValue();
|
|
||||||
|
|
||||||
if (StringUtils.isEmpty(key)) {
|
|
||||||
attributes.put(IGNITE_BATCH_FLOW_FILE_FAILED_REASON_ATTRIBUTE_KEY,
|
|
||||||
IGNITE_BATCH_FLOW_FILE_FAILED_MISSING_KEY_MESSAGE);
|
|
||||||
} else if (flowFile.getSize() == 0) {
|
|
||||||
attributes.put(IGNITE_BATCH_FLOW_FILE_FAILED_REASON_ATTRIBUTE_KEY,
|
|
||||||
IGNITE_BATCH_FLOW_FILE_FAILED_ZERO_SIZE_MESSAGE);
|
|
||||||
} else {
|
|
||||||
throw new ProcessException("Unknown reason for failing file: " + flowFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
flowFile = session.putAllAttributes(flowFile, attributes);
|
|
||||||
updatedFailedFlowFiles.add(flowFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
return updatedFailedFlowFiles;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +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.ignite.cache.PutIgniteCache
|
|
||||||
org.apache.nifi.processors.ignite.cache.GetIgniteCache
|
|
|
@ -1,26 +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.
|
|
||||||
-->
|
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
|
||||||
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
|
||||||
<!-- Imports default Ignite configuration -->
|
|
||||||
<import resource="ignite-default-client.xml"/>
|
|
||||||
|
|
||||||
<bean parent="ignite.cfg"/>
|
|
||||||
</beans>
|
|
|
@ -1,45 +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.
|
|
||||||
-->
|
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns:util="http://www.springframework.org/schema/util"
|
|
||||||
xsi:schemaLocation="
|
|
||||||
http://www.springframework.org/schema/beans
|
|
||||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
|
||||||
http://www.springframework.org/schema/util
|
|
||||||
http://www.springframework.org/schema/util/spring-util.xsd">
|
|
||||||
|
|
||||||
<bean abstract="true" id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
|
|
||||||
<property name="peerClassLoadingEnabled" value="false"/>
|
|
||||||
<property name="clientMode" value="true"/>
|
|
||||||
<property name="discoverySpi">
|
|
||||||
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
|
|
||||||
<property name="ipFinder">
|
|
||||||
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
|
|
||||||
<property name="addresses">
|
|
||||||
<list>
|
|
||||||
<!-- In distributed environment, replace with actual host IP address. -->
|
|
||||||
<value>127.0.0.1:47500..47509</value>
|
|
||||||
</list>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
</beans>
|
|
|
@ -1,184 +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.ignite.cache;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.ignite.IgniteCache;
|
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
|
||||||
import org.apache.nifi.util.TestRunner;
|
|
||||||
import org.apache.nifi.util.TestRunners;
|
|
||||||
import org.junit.jupiter.api.AfterAll;
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
public class ITGetIgniteCache {
|
|
||||||
|
|
||||||
private static final String CACHE_NAME = "testCache";
|
|
||||||
private static TestRunner runner;
|
|
||||||
private static GetIgniteCache getIgniteCache;
|
|
||||||
private static Map<String,String> properties1;
|
|
||||||
private static HashMap<String, String> properties2;
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
public static void setUp() {
|
|
||||||
getIgniteCache = new GetIgniteCache();
|
|
||||||
properties1 = new HashMap<String,String>();
|
|
||||||
properties2 = new HashMap<String,String>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
public static void teardown() {
|
|
||||||
runner = null;
|
|
||||||
IgniteCache<String, byte[]> cache = getIgniteCache.getIgniteCache();
|
|
||||||
if (cache != null )
|
|
||||||
cache.destroy();
|
|
||||||
getIgniteCache = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testgetIgniteCacheOnTriggerFileConfigurationOneFlowFile() throws IOException, InterruptedException {
|
|
||||||
runner = TestRunners.newTestRunner(getIgniteCache);
|
|
||||||
runner.setProperty(GetIgniteCache.CACHE_NAME, CACHE_NAME);
|
|
||||||
runner.setProperty(GetIgniteCache.IGNITE_CONFIGURATION_FILE,
|
|
||||||
"file:///" + new File(".").getAbsolutePath() + "/src/test/resources/test-ignite.xml");
|
|
||||||
runner.setProperty(GetIgniteCache.IGNITE_CACHE_ENTRY_KEY, "${igniteKey}");
|
|
||||||
|
|
||||||
runner.assertValid();
|
|
||||||
properties1.put("igniteKey", "key5");
|
|
||||||
runner.enqueue("test5".getBytes(),properties1);
|
|
||||||
|
|
||||||
getIgniteCache.initialize(runner.getProcessContext());
|
|
||||||
|
|
||||||
getIgniteCache.getIgniteCache().put("key5", "test5".getBytes());
|
|
||||||
runner.run(1, false, true);
|
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(GetIgniteCache.REL_SUCCESS, 1);
|
|
||||||
List<MockFlowFile> sucessfulFlowFiles = runner.getFlowFilesForRelationship(GetIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(1, sucessfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> failureFlowFiles = runner.getFlowFilesForRelationship(GetIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(0, failureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile out = runner.getFlowFilesForRelationship(GetIgniteCache.REL_SUCCESS).get(0);
|
|
||||||
|
|
||||||
out.assertContentEquals("test5".getBytes());
|
|
||||||
assertArrayEquals("test5".getBytes(),(byte[])getIgniteCache.getIgniteCache().get("key5"));
|
|
||||||
runner.shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testgetIgniteCacheOnTriggerNoConfigurationTwoFlowFile() throws IOException, InterruptedException {
|
|
||||||
runner = TestRunners.newTestRunner(getIgniteCache);
|
|
||||||
runner.setProperty(GetIgniteCache.CACHE_NAME, CACHE_NAME);
|
|
||||||
runner.setProperty(GetIgniteCache.IGNITE_CACHE_ENTRY_KEY, "${igniteKey}");
|
|
||||||
|
|
||||||
runner.assertValid();
|
|
||||||
properties1.put("igniteKey", "key51");
|
|
||||||
runner.enqueue("test1".getBytes(),properties1);
|
|
||||||
properties2.put("igniteKey", "key52");
|
|
||||||
runner.enqueue("test2".getBytes(),properties2);
|
|
||||||
getIgniteCache.initialize(runner.getProcessContext());
|
|
||||||
|
|
||||||
getIgniteCache.getIgniteCache().put("key51", "test51".getBytes());
|
|
||||||
getIgniteCache.getIgniteCache().put("key52", "test52".getBytes());
|
|
||||||
runner.run(2, false, true);
|
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(GetIgniteCache.REL_SUCCESS, 2);
|
|
||||||
List<MockFlowFile> sucessfulFlowFiles = runner.getFlowFilesForRelationship(GetIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(2, sucessfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> failureFlowFiles = runner.getFlowFilesForRelationship(GetIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(0, failureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile out = runner.getFlowFilesForRelationship(GetIgniteCache.REL_SUCCESS).get(0);
|
|
||||||
|
|
||||||
out.assertContentEquals("test51".getBytes());
|
|
||||||
assertArrayEquals("test51".getBytes(),
|
|
||||||
(byte[])getIgniteCache.getIgniteCache().get("key51"));
|
|
||||||
|
|
||||||
final MockFlowFile out2 = runner.getFlowFilesForRelationship(GetIgniteCache.REL_SUCCESS).get(1);
|
|
||||||
|
|
||||||
out2.assertContentEquals("test52".getBytes());
|
|
||||||
assertArrayEquals("test52".getBytes(),
|
|
||||||
(byte[])getIgniteCache.getIgniteCache().get("key52"));
|
|
||||||
|
|
||||||
runner.shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testgetIgniteCacheOnTriggerNoConfigurationTwoFlowFileStopStart2Times() throws IOException, InterruptedException {
|
|
||||||
runner = TestRunners.newTestRunner(getIgniteCache);
|
|
||||||
runner.setProperty(GetIgniteCache.CACHE_NAME, CACHE_NAME);
|
|
||||||
runner.setProperty(GetIgniteCache.IGNITE_CACHE_ENTRY_KEY, "${igniteKey}");
|
|
||||||
|
|
||||||
runner.assertValid();
|
|
||||||
properties1.put("igniteKey", "key51");
|
|
||||||
runner.enqueue("test1".getBytes(),properties1);
|
|
||||||
properties2.put("igniteKey", "key52");
|
|
||||||
runner.enqueue("test2".getBytes(),properties2);
|
|
||||||
getIgniteCache.initialize(runner.getProcessContext());
|
|
||||||
|
|
||||||
getIgniteCache.getIgniteCache().put("key51", "test51".getBytes());
|
|
||||||
getIgniteCache.getIgniteCache().put("key52", "test52".getBytes());
|
|
||||||
runner.run(2, false, true);
|
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(GetIgniteCache.REL_SUCCESS, 2);
|
|
||||||
|
|
||||||
getIgniteCache.closeIgniteCache();
|
|
||||||
|
|
||||||
runner.clearTransferState();
|
|
||||||
|
|
||||||
// reinit and check first time
|
|
||||||
runner.assertValid();
|
|
||||||
properties1.put("igniteKey", "key51");
|
|
||||||
runner.enqueue("test1".getBytes(),properties1);
|
|
||||||
properties2.put("igniteKey", "key52");
|
|
||||||
runner.enqueue("test2".getBytes(),properties2);
|
|
||||||
getIgniteCache.initialize(runner.getProcessContext());
|
|
||||||
|
|
||||||
runner.run(2, false, true);
|
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(GetIgniteCache.REL_SUCCESS, 2);
|
|
||||||
|
|
||||||
getIgniteCache.closeIgniteCache();
|
|
||||||
|
|
||||||
runner.clearTransferState();
|
|
||||||
|
|
||||||
// reinit and check second time
|
|
||||||
runner.assertValid();
|
|
||||||
properties1.put("igniteKey", "key51");
|
|
||||||
runner.enqueue("test1".getBytes(),properties1);
|
|
||||||
properties2.put("igniteKey", "key52");
|
|
||||||
runner.enqueue("test2".getBytes(),properties2);
|
|
||||||
getIgniteCache.initialize(runner.getProcessContext());
|
|
||||||
|
|
||||||
runner.run(2, false, true);
|
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(GetIgniteCache.REL_SUCCESS, 2);
|
|
||||||
|
|
||||||
getIgniteCache.closeIgniteCache();
|
|
||||||
|
|
||||||
runner.clearTransferState();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,195 +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.ignite.cache;
|
|
||||||
|
|
||||||
import org.apache.nifi.util.MockFlowFile;
|
|
||||||
import org.apache.nifi.util.TestRunner;
|
|
||||||
import org.apache.nifi.util.TestRunners;
|
|
||||||
import org.junit.jupiter.api.AfterAll;
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
|
|
||||||
public class ITPutIgniteCache {
|
|
||||||
|
|
||||||
private static final String CACHE_NAME = "testCache";
|
|
||||||
private static TestRunner runner;
|
|
||||||
private static PutIgniteCache putIgniteCache;
|
|
||||||
private static Map<String,String> properties1;
|
|
||||||
private static HashMap<String, String> properties2;
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
public static void setUp() {
|
|
||||||
putIgniteCache = new PutIgniteCache();
|
|
||||||
properties1 = new HashMap<String,String>();
|
|
||||||
properties2 = new HashMap<String,String>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
public static void teardown() {
|
|
||||||
runner = null;
|
|
||||||
putIgniteCache.getIgniteCache().destroy();
|
|
||||||
putIgniteCache = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPutIgniteCacheOnTriggerFileConfigurationOneFlowFile() throws IOException, InterruptedException {
|
|
||||||
runner = TestRunners.newTestRunner(putIgniteCache);
|
|
||||||
runner.setProperty(PutIgniteCache.BATCH_SIZE, "5");
|
|
||||||
runner.setProperty(PutIgniteCache.CACHE_NAME, CACHE_NAME);
|
|
||||||
runner.setProperty(PutIgniteCache.IGNITE_CONFIGURATION_FILE,
|
|
||||||
"file:///" + new File(".").getAbsolutePath() + "/src/test/resources/test-ignite.xml");
|
|
||||||
runner.setProperty(PutIgniteCache.DATA_STREAMER_PER_NODE_BUFFER_SIZE, "1");
|
|
||||||
runner.setProperty(PutIgniteCache.IGNITE_CACHE_ENTRY_KEY, "${igniteKey}");
|
|
||||||
|
|
||||||
runner.assertValid();
|
|
||||||
properties1.put("igniteKey", "key5");
|
|
||||||
runner.enqueue("test".getBytes(),properties1);
|
|
||||||
runner.run(1, false, true);
|
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(PutIgniteCache.REL_SUCCESS, 1);
|
|
||||||
List<MockFlowFile> sucessfulFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(1, sucessfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> failureFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(0, failureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile out = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS).get(0);
|
|
||||||
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_ITEM_NUMBER, "0");
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, "1");
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_COUNT, "1");
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, "0");
|
|
||||||
|
|
||||||
out.assertContentEquals("test".getBytes());
|
|
||||||
System.out.println("Value was: " + new String((byte[])putIgniteCache.getIgniteCache().get("key5")));
|
|
||||||
assertArrayEquals("test".getBytes(),(byte[])putIgniteCache.getIgniteCache().get("key5"));
|
|
||||||
putIgniteCache.getIgniteCache().remove("key5");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPutIgniteCacheOnTriggerNoConfigurationTwoFlowFile() throws IOException, InterruptedException {
|
|
||||||
runner = TestRunners.newTestRunner(putIgniteCache);
|
|
||||||
runner.setProperty(PutIgniteCache.BATCH_SIZE, "5");
|
|
||||||
runner.setProperty(PutIgniteCache.CACHE_NAME, CACHE_NAME);
|
|
||||||
runner.setProperty(PutIgniteCache.DATA_STREAMER_PER_NODE_BUFFER_SIZE, "1");
|
|
||||||
runner.setProperty(PutIgniteCache.IGNITE_CACHE_ENTRY_KEY, "${igniteKey}");
|
|
||||||
|
|
||||||
runner.assertValid();
|
|
||||||
properties1.put("igniteKey", "key51");
|
|
||||||
runner.enqueue("test1".getBytes(),properties1);
|
|
||||||
properties2.put("igniteKey", "key52");
|
|
||||||
runner.enqueue("test2".getBytes(),properties2);
|
|
||||||
runner.run(1, false, true);
|
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(PutIgniteCache.REL_SUCCESS, 2);
|
|
||||||
List<MockFlowFile> sucessfulFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(2, sucessfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> failureFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(0, failureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile out = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS).get(0);
|
|
||||||
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_ITEM_NUMBER, "0");
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, "2");
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_COUNT, "2");
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, "0");
|
|
||||||
|
|
||||||
out.assertContentEquals("test1".getBytes());
|
|
||||||
System.out.println("value was " + new String(putIgniteCache.getIgniteCache().get("key51")));
|
|
||||||
assertArrayEquals("test1".getBytes(),(byte[])putIgniteCache.getIgniteCache().get("key51"));
|
|
||||||
|
|
||||||
final MockFlowFile out2 = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS).get(1);
|
|
||||||
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_ITEM_NUMBER, "1");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, "2");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_COUNT, "2");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, "1");
|
|
||||||
|
|
||||||
out2.assertContentEquals("test2".getBytes());
|
|
||||||
assertArrayEquals("test2".getBytes(),(byte[])putIgniteCache.getIgniteCache().get("key52"));
|
|
||||||
putIgniteCache.getIgniteCache().remove("key52");
|
|
||||||
putIgniteCache.getIgniteCache().remove("key51");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPutIgniteCacheOnTriggerNoConfigurationTwoFlowFileStopAndStart2Times() throws IOException, InterruptedException {
|
|
||||||
runner = TestRunners.newTestRunner(putIgniteCache);
|
|
||||||
runner.setProperty(PutIgniteCache.BATCH_SIZE, "5");
|
|
||||||
runner.setProperty(PutIgniteCache.CACHE_NAME, CACHE_NAME);
|
|
||||||
runner.setProperty(PutIgniteCache.DATA_STREAMER_PER_NODE_BUFFER_SIZE, "1");
|
|
||||||
runner.setProperty(PutIgniteCache.IGNITE_CACHE_ENTRY_KEY, "${igniteKey}");
|
|
||||||
|
|
||||||
runner.assertValid();
|
|
||||||
properties1.put("igniteKey", "key51");
|
|
||||||
runner.enqueue("test1".getBytes(),properties1);
|
|
||||||
properties2.put("igniteKey", "key52");
|
|
||||||
runner.enqueue("test2".getBytes(),properties2);
|
|
||||||
runner.run(1, false, true);
|
|
||||||
putIgniteCache.getIgniteCache().remove("key51");
|
|
||||||
putIgniteCache.getIgniteCache().remove("key52");
|
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(PutIgniteCache.REL_SUCCESS, 2);
|
|
||||||
putIgniteCache.getIgniteCache().remove("key52");
|
|
||||||
putIgniteCache.getIgniteCache().remove("key52");
|
|
||||||
|
|
||||||
// Close and restart first time
|
|
||||||
putIgniteCache.closeIgniteDataStreamer();
|
|
||||||
|
|
||||||
runner.clearTransferState();
|
|
||||||
|
|
||||||
putIgniteCache.initializeIgniteDataStreamer(runner.getProcessContext());
|
|
||||||
|
|
||||||
runner.assertValid();
|
|
||||||
properties1.put("igniteKey", "key51");
|
|
||||||
runner.enqueue("test1".getBytes(),properties1);
|
|
||||||
properties2.put("igniteKey", "key52");
|
|
||||||
runner.enqueue("test2".getBytes(),properties2);
|
|
||||||
runner.run(1, false, true);
|
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(PutIgniteCache.REL_SUCCESS, 2);
|
|
||||||
putIgniteCache.getIgniteCache().remove("key51");
|
|
||||||
putIgniteCache.getIgniteCache().remove("key52");
|
|
||||||
|
|
||||||
// Close and restart second time
|
|
||||||
putIgniteCache.closeIgniteDataStreamer();
|
|
||||||
|
|
||||||
runner.clearTransferState();
|
|
||||||
|
|
||||||
putIgniteCache.initializeIgniteDataStreamer(runner.getProcessContext());
|
|
||||||
|
|
||||||
runner.assertValid();
|
|
||||||
properties1.put("igniteKey", "key51");
|
|
||||||
runner.enqueue("test1".getBytes(),properties1);
|
|
||||||
properties2.put("igniteKey", "key52");
|
|
||||||
runner.enqueue("test2".getBytes(),properties2);
|
|
||||||
runner.run(1, false, true);
|
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(PutIgniteCache.REL_SUCCESS, 2);
|
|
||||||
putIgniteCache.getIgniteCache().remove("key52");
|
|
||||||
putIgniteCache.getIgniteCache().remove("key51");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,379 +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.ignite.cache;
|
|
||||||
|
|
||||||
import org.apache.ignite.Ignite;
|
|
||||||
import org.apache.ignite.IgniteCache;
|
|
||||||
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 org.mockito.ArgumentMatchers;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
import static org.mockito.AdditionalMatchers.or;
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
|
||||||
import static org.mockito.ArgumentMatchers.isNull;
|
|
||||||
import static org.mockito.Mockito.doAnswer;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
public class TestGetIgniteCache {
|
|
||||||
|
|
||||||
private static final String CACHE_NAME = "testCache";
|
|
||||||
private TestRunner getRunner;
|
|
||||||
private GetIgniteCache getIgniteCache;
|
|
||||||
private Map<String,String> properties1;
|
|
||||||
private Map<String,String> properties2;
|
|
||||||
private Ignite ignite;
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
public void setUp() {
|
|
||||||
ignite = mock(Ignite.class);
|
|
||||||
final IgniteCache igniteCache = mockIgniteCache();
|
|
||||||
when(ignite.getOrCreateCache(or(ArgumentMatchers.eq(CACHE_NAME), isNull()))).thenReturn(igniteCache);
|
|
||||||
getIgniteCache = new GetIgniteCache() {
|
|
||||||
@Override
|
|
||||||
protected Ignite getIgnite() {
|
|
||||||
return ignite;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
properties1 = new HashMap<String,String>();
|
|
||||||
properties1.put("igniteKey", "key1");
|
|
||||||
properties2 = new HashMap<String,String>();
|
|
||||||
properties2.put("igniteKey", "key2");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
public void teardown() {
|
|
||||||
getRunner = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
static IgniteCache<Object, Object> mockIgniteCache() {
|
|
||||||
final IgniteCache<Object, Object> igniteCache = mock(IgniteCache.class);
|
|
||||||
final Map<Object, Object> map = new HashMap<>();
|
|
||||||
doAnswer(args -> map.put(args.getArgument(0), args.getArgument(1))).when(igniteCache).put(any(), any());
|
|
||||||
when(igniteCache.get(any())).thenAnswer(args -> map.get(args.getArgument(0)));
|
|
||||||
when(igniteCache.containsKey(anyString())).thenAnswer(args -> map.containsKey(args.getArgument(0)));
|
|
||||||
|
|
||||||
return igniteCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetIgniteCacheDefaultConfOneFlowFileWithPlainKey() throws IOException {
|
|
||||||
getRunner = TestRunners.newTestRunner(getIgniteCache);
|
|
||||||
getRunner.setProperty(GetIgniteCache.IGNITE_CACHE_ENTRY_KEY, "mykey");
|
|
||||||
|
|
||||||
getRunner.assertValid();
|
|
||||||
getRunner.enqueue(new byte[] {});
|
|
||||||
|
|
||||||
getIgniteCache.initialize(getRunner.getProcessContext());
|
|
||||||
|
|
||||||
getIgniteCache.getIgniteCache().put("mykey", "test".getBytes());
|
|
||||||
|
|
||||||
getRunner.run(1, false, true);
|
|
||||||
|
|
||||||
getRunner.assertAllFlowFilesTransferred(GetIgniteCache.REL_SUCCESS, 1);
|
|
||||||
List<MockFlowFile> getSucessfulFlowFiles = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(1, getSucessfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> getFailureFlowFiles = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(0, getFailureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile getOut = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_SUCCESS).get(0);
|
|
||||||
getOut.assertContentEquals("test".getBytes());
|
|
||||||
|
|
||||||
getRunner.shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetIgniteCacheNullGetCacheThrowsException() throws IOException, InterruptedException {
|
|
||||||
|
|
||||||
getIgniteCache = new GetIgniteCache() {
|
|
||||||
@Override
|
|
||||||
protected Ignite getIgnite() {
|
|
||||||
return ignite;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected IgniteCache<String, byte[]> getIgniteCache() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
getRunner = TestRunners.newTestRunner(getIgniteCache);
|
|
||||||
getRunner.setProperty(GetIgniteCache.IGNITE_CACHE_ENTRY_KEY, "mykey");
|
|
||||||
|
|
||||||
getRunner.assertValid();
|
|
||||||
getRunner.enqueue(new byte[] {});
|
|
||||||
|
|
||||||
getIgniteCache.initialize(getRunner.getProcessContext());
|
|
||||||
|
|
||||||
getRunner.run(1, false, true);
|
|
||||||
|
|
||||||
getRunner.assertAllFlowFilesTransferred(GetIgniteCache.REL_FAILURE, 1);
|
|
||||||
List<MockFlowFile> getSucessfulFlowFiles = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(0, getSucessfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> getFailureFlowFiles = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(1, getFailureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile failureFlowFile = getFailureFlowFiles.get(0);
|
|
||||||
failureFlowFile.assertAttributeExists(GetIgniteCache.IGNITE_GET_FAILED_REASON_ATTRIBUTE_KEY);
|
|
||||||
|
|
||||||
getRunner.shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetIgniteCacheDefaultConfOneFlowFileWithKeyExpression() throws IOException, InterruptedException {
|
|
||||||
getRunner = TestRunners.newTestRunner(getIgniteCache);
|
|
||||||
getRunner.setProperty(GetIgniteCache.CACHE_NAME, CACHE_NAME);
|
|
||||||
getRunner.setProperty(GetIgniteCache.IGNITE_CACHE_ENTRY_KEY, "${igniteKey}");
|
|
||||||
|
|
||||||
getRunner.assertValid();
|
|
||||||
getRunner.enqueue("".getBytes(),properties1);
|
|
||||||
|
|
||||||
getIgniteCache.initialize(getRunner.getProcessContext());
|
|
||||||
|
|
||||||
getIgniteCache.getIgniteCache().put("key1", "test".getBytes());
|
|
||||||
|
|
||||||
getRunner.run(1, false, true);
|
|
||||||
|
|
||||||
getRunner.assertAllFlowFilesTransferred(GetIgniteCache.REL_SUCCESS, 1);
|
|
||||||
List<MockFlowFile> sucessfulFlowFiles = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(1, sucessfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> failureFlowFiles = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(0, failureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile out = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_SUCCESS).get(0);
|
|
||||||
|
|
||||||
out.assertContentEquals("test".getBytes());
|
|
||||||
getRunner.shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetIgniteCacheDefaultConfTwoFlowFilesWithExpressionKeys() throws IOException, InterruptedException {
|
|
||||||
getRunner = TestRunners.newTestRunner(getIgniteCache);
|
|
||||||
getRunner.setProperty(GetIgniteCache.CACHE_NAME, CACHE_NAME);
|
|
||||||
getRunner.setProperty(GetIgniteCache.IGNITE_CACHE_ENTRY_KEY, "${igniteKey}");
|
|
||||||
|
|
||||||
getRunner.assertValid();
|
|
||||||
getRunner.enqueue("".getBytes(),properties1);
|
|
||||||
getRunner.enqueue("".getBytes(),properties2);
|
|
||||||
|
|
||||||
getIgniteCache.initialize(getRunner.getProcessContext());
|
|
||||||
|
|
||||||
getIgniteCache.getIgniteCache().put("key1", "test1".getBytes());
|
|
||||||
getIgniteCache.getIgniteCache().put("key2", "test2".getBytes());
|
|
||||||
|
|
||||||
getRunner.run(2, false, true);
|
|
||||||
|
|
||||||
getRunner.assertAllFlowFilesTransferred(GetIgniteCache.REL_SUCCESS, 2);
|
|
||||||
|
|
||||||
List<MockFlowFile> sucessfulFlowFiles = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(2, sucessfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> failureFlowFiles = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(0, failureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile out1 = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_SUCCESS).get(0);
|
|
||||||
|
|
||||||
out1.assertContentEquals("test1".getBytes());
|
|
||||||
assertEquals("test1",new String(getIgniteCache.getIgniteCache().get("key1")));
|
|
||||||
|
|
||||||
final MockFlowFile out2 = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_SUCCESS).get(1);
|
|
||||||
|
|
||||||
out2.assertContentEquals("test2".getBytes());
|
|
||||||
|
|
||||||
assertArrayEquals("test2".getBytes(),(byte[])getIgniteCache.getIgniteCache().get("key2"));
|
|
||||||
|
|
||||||
getRunner.shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetIgniteCacheDefaultConfOneFlowFileNoKey() throws IOException, InterruptedException {
|
|
||||||
getRunner = TestRunners.newTestRunner(getIgniteCache);
|
|
||||||
getRunner.setProperty(GetIgniteCache.IGNITE_CACHE_ENTRY_KEY, "${igniteKey}");
|
|
||||||
|
|
||||||
getRunner.assertValid();
|
|
||||||
properties1.clear();
|
|
||||||
getRunner.enqueue("".getBytes(),properties1);
|
|
||||||
getIgniteCache.initialize(getRunner.getProcessContext());
|
|
||||||
|
|
||||||
getRunner.run(1, false, true);
|
|
||||||
|
|
||||||
getRunner.assertAllFlowFilesTransferred(GetIgniteCache.REL_FAILURE, 1);
|
|
||||||
List<MockFlowFile> sucessfulFlowFiles = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(0, sucessfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> failureFlowFiles = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(1, failureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile out = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_FAILURE).get(0);
|
|
||||||
|
|
||||||
out.assertAttributeEquals(GetIgniteCache.IGNITE_GET_FAILED_REASON_ATTRIBUTE_KEY, GetIgniteCache.IGNITE_GET_FAILED_MISSING_KEY_MESSAGE);
|
|
||||||
|
|
||||||
getRunner.shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetIgniteCacheDefaultConfTwoFlowFilesNoKey() throws IOException, InterruptedException {
|
|
||||||
getRunner = TestRunners.newTestRunner(getIgniteCache);
|
|
||||||
getRunner.setProperty(GetIgniteCache.IGNITE_CACHE_ENTRY_KEY, "${igniteKey}");
|
|
||||||
|
|
||||||
getRunner.assertValid();
|
|
||||||
|
|
||||||
properties1.clear();
|
|
||||||
getRunner.enqueue("".getBytes(),properties1);
|
|
||||||
getRunner.enqueue("".getBytes(),properties1);
|
|
||||||
|
|
||||||
getIgniteCache.initialize(getRunner.getProcessContext());
|
|
||||||
|
|
||||||
getRunner.run(2, false, true);
|
|
||||||
|
|
||||||
getRunner.assertAllFlowFilesTransferred(GetIgniteCache.REL_FAILURE, 2);
|
|
||||||
List<MockFlowFile> sucessfulFlowFiles = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(0, sucessfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> failureFlowFiles = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(2, failureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile out1 = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_FAILURE).get(0);
|
|
||||||
out1.assertAttributeEquals(GetIgniteCache.IGNITE_GET_FAILED_REASON_ATTRIBUTE_KEY, GetIgniteCache.IGNITE_GET_FAILED_MISSING_KEY_MESSAGE);
|
|
||||||
final MockFlowFile out2 = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_FAILURE).get(1);
|
|
||||||
out2.assertAttributeEquals(GetIgniteCache.IGNITE_GET_FAILED_REASON_ATTRIBUTE_KEY, GetIgniteCache.IGNITE_GET_FAILED_MISSING_KEY_MESSAGE);
|
|
||||||
|
|
||||||
getRunner.shutdown();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetIgniteCacheDefaultConfTwoFlowFileFirstNoKey() throws IOException, InterruptedException {
|
|
||||||
getRunner = TestRunners.newTestRunner(getIgniteCache);
|
|
||||||
getRunner.setProperty(GetIgniteCache.CACHE_NAME, CACHE_NAME);
|
|
||||||
getRunner.setProperty(GetIgniteCache.IGNITE_CACHE_ENTRY_KEY, "${igniteKey}");
|
|
||||||
|
|
||||||
getRunner.assertValid();
|
|
||||||
getRunner.enqueue("".getBytes());
|
|
||||||
getRunner.enqueue("".getBytes(),properties2);
|
|
||||||
getIgniteCache.initialize(getRunner.getProcessContext());
|
|
||||||
getIgniteCache.getIgniteCache().put("key2", "test2".getBytes());
|
|
||||||
|
|
||||||
getRunner.run(2, false, true);
|
|
||||||
|
|
||||||
List<MockFlowFile> sucessfulFlowFiles = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(1, sucessfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> failureFlowFiles = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(1, failureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile out1 = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_FAILURE).get(0);
|
|
||||||
|
|
||||||
out1.assertContentEquals("".getBytes());
|
|
||||||
out1.assertAttributeEquals(GetIgniteCache.IGNITE_GET_FAILED_REASON_ATTRIBUTE_KEY, GetIgniteCache.IGNITE_GET_FAILED_MISSING_KEY_MESSAGE);
|
|
||||||
|
|
||||||
final MockFlowFile out2 = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_SUCCESS).get(0);
|
|
||||||
|
|
||||||
out2.assertContentEquals("test2".getBytes());
|
|
||||||
assertArrayEquals("test2".getBytes(),(byte[])getIgniteCache.getIgniteCache().get("key2"));
|
|
||||||
|
|
||||||
getRunner.shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetIgniteCacheDefaultConfTwoFlowFileSecondNoKey() throws IOException {
|
|
||||||
getRunner = TestRunners.newTestRunner(getIgniteCache);
|
|
||||||
getRunner.setProperty(GetIgniteCache.CACHE_NAME, CACHE_NAME);
|
|
||||||
getRunner.setProperty(GetIgniteCache.IGNITE_CACHE_ENTRY_KEY, "${igniteKey}");
|
|
||||||
|
|
||||||
getRunner.assertValid();
|
|
||||||
getRunner.enqueue("".getBytes(),properties1);
|
|
||||||
getRunner.enqueue("".getBytes());
|
|
||||||
getIgniteCache.initialize(getRunner.getProcessContext());
|
|
||||||
|
|
||||||
getIgniteCache.getIgniteCache().put("key1", "test1".getBytes());
|
|
||||||
getRunner.run(2, false, true);
|
|
||||||
|
|
||||||
List<MockFlowFile> sucessfulFlowFiles = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(1, sucessfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> failureFlowFiles = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(1, failureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile out1 = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_FAILURE).get(0);
|
|
||||||
|
|
||||||
out1.assertContentEquals("".getBytes());
|
|
||||||
out1.assertAttributeEquals(GetIgniteCache.IGNITE_GET_FAILED_REASON_ATTRIBUTE_KEY, GetIgniteCache.IGNITE_GET_FAILED_MISSING_KEY_MESSAGE);
|
|
||||||
|
|
||||||
final MockFlowFile out2 = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_SUCCESS).get(0);
|
|
||||||
|
|
||||||
out2.assertContentEquals("test1".getBytes());
|
|
||||||
assertArrayEquals("test1".getBytes(),(byte[])getIgniteCache.getIgniteCache().get("key1"));
|
|
||||||
|
|
||||||
getRunner.shutdown();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetIgniteCacheDefaultConfThreeFlowFilesOneOkSecondOkThirdNoExpressionKey() throws IOException, InterruptedException {
|
|
||||||
getRunner = TestRunners.newTestRunner(getIgniteCache);
|
|
||||||
getRunner.setProperty(GetIgniteCache.CACHE_NAME, CACHE_NAME);
|
|
||||||
getRunner.setProperty(GetIgniteCache.IGNITE_CACHE_ENTRY_KEY, "${igniteKey}");
|
|
||||||
|
|
||||||
getRunner.assertValid();
|
|
||||||
getRunner.enqueue("".getBytes(),properties1);
|
|
||||||
getRunner.enqueue("".getBytes(),properties2);
|
|
||||||
getRunner.enqueue("".getBytes());
|
|
||||||
getIgniteCache.initialize(getRunner.getProcessContext());
|
|
||||||
|
|
||||||
getIgniteCache.getIgniteCache().put("key1", "test1".getBytes());
|
|
||||||
getIgniteCache.getIgniteCache().put("key2", "test2".getBytes());
|
|
||||||
getRunner.run(3, false, true);
|
|
||||||
|
|
||||||
List<MockFlowFile> sucessfulFlowFiles = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(2, sucessfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> failureFlowFiles = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(1, failureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile out1 = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_FAILURE).get(0);
|
|
||||||
|
|
||||||
out1.assertContentEquals("".getBytes());
|
|
||||||
out1.assertAttributeEquals(GetIgniteCache.IGNITE_GET_FAILED_REASON_ATTRIBUTE_KEY, GetIgniteCache.IGNITE_GET_FAILED_MISSING_KEY_MESSAGE);
|
|
||||||
|
|
||||||
final MockFlowFile out2 = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_SUCCESS).get(0);
|
|
||||||
|
|
||||||
out2.assertContentEquals("test1".getBytes());
|
|
||||||
assertArrayEquals("test1".getBytes(),(byte[])getIgniteCache.getIgniteCache().get("key1"));
|
|
||||||
|
|
||||||
final MockFlowFile out3 = getRunner.getFlowFilesForRelationship(GetIgniteCache.REL_SUCCESS).get(1);
|
|
||||||
|
|
||||||
out3.assertContentEquals("test2".getBytes());
|
|
||||||
assertArrayEquals("test2".getBytes(),(byte[])getIgniteCache.getIgniteCache().get("key2"));
|
|
||||||
|
|
||||||
getRunner.shutdown();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,591 +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.ignite.cache;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.mutable.MutableBoolean;
|
|
||||||
import org.apache.ignite.Ignite;
|
|
||||||
import org.apache.ignite.IgniteCache;
|
|
||||||
import org.apache.ignite.IgniteDataStreamer;
|
|
||||||
import org.apache.ignite.lang.IgniteFuture;
|
|
||||||
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 org.mockito.ArgumentMatchers;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.AbstractMap;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
|
||||||
import static org.mockito.AdditionalMatchers.or;
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
|
||||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
|
||||||
import static org.mockito.ArgumentMatchers.isNull;
|
|
||||||
import static org.mockito.Mockito.doAnswer;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
public class TestPutIgniteCache {
|
|
||||||
|
|
||||||
private static final String CACHE_NAME = "testCache";
|
|
||||||
private TestRunner runner;
|
|
||||||
private PutIgniteCache putIgniteCache;
|
|
||||||
private Map<String,String> properties1;
|
|
||||||
private Map<String,String> properties2;
|
|
||||||
private Ignite ignite;
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
public void setUp() {
|
|
||||||
ignite = mock(Ignite.class);
|
|
||||||
final IgniteCache igniteCache = TestGetIgniteCache.mockIgniteCache();
|
|
||||||
when(igniteCache.getName()).thenReturn(CACHE_NAME);
|
|
||||||
when(ignite.getOrCreateCache(or(ArgumentMatchers.eq(CACHE_NAME), isNull()))).thenReturn(igniteCache);
|
|
||||||
final IgniteDataStreamer dataStreamer = mock(IgniteDataStreamer.class);
|
|
||||||
final IgniteFuture igniteFuture = mock(IgniteFuture.class);
|
|
||||||
when(igniteFuture.get()).thenReturn(new Object());
|
|
||||||
|
|
||||||
final MutableBoolean allowOverride = new MutableBoolean(false);
|
|
||||||
doAnswer(args -> {
|
|
||||||
allowOverride.setValue((boolean) args.getArgument(0));
|
|
||||||
return null;
|
|
||||||
}).when(dataStreamer).allowOverwrite(anyBoolean());
|
|
||||||
|
|
||||||
when(dataStreamer.addData(any(Collection.class))).thenAnswer(args -> {
|
|
||||||
((Collection)args.getArgument(0)).forEach(entry -> {
|
|
||||||
final AbstractMap.SimpleEntry simpleEntry = (AbstractMap.SimpleEntry) entry;
|
|
||||||
if (allowOverride.booleanValue() || !igniteCache.containsKey(simpleEntry.getKey())) {
|
|
||||||
igniteCache.put(simpleEntry.getKey(), simpleEntry.getValue());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return igniteFuture;
|
|
||||||
});
|
|
||||||
when(ignite.dataStreamer(CACHE_NAME)).thenReturn(dataStreamer);
|
|
||||||
putIgniteCache = new PutIgniteCache() {
|
|
||||||
@Override
|
|
||||||
protected Ignite getIgnite() {
|
|
||||||
return ignite;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
properties1 = new HashMap<String,String>();
|
|
||||||
properties1.put("igniteKey", "key1");
|
|
||||||
properties2 = new HashMap<String,String>();
|
|
||||||
properties2.put("igniteKey", "key2");
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
public void teardown() {
|
|
||||||
runner = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPutIgniteCacheOnTriggerDefaultConfigurationOneFlowFileWithPlainKey() throws IOException {
|
|
||||||
runner = TestRunners.newTestRunner(putIgniteCache);
|
|
||||||
runner.setProperty(PutIgniteCache.BATCH_SIZE, "5");
|
|
||||||
runner.setProperty(PutIgniteCache.CACHE_NAME, CACHE_NAME);
|
|
||||||
runner.setProperty(PutIgniteCache.DATA_STREAMER_PER_NODE_BUFFER_SIZE, "1");
|
|
||||||
runner.setProperty(PutIgniteCache.IGNITE_CACHE_ENTRY_KEY, "mykey");
|
|
||||||
|
|
||||||
runner.assertValid();
|
|
||||||
runner.enqueue("test".getBytes(),properties1);
|
|
||||||
runner.run(1, false, true);
|
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(PutIgniteCache.REL_SUCCESS, 1);
|
|
||||||
List<MockFlowFile> successfulFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(1, successfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> failureFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(0, failureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile out = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS).get(0);
|
|
||||||
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_ITEM_NUMBER, "0");
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, "1");
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_COUNT, "1");
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, "0");
|
|
||||||
|
|
||||||
out.assertContentEquals("test".getBytes());
|
|
||||||
assertArrayEquals("test".getBytes(),(byte[])putIgniteCache.getIgniteCache().get("mykey"));
|
|
||||||
runner.shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPutIgniteCacheOnTriggerDefaultConfigurationOneFlowFile() throws IOException {
|
|
||||||
runner = TestRunners.newTestRunner(putIgniteCache);
|
|
||||||
runner.setProperty(PutIgniteCache.BATCH_SIZE, "5");
|
|
||||||
runner.setProperty(PutIgniteCache.CACHE_NAME, CACHE_NAME);
|
|
||||||
runner.setProperty(PutIgniteCache.DATA_STREAMER_PER_NODE_BUFFER_SIZE, "1");
|
|
||||||
runner.setProperty(PutIgniteCache.IGNITE_CACHE_ENTRY_KEY, "${igniteKey}");
|
|
||||||
|
|
||||||
runner.assertValid();
|
|
||||||
runner.enqueue("test".getBytes(),properties1);
|
|
||||||
runner.run(1, false, true);
|
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(PutIgniteCache.REL_SUCCESS, 1);
|
|
||||||
List<MockFlowFile> successfulFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(1, successfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> failureFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(0, failureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile out = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS).get(0);
|
|
||||||
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_ITEM_NUMBER, "0");
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, "1");
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_COUNT, "1");
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, "0");
|
|
||||||
|
|
||||||
out.assertContentEquals("test".getBytes());
|
|
||||||
assertArrayEquals("test".getBytes(),(byte[])putIgniteCache.getIgniteCache().get("key1"));
|
|
||||||
runner.shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPutIgniteCacheOnTriggerDefaultConfigurationTwoFlowFilesAllowOverrideDefaultFalse() throws IOException {
|
|
||||||
runner = TestRunners.newTestRunner(putIgniteCache);
|
|
||||||
runner.setProperty(PutIgniteCache.BATCH_SIZE, "5");
|
|
||||||
runner.setProperty(PutIgniteCache.CACHE_NAME, CACHE_NAME);
|
|
||||||
runner.setProperty(PutIgniteCache.DATA_STREAMER_PER_NODE_BUFFER_SIZE, "1");
|
|
||||||
runner.setProperty(PutIgniteCache.IGNITE_CACHE_ENTRY_KEY, "${igniteKey}");
|
|
||||||
|
|
||||||
runner.assertValid();
|
|
||||||
runner.enqueue("test1".getBytes(),properties1);
|
|
||||||
runner.enqueue("test2".getBytes(),properties1);
|
|
||||||
runner.run(1, false, true);
|
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(PutIgniteCache.REL_SUCCESS, 2);
|
|
||||||
|
|
||||||
List<MockFlowFile> successfulFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(2, successfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> failureFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(0, failureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile out1 = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS).get(0);
|
|
||||||
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_ITEM_NUMBER, "0");
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, "2");
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_COUNT, "2");
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, "0");
|
|
||||||
|
|
||||||
out1.assertContentEquals("test1".getBytes());
|
|
||||||
assertEquals("test1",new String(putIgniteCache.getIgniteCache().get("key1")));
|
|
||||||
|
|
||||||
final MockFlowFile out2 = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS).get(1);
|
|
||||||
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_ITEM_NUMBER, "1");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, "2");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, "1");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_COUNT, "2");
|
|
||||||
|
|
||||||
out2.assertContentEquals("test2".getBytes());
|
|
||||||
assertArrayEquals("test1".getBytes(),(byte[])putIgniteCache.getIgniteCache().get("key1"));
|
|
||||||
|
|
||||||
runner.shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPutIgniteCacheOnTriggerDefaultConfigurationTwoFlowFilesAllowOverrideTrue() throws IOException {
|
|
||||||
runner = TestRunners.newTestRunner(putIgniteCache);
|
|
||||||
runner.setProperty(PutIgniteCache.BATCH_SIZE, "5");
|
|
||||||
runner.setProperty(PutIgniteCache.CACHE_NAME, CACHE_NAME);
|
|
||||||
runner.setProperty(PutIgniteCache.DATA_STREAMER_PER_NODE_BUFFER_SIZE, "1");
|
|
||||||
runner.setProperty(PutIgniteCache.DATA_STREAMER_ALLOW_OVERRIDE, "true");
|
|
||||||
runner.setProperty(PutIgniteCache.IGNITE_CACHE_ENTRY_KEY, "${igniteKey}");
|
|
||||||
|
|
||||||
runner.assertValid();
|
|
||||||
runner.enqueue("test1".getBytes(),properties1);
|
|
||||||
runner.enqueue("test2".getBytes(),properties1);
|
|
||||||
runner.run(1, false, true);
|
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(PutIgniteCache.REL_SUCCESS, 2);
|
|
||||||
|
|
||||||
List<MockFlowFile> successfulFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(2, successfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> failureFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(0, failureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile out1 = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS).get(0);
|
|
||||||
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_ITEM_NUMBER, "0");
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, "2");
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_COUNT, "2");
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, "0");
|
|
||||||
|
|
||||||
out1.assertContentEquals("test1".getBytes());
|
|
||||||
assertEquals("test2",new String(putIgniteCache.getIgniteCache().get("key1")));
|
|
||||||
|
|
||||||
final MockFlowFile out2 = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS).get(1);
|
|
||||||
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_ITEM_NUMBER, "1");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, "2");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, "1");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_COUNT, "2");
|
|
||||||
|
|
||||||
out2.assertContentEquals("test2".getBytes());
|
|
||||||
|
|
||||||
assertArrayEquals("test2".getBytes(),(byte[])putIgniteCache.getIgniteCache().get("key1"));
|
|
||||||
|
|
||||||
runner.shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPutIgniteCacheOnTriggerDefaultConfigurationOneFlowFileNoKey() throws IOException {
|
|
||||||
runner = TestRunners.newTestRunner(putIgniteCache);
|
|
||||||
runner.setProperty(PutIgniteCache.BATCH_SIZE, "5");
|
|
||||||
runner.setProperty(PutIgniteCache.CACHE_NAME, CACHE_NAME);
|
|
||||||
runner.setProperty(PutIgniteCache.DATA_STREAMER_PER_NODE_BUFFER_SIZE, "1");
|
|
||||||
runner.setProperty(PutIgniteCache.IGNITE_CACHE_ENTRY_KEY, "${igniteKey}");
|
|
||||||
|
|
||||||
runner.assertValid();
|
|
||||||
properties1.clear();
|
|
||||||
runner.enqueue("test".getBytes(),properties1);
|
|
||||||
runner.run(1, false, true);
|
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(PutIgniteCache.REL_FAILURE, 1);
|
|
||||||
List<MockFlowFile> successfulFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(0, successfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> failureFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(1, failureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile out = runner.getFlowFilesForRelationship(PutIgniteCache.REL_FAILURE).get(0);
|
|
||||||
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_ITEM_NUMBER, "0");
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, "1");
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_COUNT, "1");
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, "0");
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_REASON_ATTRIBUTE_KEY, PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_MISSING_KEY_MESSAGE);
|
|
||||||
|
|
||||||
out.assertContentEquals("test".getBytes());
|
|
||||||
assertNull((byte[])putIgniteCache.getIgniteCache().get("key1"));
|
|
||||||
runner.shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPutIgniteCacheOnTriggerDefaultConfigurationOneFlowFileNoBytes() throws IOException {
|
|
||||||
runner = TestRunners.newTestRunner(putIgniteCache);
|
|
||||||
runner.setProperty(PutIgniteCache.BATCH_SIZE, "5");
|
|
||||||
runner.setProperty(PutIgniteCache.CACHE_NAME, CACHE_NAME);
|
|
||||||
runner.setProperty(PutIgniteCache.DATA_STREAMER_PER_NODE_BUFFER_SIZE, "1");
|
|
||||||
runner.setProperty(PutIgniteCache.IGNITE_CACHE_ENTRY_KEY, "${igniteKey}");
|
|
||||||
|
|
||||||
runner.assertValid();
|
|
||||||
runner.enqueue("".getBytes(),properties1);
|
|
||||||
runner.run(1, false, true);
|
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(PutIgniteCache.REL_FAILURE, 1);
|
|
||||||
List<MockFlowFile> successfulFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(0, successfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> failureFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(1, failureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile out = runner.getFlowFilesForRelationship(PutIgniteCache.REL_FAILURE).get(0);
|
|
||||||
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_ITEM_NUMBER, "0");
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, "1");
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_COUNT, "1");
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, "0");
|
|
||||||
out.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_REASON_ATTRIBUTE_KEY, PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_ZERO_SIZE_MESSAGE);
|
|
||||||
|
|
||||||
out.assertContentEquals("".getBytes());
|
|
||||||
assertNull((byte[])putIgniteCache.getIgniteCache().get("key1"));
|
|
||||||
runner.shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPutIgniteCacheOnTriggerDefaultConfigurationTwoFlowFiles() throws IOException {
|
|
||||||
runner = TestRunners.newTestRunner(putIgniteCache);
|
|
||||||
runner.setProperty(PutIgniteCache.BATCH_SIZE, "5");
|
|
||||||
runner.setProperty(PutIgniteCache.CACHE_NAME, CACHE_NAME);
|
|
||||||
runner.setProperty(PutIgniteCache.DATA_STREAMER_PER_NODE_BUFFER_SIZE, "1");
|
|
||||||
runner.setProperty(PutIgniteCache.IGNITE_CACHE_ENTRY_KEY, "${igniteKey}");
|
|
||||||
|
|
||||||
runner.assertValid();
|
|
||||||
runner.enqueue("test1".getBytes(),properties1);
|
|
||||||
runner.enqueue("test2".getBytes(),properties2);
|
|
||||||
runner.run(1, false, true);
|
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(PutIgniteCache.REL_SUCCESS, 2);
|
|
||||||
List<MockFlowFile> successfulFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(2, successfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> failureFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(0, failureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile out1 = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS).get(0);
|
|
||||||
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_ITEM_NUMBER, "0");
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, "2");
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_COUNT, "2");
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, "0");
|
|
||||||
|
|
||||||
out1.assertContentEquals("test1".getBytes());
|
|
||||||
assertArrayEquals("test1".getBytes(),(byte[])putIgniteCache.getIgniteCache().get("key1"));
|
|
||||||
|
|
||||||
final MockFlowFile out2 = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS).get(1);
|
|
||||||
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_ITEM_NUMBER, "1");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, "2");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, "1");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_COUNT, "2");
|
|
||||||
|
|
||||||
out2.assertContentEquals("test2".getBytes());
|
|
||||||
assertArrayEquals("test2".getBytes(),(byte[])putIgniteCache.getIgniteCache().get("key2"));
|
|
||||||
|
|
||||||
runner.shutdown();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPutIgniteCacheOnTriggerDefaultConfigurationTwoFlowFilesNoKey() throws IOException {
|
|
||||||
runner = TestRunners.newTestRunner(putIgniteCache);
|
|
||||||
runner.setProperty(PutIgniteCache.BATCH_SIZE, "5");
|
|
||||||
runner.setProperty(PutIgniteCache.CACHE_NAME, CACHE_NAME);
|
|
||||||
runner.setProperty(PutIgniteCache.DATA_STREAMER_PER_NODE_BUFFER_SIZE, "1");
|
|
||||||
runner.setProperty(PutIgniteCache.IGNITE_CACHE_ENTRY_KEY, "${igniteKey}");
|
|
||||||
|
|
||||||
runner.assertValid();
|
|
||||||
|
|
||||||
runner.enqueue("test1".getBytes());
|
|
||||||
runner.enqueue("test2".getBytes());
|
|
||||||
runner.run(1, false, true);
|
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(PutIgniteCache.REL_FAILURE, 2);
|
|
||||||
List<MockFlowFile> successfulFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(0, successfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> failureFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(2, failureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile out1 = runner.getFlowFilesForRelationship(PutIgniteCache.REL_FAILURE).get(0);
|
|
||||||
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_ITEM_NUMBER, "0");
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, "2");
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_COUNT, "2");
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_REASON_ATTRIBUTE_KEY, PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_MISSING_KEY_MESSAGE);
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, "0");
|
|
||||||
|
|
||||||
out1.assertContentEquals("test1".getBytes());
|
|
||||||
assertNull((byte[])putIgniteCache.getIgniteCache().get("key1"));
|
|
||||||
|
|
||||||
final MockFlowFile out2 = runner.getFlowFilesForRelationship(PutIgniteCache.REL_FAILURE).get(1);
|
|
||||||
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_ITEM_NUMBER, "1");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, "2");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_COUNT, "2");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_REASON_ATTRIBUTE_KEY, PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_MISSING_KEY_MESSAGE);
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, "1");
|
|
||||||
|
|
||||||
out2.assertContentEquals("test2".getBytes());
|
|
||||||
assertNull((byte[])putIgniteCache.getIgniteCache().get("key2"));
|
|
||||||
|
|
||||||
runner.shutdown();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPutIgniteCacheOnTriggerDefaultConfigurationTwoFlowFileFirstNoKey() throws IOException {
|
|
||||||
runner = TestRunners.newTestRunner(putIgniteCache);
|
|
||||||
runner.setProperty(PutIgniteCache.BATCH_SIZE, "5");
|
|
||||||
runner.setProperty(PutIgniteCache.CACHE_NAME, CACHE_NAME);
|
|
||||||
runner.setProperty(PutIgniteCache.DATA_STREAMER_PER_NODE_BUFFER_SIZE, "1");
|
|
||||||
runner.setProperty(PutIgniteCache.IGNITE_CACHE_ENTRY_KEY, "${igniteKey}");
|
|
||||||
|
|
||||||
runner.assertValid();
|
|
||||||
runner.enqueue("test1".getBytes());
|
|
||||||
runner.enqueue("test2".getBytes(),properties2);
|
|
||||||
runner.run(1, false, true);
|
|
||||||
|
|
||||||
List<MockFlowFile> successfulFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(1, successfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> failureFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(1, failureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile out1 = runner.getFlowFilesForRelationship(PutIgniteCache.REL_FAILURE).get(0);
|
|
||||||
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_ITEM_NUMBER, "0");
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, "2");
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_COUNT, "1");
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_REASON_ATTRIBUTE_KEY, PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_MISSING_KEY_MESSAGE);
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, "0");
|
|
||||||
|
|
||||||
out1.assertContentEquals("test1".getBytes());
|
|
||||||
assertNull((byte[])putIgniteCache.getIgniteCache().get("key1"));
|
|
||||||
|
|
||||||
final MockFlowFile out2 = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS).get(0);
|
|
||||||
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_ITEM_NUMBER, "0");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, "2");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_COUNT, "1");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, "1");
|
|
||||||
|
|
||||||
out2.assertContentEquals("test2".getBytes());
|
|
||||||
assertArrayEquals("test2".getBytes(),(byte[])putIgniteCache.getIgniteCache().get("key2"));
|
|
||||||
|
|
||||||
runner.shutdown();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPutIgniteCacheOnTriggerDefaultConfigurationTwoFlowFileSecondNoKey() throws IOException {
|
|
||||||
runner = TestRunners.newTestRunner(putIgniteCache);
|
|
||||||
runner.setProperty(PutIgniteCache.BATCH_SIZE, "5");
|
|
||||||
runner.setProperty(PutIgniteCache.CACHE_NAME, CACHE_NAME);
|
|
||||||
runner.setProperty(PutIgniteCache.DATA_STREAMER_PER_NODE_BUFFER_SIZE, "1");
|
|
||||||
runner.setProperty(PutIgniteCache.IGNITE_CACHE_ENTRY_KEY, "${igniteKey}");
|
|
||||||
|
|
||||||
runner.assertValid();
|
|
||||||
|
|
||||||
runner.enqueue("test1".getBytes(),properties1);
|
|
||||||
runner.enqueue("test2".getBytes());
|
|
||||||
runner.run(1, false, true);
|
|
||||||
|
|
||||||
List<MockFlowFile> successfulFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(1, successfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> failureFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(1, failureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile out1 = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS).get(0);
|
|
||||||
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_ITEM_NUMBER, "0");
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, "2");
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_COUNT, "1");
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, "0");
|
|
||||||
|
|
||||||
out1.assertContentEquals("test1".getBytes());
|
|
||||||
assertArrayEquals("test1".getBytes(),(byte[])putIgniteCache.getIgniteCache().get("key1"));
|
|
||||||
|
|
||||||
final MockFlowFile out2 = runner.getFlowFilesForRelationship(PutIgniteCache.REL_FAILURE).get(0);
|
|
||||||
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_ITEM_NUMBER, "0");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, "2");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_COUNT, "1");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_REASON_ATTRIBUTE_KEY, PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_MISSING_KEY_MESSAGE);
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, "1");
|
|
||||||
|
|
||||||
out2.assertContentEquals("test2".getBytes());
|
|
||||||
assertNull((byte[])putIgniteCache.getIgniteCache().get("key2"));
|
|
||||||
|
|
||||||
|
|
||||||
runner.shutdown();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPutIgniteCacheOnTriggerDefaultConfigurationTwoFlowFilesOneNoKeyOneNoBytes() throws IOException {
|
|
||||||
runner = TestRunners.newTestRunner(putIgniteCache);
|
|
||||||
runner.setProperty(PutIgniteCache.BATCH_SIZE, "5");
|
|
||||||
runner.setProperty(PutIgniteCache.CACHE_NAME, CACHE_NAME);
|
|
||||||
runner.setProperty(PutIgniteCache.DATA_STREAMER_PER_NODE_BUFFER_SIZE, "1");
|
|
||||||
runner.setProperty(PutIgniteCache.IGNITE_CACHE_ENTRY_KEY, "${igniteKey}");
|
|
||||||
|
|
||||||
runner.assertValid();
|
|
||||||
|
|
||||||
runner.enqueue("test1".getBytes());
|
|
||||||
runner.enqueue("".getBytes(),properties2);
|
|
||||||
runner.run(1, false, true);
|
|
||||||
|
|
||||||
runner.assertAllFlowFilesTransferred(PutIgniteCache.REL_FAILURE, 2);
|
|
||||||
List<MockFlowFile> successfulFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(0, successfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> failureFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(2, failureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile out1 = runner.getFlowFilesForRelationship(PutIgniteCache.REL_FAILURE).get(0);
|
|
||||||
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_ITEM_NUMBER, "0");
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, "2");
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_COUNT, "2");
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_REASON_ATTRIBUTE_KEY, PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_MISSING_KEY_MESSAGE);
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, "0");
|
|
||||||
|
|
||||||
out1.assertContentEquals("test1".getBytes());
|
|
||||||
assertNull((byte[])putIgniteCache.getIgniteCache().get("key1"));
|
|
||||||
|
|
||||||
final MockFlowFile out2 = runner.getFlowFilesForRelationship(PutIgniteCache.REL_FAILURE).get(1);
|
|
||||||
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_ITEM_NUMBER, "1");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, "2");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_COUNT, "2");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_REASON_ATTRIBUTE_KEY, PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_ZERO_SIZE_MESSAGE);
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, "1");
|
|
||||||
|
|
||||||
out2.assertContentEquals("".getBytes());
|
|
||||||
assertNull((byte[])putIgniteCache.getIgniteCache().get("key2"));
|
|
||||||
|
|
||||||
runner.shutdown();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPutIgniteCacheOnTriggerDefaultConfigurationTwoFlowFilesOneNoKeySecondOkThirdNoBytes() throws IOException {
|
|
||||||
runner = TestRunners.newTestRunner(putIgniteCache);
|
|
||||||
runner.setProperty(PutIgniteCache.BATCH_SIZE, "5");
|
|
||||||
runner.setProperty(PutIgniteCache.CACHE_NAME, CACHE_NAME);
|
|
||||||
runner.setProperty(PutIgniteCache.DATA_STREAMER_PER_NODE_BUFFER_SIZE, "1");
|
|
||||||
runner.setProperty(PutIgniteCache.IGNITE_CACHE_ENTRY_KEY, "${igniteKey}");
|
|
||||||
|
|
||||||
runner.assertValid();
|
|
||||||
runner.enqueue("test1".getBytes());
|
|
||||||
runner.enqueue("test2".getBytes(),properties1);
|
|
||||||
runner.enqueue("".getBytes(),properties2);
|
|
||||||
runner.run(1, false, true);
|
|
||||||
|
|
||||||
List<MockFlowFile> successfulFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS);
|
|
||||||
assertEquals(1, successfulFlowFiles.size());
|
|
||||||
List<MockFlowFile> failureFlowFiles = runner.getFlowFilesForRelationship(PutIgniteCache.REL_FAILURE);
|
|
||||||
assertEquals(2, failureFlowFiles.size());
|
|
||||||
|
|
||||||
final MockFlowFile out1 = runner.getFlowFilesForRelationship(PutIgniteCache.REL_FAILURE).get(0);
|
|
||||||
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_ITEM_NUMBER, "0");
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, "3");
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_COUNT, "2");
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_REASON_ATTRIBUTE_KEY, PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_MISSING_KEY_MESSAGE);
|
|
||||||
out1.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, "0");
|
|
||||||
|
|
||||||
out1.assertContentEquals("test1".getBytes());
|
|
||||||
assertEquals("test2", new String(putIgniteCache.getIgniteCache().get("key1")));
|
|
||||||
|
|
||||||
final MockFlowFile out2 = runner.getFlowFilesForRelationship(PutIgniteCache.REL_SUCCESS).get(0);
|
|
||||||
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_ITEM_NUMBER, "0");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, "3");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, "1");
|
|
||||||
out2.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_SUCCESSFUL_COUNT, "1");
|
|
||||||
|
|
||||||
out2.assertContentEquals("test2".getBytes());
|
|
||||||
assertArrayEquals("test2".getBytes(),(byte[])putIgniteCache.getIgniteCache().get("key1"));
|
|
||||||
|
|
||||||
final MockFlowFile out3 = runner.getFlowFilesForRelationship(PutIgniteCache.REL_FAILURE).get(1);
|
|
||||||
|
|
||||||
out3.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_ITEM_NUMBER, "1");
|
|
||||||
out3.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_TOTAL_COUNT, "3");
|
|
||||||
out3.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_COUNT, "2");
|
|
||||||
out3.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_REASON_ATTRIBUTE_KEY, PutIgniteCache.IGNITE_BATCH_FLOW_FILE_FAILED_ZERO_SIZE_MESSAGE);
|
|
||||||
out3.assertAttributeEquals(PutIgniteCache.IGNITE_BATCH_FLOW_FILE_ITEM_NUMBER, "2");
|
|
||||||
|
|
||||||
out3.assertContentEquals("".getBytes());
|
|
||||||
assertNull((byte[])putIgniteCache.getIgniteCache().get("key2"));
|
|
||||||
|
|
||||||
runner.shutdown();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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.
|
|
||||||
-->
|
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns:util="http://www.springframework.org/schema/util"
|
|
||||||
xsi:schemaLocation="
|
|
||||||
http://www.springframework.org/schema/beans
|
|
||||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
|
||||||
http://www.springframework.org/schema/util
|
|
||||||
http://www.springframework.org/schema/util/spring-util.xsd">
|
|
||||||
|
|
||||||
<bean abstract="true" id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
|
|
||||||
<property name="peerClassLoadingEnabled" value="false"/>
|
|
||||||
|
|
||||||
<property name="discoverySpi">
|
|
||||||
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
|
|
||||||
<property name="ipFinder">
|
|
||||||
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
|
|
||||||
<property name="addresses">
|
|
||||||
<list>
|
|
||||||
<value>127.0.0.1:47500..47509</value>
|
|
||||||
</list>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
</beans>
|
|
|
@ -1,26 +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.
|
|
||||||
-->
|
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
|
||||||
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
|
||||||
<!-- Imports default Ignite configuration -->
|
|
||||||
<import resource="test-default.xml"/>
|
|
||||||
|
|
||||||
<bean parent="ignite.cfg"/>
|
|
||||||
</beans>
|
|
|
@ -1,41 +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-ignite-bundle</artifactId>
|
|
||||||
<packaging>pom</packaging>
|
|
||||||
|
|
||||||
<modules>
|
|
||||||
<module>nifi-ignite-processors</module>
|
|
||||||
<module>nifi-ignite-nar</module>
|
|
||||||
</modules>
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.nifi</groupId>
|
|
||||||
<artifactId>nifi-ignite-processors</artifactId>
|
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
</project>
|
|
|
@ -73,7 +73,6 @@
|
||||||
<module>nifi-snmp-bundle</module>
|
<module>nifi-snmp-bundle</module>
|
||||||
<module>nifi-datadog-bundle</module>
|
<module>nifi-datadog-bundle</module>
|
||||||
<module>nifi-windows-event-log-bundle</module>
|
<module>nifi-windows-event-log-bundle</module>
|
||||||
<module>nifi-ignite-bundle</module>
|
|
||||||
<module>nifi-rethinkdb-bundle</module>
|
<module>nifi-rethinkdb-bundle</module>
|
||||||
<module>nifi-influxdb-bundle</module>
|
<module>nifi-influxdb-bundle</module>
|
||||||
<module>nifi-graph-bundle</module>
|
<module>nifi-graph-bundle</module>
|
||||||
|
|
Loading…
Reference in New Issue