This is an automated email from the ASF dual-hosted git repository.

imesha pushed a commit to branch development
in repository https://gitbox.apache.org/repos/asf/oodt.git


The following commit(s) were added to refs/heads/development by this push:
     new 99186f5  Added isAlive() method to workflow manager. Updated workflow 
manager REST API to use that to determine 'status' of worklfow manager.
99186f5 is described below

commit 99186f5b2130500a9c67809b1a7f236c6bdcc18b
Author: Imesha Sudasingha <[email protected]>
AuthorDate: Sun Sep 22 02:45:39 2019 +0530

    Added isAlive() method to workflow manager. Updated workflow manager REST 
API to use that to determine 'status' of worklfow manager.
---
 .../oodt/cas/product/jaxrs/enums/ErrorType.java    | 68 ++++++++++++++++++++++
 workflow/src/main/avro/types/protocol.avdl         |  2 +
 .../workflow/system/AvroRpcWorkflowManager.java    |  4 ++
 .../system/AvroRpcWorkflowManagerClient.java       | 11 ++++
 .../cas/workflow/system/WorkflowManagerClient.java |  2 +
 .../cas/workflow/system/XmlRpcWorkflowManager.java |  4 ++
 .../system/XmlRpcWorkflowManagerClient.java        | 11 ++++
 .../system/TestXmlRpcWorkflowManagerClient.java    |  4 ++
 8 files changed, 106 insertions(+)

diff --git 
a/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/enums/ErrorType.java
 
