You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@falcon.apache.org by sh...@apache.org on 2014/01/16 09:43:25 UTC

git commit: FALCON-247 Add scripts to check the status of falcon and prism. Contributed by Jean-Baptiste Onofré

Updated Branches:
  refs/heads/master 934aebd26 -> ec4f43349


FALCON-247 Add scripts to check the status of falcon and prism. Contributed by Jean-Baptiste Onofré


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

Branch: refs/heads/master
Commit: ec4f4334972df1000bf60b3c8c25f0821efaa1fe
Parents: 934aebd
Author: Shwetha GS <sh...@gmail.com>
Authored: Thu Jan 16 14:13:15 2014 +0530
Committer: Shwetha GS <sh...@gmail.com>
Committed: Thu Jan 16 14:13:15 2014 +0530

----------------------------------------------------------------------
 CHANGES.txt                                     |  3 ++
 .../java/org/apache/falcon/cli/FalconCLI.java   | 25 ++++++++--
 .../org/apache/falcon/client/FalconClient.java  |  8 ++++
 src/bin/falcon-status                           | 32 +++++++++++++
 src/bin/prism-status                            | 32 +++++++++++++
 src/bin/service-status.sh                       | 48 ++++++++++++++++++++
 src/main/assemblies/standalone-package.xml      |  2 +
 7 files changed, 146 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/ec4f4334/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 229d4df..50b9ddd 100755
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -8,6 +8,9 @@ Trunk (Unreleased)
     FALCON-238 Support updates at specific time. (Shwetha GS)
    
   IMPROVEMENTS
