RYA-446 Create a bin and rpm distribution for the Rya Streams Query Manager application.
Project: http://git-wip-us.apache.org/repos/asf/incubator-rya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-rya/commit/3b05a0b7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-rya/tree/3b05a0b7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-rya/diff/3b05a0b7 Branch: refs/heads/master Commit: 3b05a0b76cdef5ba38503a2d174d81b9bfe044d7 Parents: 16202ac Author: kchilton2 <[email protected]> Authored: Thu Jan 25 17:19:58 2018 -0500 Committer: Valiyil <[email protected]> Committed: Fri Mar 9 12:59:50 2018 -0500 ---------------------------------------------------------------------- extras/rya.streams/query-manager/pom.xml | 131 ++++++++++++++++++- .../src/assembly/binary-release.xml | 30 +++++ .../src/assembly/component-release.xml | 71 ++++++++++ .../query-manager/src/assembly/rpm-staging.xml | 31 +++++ .../query-manager/src/main/README.txt | 55 ++++++++ .../query-manager/src/main/config/log4j.xml | 36 +++++ .../main/scripts/rya-streams-query-manager.sh | 104 +++++++++++++++ .../systemd/rya-streams-query-manager.service | 29 ++++ 8 files changed, 484 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/3b05a0b7/extras/rya.streams/query-manager/pom.xml ---------------------------------------------------------------------- diff --git a/extras/rya.streams/query-manager/pom.xml b/extras/rya.streams/query-manager/pom.xml index deaccdb..e459814 100644 --- a/extras/rya.streams/query-manager/pom.xml +++ b/extras/rya.streams/query-manager/pom.xml @@ -33,6 +33,10 @@ under the License. This module contains the Rya Streams Query Manager. </description> + <properties> + <rpm.staging.path>${project.build.directory}/${project.artifactId}-${project.version}-rpm-staging</rpm.staging.path> + </properties> + <dependencies> <!-- Rya dependencies --> <dependency> @@ -46,7 +50,10 @@ under the License. <artifactId>commons-daemon</artifactId> <version>1.1.0</version> </dependency> - + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + </dependency> <dependency> <groupId>com.beust</groupId> <artifactId>jcommander</artifactId> @@ -97,7 +104,7 @@ under the License. </configuration> </plugin> - <!-- Ensure the generated java source contains the lisence header. --> + <!-- Ensure the generated java source contains the license header. --> <plugin> <groupId>com.mycila</groupId> <artifactId>license-maven-plugin</artifactId> @@ -121,6 +128,7 @@ under the License. </executions> </plugin> + <!-- Create a shaded jar that is able to execute the Daemon. --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> @@ -141,6 +149,123 @@ under the License. </execution> </executions> </plugin> + + <!-- Use the assembly plugin to create the binary and RPM distributions. --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-assembly-plugin</artifactId> + <executions> + <!-- The binary distribution of Rya Streams Query Manager. --> + <execution> + <id>create-binary-distribution</id> + <goals> + <goal>single</goal> + </goals> + <phase>package</phase> + <configuration> + <tarLongFileMode>gnu</tarLongFileMode> + <descriptors> + <descriptor>src/assembly/binary-release.xml</descriptor> + </descriptors> + </configuration> + </execution> + + <!-- Stage the files for the RPM construction. --> + <execution> + <id>stage-content-for-rpms</id> + <goals> + <goal>single</goal> + </goals> + <phase>package</phase> + <configuration> + <!-- This is only staging, so don't attach the built folder to the project. --> + <attach>false</attach> + <descriptors> + <descriptor>src/assembly/rpm-staging.xml</descriptor> + </descriptors> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>rpm-maven-plugin</artifactId> + <executions> + <execution> + <id>set-rpm-properties</id> + <goals> + <goal>version</goal> + </goals> + </execution> + <execution> + <id>create-rpm-distribution</id> + <goals> + <goal>attached-rpm</goal> + </goals> + <phase>package</phase> + <configuration> + <group>${project.groupId}</group> + <name>${project.artifactId}</name> + <classifier>noarch</classifier> + <defaultUsername>root</defaultUsername> + <defaultGroupname>root</defaultGroupname> + <defaultDirmode>755</defaultDirmode> + <defaultFilemode>644</defaultFilemode> + + <!-- This project requires the Apache Commons Daemon applications. --> + <requires> + <require>jsvc</require> + </requires> + + <mappings> + <!-- Copy everything over to the /opt directory, except for the scripts. --> + <mapping> + <directory>/opt/rya-streams-query-manager-${rpm.version}</directory> + <sources> + <!-- Copy over everything exception for the executable script. --> + <source> + <location>${rpm.staging.path}</location> + <includes> + <include>bin/systemd/rya-streams-query-manager.service</include> + <include>config/*</include> + <include>lib/*</include> + <include>README.txt</include> + </includes> + </source> + </sources> + </mapping> + + <!-- Copy over the scripts with the correct execution permissions. --> + <mapping> + <directory>/opt/rya-streams-query-manager-${rpm.version}/bin</directory> + <directoryIncluded>false</directoryIncluded> + <filemode>554</filemode> + <sources> + <source> + <location>${rpm.staging.path}/bin</location> + <includes> + <include>rya-streams-query-manager.sh</include> + </includes> + </source> + </sources> + </mapping> + + <!-- Symbolic link the service file after it has been copied over. --> + <mapping> + <directory>/etc/systemd/system/</directory> + <sources> + <softlinkSource> + <location>/opt/rya-streams-query-manager-${rpm.version}/bin/systemd/rya-streams-query-manager.service</location> + <destination>rya-streams-query-manager.service</destination> + </softlinkSource> + </sources> + </mapping> + </mappings> + </configuration> + </execution> + </executions> + </plugin> </plugins> </build> -</project> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/3b05a0b7/extras/rya.streams/query-manager/src/assembly/binary-release.xml ---------------------------------------------------------------------- diff --git a/extras/rya.streams/query-manager/src/assembly/binary-release.xml b/extras/rya.streams/query-manager/src/assembly/binary-release.xml new file mode 100644 index 0000000..07e2de0 --- /dev/null +++ b/extras/rya.streams/query-manager/src/assembly/binary-release.xml @@ -0,0 +1,30 @@ +<?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. +--> +<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd"> + <id>bin</id> + <formats> + <format>tar.gz</format> + </formats> + <componentDescriptors> + <componentDescriptor>src/assembly/component-release.xml</componentDescriptor> + </componentDescriptors> +</assembly> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/3b05a0b7/extras/rya.streams/query-manager/src/assembly/component-release.xml ---------------------------------------------------------------------- diff --git a/extras/rya.streams/query-manager/src/assembly/component-release.xml b/extras/rya.streams/query-manager/src/assembly/component-release.xml new file mode 100644 index 0000000..f68d53d --- /dev/null +++ b/extras/rya.streams/query-manager/src/assembly/component-release.xml @@ -0,0 +1,71 @@ +<?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. +--> +<component xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/component/1.1.3" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/component/1.1.3 http://maven.apache.org/xsd/component-1.1.3.xsd"> + + <!-- Define the files that will be included in the distribution. --> + <fileSets> + <!-- Configuration files. --> + <fileSet> + <directory>src/main/config</directory> + <outputDirectory>config</outputDirectory> + <lineEnding>unix</lineEnding> + </fileSet> + + <!-- Linux Scripts. --> + <fileSet> + <directory>src/main/scripts</directory> + <outputDirectory>bin</outputDirectory> + <lineEnding>unix</lineEnding> + <filtered>true</filtered> + </fileSet> + + <!-- The README.txt file. --> + <fileSet> + <directory>src/main</directory> + <outputDirectory></outputDirectory> + <includes> + <include>README.txt</include> + </includes> + <lineEnding>unix</lineEnding> + <filtered>true</filtered> + </fileSet> + + <!-- The shaded jar that is executed to run the program. --> + <fileSet> + <directory>${project.build.directory}</directory> + <outputDirectory>lib</outputDirectory> + <includes> + <include>${project.artifactId}-${project.version}-shaded.jar</include> + </includes> + </fileSet> + </fileSets> + + <!-- The commons-daemon jar file. --> + <dependencySets> + <dependencySet> + <outputDirectory>lib</outputDirectory> + <includes> + <include>commons-daemon:commons-daemon</include> + </includes> + </dependencySet> + </dependencySets> +</component> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/3b05a0b7/extras/rya.streams/query-manager/src/assembly/rpm-staging.xml ---------------------------------------------------------------------- diff --git a/extras/rya.streams/query-manager/src/assembly/rpm-staging.xml b/extras/rya.streams/query-manager/src/assembly/rpm-staging.xml new file mode 100644 index 0000000..09b3bf2 --- /dev/null +++ b/extras/rya.streams/query-manager/src/assembly/rpm-staging.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. +--> +<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd"> + <id>rpm-staging</id> + <formats> + <format>dir</format> + </formats> + <includeBaseDirectory>false</includeBaseDirectory> + <componentDescriptors> + <componentDescriptor>src/assembly/component-release.xml</componentDescriptor> + </componentDescriptors> +</assembly> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/3b05a0b7/extras/rya.streams/query-manager/src/main/README.txt ---------------------------------------------------------------------- diff --git a/extras/rya.streams/query-manager/src/main/README.txt b/extras/rya.streams/query-manager/src/main/README.txt new file mode 100644 index 0000000..03f9c01 --- /dev/null +++ b/extras/rya.streams/query-manager/src/main/README.txt @@ -0,0 +1,55 @@ +# 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: rya-streams-query-manager +Version: ${project.version} + +### Description ### +The Rya Streams Query Manager daemon service is an application that notices +when new Rya instances are registered to use Rya Streams and then reacts to +query create/delete/start/stop requests. Users may use the Rya Shell to issue +those commands. + +This version of the manager only supports Kafka sources and it runs every query +as a single threaded Kafka Streams job. All of the queries are processed within +a single JVM, so it is only suitable for a single node instance of Rya. This +version does not scale. + +### Requirements ### +CentOS 7 +JSVC +Java 8 + +### Installation ### + 1. Copy over the RPM to the machine that will run the daemon. + + 2. Use yum to install the RPM: + yum install -y ${project.artifactId}-${project.version}.noarch.rpm + + 3. Update the configuration file: + Replace "[Kafka Broker Hostname]" with the IP address of the Kafka broker. + Replace "[Kafka Broker Port]" with the port of the Kafka broker (usually 9092) + + 4. Start the service: + systemctl start rya-streams-query-manager + +### Uninstallation ### + 1. Get the name of the RPM you want to uninstall: + rpm -qa | grep rya.streams.query-manager + + 2. Uninstall it: + rpm -e <the value from the last command here> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/3b05a0b7/extras/rya.streams/query-manager/src/main/config/log4j.xml ---------------------------------------------------------------------- diff --git a/extras/rya.streams/query-manager/src/main/config/log4j.xml b/extras/rya.streams/query-manager/src/main/config/log4j.xml new file mode 100644 index 0000000..2021638 --- /dev/null +++ b/extras/rya.streams/query-manager/src/main/config/log4j.xml @@ -0,0 +1,36 @@ +<?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. +--> +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> +<log4j:configuration debug="true" + xmlns:log4j='http://jakarta.apache.org/log4j/'> + + <appender name="console" class="org.apache.log4j.ConsoleAppender"> + <layout class="org.apache.log4j.PatternLayout"> + <param name="ConversionPattern" + value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" /> + </layout> + </appender> + + <root> + <level value="INFO" /> + <appender-ref ref="console" /> + </root> + +</log4j:configuration> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/3b05a0b7/extras/rya.streams/query-manager/src/main/scripts/rya-streams-query-manager.sh ---------------------------------------------------------------------- diff --git a/extras/rya.streams/query-manager/src/main/scripts/rya-streams-query-manager.sh b/extras/rya.streams/query-manager/src/main/scripts/rya-streams-query-manager.sh new file mode 100644 index 0000000..daa1ae5 --- /dev/null +++ b/extras/rya.streams/query-manager/src/main/scripts/rya-streams-query-manager.sh @@ -0,0 +1,104 @@ +#!/bin/bash +# +# 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. +# + +NAME=rya-streams-query-manager +DESC="Rya Streams Query Manager Daemon service" + +# The path to JSVC +EXEC="/usr/bin/jsvc" + +# Get the parent directory of the dir this script resides within. +PROJECT_HOME=$(dirname $(cd $(dirname $0) && pwd)) + +# This classpath must contain the commons-daemon jar as well as the jar we're executing. +CLASS_PATH="$PROJECT_HOME/lib/commons-daemon-1.1.0.jar:$PROJECT_HOME/lib/${project.artifactId}-${project.version}-shaded.jar:$PROJECT_HOME/config/log4j.xml" + +# The fully qualified name of the class to execute. This class must implement the Daemon interface. +DAEMON_CLASS=org.apache.rya.streams.querymanager.QueryManagerDaemon + +# The PID file that indicates if rya-streams-query-manager is running. +PID="/var/run/$NAME.pid" + +# System.out writes to this file... +LOG_OUT="$PROJECT_HOME/logs/$NAME.out" + +# System.err writes to this file... +LOG_ERR="$PROJECT_HOME/logs/$NAME.err" + +start () +{ + if [ -f "$PID" ] + then + echo "The $DESC is already running." + exit 1 + else + echo "Starting the $DESC." + $EXEC -cp $CLASS_PATH -user root -outfile $LOG_OUT -errfile $LOG_ERR -pidfile $PID $1 $DAEMON_CLASS \ + -c "$PROJECT_HOME/config/configuration.xml" + fi +} + +stop () +{ + if [ -f "$PID" ] + then + echo "Stopping the $DESC." + $EXEC -cp $CLASS_PATH -user root -outfile $LOG_OUT -errfile $LOG_ERR -pidfile $PID -stop $DAEMON_CLASS + else + echo "The $DESC is already stopped." + fi +} + +status () +{ + if [ -f "$PID" ] + then + echo "The $DESC is running." + else + echo "The $DESC is stopped." + fi +} + +restart () +{ + echo "Restarting the $DESC..." + if [ -f "$PID" ]; then + # Stop the service + stop + fi + + # Start the service + start + echo "The $DESC has restarted." +} + +usage () +{ + echo "usage: rya-streams-query-manager.sh (start|stop|status|restart)" + exit 1 +} + +case "$1" in + start) start ;; + stop) stop ;; + status) status ;; + restart) restart ;; + *) usage ;; +esac \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/3b05a0b7/extras/rya.streams/query-manager/src/main/scripts/systemd/rya-streams-query-manager.service ---------------------------------------------------------------------- diff --git a/extras/rya.streams/query-manager/src/main/scripts/systemd/rya-streams-query-manager.service b/extras/rya.streams/query-manager/src/main/scripts/systemd/rya-streams-query-manager.service new file mode 100644 index 0000000..0ec41c5 --- /dev/null +++ b/extras/rya.streams/query-manager/src/main/scripts/systemd/rya-streams-query-manager.service @@ -0,0 +1,29 @@ +# +# 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. +# + +TODO This will be the service file installed to CentOS 7 for systemd integration. + +[Units] +TODO + +[Service] +TODO + +[Install] +TODO \ No newline at end of file