b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/enums/ErrorType.java
new file mode 100644
index 0000000..2a2339b
--- /dev/null
+++ 
b/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/jaxrs/enums/ErrorType.java
@@ -0,0 +1,68 @@
+/*
+ * 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.oodt.cas.product.jaxrs.enums;
+
+/**
+ * This is the Enumeration file for storing HTTP Exception types. Use these 
constants instead of
+ * hardcoding errors in REST API implementations
+ *
+ * @author ngimhana (Nadeeshan Gimhana)
+ */
+public enum ErrorType {
+  BAD_REQUEST_EXCEPTION("Malformed message"),
+  BAD_REQUEST_EXCEPTION_REFERENCE_RESOURCE(
+      "This URL requires a productId query parameter with a product ID value,"
+          + " e.g. /reference?productId=1787a257-df87-11e2-8a2d-e3f6264e86c5"),
+
+  BAD_REQUEST_EXCEPTION_PRODUCT_RESOURCE(
+      "Failed to load resource: the server responded with a status of 400"),
+  BAD_REQUEST_EXCEPTION_DATASET_RESOURCE(
+      "This URL requires a productTypeId query parameter and either a "
+          + "product type ID value or 'ALL' for all product types"),
+
+  BAD_REQUEST_EXCEPTION_TRANSFER_RESOURCE(
+      "This URL requires a dataStoreRef query parameter "
+          + "and a data store reference value, e.g. 
/transfer?dataStoreRef=file:/repository/test.txt/test.txt"),
+
+  INTERNAL_SERVER_ERROR("General Server Error"),
+
+  NOT_FOUND_EXCEPTION("Couldn’t find resource"),
+  NOT_FOUND_EXCEPTION_TRANSFER_RESOURCE(
+      "Unable to find a current file transfer status for data store reference: 
"),
+
+  CAS_PRODUCT_EXCEPTION_FILEMGR_CLIENT_UNAVILABLE(
+      "Unable to get the file manager client from the servlet context."),
+  CAS_PRODUCT_EXCEPTION_FILEMGR_WORKING_DIR_UNAVILABLE(
+      "Unable to get the file manager's" + " working directory from the 
servlet context.");
+
+  private String errorType;
+
+  ErrorType(String errorType) {
+    this.errorType = errorType;
+  }
+
+  /** @return the errorType */
+  public String getErrorType() {
+    return errorType;
+  }
+
+  /** @param errorType the errorType to set */
+  public void setErrorType(String errorType) {
+    this.errorType = errorType;
+  }
+}
diff --git a/workflow/src/main/avro/types/protocol.avdl 
b/workflow/src/main/avro/types/protocol.avdl
index 5361630..4db4f84 100644
--- a/workflow/src/main/avro/types/protocol.avdl
+++ b/workflow/src/main/avro/types/protocol.avdl
@@ -72,4 +72,6 @@ import schema "AvroWorkflowInstancePage.avsc";
     boolean updateWorkflowInstanceStatus(
             string workflowInstId, string status);
 
+    boolean isAlive();
+
 }
\ No newline at end of file
diff --git 
a/workflow/src/main/java/org/apache/oodt/cas/workflow/system/AvroRpcWorkflowManager.java
 
b/workflow/src/main/java/org/apache/oodt/cas/workflow/system/AvroRpcWorkflowManager.java
index 2bedd0e..3cf5a04 100644
--- 
a/workflow/src/main/java/org/apache/oodt/cas/workflow/system/AvroRpcWorkflowManager.java
+++ 
b/workflow/src/main/java/org/apache/oodt/cas/workflow/system/AvroRpcWorkflowManager.java
@@ -628,6 +628,10 @@ public class AvroRpcWorkflowManager implements 
WorkflowManager,org.apache.oodt.c
         return doUpdateWorkflowInstance(wInst);
     }
 
+    @Override
+    public boolean isAlive() {
+        return true;
+    }
 
     private static WorkflowEngine getWorkflowEngineFromProperty() {
         return getWorkflowEngineFromClassName(System.getProperty(
diff --git 
a/workflow/src/main/java/org/apache/oodt/cas/workflow/system/AvroRpcWorkflowManagerClient.java
 
b/workflow/src/main/java/org/apache/oodt/cas/workflow/system/AvroRpcWorkflowManagerClient.java
index a237448..57670f3 100644
--- 
a/workflow/src/main/java/org/apache/oodt/cas/workflow/system/AvroRpcWorkflowManagerClient.java
+++ 
b/workflow/src/main/java/org/apache/oodt/cas/workflow/system/AvroRpcWorkflowManagerClient.java
@@ -17,6 +17,7 @@
 
 package org.apache.oodt.cas.workflow.system;
 
+import org.apache.avro.AvroRemoteException;
 import org.apache.avro.ipc.HttpTransceiver;
 import org.apache.avro.ipc.NettyTransceiver;
 import org.apache.avro.ipc.Transceiver;
@@ -249,6 +250,16 @@ public class AvroRpcWorkflowManagerClient implements 
WorkflowManagerClient {
     }
 
     @Override
+    public boolean isAlive() {
+        try {
+            return proxy.isAlive();
+        } catch (AvroRemoteException e) {
+            logger.error("Error occurred when checking if WM is alive", e);
+            return false;
+        }
+    }
+
+    @Override
     public void close() throws IOException {
         if (client != null) {
             client.close();
diff --git 
a/workflow/src/main/java/org/apache/oodt/cas/workflow/system/WorkflowManagerClient.java
 
b/workflow/src/main/java/org/apache/oodt/cas/workflow/system/WorkflowManagerClient.java
index 784b828..4ace82e 100644
--- 
a/workflow/src/main/java/org/apache/oodt/cas/workflow/system/WorkflowManagerClient.java
+++ 
b/workflow/src/main/java/org/apache/oodt/cas/workflow/system/WorkflowManagerClient.java
@@ -131,5 +131,7 @@ public interface WorkflowManagerClient extends Closeable, 
Serializable {
 
     URL getWorkflowManagerUrl();
 
+    boolean isAlive();
+
     void setWorkflowManagerUrl(URL workflowManagerUrl);
 }
diff --git 
a/workflow/src/main/java/org/apache/oodt/cas/workflow/system/XmlRpcWorkflowManager.java
 
b/workflow/src/main/java/org/apache/oodt/cas/workflow/system/XmlRpcWorkflowManager.java
index ae72a14..d1cb28a 100644
--- 
a/workflow/src/main/java/org/apache/oodt/cas/workflow/system/XmlRpcWorkflowManager.java
+++ 
b/workflow/src/main/java/org/apache/oodt/cas/workflow/system/XmlRpcWorkflowManager.java
@@ -654,6 +654,10 @@ public class XmlRpcWorkflowManager implements 
WorkflowManager {
     return doUpdateWorkflowInstance(wInst);
   }
 
+  public boolean isAlive() {
+    return true;
+  }
+
   public static void main(String[] args) throws IOException {
     int portNum = -1;
     String usage = "XmlRpcWorkflowManager --portNum <port number for xml rpc 
service>\n";
diff --git 
a/workflow/src/main/java/org/apache/oodt/cas/workflow/system/XmlRpcWorkflowManagerClient.java
 
b/workflow/src/main/java/org/apache/oodt/cas/workflow/system/XmlRpcWorkflowManagerClient.java
index 4d05b3f..fe31e5c 100644
--- 
a/workflow/src/main/java/org/apache/oodt/cas/workflow/system/XmlRpcWorkflowManagerClient.java
+++ 
b/workflow/src/main/java/org/apache/oodt/cas/workflow/system/XmlRpcWorkflowManagerClient.java
@@ -19,6 +19,7 @@
 package org.apache.oodt.cas.workflow.system;
 
 
+import java.util.Collections;
 import org.apache.oodt.cas.metadata.Metadata;
 import org.apache.oodt.cas.workflow.structs.Workflow;
 import org.apache.oodt.cas.workflow.structs.WorkflowCondition;
@@ -531,6 +532,16 @@ public class XmlRpcWorkflowManagerClient implements 
WorkflowManagerClient {
     }
 
     @Override
+    public boolean isAlive() {
+      try {
+        return (boolean) client.execute("workflowmgr.isAlive", new Vector());
+      } catch (XmlRpcException | IOException e) {
+        LOG.log(Level.SEVERE, "An error occurred when checking WM status", e);
+        return false;
+      }
+    }
+
+    @Override
     public void close() throws IOException {
 
     }
diff --git 
a/workflow/src/test/java/org/apache/oodt/cas/workflow/system/TestXmlRpcWorkflowManagerClient.java
 
b/workflow/src/test/java/org/apache/oodt/cas/workflow/system/TestXmlRpcWorkflowManagerClient.java
index f20127f..e1be1df 100644
--- 
a/workflow/src/test/java/org/apache/oodt/cas/workflow/system/TestXmlRpcWorkflowManagerClient.java
+++ 
b/workflow/src/test/java/org/apache/oodt/cas/workflow/system/TestXmlRpcWorkflowManagerClient.java
@@ -580,6 +580,10 @@ public class TestXmlRpcWorkflowManagerClient {
     assertTrue(checkVal4 && checkVal5);
   }
 
+  @Test
+  public void testIsAlive() {
+    assertTrue(wmc.isAlive());
+  }
 
   private static void startXmlRpcWorkflowManager() {
     System.setProperty("java.util.logging.config.file", new File(

Reply via email to