NIFIREG-1 Initial project structure for NiFi Registry
Project: http://git-wip-us.apache.org/repos/asf/nifi-registry/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi-registry/commit/8c295feb Tree: http://git-wip-us.apache.org/repos/asf/nifi-registry/tree/8c295feb Diff: http://git-wip-us.apache.org/repos/asf/nifi-registry/diff/8c295feb Branch: refs/heads/NIFIREG-1 Commit: 8c295feb1b1469e565635be25305f5ea0cccdc6e Parents: Author: Bryan Bende <[email protected]> Authored: Thu Mar 16 13:45:16 2017 -0400 Committer: Bryan Bende <[email protected]> Committed: Thu Mar 16 13:45:16 2017 -0400 ---------------------------------------------------------------------- .gitignore | 16 + LICENSE | 203 ++++++ NOTICE | 6 + README.md | 44 ++ nifi-registry-assembly/pom.xml | 127 ++++ .../src/main/assembly/dependencies.xml | 80 +++ nifi-registry-jetty/pom.xml | 77 +++ .../apache/nifi/registry/jetty/JettyServer.java | 343 ++++++++++ nifi-registry-properties/pom.xml | 31 + .../properties/NiFiRegistryProperties.java | 147 ++++ nifi-registry-resources/pom.xml | 50 ++ .../src/main/assembly/dependencies.xml | 36 + .../main/resources/bin/dump-nifi-registry.bat | 47 ++ .../src/main/resources/bin/nifi-registry.sh | 216 ++++++ .../main/resources/bin/run-nifi-registry.bat | 48 ++ .../main/resources/bin/status-nifi-registry.bat | 47 ++ .../main/resources/conf/authorized-users.xml | 20 + .../src/main/resources/conf/bootstrap.conf | 57 ++ .../src/main/resources/conf/logback.xml | 51 ++ .../resources/conf/nifi-registry.properties | 34 + nifi-registry-runtime/pom.xml | 37 + .../org/apache/nifi/registry/NiFiRegistry.java | 70 ++ nifi-registry-security/pom.xml | 70 ++ .../security/AuthorizationProvider.java | 88 +++ .../registry/security/AuthorizedUserFilter.java | 87 +++ nifi-registry-security/src/main/xsd/users.xsd | 37 + nifi-registry-service-api/pom.xml | 35 + nifi-registry-web-api/pom.xml | 61 ++ .../web/NiFiRegistryResourceConfig.java | 44 ++ .../nifi/registry/web/api/TestResource.java | 37 + .../mapper/IllegalArgumentExceptionMapper.java | 46 ++ .../registry/web/mapper/ThrowableMapper.java | 40 ++ .../registry/web/request/IntegerParameter.java | 39 ++ .../nifi/registry/web/response/TestEntity.java | 31 + .../src/main/webapp/WEB-INF/web.xml | 45 ++ nifi-registry-web-ui/pom.xml | 50 ++ .../src/main/webapp/WEB-INF/pages/index.jsp | 30 + .../src/main/webapp/WEB-INF/web.xml | 32 + .../src/main/webapp/css/main.css | 22 + pom.xml | 680 +++++++++++++++++++ 40 files changed, 3261 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/8c295feb/.gitignore ---------------------------------------------------------------------- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a2e04fa --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +target +.project +.settings +.classpath +nbactions.xml +nb-configuration.xml +.DS_Store +.metadata +.recommenders + +# Intellij +.idea/ +*.iml +*.iws +*~ + http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/8c295feb/LICENSE ---------------------------------------------------------------------- diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6b0b127 --- /dev/null +++ b/LICENSE @@ -0,0 +1,203 @@ + + 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. + http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/8c295feb/NOTICE ---------------------------------------------------------------------- diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..03786c7 --- /dev/null +++ b/NOTICE @@ -0,0 +1,6 @@ +Apache NiFi +Copyright 2014-2017 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). + http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/8c295feb/README.md ---------------------------------------------------------------------- diff --git a/README.md b/README.md new file mode 100644 index 0000000..a565537 --- /dev/null +++ b/README.md @@ -0,0 +1,44 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +# Apache NiFi Registry + +Registryâa subproject of Apache NiFiâis a complementary application that provides a central location for storage and management of shared resources across one or more instances of NiFi and/or MiNiFi. + +## Table of Contents + +- [Getting Started](#getting-started) +- [License](#license) + +## Getting Started + +TBD + +## License + +Except as otherwise noted this software is licensed under the +[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) + +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. + http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/8c295feb/nifi-registry-assembly/pom.xml ---------------------------------------------------------------------- diff --git a/nifi-registry-assembly/pom.xml b/nifi-registry-assembly/pom.xml new file mode 100644 index 0000000..1786d64 --- /dev/null +++ b/nifi-registry-assembly/pom.xml @@ -0,0 +1,127 @@ +<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.nifi.registry</groupId> + <artifactId>nifi-registry</artifactId> + <version>0.0.1-SNAPSHOT</version> + </parent> + <artifactId>nifi-registry-assembly</artifactId> + <packaging>pom</packaging> + <description>This is the assembly for nifi-registry.</description> + <build> + <plugins> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <configuration> + <finalName>nifi-registry-${project.version}</finalName> + <attach>false</attach> + </configuration> + <executions> + <execution> + <id>make shared resource</id> + <goals> + <goal>single</goal> + </goals> + <phase>package</phase> + <configuration> + <archiverConfig> + <defaultDirectoryMode>0775</defaultDirectoryMode> + <directoryMode>0775</directoryMode> + <fileMode>0664</fileMode> + </archiverConfig> + <descriptors> + <descriptor>src/main/assembly/dependencies.xml</descriptor> + </descriptors> + <tarLongFileMode>posix</tarLongFileMode> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jcl-over-slf4j</artifactId> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jul-to-slf4j</artifactId> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>log4j-over-slf4j</artifactId> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.apache.nifi.registry</groupId> + <artifactId>nifi-registry-runtime</artifactId> + <version>0.0.1-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.nifi.registry</groupId> + <artifactId>nifi-registry-web-ui</artifactId> + <type>war</type> + <version>0.0.1-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.nifi.registry</groupId> + <artifactId>nifi-registry-web-api</artifactId> + <type>war</type> + <version>0.0.1-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.nifi.registry</groupId> + <artifactId>nifi-registry-resources</artifactId> + <classifier>resources</classifier> + <scope>runtime</scope> + <type>zip</type> + <version>0.0.1-SNAPSHOT</version> + </dependency> + </dependencies> + <properties> + <!-- nifi-registry.properties: web properties --> + <nifi.registry.web.war.directory>./lib</nifi.registry.web.war.directory> + <nifi.registry.web.http.host /> + <nifi.registry.web.http.port>8080</nifi.registry.web.http.port> + <nifi.registry.web.https.host /> + <nifi.registry.web.https.port /> + <nifi.registry.jetty.work.dir>./work/jetty</nifi.registry.jetty.work.dir> + <nifi.registry.web.jetty.threads>200</nifi.registry.web.jetty.threads> + + <!-- nifi-registry.properties: security properties --> + <nifi.registry.security.keystore /> + <nifi.registry.security.keystoreType /> + <nifi.registry.security.keystorePasswd /> + <nifi.registry.security.keyPasswd /> + <nifi.registry.security.truststore /> + <nifi.registry.security.truststoreType /> + <nifi.registry.security.truststorePasswd /> + <nifi.registry.security.needClientAuth /> + <nifi.registry.security.authorized.users>./conf/authorized-users.xml</nifi.registry.security.authorized.users> + + </properties> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/8c295feb/nifi-registry-assembly/src/main/assembly/dependencies.xml ---------------------------------------------------------------------- diff --git a/nifi-registry-assembly/src/main/assembly/dependencies.xml b/nifi-registry-assembly/src/main/assembly/dependencies.xml new file mode 100644 index 0000000..f3864ca --- /dev/null +++ b/nifi-registry-assembly/src/main/assembly/dependencies.xml @@ -0,0 +1,80 @@ +<?xml version="1.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. +--> +<assembly> + <id>bin</id> + <formats> + <format>dir</format> + <format>zip</format> + <format>tar.gz</format> + </formats> + <includeBaseDirectory>true</includeBaseDirectory> + <baseDirectory>nifi-registry-${project.version}</baseDirectory> + + <dependencySets> + <!-- Write out all dependency artifacts to lib directory --> + <dependencySet> + <scope>runtime</scope> + <useProjectArtifact>false</useProjectArtifact> + <outputDirectory>lib</outputDirectory> + <directoryMode>0770</directoryMode> + <fileMode>0660</fileMode> + <useTransitiveFiltering>true</useTransitiveFiltering> + <excludes> + <exclude>nifi-registry-resources</exclude> + </excludes> + </dependencySet> + + <!-- Write out the conf directory contents --> + <dependencySet> + <scope>runtime</scope> + <useProjectArtifact>false</useProjectArtifact> + <outputDirectory>./</outputDirectory> + <directoryMode>0770</directoryMode> + <fileMode>0664</fileMode> + <useTransitiveFiltering>true</useTransitiveFiltering> + <includes> + <include>nifi-registry-resources</include> + </includes> + <unpack>true</unpack> + <unpackOptions> + <filtered>true</filtered> + <includes> + <include>conf/*</include> + </includes> + </unpackOptions> + </dependencySet> + + <!-- Write out the bin directory contents --> + <dependencySet> + <scope>runtime</scope> + <useProjectArtifact>false</useProjectArtifact> + <outputDirectory>./</outputDirectory> + <directoryMode>0770</directoryMode> + <fileMode>0770</fileMode> + <useTransitiveFiltering>true</useTransitiveFiltering> + <includes> + <include>nifi-registry-resources</include> + </includes> + <unpack>true</unpack> + <unpackOptions> + <filtered>true</filtered> + <includes> + <include>bin/*</include> + </includes> + </unpackOptions> + </dependencySet> + </dependencySets> +</assembly> http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/8c295feb/nifi-registry-jetty/pom.xml ---------------------------------------------------------------------- diff --git a/nifi-registry-jetty/pom.xml b/nifi-registry-jetty/pom.xml new file mode 100644 index 0000000..3c75832 --- /dev/null +++ b/nifi-registry-jetty/pom.xml @@ -0,0 +1,77 @@ +<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.nifi.registry</groupId> + <artifactId>nifi-registry</artifactId> + <version>0.0.1-SNAPSHOT</version> + </parent> + <artifactId>nifi-registry-jetty</artifactId> + <packaging>jar</packaging> + <dependencies> + <dependency> + <groupId>org.apache.nifi.registry</groupId> + <artifactId>nifi-registry-properties</artifactId> + <version>0.0.1-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.nifi.registry</groupId> + <artifactId>nifi-registry-security</artifactId> + <version>0.0.1-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-server</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-servlet</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-webapp</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-servlets</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-jsp</artifactId> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + </dependency> + <dependency> + <groupId>javax.servlet.jsp</groupId> + <artifactId>javax.servlet.jsp-api</artifactId> + </dependency> + <dependency> + <groupId>javax.el</groupId> + <artifactId>javax.el-api</artifactId> + </dependency> + <dependency> + <groupId>javax.servlet.jsp.jstl</groupId> + <artifactId>javax.servlet.jsp.jstl-api</artifactId> + </dependency> + </dependencies> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/8c295feb/nifi-registry-jetty/src/main/java/org/apache/nifi/registry/jetty/JettyServer.java ---------------------------------------------------------------------- diff --git a/nifi-registry-jetty/src/main/java/org/apache/nifi/registry/jetty/JettyServer.java b/nifi-registry-jetty/src/main/java/org/apache/nifi/registry/jetty/JettyServer.java new file mode 100644 index 0000000..474f907 --- /dev/null +++ b/nifi-registry-jetty/src/main/java/org/apache/nifi/registry/jetty/JettyServer.java @@ -0,0 +1,343 @@ +/* + * 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.registry.jetty; + +import org.apache.nifi.registry.security.AuthorizationProvider; +import org.apache.nifi.registry.security.AuthorizedUserFilter; +import org.apache.commons.lang3.StringUtils; +import org.apache.nifi.registry.properties.NiFiRegistryProperties; +import org.eclipse.jetty.server.Connector; +import org.eclipse.jetty.server.Handler; +import org.eclipse.jetty.server.HttpConfiguration; +import org.eclipse.jetty.server.HttpConnectionFactory; +import org.eclipse.jetty.server.SecureRequestCustomizer; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.ServerConnector; +import org.eclipse.jetty.server.SslConnectionFactory; +import org.eclipse.jetty.server.handler.HandlerCollection; +import org.eclipse.jetty.servlet.FilterHolder; +import org.eclipse.jetty.util.ssl.SslContextFactory; +import org.eclipse.jetty.util.thread.QueuedThreadPool; +import org.eclipse.jetty.webapp.WebAppContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.DispatcherType; +import javax.servlet.Filter; +import java.io.File; +import java.io.FileFilter; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.net.SocketException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.EnumSet; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + + +public class JettyServer { + + private static final Logger logger = LoggerFactory.getLogger(JettyServer.class); + + private static final int HEADER_BUFFER_SIZE = 16 * 1024; // 16kb + + private static final FileFilter WAR_FILTER = new FileFilter() { + @Override + public boolean accept(File pathname) { + final String nameToTest = pathname.getName().toLowerCase(); + return nameToTest.endsWith(".war") && pathname.isFile(); + } + }; + + private final NiFiRegistryProperties properties; + private final Server server; + + private WebAppContext webUiContext; + private WebAppContext webApiContext; + + public JettyServer(final NiFiRegistryProperties properties) { + final QueuedThreadPool threadPool = new QueuedThreadPool(properties.getWebThreads()); + threadPool.setName("NiFi Registry Web Server"); + + this.properties = properties; + this.server = new Server(threadPool); + configureConnectors(); + loadWars(); + } + + private void configureConnectors() { + // create the http configuration + final HttpConfiguration httpConfiguration = new HttpConfiguration(); + httpConfiguration.setRequestHeaderSize(HEADER_BUFFER_SIZE); + httpConfiguration.setResponseHeaderSize(HEADER_BUFFER_SIZE); + + if (properties.getPort() != null) { + final Integer port = properties.getPort(); + if (port < 0 || (int) Math.pow(2, 16) <= port) { + throw new IllegalStateException("Invalid HTTP port: " + port); + } + + logger.info("Configuring Jetty for HTTP on port: " + port); + + // create the connector + final ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfiguration)); + + // set host and port + if (StringUtils.isNotBlank(properties.getHttpHost())) { + http.setHost(properties.getHttpHost()); + } + http.setPort(port); + + // add this connector + server.addConnector(http); + } else if (properties.getSslPort() != null) { + final Integer port = properties.getSslPort(); + if (port < 0 || (int) Math.pow(2, 16) <= port) { + throw new IllegalStateException("Invalid HTTPs port: " + port); + } + + logger.info("Configuring Jetty for HTTPs on port: " + port); + + // add some secure config + final HttpConfiguration httpsConfiguration = new HttpConfiguration(httpConfiguration); + httpsConfiguration.setSecureScheme("https"); + httpsConfiguration.setSecurePort(properties.getSslPort()); + httpsConfiguration.addCustomizer(new SecureRequestCustomizer()); + + // build the connector + final ServerConnector https = new ServerConnector(server, + new SslConnectionFactory(createSslContextFactory(), "http/1.1"), + new HttpConnectionFactory(httpsConfiguration)); + + // set host and port + if (StringUtils.isNotBlank(properties.getHttpsHost())) { + https.setHost(properties.getHttpsHost()); + } + https.setPort(port); + + // add this connector + server.addConnector(https); + } + } + + private SslContextFactory createSslContextFactory() { + final SslContextFactory contextFactory = new SslContextFactory(); + + logger.error("" + properties.getNeedClientAuth()); + + // need client auth + contextFactory.setNeedClientAuth(properties.getNeedClientAuth()); + + /* below code sets JSSE system properties when values are provided */ + // keystore properties + if (StringUtils.isNotBlank(properties.getKeyStorePath())) { + contextFactory.setKeyStorePath(properties.getKeyStorePath()); + } + if (StringUtils.isNotBlank(properties.getKeyStoreType())) { + contextFactory.setKeyStoreType(properties.getKeyStoreType()); + } + final String keystorePassword = properties.getKeyStorePassword(); + final String keyPassword = properties.getKeyPassword(); + if (StringUtils.isNotBlank(keystorePassword)) { + // if no key password was provided, then assume the keystore password is the same as the key password. + final String defaultKeyPassword = (StringUtils.isBlank(keyPassword)) ? keystorePassword : keyPassword; + contextFactory.setKeyManagerPassword(keystorePassword); + contextFactory.setKeyStorePassword(defaultKeyPassword); + } else if (StringUtils.isNotBlank(keyPassword)) { + // since no keystore password was provided, there will be no keystore integrity check + contextFactory.setKeyStorePassword(keyPassword); + } + + // truststore properties + if (StringUtils.isNotBlank(properties.getTrustStorePath())) { + contextFactory.setTrustStorePath(properties.getTrustStorePath()); + } + if (StringUtils.isNotBlank(properties.getTrustStoreType())) { + contextFactory.setTrustStoreType(properties.getTrustStoreType()); + } + if (StringUtils.isNotBlank(properties.getTrustStorePassword())) { + contextFactory.setTrustStorePassword(properties.getTrustStorePassword()); + } + + return contextFactory; + } + + private void loadWars() { + final File warDirectory = properties.getWarLibDirectory(); + final File[] wars = warDirectory.listFiles(WAR_FILTER); + + if (wars == null) { + throw new RuntimeException("Unable to access war lib directory: " + warDirectory); + } + + File webUiWar = null; + File webApiWar = null; + for (final File war : wars) { + if (war.getName().startsWith("nifi-registry-web-ui")) { + webUiWar = war; + } else if (war.getName().startsWith("nifi-registry-web-api")) { + webApiWar = war; + } + } + + if (webUiWar == null) { + throw new IllegalStateException("Unable to locate NiFi Registry Web UI"); + } else if (webApiWar == null) { + throw new IllegalStateException("Unable to locate NiFi Registry Web API"); + } + + webUiContext = loadWar(webUiWar, "/nifi-registry"); + webApiContext = loadWar(webApiWar, "/nifi-registry-api"); + webApiContext.setAttribute("nifi-registry.properties", properties); + + final HandlerCollection handlers = new HandlerCollection(); + handlers.addHandler(webUiContext); + handlers.addHandler(webApiContext); + server.setHandler(handlers); + } + + private WebAppContext loadWar(final File warFile, final String contextPath) { + final WebAppContext webappContext = new WebAppContext(warFile.getPath(), contextPath); + webappContext.setContextPath(contextPath); + webappContext.setDisplayName(contextPath); + + // remove slf4j server class to allow WAR files to have slf4j dependencies in WEB-INF/lib + List<String> serverClasses = new ArrayList<>(Arrays.asList(webappContext.getServerClasses())); + serverClasses.remove("org.slf4j."); + webappContext.setServerClasses(serverClasses.toArray(new String[0])); + + // get the temp directory for this webapp + final File webWorkingDirectory = properties.getWebWorkingDirectory(); + final File tempDir = new File(webWorkingDirectory, warFile.getName()); + if (tempDir.exists() && !tempDir.isDirectory()) { + throw new RuntimeException(tempDir.getAbsolutePath() + " is not a directory"); + } else if (!tempDir.exists()) { + final boolean made = tempDir.mkdirs(); + if (!made) { + throw new RuntimeException(tempDir.getAbsolutePath() + " could not be created"); + } + } + if (!(tempDir.canRead() && tempDir.canWrite())) { + throw new RuntimeException(tempDir.getAbsolutePath() + " directory does not have read/write privilege"); + } + + // configure the temp dir + webappContext.setTempDirectory(tempDir); + + // configure the max form size (3x the default) + webappContext.setMaxFormContentSize(600000); + +// try { +// webappContext.setClassLoader(new WebAppClassLoader(ClassLoader.getSystemClassLoader(), webappContext)); +// } catch (final IOException ioe) { +// throw new RuntimeException(ioe); +// } + logger.info("Loading WAR: " + warFile.getAbsolutePath() + " with context path set to " + contextPath); + return webappContext; + } + + public void start() { + try { + // start the server + server.start(); + + // ensure everything started successfully + for (Handler handler : server.getChildHandlers()) { + // see if the handler is a web app + if (handler instanceof WebAppContext) { + WebAppContext context = (WebAppContext) handler; + + // see if this webapp had any exceptions that would + // cause it to be unavailable + if (context.getUnavailableException() != null) { + throw context.getUnavailableException(); + } + } + } + + // add the authorization filter + final Filter authorizationFilter = new AuthorizedUserFilter(new AuthorizationProvider(properties)); + webUiContext.addFilter(new FilterHolder(authorizationFilter), "/*", EnumSet.allOf(DispatcherType.class)); + webApiContext.addFilter(new FilterHolder(authorizationFilter), "/*", EnumSet.allOf(DispatcherType.class)); + + dumpUrls(); + } catch (final Throwable t) { + throw new RuntimeException("Unable to start up: " + t, t); + } + } + + private void dumpUrls() throws SocketException { + final List<String> urls = new ArrayList<>(); + + for (Connector connector : server.getConnectors()) { + if (connector instanceof ServerConnector) { + final ServerConnector serverConnector = (ServerConnector) connector; + + Set<String> hosts = new HashSet<>(); + + // determine the hosts + if (StringUtils.isNotBlank(serverConnector.getHost())) { + hosts.add(serverConnector.getHost()); + } else { + Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); + if (networkInterfaces != null) { + for (NetworkInterface networkInterface : Collections.list(networkInterfaces)) { + for (InetAddress inetAddress : Collections.list(networkInterface.getInetAddresses())) { + hosts.add(inetAddress.getHostAddress()); + } + } + } + } + + // ensure some hosts were found + if (!hosts.isEmpty()) { + String scheme = "http"; + if (properties.getSslPort() != null && serverConnector.getPort() == properties.getSslPort()) { + scheme = "https"; + } + + // dump each url + for (String host : hosts) { + urls.add(String.format("%s://%s:%s", scheme, host, serverConnector.getPort())); + } + } + } + } + + if (urls.isEmpty()) { + logger.warn("NiFi Registry has started, but the UI is not available on any hosts. Please verify the host properties."); + } else { + // log the ui location + logger.info("NiFi Registry has started. The UI is available at the following URLs:"); + for (final String url : urls) { + logger.info(String.format("%s/nifi-registry", url)); + } + } + } + + public void stop() { + try { + server.stop(); + } catch (Exception ex) { + logger.warn("Failed to stop web server", ex); + } + } +} http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/8c295feb/nifi-registry-properties/pom.xml ---------------------------------------------------------------------- diff --git a/nifi-registry-properties/pom.xml b/nifi-registry-properties/pom.xml new file mode 100644 index 0000000..24c9aa3 --- /dev/null +++ b/nifi-registry-properties/pom.xml @@ -0,0 +1,31 @@ +<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.nifi.registry</groupId> + <artifactId>nifi-registry</artifactId> + <version>0.0.1-SNAPSHOT</version> + </parent> + <artifactId>nifi-registry-properties</artifactId> + <packaging>jar</packaging> + <dependencies> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + </dependency> + </dependencies> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/8c295feb/nifi-registry-properties/src/main/java/org/apache/nifi/registry/properties/NiFiRegistryProperties.java ---------------------------------------------------------------------- diff --git a/nifi-registry-properties/src/main/java/org/apache/nifi/registry/properties/NiFiRegistryProperties.java b/nifi-registry-properties/src/main/java/org/apache/nifi/registry/properties/NiFiRegistryProperties.java new file mode 100644 index 0000000..5efea84 --- /dev/null +++ b/nifi-registry-properties/src/main/java/org/apache/nifi/registry/properties/NiFiRegistryProperties.java @@ -0,0 +1,147 @@ +/* + * 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.registry.properties; + +import java.io.File; +import java.util.Properties; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class NiFiRegistryProperties extends Properties { + + private static final Logger logger = LoggerFactory.getLogger(NiFiRegistryProperties.class); + + // Keys + public static final String WEB_WAR_DIR = "nifi.registry.web.war.directory"; + public static final String WEB_HTTP_PORT = "nifi.registry.web.http.port"; + public static final String WEB_HTTP_HOST = "nifi.registry.web.http.host"; + public static final String WEB_HTTPS_PORT = "nifi.registry.web.https.port"; + public static final String WEB_HTTPS_HOST = "nifi.registry.web.https.host"; + public static final String WEB_WORKING_DIR = "nifi.registry.web.jetty.working.directory"; + public static final String WEB_THREADS = "nifi.registry.web.jetty.threads"; + + public static final String SECURITY_KEYSTORE = "nifi.registry.security.keystore"; + public static final String SECURITY_KEYSTORE_TYPE = "nifi.registry.security.keystoreType"; + public static final String SECURITY_KEYSTORE_PASSWD = "nifi.registry.security.keystorePasswd"; + public static final String SECURITY_KEY_PASSWD = "nifi.registry.security.keyPasswd"; + public static final String SECURITY_TRUSTSTORE = "nifi.registry.security.truststore"; + public static final String SECURITY_TRUSTSTORE_TYPE = "nifi.registry.security.truststoreType"; + public static final String SECURITY_TRUSTSTORE_PASSWD = "nifi.registry.security.truststorePasswd"; + public static final String SECURITY_NEED_CLIENT_AUTH = "nifi.registry.security.needClientAuth"; + public static final String SECURITY_AUTHORIZED_USERS = "nifi.registry.security.authorized.users"; + + // Defaults + public static final String DEFAULT_WEB_WORKING_DIR = "./work/jetty"; + public static final String DEFAULT_WAR_DIR = "./lib"; + + public int getWebThreads() { + int webThreads = 200; + try { + webThreads = Integer.parseInt(getProperty(WEB_THREADS)); + } catch (final NumberFormatException nfe) { + logger.warn(String.format("%s must be an integer value. Defaulting to %s", WEB_THREADS, webThreads)); + } + return webThreads; + } + + public Integer getPort() { + final String rawPort = getProperty(WEB_HTTP_PORT); + if (StringUtils.isBlank(rawPort)) { + return null; + } + try { + return Integer.parseInt(rawPort); + } catch (final NumberFormatException nfe) { + throw new IllegalStateException(String.format("%s must be an integer value.", WEB_HTTP_PORT)); + } + } + + public String getHttpHost() { + return getProperty(WEB_HTTP_HOST); + } + + public Integer getSslPort() { + final String rawPort = getProperty(WEB_HTTPS_PORT); + if (StringUtils.isBlank(rawPort)) { + return null; + } + try { + return Integer.parseInt(rawPort); + } catch (final NumberFormatException nfe) { + throw new IllegalStateException(String.format("%s must be an integer value.", WEB_HTTPS_PORT)); + } + } + + public String getHttpsHost() { + return getProperty(WEB_HTTPS_HOST); + } + + public boolean getNeedClientAuth() { + boolean needClientAuth = true; + String rawNeedClientAuth = getProperty(SECURITY_NEED_CLIENT_AUTH); + if ("false".equalsIgnoreCase(rawNeedClientAuth)) { + needClientAuth = false; + } + return needClientAuth; + } + + public String getKeyStorePath() { + return getProperty(SECURITY_KEYSTORE); + } + + public String getKeyStoreType() { + return getProperty(SECURITY_KEYSTORE_TYPE); + } + + public String getKeyStorePassword() { + return getProperty(SECURITY_KEYSTORE_PASSWD); + } + + public String getKeyPassword() { + return getProperty(SECURITY_KEY_PASSWD); + } + + public String getTrustStorePath() { + return getProperty(SECURITY_TRUSTSTORE); + } + + public String getTrustStoreType() { + return getProperty(SECURITY_TRUSTSTORE_TYPE); + } + + public String getTrustStorePassword() { + return getProperty(SECURITY_TRUSTSTORE_PASSWD); + } + + public File getWarLibDirectory() { + return new File(getProperty(WEB_WAR_DIR, DEFAULT_WAR_DIR)); + } + + public File getWebWorkingDirectory() { + return new File(getProperty(WEB_WORKING_DIR, DEFAULT_WEB_WORKING_DIR)); + } + + public File getAuthorizedUsersFile() { + final String authorizedUsersFile = getProperty(SECURITY_AUTHORIZED_USERS); + if (StringUtils.isBlank(authorizedUsersFile)) { + return null; + } + return new File(authorizedUsersFile); + } + +} http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/8c295feb/nifi-registry-resources/pom.xml ---------------------------------------------------------------------- diff --git a/nifi-registry-resources/pom.xml b/nifi-registry-resources/pom.xml new file mode 100644 index 0000000..995441f --- /dev/null +++ b/nifi-registry-resources/pom.xml @@ -0,0 +1,50 @@ +<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.nifi.registry</groupId> + <artifactId>nifi-registry</artifactId> + <version>0.0.1-SNAPSHOT</version> + </parent> + <artifactId>nifi-registry-resources</artifactId> + <packaging>pom</packaging> + <description>holds common resources used to build installers</description> + <build> + <plugins> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <configuration> + <attach>true</attach> + </configuration> + <executions> + <execution> + <id>make shared resource</id> + <goals> + <goal>single</goal> + </goals> + <phase>package</phase> + <configuration> + <descriptors> + <descriptor>src/main/assembly/dependencies.xml</descriptor> + </descriptors> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/8c295feb/nifi-registry-resources/src/main/assembly/dependencies.xml ---------------------------------------------------------------------- diff --git a/nifi-registry-resources/src/main/assembly/dependencies.xml b/nifi-registry-resources/src/main/assembly/dependencies.xml new file mode 100644 index 0000000..fed8098 --- /dev/null +++ b/nifi-registry-resources/src/main/assembly/dependencies.xml @@ -0,0 +1,36 @@ +<?xml version="1.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. +--> +<assembly> + <id>resources</id> + <formats> + <format>zip</format> + </formats> + <includeBaseDirectory>false</includeBaseDirectory> + <fileSets> + <fileSet> + <directory>src/main/resources</directory> + <outputDirectory>/</outputDirectory> + </fileSet> + <fileSet> + <directory>src/main/resources/bin</directory> + <outputDirectory>/bin/</outputDirectory> + <includes> + <include>nifi-registry.sh</include> + </includes> + <fileMode>0750</fileMode> + </fileSet> + </fileSets> +</assembly> http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/8c295feb/nifi-registry-resources/src/main/resources/bin/dump-nifi-registry.bat ---------------------------------------------------------------------- diff --git a/nifi-registry-resources/src/main/resources/bin/dump-nifi-registry.bat b/nifi-registry-resources/src/main/resources/bin/dump-nifi-registry.bat new file mode 100644 index 0000000..0703c2c --- /dev/null +++ b/nifi-registry-resources/src/main/resources/bin/dump-nifi-registry.bat @@ -0,0 +1,47 @@ +@echo off +rem +rem Licensed to the Apache Software Foundation (ASF) under one or more +rem contributor license agreements. See the NOTICE file distributed with +rem this work for additional information regarding copyright ownership. +rem The ASF licenses this file to You under the Apache License, Version 2.0 +rem (the "License"); you may not use this file except in compliance with +rem the License. You may obtain a copy of the License at +rem +rem http://www.apache.org/licenses/LICENSE-2.0 +rem +rem Unless required by applicable law or agreed to in writing, software +rem distributed under the License is distributed on an "AS IS" BASIS, +rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +rem See the License for the specific language governing permissions and +rem limitations under the License. +rem + +rem Use JAVA_HOME if it's set; otherwise, just use java + +if "%JAVA_HOME%" == "" goto noJavaHome +if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome +set JAVA_EXE=%JAVA_HOME%\bin\java.exe +goto startNiFiRegistry + +:noJavaHome +echo The JAVA_HOME environment variable is not defined correctly. +echo Instead the PATH will be used to find the java executable. +echo. +set JAVA_EXE=java +goto startNiFiRegistry + +:startNiFiRegistry +set NIFI_REGISTRY_ROOT=%~dp0..\ +pushd "%NIFI_REGISTRY%" +set LIB_DIR=lib\bootstrap +set CONF_DIR=conf + +set BOOTSTRAP_CONF_FILE=%CONF_DIR%\bootstrap.conf +set JAVA_ARGS=-Dorg.apache.nifi.registry.bootstrap.config.file=%BOOTSTRAP_CONF_FILE% + +SET JAVA_PARAMS=-cp %CONF_DIR%;%LIB_DIR%\* -Xms12m -Xmx24m %JAVA_ARGS% org.apache.nifi.registry.NiFiRegistry +set BOOTSTRAP_ACTION=dump + +cmd.exe /C "%JAVA_EXE%" %JAVA_PARAMS% %BOOTSTRAP_ACTION% + +popd http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/8c295feb/nifi-registry-resources/src/main/resources/bin/nifi-registry.sh ---------------------------------------------------------------------- diff --git a/nifi-registry-resources/src/main/resources/bin/nifi-registry.sh b/nifi-registry-resources/src/main/resources/bin/nifi-registry.sh new file mode 100644 index 0000000..dcd2a6a --- /dev/null +++ b/nifi-registry-resources/src/main/resources/bin/nifi-registry.sh @@ -0,0 +1,216 @@ +#!/bin/sh +# +# 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. + + +# Script structure inspired from Apache Karaf and other Apache projects with similar startup approaches + +NIFI_REGISTRY_HOME=`cd $(dirname "$0") && cd .. && pwd` +PROGNAME=`basename "$0"` + + +warn() { + echo "${PROGNAME}: $*" +} + +die() { + warn "$*" + exit 1 +} + +detectOS() { + # OS specific support (must be 'true' or 'false'). + cygwin=false; + aix=false; + os400=false; + darwin=false; + case "`uname`" in + CYGWIN*) + cygwin=true + ;; + AIX*) + aix=true + ;; + OS400*) + os400=true + ;; + Darwin) + darwin=true + ;; + esac + # For AIX, set an environment variable + if $aix; then + export LDR_CNTRL=MAXDATA=0xB0000000@DSA + echo $LDR_CNTRL + fi +} + +unlimitFD() { + # Use the maximum available, or set MAX_FD != -1 to use that + if [ "x$MAX_FD" = "x" ]; then + MAX_FD="maximum" + fi + + # Increase the maximum file descriptors if we can + if [ "$os400" = "false" ] && [ "$cygwin" = "false" ]; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ "$MAX_FD_LIMIT" != 'unlimited' ]; then + if [ $? -eq 0 ]; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ]; then + # use the system max + MAX_FD="$MAX_FD_LIMIT" + fi + + ulimit -n $MAX_FD > /dev/null + # echo "ulimit -n" `ulimit -n` + if [ $? -ne 0 ]; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query system maximum file descriptor limit: $MAX_FD_LIMIT" + fi + fi + fi +} + + + +locateJava() { + # Setup the Java Virtual Machine + if $cygwin ; then + [ -n "$JAVA" ] && JAVA=`cygpath --unix "$JAVA"` + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + fi + + if [ "x$JAVA" = "x" ] && [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi + if [ "x$JAVA" = "x" ]; then + if [ "x$JAVA_HOME" != "x" ]; then + if [ ! -d "$JAVA_HOME" ]; then + die "JAVA_HOME is not valid: $JAVA_HOME" + fi + JAVA="$JAVA_HOME/bin/java" + else + warn "JAVA_HOME not set; results may vary" + JAVA=`type java` + JAVA=`expr "$JAVA" : '.* \(/.*\)$'` + if [ "x$JAVA" = "x" ]; then + die "java command not found" + fi + fi + fi +} + +init() { + # Determine if there is special OS handling we must perform + detectOS + + # Unlimit the number of file descriptors if possible + unlimitFD + + # Locate the Java VM to execute + locateJava +} + + +install() { + SVC_NAME=nifi-registry + if [ "x$2" != "x" ] ; then + SVC_NAME=$2 + fi + + SVC_FILE=/etc/init.d/$SVC_NAME + cp $0 $SVC_FILE + sed -i s:NIFI_REGISTRY_HOME=.*:NIFI_REGISTRY_HOME="$NIFI_REGISTRY_HOME": $SVC_FILE + sed -i s:PROGNAME=.*:PROGNAME=$(basename "$0"): $SVC_FILE + rm -f /etc/rc2.d/S65${SVC_NAME} + ln -s /etc/init.d/$SVC_NAME /etc/rc2.d/S65${SVC_NAME} + rm -f /etc/rc2.d/K65${SVC_NAME} + ln -s /etc/init.d/$SVC_NAME /etc/rc2.d/K65${SVC_NAME} + echo Service $SVC_NAME installed +} + + +run() { + BOOTSTRAP_CONF="$NIFI_REGISTRY_HOME/conf/bootstrap.conf"; + + run_as=$(grep run.as ${BOOTSTRAP_CONF} | cut -d'=' -f2) + + sudo_cmd_prefix="" + if $cygwin; then + if [[ -n "$run_as" ]]; then + echo "The run.as option is not supported in a Cygwin environment. Exiting." + exit 1 + fi; + + NIFI_REGISTRY_HOME=`cygpath --path --windows "$NIFI_REGISTRY_HOME"` + BOOTSTRAP_CONF=`cygpath --path --windows "$BOOTSTRAP_CONF"` + else + if [[ -n "$run_as" ]]; then + if id -u "$run_as" >/dev/null 2>&1; then + sudo_cmd_prefix="sudo -u ${run_as}" + else + echo "The specified run.as user ${run_as} does not exist. Exiting." + exit 1 + fi + fi; + fi + + echo + echo "Java home: $JAVA_HOME" + echo "NiFi Registry home: $NIFI_REGISTRY_HOME" + echo + echo "Bootstrap Config File: $BOOTSTRAP_CONF" + echo + + # run 'start' in the background because the process will continue to run, monitoring NiFi Registry. + # all other commands will terminate quickly so want to just wait for them + if [ "$1" = "start" ]; then + (cd $NIFI_REGISTRY_HOME && ${sudo_cmd_prefix} "$JAVA" -cp "$NIFI_REGISTRY_HOME"/conf/:"$NIFI_REGISTRY_HOME"/lib/* -Xms512m -Xmx1024m -Dorg.apache.nifi.registry.bootstrap.config.file="$BOOTSTRAP_CONF" org.apache.nifi.registry.NiFiRegistry $@ &) + else + (cd $NIFI_REGISTRY_HOME && ${sudo_cmd_prefix} "$JAVA" -cp "$NIFI_REGISTRY_HOME"/conf/:"$NIFI_REGISTRY_HOME"/lib/* -Xms512m -Xmx1024m -Dorg.apache.nifi.registry.bootstrap.config.file="$BOOTSTRAP_CONF" org.apache.nifi.registry.NiFiRegistry $@) + fi + + # Wait just a bit (3 secs) to wait for the logging to finish and then echo a new-line. + # We do this to avoid having logs spewed on the console after running the command and then not giving + # control back to the user + sleep 3 + echo +} + +main() { + init + run "$@" +} + + +case "$1" in + install) + install "$@" + ;; + start|stop|run|status|dump) + main "$@" + ;; + restart) + init + run "stop" + run "start" + ;; + *) + echo "Usage nifi-registry {start|stop|run|restart|status|dump|install}" + ;; +esac http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/8c295feb/nifi-registry-resources/src/main/resources/bin/run-nifi-registry.bat ---------------------------------------------------------------------- diff --git a/nifi-registry-resources/src/main/resources/bin/run-nifi-registry.bat b/nifi-registry-resources/src/main/resources/bin/run-nifi-registry.bat new file mode 100644 index 0000000..e75e627 --- /dev/null +++ b/nifi-registry-resources/src/main/resources/bin/run-nifi-registry.bat @@ -0,0 +1,48 @@ +@echo off +rem +rem Licensed to the Apache Software Foundation (ASF) under one or more +rem contributor license agreements. See the NOTICE file distributed with +rem this work for additional information regarding copyright ownership. +rem The ASF licenses this file to You under the Apache License, Version 2.0 +rem (the "License"); you may not use this file except in compliance with +rem the License. You may obtain a copy of the License at +rem +rem http://www.apache.org/licenses/LICENSE-2.0 +rem +rem Unless required by applicable law or agreed to in writing, software +rem distributed under the License is distributed on an "AS IS" BASIS, +rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +rem See the License for the specific language governing permissions and +rem limitations under the License. +rem + +rem Use JAVA_HOME if it's set; otherwise, just use java + +if "%JAVA_HOME%" == "" goto noJavaHome +if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome +set JAVA_EXE=%JAVA_HOME%\bin\java.exe +goto startNiFiRegistry + +:noJavaHome +echo The JAVA_HOME environment variable is not defined correctly. +echo Instead the PATH will be used to find the java executable. +echo. +set JAVA_EXE=java +goto startNiFiRegistry + +:startNiFiRegistry +set NIFI_REGISTRY_ROOT=%~dp0.. +pushd "%NIFI_REGISTRY_ROOT%\" +set LIB_DIR=%NIFI_REGISTRY_ROOT%\lib +set CONF_DIR=%NIFI_REGISTRY_ROOT%\conf + +set BOOTSTRAP_CONF_FILE=%CONF_DIR%\bootstrap.conf +set JAVA_ARGS=-Dorg.apache.nifi.registry.bootstrap.config.file=%BOOTSTRAP_CONF_FILE% + +SET JAVA_PARAMS=-cp %CONF_DIR%;%LIB_DIR%\* -Xms512m -Xmx1024m %JAVA_ARGS% org.apache.nifi.registry.NiFiRegistry +set BOOTSTRAP_ACTION=run + +echo cmd.exe /C "%JAVA_EXE%" %JAVA_PARAMS% %BOOTSTRAP_ACTION% +cmd.exe /C "%JAVA_EXE%" %JAVA_PARAMS% %BOOTSTRAP_ACTION% + +popd http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/8c295feb/nifi-registry-resources/src/main/resources/bin/status-nifi-registry.bat ---------------------------------------------------------------------- diff --git a/nifi-registry-resources/src/main/resources/bin/status-nifi-registry.bat b/nifi-registry-resources/src/main/resources/bin/status-nifi-registry.bat new file mode 100644 index 0000000..0e9155a --- /dev/null +++ b/nifi-registry-resources/src/main/resources/bin/status-nifi-registry.bat @@ -0,0 +1,47 @@ +@echo off +rem +rem Licensed to the Apache Software Foundation (ASF) under one or more +rem contributor license agreements. See the NOTICE file distributed with +rem this work for additional information regarding copyright ownership. +rem The ASF licenses this file to You under the Apache License, Version 2.0 +rem (the "License"); you may not use this file except in compliance with +rem the License. You may obtain a copy of the License at +rem +rem http://www.apache.org/licenses/LICENSE-2.0 +rem +rem Unless required by applicable law or agreed to in writing, software +rem distributed under the License is distributed on an "AS IS" BASIS, +rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +rem See the License for the specific language governing permissions and +rem limitations under the License. +rem + +rem Use JAVA_HOME if it's set; otherwise, just use java + +if "%JAVA_HOME%" == "" goto noJavaHome +if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome +set JAVA_EXE=%JAVA_HOME%\bin\java.exe +goto startNiFiRegistry + +:noJavaHome +echo The JAVA_HOME environment variable is not defined correctly. +echo Instead the PATH will be used to find the java executable. +echo. +set JAVA_EXE=java +goto startNiFiRegistry + +:startNiFiRegistry +set NIFI_REGISTRY_ROOT=%~dp0..\ +pushd "%NIFI_REGISTRY_ROOT%" +set LIB_DIR=lib\bootstrap +set CONF_DIR=conf + +set BOOTSTRAP_CONF_FILE=%CONF_DIR%\bootstrap.conf +set JAVA_ARGS=-Dorg.apache.nifi.registry.bootstrap.config.file=%BOOTSTRAP_CONF_FILE% + +set JAVA_PARAMS=-cp %LIB_DIR%\* -Xms12m -Xmx24m %JAVA_ARGS% org.apache.nifi.registry.NiFiRegistry +set BOOTSTRAP_ACTION=status + +cmd.exe /C "%JAVA_EXE%" %JAVA_PARAMS% %BOOTSTRAP_ACTION% + +popd \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/8c295feb/nifi-registry-resources/src/main/resources/conf/authorized-users.xml ---------------------------------------------------------------------- diff --git a/nifi-registry-resources/src/main/resources/conf/authorized-users.xml b/nifi-registry-resources/src/main/resources/conf/authorized-users.xml new file mode 100644 index 0000000..7519756 --- /dev/null +++ b/nifi-registry-resources/src/main/resources/conf/authorized-users.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<!-- + 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. +--> +<users> + <!-- + <user dn="[user dn]"></user> + --> +</users> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/8c295feb/nifi-registry-resources/src/main/resources/conf/bootstrap.conf ---------------------------------------------------------------------- diff --git a/nifi-registry-resources/src/main/resources/conf/bootstrap.conf b/nifi-registry-resources/src/main/resources/conf/bootstrap.conf new file mode 100644 index 0000000..bdbd108 --- /dev/null +++ b/nifi-registry-resources/src/main/resources/conf/bootstrap.conf @@ -0,0 +1,57 @@ +# +# 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. +# + +# Java command to use when running nifi-registry +java=java + +# Username to use when running nifi-registry. This value will be ignored on Windows. +run.as= + +# Configure where nifi-registry's lib and conf directories live +lib.dir=./lib +conf.dir=./conf + +# How long to wait after telling nifi-registry to shutdown before explicitly killing the Process +graceful.shutdown.seconds=20 + +# Disable JSR 199 so that we can use JSP's without running a JDK +java.arg.1=-Dorg.apache.jasper.compiler.disablejsr199=true + +# JVM memory settings +java.arg.2=-Xms512m +java.arg.3=-Xmx512m + +# Enable Remote Debugging +#java.arg.debug=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000 + +java.arg.4=-Djava.net.preferIPv4Stack=true + +# allowRestrictedHeaders is required for Cluster/Node communications to work properly +java.arg.5=-Dsun.net.http.allowRestrictedHeaders=true +java.arg.6=-Djava.protocol.handler.pkgs=sun.net.www.protocol + +# Java 7 and below have issues with Code Cache. The following lines allow us to run well even with +# many classes loaded in the JVM. +#java.arg.7=-XX:ReservedCodeCacheSize=256m +#java.arg.8=-XX:CodeCacheFlushingMinimumFreeSpace=10m +#java.arg.9=-XX:+UseCodeCacheFlushing +#java.arg.11=-XX:PermSize=128M +#java.arg.12=-XX:MaxPermSize=128M + +# The G1GC is still considered experimental but has proven to be very advantageous in providing great +# performance without significant "stop-the-world" delays. +#java.arg.10=-XX:+UseG1GC \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/8c295feb/nifi-registry-resources/src/main/resources/conf/logback.xml ---------------------------------------------------------------------- diff --git a/nifi-registry-resources/src/main/resources/conf/logback.xml b/nifi-registry-resources/src/main/resources/conf/logback.xml new file mode 100644 index 0000000..5ef700d --- /dev/null +++ b/nifi-registry-resources/src/main/resources/conf/logback.xml @@ -0,0 +1,51 @@ +<?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. +--> +<configuration scan="true" scanPeriod="30 seconds"> + <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator"> + <resetJUL>true</resetJUL> + </contextListener> + + <appender name="APP_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>logs/nifi-registry-app.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <!-- + For daily rollover, use 'app_%d.log'. + For hourly rollover, use 'app_%d{yyyy-MM-dd_HH}.log'. + To GZIP rolled files, replace '.log' with '.log.gz'. + To ZIP rolled files, replace '.log' with '.log.zip'. + --> + <fileNamePattern>./logs/nifi-registry-app_%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern> + <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> + <maxFileSize>100MB</maxFileSize> + </timeBasedFileNamingAndTriggeringPolicy> + <!-- keep 30 log files worth of history --> + <maxHistory>30</maxHistory> + </rollingPolicy> + <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> + <pattern>%date %level [%thread] %logger{40} %msg%n</pattern> + <immediateFlush>true</immediateFlush> + </encoder> + </appender> + + <!-- valid logging levels: TRACE, DEBUG, INFO, WARN, ERROR --> + + <logger name="org.apache.nifi.registry" level="INFO"/> + + <root level="INFO"> + <appender-ref ref="APP_FILE"/> + </root> + +</configuration> http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/8c295feb/nifi-registry-resources/src/main/resources/conf/nifi-registry.properties ---------------------------------------------------------------------- diff --git a/nifi-registry-resources/src/main/resources/conf/nifi-registry.properties b/nifi-registry-resources/src/main/resources/conf/nifi-registry.properties new file mode 100644 index 0000000..156db2e --- /dev/null +++ b/nifi-registry-resources/src/main/resources/conf/nifi-registry.properties @@ -0,0 +1,34 @@ +# 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. + +# web properties # +nifi.registry.web.war.directory=${nifi.registry.web.war.directory} +nifi.registry.web.http.host=${nifi.registry.web.http.host} +nifi.registry.web.http.port=${nifi.registry.web.http.port} +nifi.registry.web.https.host=${nifi.registry.web.https.host} +nifi.registry.web.https.port=${nifi.registry.web.https.port} +nifi.registry.web.jetty.working.directory=${nifi.registry.jetty.work.dir} +nifi.registry.web.jetty.threads=${nifi.registry.web.jetty.threads} + +# security properties # +nifi.registry.security.keystore=${nifi.registry.security.keystore} +nifi.registry.security.keystoreType=${nifi.registry.security.keystoreType} +nifi.registry.security.keystorePasswd=${nifi.registry.security.keystorePasswd} +nifi.registry.security.keyPasswd=${nifi.registry.security.keyPasswd} +nifi.registry.security.truststore=${nifi.registry.security.truststore} +nifi.registry.security.truststoreType=${nifi.registry.security.truststoreType} +nifi.registry.security.truststorePasswd=${nifi.registry.security.truststorePasswd} +nifi.registry.security.needClientAuth=${nifi.registry.security.needClientAuth} +nifi.registry.security.authorized.users=${nifi.registry.security.authorized.users} http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/8c295feb/nifi-registry-runtime/pom.xml ---------------------------------------------------------------------- diff --git a/nifi-registry-runtime/pom.xml b/nifi-registry-runtime/pom.xml new file mode 100644 index 0000000..2e42ff3 --- /dev/null +++ b/nifi-registry-runtime/pom.xml @@ -0,0 +1,37 @@ +<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.nifi.registry</groupId> + <artifactId>nifi-registry</artifactId> + <version>0.0.1-SNAPSHOT</version> + </parent> + <artifactId>nifi-registry-runtime</artifactId> + <packaging>jar</packaging> + <dependencies> + <dependency> + <groupId>org.apache.nifi.registry</groupId> + <artifactId>nifi-registry-properties</artifactId> + <version>0.0.1-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.nifi.registry</groupId> + <artifactId>nifi-registry-jetty</artifactId> + <version>0.0.1-SNAPSHOT</version> + </dependency> + </dependencies> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-registry/blob/8c295feb/nifi-registry-runtime/src/main/java/org/apache/nifi/registry/NiFiRegistry.java ---------------------------------------------------------------------- diff --git a/nifi-registry-runtime/src/main/java/org/apache/nifi/registry/NiFiRegistry.java b/nifi-registry-runtime/src/main/java/org/apache/nifi/registry/NiFiRegistry.java new file mode 100644 index 0000000..84b51c0 --- /dev/null +++ b/nifi-registry-runtime/src/main/java/org/apache/nifi/registry/NiFiRegistry.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.registry; + +import org.apache.nifi.registry.jetty.JettyServer; +import org.apache.nifi.registry.properties.NiFiRegistryProperties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.FileReader; +import java.io.IOException; + +/** + * Main entry point for NiFiRegistry. + */ +public class NiFiRegistry { + + private static final Logger logger = LoggerFactory.getLogger(JettyServer.class); + + private static JettyServer server; + + public static void main(final String[] args) { + // register the shutdown hook + Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { + @Override + public void run() { + // shutdown the jetty server + shutdownHook(); + } + })); + + // load the properties + final NiFiRegistryProperties properties = new NiFiRegistryProperties(); + try (final FileReader reader = new FileReader("conf/nifi-registry.properties")) { + properties.load(reader); + } catch (final IOException ioe) { + throw new RuntimeException("Unable to load properties: " + ioe, ioe); + } + + // start the server + server = new JettyServer(properties); + server.start(); + } + + private static void shutdownHook() { + try { + logger.info("Initiating shutdown of Jetty web server..."); + if (server != null) { + server.stop(); + } + logger.info("Jetty web server shutdown completed (nicely or otherwise)."); + } catch (final Throwable t) { + logger.warn("Problem occurred ensuring Jetty web server was properly terminated due to " + t); + } + } +}
