http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/f89f4150/minifi-c2/minifi-c2-assembly/src/main/assembly/dependencies.xml ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-assembly/src/main/assembly/dependencies.xml b/minifi-c2/minifi-c2-assembly/src/main/assembly/dependencies.xml new file mode 100644 index 0000000..026200c --- /dev/null +++ b/minifi-c2/minifi-c2-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>minifi-c2-${project.version}</baseDirectory> + + <dependencySets> + <!-- Write out all non-war dependency artifacts to lib directory --> + <dependencySet> + <outputDirectory>lib</outputDirectory> + <useProjectArtifact>false</useProjectArtifact> + <directoryMode>0770</directoryMode> + <fileMode>0660</fileMode> + <excludes> + <exclude>*:war</exclude> + </excludes> + </dependencySet> + + <!-- Write out all war dependency artifacts to lib directory --> + <dependencySet> + <outputDirectory>webapps</outputDirectory> + <useProjectArtifact>false</useProjectArtifact> + <directoryMode>0770</directoryMode> + <fileMode>0660</fileMode> + <includes> + <include>*:war</include> + </includes> + </dependencySet> + </dependencySets> + <fileSets> + <fileSet> + <directory>${project.basedir}/src/main/resources</directory> + <outputDirectory>/</outputDirectory> + <fileMode>0755</fileMode> + <filtered>true</filtered> + </fileSet> + </fileSets> + <files> + <file> + <source>./README.md</source> + <outputDirectory>./</outputDirectory> + <destName>README</destName> + <fileMode>0644</fileMode> + <filtered>true</filtered> + </file> + <file> + <source>./LICENSE</source> + <outputDirectory>./</outputDirectory> + <destName>LICENSE</destName> + <fileMode>0644</fileMode> + <filtered>true</filtered> + </file> + <file> + <source>./NOTICE</source> + <outputDirectory>./</outputDirectory> + <destName>NOTICE</destName> + <fileMode>0644</fileMode> + <filtered>true</filtered> + </file> + </files> +</assembly>
http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/f89f4150/minifi-c2/minifi-c2-assembly/src/main/resources/bin/c2.bat ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-assembly/src/main/resources/bin/c2.bat b/minifi-c2/minifi-c2-assembly/src/main/resources/bin/c2.bat new file mode 100644 index 0000000..6c02746 --- /dev/null +++ b/minifi-c2/minifi-c2-assembly/src/main/resources/bin/c2.bat @@ -0,0 +1,41 @@ +@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 startConfig + +: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 startConfig + +:startConfig +set LIB_DIR=%~dp0..\conf;%~dp0..\lib + +set C2_SERVER_HOME=%~sdp0..\ + +SET JAVA_PARAMS=-cp %LIB_DIR%\* -Xms12m -Xmx24m %JAVA_ARGS% -Djava.net.preferIPv4Stack=true org.apache.nifi.minifi.c2.jetty.JettyServer + +cmd.exe /C "%JAVA_EXE%" %JAVA_PARAMS% %* + http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/f89f4150/minifi-c2/minifi-c2-assembly/src/main/resources/bin/c2.sh ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-assembly/src/main/resources/bin/c2.sh b/minifi-c2/minifi-c2-assembly/src/main/resources/bin/c2.sh new file mode 100755 index 0000000..c6dc8de --- /dev/null +++ b/minifi-c2/minifi-c2-assembly/src/main/resources/bin/c2.sh @@ -0,0 +1,125 @@ +#!/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 + +SCRIPT_DIR=$(dirname "$0") +SCRIPT_NAME=$(basename "$0") +export C2_SERVER_HOME=$(cd "${SCRIPT_DIR}" && 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 +} + +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 + + # Locate the Java VM to execute + locateJava +} + +run() { + LIBS="${C2_SERVER_HOME}/lib/*" + + sudo_cmd_prefix="" + if $cygwin; then + C2_SERVER_HOME=$(cygpath --path --windows "${C2_SERVER_HOME}") + CLASSPATH="$C2_SERVER_HOME/conf;$(cygpath --path --windows "${LIBS}")" + else + CLASSPATH="$C2_SERVER_HOME/conf:${LIBS}" + fi + + echo + echo "Java home: ${JAVA_HOME}" + echo "C2 Server home: ${C2_SERVER_HOME}" + echo + echo + + if [ "$1" = "debug" ]; then + "${JAVA}" -cp "${CLASSPATH}" -Xms12m -Xmx24m -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 -Djava.net.preferIPv4Stack=true org.apache.nifi.minifi.c2.jetty.JettyServer $@ + else + "${JAVA}" -cp "${CLASSPATH}" -Xms12m -Xmx24m -Djava.net.preferIPv4Stack=true org.apache.nifi.minifi.c2.jetty.JettyServer $@ + fi + return $? +} + +init +run "$@" http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/f89f4150/minifi-c2/minifi-c2-assembly/src/main/resources/conf/authorities.yaml ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-assembly/src/main/resources/conf/authorities.yaml b/minifi-c2/minifi-c2-assembly/src/main/resources/conf/authorities.yaml new file mode 100644 index 0000000..a57dd4c --- /dev/null +++ b/minifi-c2/minifi-c2-assembly/src/main/resources/conf/authorities.yaml @@ -0,0 +1,17 @@ +# 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. + +CN=raspi3, OU=NIFI: + - CLASS_RASPI_3 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/f89f4150/minifi-c2/minifi-c2-assembly/src/main/resources/conf/authorizations.yaml ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-assembly/src/main/resources/conf/authorizations.yaml b/minifi-c2/minifi-c2-assembly/src/main/resources/conf/authorizations.yaml new file mode 100644 index 0000000..7016ff4 --- /dev/null +++ b/minifi-c2/minifi-c2-assembly/src/main/resources/conf/authorizations.yaml @@ -0,0 +1,30 @@ +# 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. + +Default Action: deny +Paths: + /c2/config: + Default Action: deny + Actions: + - Authorization: CLASS_RASPI_3 + Query Parameters: + class: raspi3 + Action: allow + - Authorization: ROLE_SUPERUSER + Action: allow + + # Default authorization lets anonymous pull any config. Remove below to change that. + - Authorization: ROLE_ANONYMOUS + Action: allow \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/f89f4150/minifi-c2/minifi-c2-assembly/src/main/resources/conf/c2.properties ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-assembly/src/main/resources/conf/c2.properties b/minifi-c2/minifi-c2-assembly/src/main/resources/conf/c2.properties new file mode 100644 index 0000000..c68a3e3 --- /dev/null +++ b/minifi-c2/minifi-c2-assembly/src/main/resources/conf/c2.properties @@ -0,0 +1,27 @@ +# +# 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. +# + +minifi.c2.server.port=${minifi.c2.server.port} + +minifi.c2.server.secure=${minifi.c2.server.secure} +minifi.c2.server.keystore=${minifi.c2.server.keystore} +minifi.c2.server.keystoreType=${minifi.c2.server.keystoreType} +minifi.c2.server.keystorePasswd=${minifi.c2.server.keystorePasswd} +minifi.c2.server.keyPasswd=${minifi.c2.server.keyPasswd} +minifi.c2.server.truststore=${minifi.c2.server.truststore} +minifi.c2.server.truststoreType=${minifi.c2.server.truststoreType} +minifi.c2.server.truststorePasswd=${minifi.c2.server.truststorePasswd} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/f89f4150/minifi-c2/minifi-c2-assembly/src/main/resources/conf/logback.xml ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-assembly/src/main/resources/conf/logback.xml b/minifi-c2/minifi-c2-assembly/src/main/resources/conf/logback.xml new file mode 100644 index 0000000..b9a8129 --- /dev/null +++ b/minifi-c2/minifi-c2-assembly/src/main/resources/conf/logback.xml @@ -0,0 +1,38 @@ +<?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="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> + <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> + <pattern>%date %level [%thread] %logger{40} %msg%n</pattern> + </encoder> + </appender> + + <logger name="org.apache.nifi.minifi.c2" level="DEBUG"/> + + <root level="INFO"> + <appender-ref ref="CONSOLE"/> + </root> + +</configuration> http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/f89f4150/minifi-c2/minifi-c2-assembly/src/main/resources/conf/minifi-c2-context.xml ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-assembly/src/main/resources/conf/minifi-c2-context.xml b/minifi-c2/minifi-c2-assembly/src/main/resources/conf/minifi-c2-context.xml new file mode 100644 index 0000000..82a3dfc --- /dev/null +++ b/minifi-c2/minifi-c2-assembly/src/main/resources/conf/minifi-c2-context.xml @@ -0,0 +1,70 @@ +<?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 default-lazy-init="true" + xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:util="http://www.springframework.org/schema/util" + xmlns:context="http://www.springframework.org/schema/context" + xmlns:aop="http://www.springframework.org/schema/aop" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd + http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd"> + + <bean id="configService" class="org.apache.nifi.minifi.c2.service.ConfigService" scope="singleton"> + <constructor-arg> + <list> + <bean class="org.apache.nifi.minifi.c2.provider.cache.CacheConfigurationProvider"> + <constructor-arg> + <value>text/yml</value> + </constructor-arg> + <constructor-arg> + <bean class="org.apache.nifi.minifi.c2.cache.filesystem.FileSystemConfigurationCache"> + <constructor-arg> + <value>./files</value> + </constructor-arg> + <constructor-arg> + <value>\${class}/config.yml</value> + </constructor-arg> + </bean> + </constructor-arg> + </bean> + <!--<bean class="org.apache.nifi.minifi.c2.provider.nifi.rest.NiFiRestConfigurationProvider"> + <constructor-arg> + <bean class="org.apache.nifi.minifi.c2.cache.filesystem.FileSystemConfigurationCache"> + <constructor-arg> + <value>./cache</value> + </constructor-arg> + <constructor-arg> + <value>\${class}/\${class}</value> + </constructor-arg> + </bean> + </constructor-arg> + <constructor-arg> + <value>${minifi.c2.server.provider.nifi.rest.api.url}</value> + </constructor-arg> + </bean>--> + </list> + </constructor-arg> + <constructor-arg> + <bean class="org.apache.nifi.minifi.c2.security.authorization.GrantedAuthorityAuthorizer"> + <constructor-arg value="classpath:authorizations.yaml"/> + </bean> + </constructor-arg> + </bean> +</beans> http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/f89f4150/minifi-c2/minifi-c2-assembly/src/main/resources/conf/minifi-c2-web-security-context.xml ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-assembly/src/main/resources/conf/minifi-c2-web-security-context.xml b/minifi-c2/minifi-c2-assembly/src/main/resources/conf/minifi-c2-web-security-context.xml new file mode 100644 index 0000000..9b3f15c --- /dev/null +++ b/minifi-c2/minifi-c2-assembly/src/main/resources/conf/minifi-c2-web-security-context.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. +--> +<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-3.1.xsd"> + + <bean id="x509AuthenticationProvider" class="org.apache.nifi.minifi.c2.security.authentication.X509AuthenticationProvider"> + <constructor-arg> + <bean class="org.apache.nifi.minifi.c2.security.authorization.PrincipalStringAuthorityGranter"> + <constructor-arg value="classpath:authorities.yaml"/> + </bean> + </constructor-arg> + </bean> + + <bean id="x509AuthenticationFilter" class="org.apache.nifi.minifi.c2.security.authentication.X509AuthenticationFilter"/> + + <bean id="c2AnonymousAuthenticationFilter" class="org.apache.nifi.minifi.c2.security.authentication.C2AnonymousAuthenticationFilter"/> +</beans> http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/f89f4150/minifi-c2/minifi-c2-assembly/src/main/resources/conf/webdefault.xml ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-assembly/src/main/resources/conf/webdefault.xml b/minifi-c2/minifi-c2-assembly/src/main/resources/conf/webdefault.xml new file mode 100644 index 0000000..8a89e1b --- /dev/null +++ b/minifi-c2/minifi-c2-assembly/src/main/resources/conf/webdefault.xml @@ -0,0 +1,556 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + 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-app + xmlns="http://xmlns.jcp.org/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" + metadata-complete="false" + version="3.1"> + + <!-- ===================================================================== --> + <!-- This file contains the default descriptor for web applications. --> + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> + <!-- The intent of this descriptor is to include jetty specific or common --> + <!-- configuration for all webapps. If a context has a webdefault.xml --> + <!-- descriptor, it is applied before the contexts own web.xml file --> + <!-- --> + <!-- A context may be assigned a default descriptor by: --> + <!-- + Calling WebApplicationContext.setDefaultsDescriptor --> + <!-- + Passed an arg to addWebApplications --> + <!-- --> + <!-- This file is used both as the resource within the jetty.jar (which is --> + <!-- used as the default if no explicit defaults descriptor is set) and it --> + <!-- is copied to the etc directory of the Jetty distro and explicitly --> + <!-- by the jetty.xml file. --> + <!-- --> + <!-- ===================================================================== --> + + <description> + Default web.xml file. + This file is applied to a Web application before it's own WEB_INF/web.xml file + </description> + + <!-- ==================================================================== --> + <!-- Removes static references to beans from javax.el.BeanELResolver to --> + <!-- ensure webapp classloader can be released on undeploy --> + <!-- ==================================================================== --> + <listener> + <listener-class>org.eclipse.jetty.servlet.listener.ELContextCleaner</listener-class> + </listener> + + <!-- ==================================================================== --> + <!-- Removes static configurationCache of Methods from java.beans.Introspector to --> + <!-- ensure webapp classloader can be released on undeploy --> + <!-- ==================================================================== --> + <listener> + <listener-class>org.eclipse.jetty.servlet.listener.IntrospectorCleaner</listener-class> + </listener> + + + <!-- ==================================================================== --> + <!-- Context params to control Session Cookies --> + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> + <!-- + UNCOMMENT TO ACTIVATE + <context-param> + <param-name>org.eclipse.jetty.servlet.SessionDomain</param-name> + <param-value>127.0.0.1</param-value> + </context-param> + <context-param> + <param-name>org.eclipse.jetty.servlet.SessionPath</param-name> + <param-value>/</param-value> + </context-param> + <context-param> + <param-name>org.eclipse.jetty.servlet.MaxAge</param-name> + <param-value>-1</param-value> + </context-param> + --> + + <!-- ==================================================================== --> + <!-- The default servlet. --> + <!-- This servlet, normally mapped to /, provides the handling for static --> + <!-- content, OPTIONS and TRACE methods for the context. --> + <!-- The following initParameters are supported: --> + <!-- + * acceptRanges If true, range requests and responses are + * supported + * + * dirAllowed If true, directory listings are returned if no + * welcome file is found. Else 403 Forbidden. + * + * welcomeServlets If true, attempt to dispatch to welcome files + * that are servlets, but only after no matching static + * resources could be found. If false, then a welcome + * file must exist on disk. If "exact", then exact + * servlet matches are supported without an existing file. + * Default is true. + * + * This must be false if you want directory listings, + * but have index.jsp in your welcome file list. + * + * redirectWelcome If true, welcome files are redirected rather than + * forwarded to. + * + * gzip If set to true, then static content will be served as + * gzip content encoded if a matching resource is + * found ending with ".gz" + * + * resourceBase Set to replace the context resource base + * + * resourceCache If set, this is a context attribute name, which the servlet + * will use to look for a shared ResourceCache instance. + * + * relativeResourceBase + * Set with a pathname relative to the base of the + * servlet context root. Useful for only serving static content out + * of only specific subdirectories. + * + * pathInfoOnly If true, only the path info will be applied to the resourceBase + * + * stylesheet Set with the location of an optional stylesheet that will be used + * to decorate the directory listing html. + * + * aliases If True, aliases of resources are allowed (eg. symbolic + * links and caps variations). May bypass security constraints. + * + * etags If True, weak etags will be generated and handled. + * + * maxCacheSize The maximum total size of the configurationCache or 0 for no configurationCache. + * maxCachedFileSize The maximum size of a file to configurationCache + * maxCachedFiles The maximum number of files to configurationCache + * + * useFileMappedBuffer + * If set to true, it will use mapped file buffer to serve static content + * when using NIO connector. Setting this value to false means that + * a direct buffer will be used instead of a mapped file buffer. + * By default, this is set to true. + * + * cacheControl If set, all static content will have this value set as the configurationCache-control + * header. + * + --> + + + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> + <servlet> + <servlet-name>default</servlet-name> + <servlet-class>org.eclipse.jetty.servlet.DefaultServlet</servlet-class> + <init-param> + <param-name>aliases</param-name> + <param-value>false</param-value> + </init-param> + <init-param> + <param-name>acceptRanges</param-name> + <param-value>true</param-value> + </init-param> + <init-param> + <param-name>dirAllowed</param-name> + <param-value>false</param-value> + </init-param> + <init-param> + <param-name>welcomeServlets</param-name> + <param-value>true</param-value> + </init-param> + <init-param> + <param-name>redirectWelcome</param-name> + <param-value>false</param-value> + </init-param> + <init-param> + <param-name>maxCacheSize</param-name> + <param-value>256000000</param-value> + </init-param> + <init-param> + <param-name>maxCachedFileSize</param-name> + <param-value>200000000</param-value> + </init-param> + <init-param> + <param-name>maxCachedFiles</param-name> + <param-value>2048</param-value> + </init-param> + <init-param> + <param-name>gzip</param-name> + <param-value>true</param-value> + </init-param> + <init-param> + <param-name>etags</param-name> + <param-value>false</param-value> + </init-param> + <init-param> + <param-name>useFileMappedBuffer</param-name> + <param-value>true</param-value> + </init-param> + <!-- + <init-param> + <param-name>resourceCache</param-name> + <param-value>resourceCache</param-value> + </init-param> + --> + <!-- + <init-param> + <param-name>cacheControl</param-name> + <param-value>max-age=3600,public</param-value> + </init-param> + --> + <load-on-startup>0</load-on-startup> + </servlet> + + <servlet-mapping> + <servlet-name>default</servlet-name> + <url-pattern>/</url-pattern> + </servlet-mapping> + + + <!-- ==================================================================== --> + <!-- JSP Servlet --> + <!-- This is the jasper JSP servlet from the jakarta project --> + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> + <!-- The JSP page compiler and execution servlet, which is the mechanism --> + <!-- used by Glassfish to support JSP pages. Traditionally, this servlet --> + <!-- is mapped to URL patterh "*.jsp". This servlet supports the --> + <!-- following initialization parameters (default values are in square --> + <!-- brackets): --> + <!-- --> + <!-- checkInterval If development is false and reloading is true, --> + <!-- background compiles are enabled. checkInterval --> + <!-- is the time in seconds between checks to see --> + <!-- if a JSP page needs to be recompiled. [300] --> + <!-- --> + <!-- compiler Which compiler Ant should use to compile JSP --> + <!-- pages. See the Ant documenation for more --> + <!-- information. [javac] --> + <!-- --> + <!-- classdebuginfo Should the class file be compiled with --> + <!-- debugging information? [true] --> + <!-- --> + <!-- classpath What class path should I use while compiling --> + <!-- generated servlets? [Created dynamically --> + <!-- based on the current web application] --> + <!-- Set to ? to make the container explicitly set --> + <!-- this parameter. --> + <!-- --> + <!-- development Is Jasper used in development mode (will check --> + <!-- for JSP modification on every access)? [true] --> + <!-- --> + <!-- enablePooling Determines whether tag handler pooling is --> + <!-- enabled [true] --> + <!-- --> + <!-- fork Tell Ant to fork compiles of JSP pages so that --> + <!-- a separate JVM is used for JSP page compiles --> + <!-- from the one Tomcat is running in. [true] --> + <!-- --> + <!-- ieClassId The class-id value to be sent to Internet --> + <!-- Explorer when using <jsp:plugin> tags. --> + <!-- [clsid:8AD9C840-044E-11D1-B3E9-00805F499D93] --> + <!-- --> + <!-- javaEncoding Java file encoding to use for generating java --> + <!-- source files. [UTF-8] --> + <!-- --> + <!-- keepgenerated Should we keep the generated Java source code --> + <!-- for each page instead of deleting it? [true] --> + <!-- --> + <!-- logVerbosityLevel The level of detailed messages to be produced --> + <!-- by this servlet. Increasing levels cause the --> + <!-- generation of more messages. Valid values are --> + <!-- FATAL, ERROR, WARNING, INFORMATION, and DEBUG. --> + <!-- [WARNING] --> + <!-- --> + <!-- mappedfile Should we generate static content with one --> + <!-- print statement per input line, to ease --> + <!-- debugging? [false] --> + <!-- --> + <!-- --> + <!-- reloading Should Jasper check for modified JSPs? [true] --> + <!-- --> + <!-- suppressSmap Should the generation of SMAP info for JSR45 --> + <!-- debugging be suppressed? [false] --> + <!-- --> + <!-- dumpSmap Should the SMAP info for JSR45 debugging be --> + <!-- dumped to a file? [false] --> + <!-- False if suppressSmap is true --> + <!-- --> + <!-- scratchdir What scratch directory should we use when --> + <!-- compiling JSP pages? [default work directory --> + <!-- for the current web application] --> + <!-- --> + <!-- tagpoolMaxSize The maximum tag handler pool size [5] --> + <!-- --> + <!-- xpoweredBy Determines whether X-Powered-By response --> + <!-- header is added by generated servlet [false] --> + <!-- --> + <!-- If you wish to use Jikes to compile JSP pages: --> + <!-- Set the init parameter "compiler" to "jikes". Define --> + <!-- the property "-Dbuild.compiler.emacs=true" when starting Jetty --> + <!-- to cause Jikes to emit error messages in a format compatible with --> + <!-- Jasper. --> + <!-- If you get an error reporting that jikes can't use UTF-8 encoding, --> + <!-- try setting the init parameter "javaEncoding" to "ISO-8859-1". --> + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> + <servlet id="jsp"> + <servlet-name>jsp</servlet-name> + <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class> + <init-param> + <param-name>logVerbosityLevel</param-name> + <param-value>DEBUG</param-value> + </init-param> + <init-param> + <param-name>fork</param-name> + <param-value>false</param-value> + </init-param> + <init-param> + <param-name>keepgenerated</param-name> + <param-value>true</param-value> + </init-param> + <init-param> + <param-name>development</param-name> + <param-value>false</param-value> + </init-param> + <init-param> + <param-name>xpoweredBy</param-name> + <param-value>false</param-value> + </init-param> + <init-param> + <param-name>compilerTargetVM</param-name> + <param-value>1.7</param-value> + </init-param> + <init-param> + <param-name>compilerSourceVM</param-name> + <param-value>1.7</param-value> + </init-param> + <!-- + <init-param> + <param-name>classpath</param-name> + <param-value>?</param-value> + </init-param> + --> + <load-on-startup>0</load-on-startup> + </servlet> + + <servlet-mapping> + <servlet-name>jsp</servlet-name> + <url-pattern>*.jsp</url-pattern> + <url-pattern>*.jspf</url-pattern> + <url-pattern>*.jspx</url-pattern> + <url-pattern>*.xsp</url-pattern> + <url-pattern>*.JSP</url-pattern> + <url-pattern>*.JSPF</url-pattern> + <url-pattern>*.JSPX</url-pattern> + <url-pattern>*.XSP</url-pattern> + </servlet-mapping> + + + <!-- ==================================================================== --> + <session-config> + <session-timeout>30</session-timeout> + </session-config> + + <!-- ==================================================================== --> + <!-- Default MIME mappings --> + <!-- The default MIME mappings are provided by the mime.properties --> + <!-- resource in the org.eclipse.jetty.server.jar file. Additional or modified --> + <!-- mappings may be specified here --> + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> + <!-- UNCOMMENT TO ACTIVATE + <mime-mapping> + <extension>mysuffix</extension> + <mime-type>mymime/type</mime-type> + </mime-mapping> + --> + + <!-- ==================================================================== --> + <welcome-file-list> + <welcome-file>index.html</welcome-file> + <welcome-file>index.htm</welcome-file> + <welcome-file>index.jsp</welcome-file> + </welcome-file-list> + + <!-- ==================================================================== --> + <locale-encoding-mapping-list> + <locale-encoding-mapping> + <locale>ar</locale> + <encoding>ISO-8859-6</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>be</locale> + <encoding>ISO-8859-5</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>bg</locale> + <encoding>ISO-8859-5</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>ca</locale> + <encoding>ISO-8859-1</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>cs</locale> + <encoding>ISO-8859-2</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>da</locale> + <encoding>ISO-8859-1</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>de</locale> + <encoding>ISO-8859-1</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>el</locale> + <encoding>ISO-8859-7</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>en</locale> + <encoding>ISO-8859-1</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>es</locale> + <encoding>ISO-8859-1</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>et</locale> + <encoding>ISO-8859-1</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>fi</locale> + <encoding>ISO-8859-1</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>fr</locale> + <encoding>ISO-8859-1</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>hr</locale> + <encoding>ISO-8859-2</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>hu</locale> + <encoding>ISO-8859-2</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>is</locale> + <encoding>ISO-8859-1</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>it</locale> + <encoding>ISO-8859-1</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>iw</locale> + <encoding>ISO-8859-8</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>ja</locale> + <encoding>Shift_JIS</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>ko</locale> + <encoding>EUC-KR</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>lt</locale> + <encoding>ISO-8859-2</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>lv</locale> + <encoding>ISO-8859-2</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>mk</locale> + <encoding>ISO-8859-5</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>nl</locale> + <encoding>ISO-8859-1</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>no</locale> + <encoding>ISO-8859-1</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>pl</locale> + <encoding>ISO-8859-2</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>pt</locale> + <encoding>ISO-8859-1</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>ro</locale> + <encoding>ISO-8859-2</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>ru</locale> + <encoding>ISO-8859-5</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>sh</locale> + <encoding>ISO-8859-5</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>sk</locale> + <encoding>ISO-8859-2</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>sl</locale> + <encoding>ISO-8859-2</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>sq</locale> + <encoding>ISO-8859-2</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>sr</locale> + <encoding>ISO-8859-5</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>sv</locale> + <encoding>ISO-8859-1</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>tr</locale> + <encoding>ISO-8859-9</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>uk</locale> + <encoding>ISO-8859-5</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>zh</locale> + <encoding>GB2312</encoding> + </locale-encoding-mapping> + <locale-encoding-mapping> + <locale>zh_TW</locale> + <encoding>Big5</encoding> + </locale-encoding-mapping> + </locale-encoding-mapping-list> + + <security-constraint> + <web-resource-collection> + <web-resource-name>Disable TRACE</web-resource-name> + <url-pattern>/</url-pattern> + <http-method>TRACE</http-method> + </web-resource-collection> + <auth-constraint/> + </security-constraint> + <security-constraint> + <web-resource-collection> + <web-resource-name>Enable everything but TRACE</web-resource-name> + <url-pattern>/</url-pattern> + <http-method-omission>TRACE</http-method-omission> + </web-resource-collection> + </security-constraint> + +</web-app> + http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/f89f4150/minifi-c2/minifi-c2-assembly/src/main/resources/files/raspi3/config.yml.v1 ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-assembly/src/main/resources/files/raspi3/config.yml.v1 b/minifi-c2/minifi-c2-assembly/src/main/resources/files/raspi3/config.yml.v1 new file mode 100644 index 0000000..1a7f872 --- /dev/null +++ b/minifi-c2/minifi-c2-assembly/src/main/resources/files/raspi3/config.yml.v1 @@ -0,0 +1,63 @@ +# 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. + +MiNiFi Config Version: 3 +Flow Controller: + name: MiNiFi Flow + comment: '' +Core Properties: + flow controller graceful shutdown period: 10 sec + flow service write delay interval: 500 ms + administrative yield duration: 30 sec + bored yield duration: 10 millis + max concurrent threads: 1 +FlowFile Repository: + partitions: 256 + checkpoint interval: 2 mins + always sync: false + Swap: + threshold: 20000 + in period: 5 sec + in threads: 1 + out period: 5 sec + out threads: 4 +Content Repository: + content claim max appendable size: 10 MB + content claim max flow files: 100 + always sync: false +Provenance Repository: + provenance rollover time: 1 min +Component Status Repository: + buffer size: 1440 + snapshot frequency: 1 min +Security Properties: + keystore: '' + keystore type: '' + keystore password: '' + key password: '' + truststore: '' + truststore type: '' + truststore password: '' + ssl protocol: '' + Sensitive Props: + key: '' + algorithm: PBEWITHMD5AND256BITAES-CBC-OPENSSL + provider: BC +Processors: [] +Process Groups: [] +Funnels: [] +Connections: [] +Remote Process Groups: [] +NiFi Properties Overrides: {} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/f89f4150/minifi-c2/minifi-c2-cache/minifi-c2-cache-filesystem/pom.xml ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-cache/minifi-c2-cache-filesystem/pom.xml b/minifi-c2/minifi-c2-cache/minifi-c2-cache-filesystem/pom.xml new file mode 100644 index 0000000..b11ddfa --- /dev/null +++ b/minifi-c2/minifi-c2-cache/minifi-c2-cache-filesystem/pom.xml @@ -0,0 +1,35 @@ +<?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> + <artifactId>minifi-c2-cache</artifactId> + <groupId>org.apache.nifi.minifi</groupId> + <version>0.2.0-SNAPSHOT</version> + </parent> + <artifactId>minifi-c2-cache-filesystem</artifactId> + <packaging>jar</packaging> + + <dependencies> + <dependency> + <groupId>org.apache.nifi.minifi</groupId> + <artifactId>minifi-c2-api</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> +</project> http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/f89f4150/minifi-c2/minifi-c2-cache/minifi-c2-cache-filesystem/src/main/java/org/apache/nifi/minifi/c2/cache/filesystem/FileSystemCacheFileInfoImpl.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-cache/minifi-c2-cache-filesystem/src/main/java/org/apache/nifi/minifi/c2/cache/filesystem/FileSystemCacheFileInfoImpl.java b/minifi-c2/minifi-c2-cache/minifi-c2-cache-filesystem/src/main/java/org/apache/nifi/minifi/c2/cache/filesystem/FileSystemCacheFileInfoImpl.java new file mode 100644 index 0000000..ae2c1ae --- /dev/null +++ b/minifi-c2/minifi-c2-cache/minifi-c2-cache-filesystem/src/main/java/org/apache/nifi/minifi/c2/cache/filesystem/FileSystemCacheFileInfoImpl.java @@ -0,0 +1,86 @@ +/* + * 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.minifi.c2.cache.filesystem; + +import org.apache.nifi.minifi.c2.api.ConfigurationProviderException; +import org.apache.nifi.minifi.c2.api.InvalidParameterException; +import org.apache.nifi.minifi.c2.api.cache.ConfigurationCacheFileInfo; +import org.apache.nifi.minifi.c2.api.cache.WriteableConfiguration; +import org.apache.nifi.minifi.c2.api.util.Pair; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Comparator; +import java.util.Objects; +import java.util.stream.Stream; + +public class FileSystemCacheFileInfoImpl implements ConfigurationCacheFileInfo { + private final FileSystemConfigurationCache cache; + private final Path dirPath; + private final String expectedFilename; + private final int expectedFilenameLength; + + public FileSystemCacheFileInfoImpl(FileSystemConfigurationCache cache, Path dirPath, String expectedFilename) { + this.cache = cache; + this.dirPath = dirPath; + this.expectedFilename = expectedFilename; + this.expectedFilenameLength = expectedFilename.length(); + } + + @Override + public Integer getVersionIfMatch(String filename) { + if (!filename.startsWith(expectedFilename) || filename.length() == expectedFilenameLength) { + return null; + } + try { + return Integer.parseInt(filename.substring(expectedFilenameLength)); + } catch (NumberFormatException e) { + return null; + } + } + + @Override + public Stream<WriteableConfiguration> getCachedConfigurations() throws IOException { + return Files.list(dirPath).map(p -> { + Integer version = getVersionIfMatch(p.getFileName().toString()); + if (version == null) { + return null; + } + return new Pair<>(version, p); + }).filter(Objects::nonNull) + .sorted(Comparator.comparing(pair -> ((Pair<Integer, Path>) pair).getFirst()) + .reversed()).map(pair -> new FileSystemWritableConfiguration(cache, pair.getSecond(), Integer.toString(pair.getFirst()))); + } + + @Override + public WriteableConfiguration getConfiguration(Integer version) throws ConfigurationProviderException { + if (version == null) { + try { + return getCachedConfigurations().findFirst().orElseThrow(() -> new ConfigurationProviderException("No configurations found for " + dirPath + "/" + expectedFilename + "[0-9]+")); + } catch (IOException e) { + throw new ConfigurationProviderException("Unable to get cached configurations.", e); + } + } + try { + return new FileSystemWritableConfiguration(cache, cache.resolveChildAndVerifyParent(dirPath, expectedFilename + version), Integer.toString(version)); + } catch (NumberFormatException e) { + throw new InvalidParameterException("Expected numeric version.", e); + } + } +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/f89f4150/minifi-c2/minifi-c2-cache/minifi-c2-cache-filesystem/src/main/java/org/apache/nifi/minifi/c2/cache/filesystem/FileSystemConfigurationCache.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-cache/minifi-c2-cache-filesystem/src/main/java/org/apache/nifi/minifi/c2/cache/filesystem/FileSystemConfigurationCache.java b/minifi-c2/minifi-c2-cache/minifi-c2-cache-filesystem/src/main/java/org/apache/nifi/minifi/c2/cache/filesystem/FileSystemConfigurationCache.java new file mode 100644 index 0000000..ced36a9 --- /dev/null +++ b/minifi-c2/minifi-c2-cache/minifi-c2-cache-filesystem/src/main/java/org/apache/nifi/minifi/c2/cache/filesystem/FileSystemConfigurationCache.java @@ -0,0 +1,80 @@ +/* + * 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.minifi.c2.cache.filesystem; + +import org.apache.nifi.minifi.c2.api.InvalidParameterException; +import org.apache.nifi.minifi.c2.api.cache.ConfigurationCache; +import org.apache.nifi.minifi.c2.api.cache.ConfigurationCacheFileInfo; +import org.apache.nifi.minifi.c2.api.util.Pair; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.Map; +import java.util.regex.Pattern; + +public class FileSystemConfigurationCache implements ConfigurationCache { + private final Path pathRoot; + private final String pathPattern; + + public FileSystemConfigurationCache(String pathRoot, String pathPattern) throws IOException { + this.pathRoot = Paths.get(System.getenv("C2_SERVER_HOME")).resolve(pathRoot).toAbsolutePath(); + Files.createDirectories(this.pathRoot); + this.pathPattern = pathPattern; + } + + protected Path resolveChildAndVerifyParent(Path parent, String s) throws InvalidParameterException { + Path child = parent.resolve(s).toAbsolutePath(); + if (child.toAbsolutePath().getParent().equals(parent)) { + return child; + } else { + throw new InvalidParameterException("Path entry " + s + " not child of " + parent); + } + } + + @Override + public ConfigurationCacheFileInfo getCacheFileInfo(Map<String, List<String>> parameters) throws InvalidParameterException { + String pathString = pathPattern; + for (Map.Entry<String, List<String>> entry : parameters.entrySet()) { + if (entry.getValue().size() != 1) { + throw new InvalidParameterException("Multiple values for same parameter not supported in this provider."); + } + pathString = pathString.replaceAll(Pattern.quote("${" + entry.getKey() + "}"), entry.getValue().get(0)); + } + String[] split = pathString.split("/"); + for (String s1 : split) { + int openBrace = s1.indexOf("${"); + if (openBrace >= 0 && openBrace < s1.length() + 2) { + int closeBrace = s1.indexOf("}", openBrace + 2); + if (closeBrace >= 0) { + throw new InvalidParameterException("Found unsubstituted variable " + s1.substring(openBrace + 2, closeBrace)); + } + } + } + String[] splitPath = split; + Path path = pathRoot.toAbsolutePath(); + for (int i = 0; i < splitPath.length - 1; i++) { + String s = splitPath[i]; + path = resolveChildAndVerifyParent(path, s); + } + Pair<Path, String> dirPathAndFilename = new Pair<>(path, splitPath[splitPath.length - 1]); + return new FileSystemCacheFileInfoImpl(this, dirPathAndFilename.getFirst(), dirPathAndFilename.getSecond() + ".v"); + } +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/f89f4150/minifi-c2/minifi-c2-cache/minifi-c2-cache-filesystem/src/main/java/org/apache/nifi/minifi/c2/cache/filesystem/FileSystemWritableConfiguration.java ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-cache/minifi-c2-cache-filesystem/src/main/java/org/apache/nifi/minifi/c2/cache/filesystem/FileSystemWritableConfiguration.java b/minifi-c2/minifi-c2-cache/minifi-c2-cache-filesystem/src/main/java/org/apache/nifi/minifi/c2/cache/filesystem/FileSystemWritableConfiguration.java new file mode 100644 index 0000000..bb48dcc --- /dev/null +++ b/minifi-c2/minifi-c2-cache/minifi-c2-cache-filesystem/src/main/java/org/apache/nifi/minifi/c2/cache/filesystem/FileSystemWritableConfiguration.java @@ -0,0 +1,94 @@ +/* + * 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.minifi.c2.cache.filesystem; + +import org.apache.nifi.minifi.c2.api.ConfigurationProviderException; +import org.apache.nifi.minifi.c2.api.InvalidParameterException; +import org.apache.nifi.minifi.c2.api.cache.WriteableConfiguration; +import org.apache.nifi.minifi.c2.api.util.DelegatingOutputStream; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardOpenOption; +import java.util.UUID; + +public class FileSystemWritableConfiguration implements WriteableConfiguration { + private final FileSystemConfigurationCache cache; + private final Path path; + private final String version; + + public FileSystemWritableConfiguration(FileSystemConfigurationCache cache, Path path, String version) { + this.cache = cache; + this.path = path; + this.version = version; + } + + @Override + public String getVersion() { + return version; + } + + @Override + public boolean exists() { + return Files.exists(path); + } + + @Override + public OutputStream getOutputStream() throws ConfigurationProviderException { + try { + Path parent = path.getParent(); + Files.createDirectories(parent); + Path tmpPath = cache.resolveChildAndVerifyParent(parent, path.getFileName().toString() + "." + UUID.randomUUID().toString()); + return new DelegatingOutputStream(Files.newOutputStream(tmpPath)) { + @Override + public void close() throws IOException { + super.close(); + Files.move(tmpPath, path); + } + }; + } catch (IOException e) { + throw new ConfigurationProviderException("Unable to open " + path + " for writing.", e); + } + } + + @Override + public InputStream getInputStream() throws ConfigurationProviderException { + try { + return Files.newInputStream(path, StandardOpenOption.READ); + } catch (IOException e) { + if (Files.exists(path)) { + throw new ConfigurationProviderException("Unable to open " + path + " for reading.", e); + } else { + throw new InvalidParameterException("File not found: " + path, e); + } + } + } + + @Override + public String getName() { + return path.getFileName().toString(); + } + + @Override + public String toString() { + return "FileSystemWritableConfiguration{path=" + path + ", version='" + version + "'}"; + } +} http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/f89f4150/minifi-c2/minifi-c2-cache/pom.xml ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-cache/pom.xml b/minifi-c2/minifi-c2-cache/pom.xml new file mode 100644 index 0000000..f452317 --- /dev/null +++ b/minifi-c2/minifi-c2-cache/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> + <artifactId>minifi-c2</artifactId> + <groupId>org.apache.nifi.minifi</groupId> + <version>0.2.0-SNAPSHOT</version> + </parent> + <artifactId>minifi-c2-cache</artifactId> + <packaging>pom</packaging> + + <modules> + <module>minifi-c2-cache-filesystem</module> + </modules> +</project> http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/f89f4150/minifi-c2/minifi-c2-docker/README.md ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-docker/README.md b/minifi-c2/minifi-c2-docker/README.md new file mode 100644 index 0000000..9e0d846 --- /dev/null +++ b/minifi-c2/minifi-c2-docker/README.md @@ -0,0 +1,27 @@ +<!-- + 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 MiNiFi Command And Control Server +------------- +A subproject of Apache NiFi and a complementary data collection approach that supplements the core tenets of NiFi in dataflow management, focusing on the collection of data at the source of its creation. + +Specific goals for the initial thrust of the MiNiFi effort comprise: + +* small and lightweight footprint, +* central management of agents, +* generation of data provenance, and +* integration with NiFi for follow-on dataflow management and full chain of custody of information. + +Perspectives of the role of MiNiFi should be from the perspective of the agent acting immediately at, or directly adjacent to, source sensors, systems, or servers. http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/f89f4150/minifi-c2/minifi-c2-docker/dockerhub/.dockerignore ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-docker/dockerhub/.dockerignore b/minifi-c2/minifi-c2-docker/dockerhub/.dockerignore new file mode 100644 index 0000000..30a2650 --- /dev/null +++ b/minifi-c2/minifi-c2-docker/dockerhub/.dockerignore @@ -0,0 +1,19 @@ +# 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. + +# Place files you want to exclude from the docker build here similar to .gitignore https://docs.docker.com/engine/reference/builder/#dockerignore-file +DockerBuild.sh +DockerRun.sh +DockerImage.txt \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/f89f4150/minifi-c2/minifi-c2-docker/dockerhub/DockerBuild.sh ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-docker/dockerhub/DockerBuild.sh b/minifi-c2/minifi-c2-docker/dockerhub/DockerBuild.sh new file mode 100755 index 0000000..0ce7783 --- /dev/null +++ b/minifi-c2/minifi-c2-docker/dockerhub/DockerBuild.sh @@ -0,0 +1,31 @@ +# 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. + +#!/bin/bash + +DOCKER_UID=1000 +if [ -n "$1" ]; then + DOCKER_UID="$1" +fi + +DOCKER_GID=50 +if [ -n "$2" ]; then + DOCKER_GID="$2" +fi + +DOCKER_IMAGE="$(egrep -v '(^#|^\s*$|^\s*\t*#)' DockerImage.txt)" +MINIFI_C2_IMAGE_VERSION="$(echo $DOCKER_IMAGE | cut -d : -f 2)" +echo "Building MiNiFi C2 Server Image: '$DOCKER_IMAGE' Version: $MINIFI_C2_IMAGE_VERSION" +docker build --build-arg UID="$DOCKER_UID" --build-arg GID="$DOCKER_GID" --build-arg MINIFI_C2_VERSION="$MINIFI_C2_IMAGE_VERSION" -t $DOCKER_IMAGE . http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/f89f4150/minifi-c2/minifi-c2-docker/dockerhub/DockerImage.txt ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-docker/dockerhub/DockerImage.txt b/minifi-c2/minifi-c2-docker/dockerhub/DockerImage.txt new file mode 100644 index 0000000..bc7c4a3 --- /dev/null +++ b/minifi-c2/minifi-c2-docker/dockerhub/DockerImage.txt @@ -0,0 +1,16 @@ +# 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. + +apacheminific2:0.1.0 http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/f89f4150/minifi-c2/minifi-c2-docker/dockerhub/DockerRun.sh ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-docker/dockerhub/DockerRun.sh b/minifi-c2/minifi-c2-docker/dockerhub/DockerRun.sh new file mode 100755 index 0000000..9436848 --- /dev/null +++ b/minifi-c2/minifi-c2-docker/dockerhub/DockerRun.sh @@ -0,0 +1,19 @@ +# 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. + +#!/bin/bash +DOCKER_IMAGE="$(egrep -v '(^#|^\s*$|^\s*\t*#)' DockerImage.txt)" +echo "Running Docker Image: $DOCKER_IMAGE" +docker run -it -d $DOCKER_IMAGE http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/f89f4150/minifi-c2/minifi-c2-docker/dockerhub/Dockerfile ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-docker/dockerhub/Dockerfile b/minifi-c2/minifi-c2-docker/dockerhub/Dockerfile new file mode 100644 index 0000000..f139052 --- /dev/null +++ b/minifi-c2/minifi-c2-docker/dockerhub/Dockerfile @@ -0,0 +1,49 @@ +# 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. +# + +FROM openjdk:8 +MAINTAINER Apache MiNiFi <[email protected]> + +ARG UID=1000 +ARG GID=50 +ARG MINIFI_C2_VERSION=0.2.0 + +ENV MINIFI_C2_BASE_DIR /opt/minifi-c2 +ENV MINIFI_C2_HOME $MINIFI_C2_BASE_DIR/minifi-c2-$MINIFI_C2_VERSION +ENV MINIFI_C2_BINARY_URL https://archive.apache.org/dist/minifi/$MINIFI_C2_VERSION/minifi-c2-$MINIFI_C2_VERSION-bin.tar.gz + +# Setup c2 user +RUN groupadd -g $GID c2 || groupmod -n c2 `getent group $GID | cut -d: -f1` +RUN useradd --shell /bin/bash -u $UID -g $GID -m c2 +RUN mkdir -p $MINIFI_C2_HOME + +# Download, validate, and expand Apache MiNiFi C2 binary. +RUN curl -fSL $MINIFI_C2_BINARY_URL -o $MINIFI_C2_BASE_DIR/minifi-c2-$MINIFI_C2_VERSION-bin.tar.gz \ + && echo "$(curl $MINIFI_C2_BINARY_URL.sha256) *$MINIFI_C2_BASE_DIR/minifi-c2-$MINIFI_C2_VERSION-bin.tar.gz" | sha256sum -c - \ + && tar -xvzf $MINIFI_C2_BASE_DIR/minifi-c2-$MINIFI_C2_VERSION-bin.tar.gz -C $MINIFI_C2_BASE_DIR \ + && rm $MINIFI_C2_BASE_DIR/minifi-c2-$MINIFI_C2_VERSION-bin.tar.gz + +RUN chown -R c2:c2 $MINIFI_C2_HOME + +USER c2 + +#Default http port +EXPOSE 10080 + +# Startup MiNiFi C2 +CMD $MINIFI_C2_HOME/bin/c2.sh http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/f89f4150/minifi-c2/minifi-c2-docker/dockermaven/Dockerfile ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-docker/dockermaven/Dockerfile b/minifi-c2/minifi-c2-docker/dockermaven/Dockerfile new file mode 100644 index 0000000..329a110 --- /dev/null +++ b/minifi-c2/minifi-c2-docker/dockermaven/Dockerfile @@ -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. +# + +FROM openjdk:8 +MAINTAINER Apache MiNiFi <[email protected]> + +ARG UID=1000 +ARG GID=50 +ARG MINIFI_C2_VERSION +ARG MINIFI_C2_BINARY + +ENV MINIFI_C2_BASE_DIR /opt/minifi-c2 +ENV MINIFI_C2_HOME $MINIFI_C2_BASE_DIR/minifi-c2-$MINIFI_C2_VERSION + +# Setup MiNiFi C2 user +RUN groupadd -g $GID c2 || groupmod -n c2 `getent group $GID | cut -d: -f1` +RUN useradd --shell /bin/bash -u $UID -g $GID -m c2 +RUN mkdir -p $MINIFI_C2_HOME + +ADD $MINIFI_C2_BINARY $MINIFI_C2_BASE_DIR +RUN chown -R c2:c2 $MINIFI_C2_HOME + +USER c2 + +#Default http port +EXPOSE 10080 + +# Startup MiNiFi c2 +CMD $MINIFI_C2_HOME/bin/c2.sh run http://git-wip-us.apache.org/repos/asf/nifi-minifi/blob/f89f4150/minifi-c2/minifi-c2-docker/pom.xml ---------------------------------------------------------------------- diff --git a/minifi-c2/minifi-c2-docker/pom.xml b/minifi-c2/minifi-c2-docker/pom.xml new file mode 100644 index 0000000..edf91d4 --- /dev/null +++ b/minifi-c2/minifi-c2-docker/pom.xml @@ -0,0 +1,73 @@ +<?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/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.nifi.minifi</groupId> + <artifactId>minifi-c2</artifactId> + <version>0.2.0-SNAPSHOT</version> + </parent> + + <groupId>org.apache.nifi.minifi</groupId> + <artifactId>minifi-c2-docker</artifactId> + <version>0.2.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <properties> + <minifi.c2.version>${project.version}</minifi.c2.version> + </properties> + + <profiles> + <!-- Profile for building official Docker images. Not bound to build phases since that would require anyone build to have the Docker engine installed on their machine --> + <profile> + <id>docker</id> + <build> + <plugins> + <plugin> + <groupId>com.spotify</groupId> + <artifactId>docker-maven-plugin</artifactId> + <version>0.4.13</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>build</goal> + </goals> + </execution> + </executions> + <configuration> + <imageName>apacheminific2</imageName> + <dockerDirectory>${project.basedir}/dockermaven</dockerDirectory> + <imageTags> + <imageTag>${minifi.c2.version}</imageTag> + </imageTags> + <buildArgs> + <UID>1000</UID> + <GID>1000</GID> + <MINIFI_C2_VERSION>${minifi.c2.version}</MINIFI_C2_VERSION> + <MINIFI_C2_BINARY>minifi-c2-${minifi.c2.version}-bin.tar.gz</MINIFI_C2_BINARY> + </buildArgs> + <resources> + <resource> + <targetPath>/</targetPath> + <directory>${project.basedir}/../minifi-c2-assembly/target</directory> + <include>minifi-c2-${minifi.c2.version}-bin.tar.gz</include> + </resource> + </resources> + </configuration> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project>
