You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rya.apache.org by pu...@apache.org on 2018/03/09 18:21:00 UTC

[14/22] incubator-rya git commit: RYA-446 Making the Rya Streams Query Manager run as a service on CentOS 7.

RYA-446 Making the Rya Streams Query Manager run as a service on CentOS 7.


Project: http://git-wip-us.apache.org/repos/asf/incubator-rya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-rya/commit/a342fe2a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-rya/tree/a342fe2a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-rya/diff/a342fe2a

Branch: refs/heads/master
Commit: a342fe2a88ab8ff64c2a7fc989a96ffbf793ee18
Parents: 4076804
Author: kchilton2 <ke...@gmail.com>
Authored: Thu Feb 1 18:31:41 2018 -0500
Committer: Valiyil <Pu...@parsons.com>
Committed: Fri Mar 9 12:59:53 2018 -0500

----------------------------------------------------------------------
 .../kafka/KafkaRyaStreamsClientFactory.java     |  9 +++-
 extras/rya.streams/query-manager/pom.xml        | 48 ++++++--------------
 .../src/assembly/binary-release.xml             | 30 ------------
 .../query-manager/src/main/README.txt           |  4 +-
 .../src/main/config/configuration.xml           |  2 +-
 .../src/main/scripts/rpm/postinstall.sh         | 21 +++++++++
 .../src/main/scripts/rpm/preremove.sh           | 21 +++++++++
 .../main/scripts/rya-streams-query-manager.sh   |  7 +--
 .../systemd/rya-streams-query-manager.service   | 11 +++--
 9 files changed, 77 insertions(+), 76 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/a342fe2a/extras/rya.streams/kafka/src/main/java/org/apache/rya/streams/kafka/KafkaRyaStreamsClientFactory.java
----------------------------------------------------------------------
diff --git a/extras/rya.streams/kafka/src/main/java/org/apache/rya/streams/kafka/KafkaRyaStreamsClientFactory.java b/extras/rya.streams/kafka/src/main/java/org/apache/rya/streams/kafka/KafkaRyaStreamsClientFactory.java
index 9250d9d..0bf13d1 100644
--- a/extras/rya.streams/kafka/src/main/java/org/apache/rya/streams/kafka/KafkaRyaStreamsClientFactory.java
+++ b/extras/rya.streams/kafka/src/main/java/org/apache/rya/streams/kafka/KafkaRyaStreamsClientFactory.java
@@ -22,6 +22,7 @@ import static java.util.Objects.requireNonNull;
 
 import java.util.Properties;
 import java.util.UUID;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.kafka.clients.CommonClientConfigs;
 import org.apache.kafka.clients.consumer.Consumer;
@@ -54,6 +55,8 @@ import org.apache.rya.streams.kafka.serialization.queries.QueryChangeSerializer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.util.concurrent.AbstractScheduledService.Scheduler;
+
 import edu.umd.cs.findbugs.annotations.DefaultAnnotation;
 import edu.umd.cs.findbugs.annotations.NonNull;
 