+    FALCON-247 Add scripts to check the status of falcon and prism. (Jean-Baptiste Onofré
+    via Shwetha GS)
+
     FALCON-245 POM should use Apache POM as parent. (Jean-Baptiste Onofré via Shwetha GS)
 
     FALCON-252 Upgrade to json-simple 1.1.1. (Jean-Baptiste Onofré via Shwetha GS)

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/ec4f4334/client/src/main/java/org/apache/falcon/cli/FalconCLI.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/cli/FalconCLI.java b/client/src/main/java/org/apache/falcon/cli/FalconCLI.java
index 0623074..2016c96 100644
--- a/client/src/main/java/org/apache/falcon/cli/FalconCLI.java
+++ b/client/src/main/java/org/apache/falcon/cli/FalconCLI.java
@@ -47,6 +47,7 @@ public class FalconCLI {
     public static final String FALCON_URL = "FALCON_URL";
     public static final String URL_OPTION = "url";
     public static final String VERSION_OPTION = "version";
+    public static final String STATUS_OPTION = "status";
     public static final String ADMIN_CMD = "admin";
     public static final String HELP_CMD = "help";
     private static final String VERSION_CMD = "version";
@@ -121,7 +122,7 @@ public class FalconCLI {
         parser.addCommand(VERSION_CMD, "", "show client version", new Options(), false);
         parser.addCommand(ENTITY_CMD,
                 "",
-                "Entity opertions like submit, suspend, resume, delete, status, defintion, submitAndSchedule",
+                "Entity operations like submit, suspend, resume, delete, status, definition, submitAndSchedule",
                 entityOptions(), false);
         parser.addCommand(INSTANCE_CMD,
                 "",
@@ -370,11 +371,12 @@ public class FalconCLI {
         adminOptions.addOption(url);
 
         OptionGroup group = new OptionGroup();
-        // Option status = new Option(STATUS_OPTION, false,
-        // "show the current system status");
+        Option status = new Option(STATUS_OPTION, false,
+                "show the current system status");
         Option version = new Option(VERSION_OPTION, false,
                 "show Falcon server build version");
         Option help = new Option("help", false, "show Falcon help");
+        group.addOption(status);
         group.addOption(version);
         group.addOption(help);
 
@@ -574,7 +576,22 @@ public class FalconCLI {
             result = client.getThreadDump();
             OUT.get().println(result);
         }
-        if (optionsList.contains(VERSION_OPTION)) {
+        if (optionsList.contains(STATUS_OPTION)) {
+            int status = 0;
+            try {
+                status = client.getStatus();
+                if (status != 200) {
+                    ERR.get().println("Falcon server is not fully operational (on " + falconUrl + "). Please check log files.");
+                    System.exit(status);
+                } else {
+                    OUT.get().println("Falcon server is running (on " + falconUrl + ")");
+                    System.exit(0);
+                }
+            } catch (Exception e) {
+                ERR.get().println("Falcon server doesn't seem to be running on " + falconUrl);
+                System.exit(-1);
+            }
+        } else if (optionsList.contains(VERSION_OPTION)) {
             result = client.getVersion();
             OUT.get().println("Falcon server build version: " + result);
         } else if (optionsList.contains(HELP_CMD)) {

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/ec4f4334/client/src/main/java/org/apache/falcon/client/FalconClient.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/falcon/client/FalconClient.java b/client/src/main/java/org/apache/falcon/client/FalconClient.java
index f633db5..e64bfe8 100644
--- a/client/src/main/java/org/apache/falcon/client/FalconClient.java
+++ b/client/src/main/java/org/apache/falcon/client/FalconClient.java
@@ -356,6 +356,14 @@ public class FalconClient {
         return sendAdminRequest(AdminOperations.VERSION);
     }
 
+    public int getStatus() throws FalconCLIException {
+        AdminOperations job =  AdminOperations.VERSION;
+        ClientResponse clientResponse = service.path(job.path)
+                .header(REMOTE_USER, USER).accept(job.mimeType)
+                .type(MediaType.TEXT_PLAIN).method(job.method, ClientResponse.class);
+        return clientResponse.getStatus();
+    }
+
     /**
      * Converts a InputStream into ServletInputStream.
      *

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/ec4f4334/src/bin/falcon-status
----------------------------------------------------------------------
diff --git a/src/bin/falcon-status b/src/bin/falcon-status
new file mode 100644
index 0000000..865285c
--- /dev/null
+++ b/src/bin/falcon-status
@@ -0,0 +1,32 @@
+#!/bin/bash
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License. See accompanying LICENSE file.
+#
+
+# resolve links - $0 may be a softlink
+PRG="${0}"
+
+while [ -h "${PRG}" ]; do
+  ls=`ls -ld "${PRG}"`
+  link=`expr "$ls" : '.*-> \(.*\)$'`
+  if expr "$link" : '/.*' > /dev/null; then
+    PRG="$link"
+  else
+    PRG=`dirname "${PRG}"`/"$link"
+  fi
+done
+
+BASEDIR=`dirname ${PRG}`
+BASEDIR=`cd ${BASEDIR}/..;pwd`
+
+exec ${BASEDIR}/bin/service-status.sh falcon
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/ec4f4334/src/bin/prism-status
----------------------------------------------------------------------
diff --git a/src/bin/prism-status b/src/bin/prism-status
new file mode 100644
index 0000000..6b6bb5e
--- /dev/null
+++ b/src/bin/prism-status
@@ -0,0 +1,32 @@
+#!/bin/bash
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License. See accompanying LICENSE file.
+#
+
+# resolve links - $0 may be a softlink
+PRG="${0}"
+
+while [ -h "${PRG}" ]; do
+  ls=`ls -ld "${PRG}"`
+  link=`expr "$ls" : '.*-> \(.*\)$'`
+  if expr "$link" : '/.*' > /dev/null; then
+    PRG="$link"
+  else
+    PRG=`dirname "${PRG}"`/"$link"
+  fi
+done
+
+BASEDIR=`dirname ${PRG}`
+BASEDIR=`cd ${BASEDIR}/..;pwd`
+
+exec ${BASEDIR}/bin/service-status.sh prism
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/ec4f4334/src/bin/service-status.sh
----------------------------------------------------------------------
diff --git a/src/bin/service-status.sh b/src/bin/service-status.sh
new file mode 100644
index 0000000..cd33776
--- /dev/null
+++ b/src/bin/service-status.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License. See accompanying LICENSE file.
+#
+
+# resolve links - $0 may be a softlink
+PRG="${0}"
+
+while [ -h "${PRG}" ]; do
+  ls=`ls -ld "${PRG}"`
+  link=`expr "$ls" : '.*-> \(.*\)$'`
+  if expr "$link" : '/.*' > /dev/null; then
+    PRG="$link"
+  else
+    PRG=`dirname "${PRG}"`/"$link"
+  fi
+done
+
+BASEDIR=`dirname ${PRG}`
+BASEDIR=`cd ${BASEDIR}/..;pwd`
+APP_TYPE=$1
+. ${BASEDIR}/bin/falcon-config.sh 'server' "$APP_TYPE"
+
+# test if the process is running
+if [ -f $FALCON_PID_FILE ]; then
+  if kill -0 `cat $FALCON_PID_FILE` > /dev/null 2>&1; then
+    . ${BASEDIR}/bin/falcon admin -status
+    if [ $? -eq 0 ]; then
+        echo "$APP_TYPE process: `cat $FALCON_PID_FILE`"
+        exit `cat $FALCON_PID_FILE`
+    else
+        exit -2
+    fi
+  fi
+fi
+
+echo $APP_TYPE is not running.
+exit -1
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-falcon/blob/ec4f4334/src/main/assemblies/standalone-package.xml
----------------------------------------------------------------------
diff --git a/src/main/assemblies/standalone-package.xml b/src/main/assemblies/standalone-package.xml
index 685fd5c..1dcf253 100644
--- a/src/main/assemblies/standalone-package.xml
+++ b/src/main/assemblies/standalone-package.xml
@@ -57,9 +57,11 @@
                 <include>falcon</include>
                 <include>falcon-config.sh</include>
                 <include>falcon-start</include>
+                <include>falcon-status</include>
                 <include>falcon-stop</include>
                 <include>service-start.sh</include>
                 <include>service-stop.sh</include>
+                <include>service-status.sh</include>
             </includes>
         </fileSet>