@@ -64,6 +67,8 @@ import edu.umd.cs.findbugs.annotations.NonNull;
 public final class KafkaRyaStreamsClientFactory {
     private static final Logger log = LoggerFactory.getLogger(KafkaRyaStreamsClientFactory.class);
 
+    private static final Scheduler SCHEDULER = Scheduler.newFixedDelaySchedule(0, 5, TimeUnit.SECONDS);
+
     /**
      * Initialize a {@link RyaStreamsClient} that will interact with an instance of Rya Streams
      * that is backed by Kafka.
@@ -87,7 +92,7 @@ public final class KafkaRyaStreamsClientFactory {
                 fromStartConsumer(kafkaHostname, kafkaPort, StringDeserializer.class, QueryChangeDeserializer.class);
         final String changeLogTopic = KafkaTopics.queryChangeLogTopic(ryaInstance);
         final QueryChangeLog changeLog = new KafkaQueryChangeLog(queryProducer, queryConsumer, changeLogTopic);
-        final QueryRepository queryRepo = new InMemoryQueryRepository(changeLog);
+        final QueryRepository queryRepo = new InMemoryQueryRepository(changeLog, SCHEDULER);
 
         // Create the Rya Streams client that is backed by a Kafka Query Change Log.
         return new RyaStreamsClient(
@@ -106,7 +111,7 @@ public final class KafkaRyaStreamsClientFactory {
             @Override
             public void close() {
                 try {
-                    queryRepo.close();
+                    queryRepo.stopAndWait();
                 } catch (final Exception e) {
                     log.warn("Couldn't close a QueryRepository.", e);
                 }

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/a342fe2a/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 e459814..d2ccbf5 100644
--- a/extras/rya.streams/query-manager/pom.xml
+++ b/extras/rya.streams/query-manager/pom.xml
@@ -155,21 +155,6 @@ under the License.
                 <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>
@@ -213,6 +198,16 @@ under the License.
                             <defaultDirmode>755</defaultDirmode>
                             <defaultFilemode>644</defaultFilemode>
                             
+                            <!-- (Un)Install scripts that enable/disable the daemon.-->
+                            <postinstallScriptlet>
+                                <scriptFile>${rpm.staging.path}/bin/rpm/postinstall.sh</scriptFile>
+                                <fileEncoding>utf-8</fileEncoding>
+                            </postinstallScriptlet>
+                            <preremoveScriptlet>
+                                <scriptFile>${rpm.staging.path}/bin/rpm/preremove.sh</scriptFile>
+                                <fileEncoding>utf-8</fileEncoding>
+                            </preremoveScriptlet>
+                            
                             <!-- This project requires the Apache Commons Daemon applications. -->
                             <requires>
                                 <require>jsvc</require>
@@ -226,16 +221,14 @@ under the License.
                                         <!-- 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>
+                                            <excludes>
+                                                <exclude>bin/rpm/**</exclude>
+                                                <exclude>bin/rya-streams-query-manager.sh</exclude>
+                                            </excludes>
                                         </source>
                                     </sources>
                                 </mapping>
-                                
+
                                 <!-- Copy over the scripts with the correct execution permissions. -->
                                 <mapping>
                                     <directory>/opt/rya-streams-query-manager-${rpm.version}/bin</directory>
@@ -250,17 +243,6 @@ under the License.
                                         </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>

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/a342fe2a/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
deleted file mode 100644
index 07e2de0..0000000
--- a/extras/rya.streams/query-manager/src/assembly/binary-release.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<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/a342fe2a/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
index 03f9c01..3b2dbfe 100644
--- a/extras/rya.streams/query-manager/src/main/README.txt
+++ b/extras/rya.streams/query-manager/src/main/README.txt
@@ -42,10 +42,10 @@ Java 8
     
  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)
+    Replace the Kafka port if using something other than the default of 9092.
     
  4. Start the service:
-    systemctl start rya-streams-query-manager
+    systemctl start rya-streams-query-manager.service
     
 ### Uninstallation ###
  1. Get the name of the RPM you want to uninstall:

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/a342fe2a/extras/rya.streams/query-manager/src/main/config/configuration.xml
----------------------------------------------------------------------
diff --git a/extras/rya.streams/query-manager/src/main/config/configuration.xml b/extras/rya.streams/query-manager/src/main/config/configuration.xml
index a5e3fb6..96da501 100644
--- a/extras/rya.streams/query-manager/src/main/config/configuration.xml
+++ b/extras/rya.streams/query-manager/src/main/config/configuration.xml
@@ -26,7 +26,7 @@ under the License.
     <queryChangeLogSource>
         <kafka>
             <hostname>[Kafka Broker Hostname]</hostname>
-            <port>[Kafka Broker Port]</port>
+            <port>9092</port>
         </kafka>
     </queryChangeLogSource>
     

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/a342fe2a/extras/rya.streams/query-manager/src/main/scripts/rpm/postinstall.sh
----------------------------------------------------------------------
diff --git a/extras/rya.streams/query-manager/src/main/scripts/rpm/postinstall.sh b/extras/rya.streams/query-manager/src/main/scripts/rpm/postinstall.sh
new file mode 100644
index 0000000..83dbb9e
--- /dev/null
+++ b/extras/rya.streams/query-manager/src/main/scripts/rpm/postinstall.sh
@@ -0,0 +1,21 @@
+#!/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.
+#
+
+systemctl enable /opt/rya-streams-query-manager-${rpm.version}/bin/systemd/rya-streams-query-manager.service
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/a342fe2a/extras/rya.streams/query-manager/src/main/scripts/rpm/preremove.sh
----------------------------------------------------------------------
diff --git a/extras/rya.streams/query-manager/src/main/scripts/rpm/preremove.sh b/extras/rya.streams/query-manager/src/main/scripts/rpm/preremove.sh
new file mode 100644
index 0000000..20a0169
--- /dev/null
+++ b/extras/rya.streams/query-manager/src/main/scripts/rpm/preremove.sh
@@ -0,0 +1,21 @@
+#!/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.
+#
+
+systemctl disable rya-streams-query-manager.service 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/a342fe2a/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
index daa1ae5..ddf61e6 100644
--- 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
@@ -28,7 +28,7 @@ EXEC="/usr/bin/jsvc"
 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"
+CLASS_PATH="$PROJECT_HOME/lib/commons-daemon-1.1.0.jar:$PROJECT_HOME/lib/${project.artifactId}-${project.version}-shaded.jar"
 
 # The fully qualified name of the class to execute. This class must implement the Daemon interface.
 DAEMON_CLASS=org.apache.rya.streams.querymanager.QueryManagerDaemon
@@ -50,8 +50,9 @@ start ()
         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"
+        $EXEC -cp $CLASS_PATH -user root -outfile $LOG_OUT -errfile $LOG_ERR -pidfile $PID \
+              -Dlog4j.configuration="file://$PROJECT_HOME/config/log4j.xml" \
+              $DAEMON_CLASS -c "$PROJECT_HOME/config/configuration.xml"
     fi
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/a342fe2a/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
index 5ff40b6..0709879 100644
--- 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
@@ -18,14 +18,15 @@
 #
 [Unit]
 Description=Rya Streams Query Manager Service
+After=network.target
 
 [Service]
+Type=forking
 PIDFile=/var/run/rya-streams-query-manager.pid
-ExecStart=/opt/rya-streams-query-manager/rya-query-manager.sh start
-ExecStop=/opt/rya-streams-query-manager/rya-query-manager.sh stop
-ExecReload=/opt/rya-streams-query-manager/rya-query-manager.sh restart
-Type=oneshot
+ExecStart=/opt/rya-streams-query-manager-${rpm.version}/bin/rya-streams-query-manager.sh start
+ExecStop=/opt/rya-streams-query-manager-${rpm.version}/bin/rya-streams-query-manager.sh stop
+ExecReload=/opt/rya-streams-query-manager-${rpm.version}/bin/rya-streams-query-manager.sh restart
 Restart=always
 
 [Install]
-Alias=rya-streams-query-manager
\ No newline at end of file
+WantedBy=multi-user.target
\ No newline at end of file