You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2020/07/29 04:08:03 UTC

[shardingsphere-elasticjob-ui] branch master updated: Fixed unchecked exception

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

zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob-ui.git


The following commit(s) were added to refs/heads/master by this push:
     new 73e6159  Fixed unchecked exception
     new 64c7700  Merge pull request #26 from viviel/uncatched-exception
73e6159 is described below

commit 73e615925c93e1425af513acfd15b372bad4ff89
Author: 郭世雄 <gu...@zmeng123.com>
AuthorDate: Wed Jul 29 11:14:22 2020 +0800

    Fixed unchecked exception
---
 .../cloud/ui/web/controller/CloudAppController.java       | 15 +++++++++++----
 .../cloud/ui/web/controller/CloudOperationController.java |  8 +++++++-
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/shardingsphere-elasticjob-cloud-ui/shardingsphere-elasticjob-cloud-ui-backend/src/main/java/org/apache/shardingsphere/elasticjob/cloud/ui/web/controller/CloudAppController.java b/shardingsphere-elasticjob-cloud-ui/shardingsphere-elasticjob-cloud-ui-backend/src/main/java/org/apache/shardingsphere/elasticjob/cloud/ui/web/controller/CloudAppController.java
index 0659807..2511fa5 100644
--- a/shardingsphere-elasticjob-cloud-ui/shardingsphere-elasticjob-cloud-ui-backend/src/main/java/org/apache/shardingsphere/elasticjob/cloud/ui/web/controller/CloudAppController.java
+++ b/shardingsphere-elasticjob-cloud-ui/shardingsphere-elasticjob-cloud-ui-backend/src/main/java/org/apache/shardingsphere/elasticjob/cloud/ui/web/controller/CloudAppController.java
@@ -31,6 +31,8 @@ import org.apache.shardingsphere.elasticjob.cloud.scheduler.state.disable.app.Di
 import org.apache.shardingsphere.elasticjob.cloud.ui.web.dto.CloudAppConfiguration;
 import org.apache.shardingsphere.elasticjob.cloud.ui.web.response.ResponseResult;
 import org.apache.shardingsphere.elasticjob.cloud.ui.web.response.ResponseResultUtil;
+import org.apache.shardingsphere.elasticjob.infra.exception.JobSystemException;
+import org.codehaus.jettison.json.JSONException;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.DeleteMapping;
@@ -179,10 +181,15 @@ public final class CloudAppController {
     }
     
     private void stopExecutors(final String appName) {
-        Collection<ExecutorStateInfo> executorBriefInfo = mesosStateService.executors(appName);
-        for (ExecutorStateInfo each : executorBriefInfo) {
-            producerManager.sendFrameworkMessage(ExecutorID.newBuilder().setValue(each.getId()).build(),
-                    SlaveID.newBuilder().setValue(each.getSlaveId()).build(), "STOP".getBytes());
+        try {
+            Collection<ExecutorStateInfo> executorBriefInfo = mesosStateService.executors(appName);
+            for (ExecutorStateInfo each : executorBriefInfo) {
+                producerManager.sendFrameworkMessage(ExecutorID.newBuilder().setValue(each.getId()).build(),
+                                                     SlaveID.newBuilder().setValue(each.getSlaveId()).build(),
+                                                     "STOP".getBytes());
+            }
+        } catch (final JSONException ex) {
+            throw new JobSystemException(ex);
         }
     }
     
diff --git a/shardingsphere-elasticjob-cloud-ui/shardingsphere-elasticjob-cloud-ui-backend/src/main/java/org/apache/shardingsphere/elasticjob/cloud/ui/web/controller/CloudOperationController.java b/shardingsphere-elasticjob-cloud-ui/shardingsphere-elasticjob-cloud-ui-backend/src/main/java/org/apache/shardingsphere/elasticjob/cloud/ui/web/controller/CloudOperationController.java
index ca6ec0e..95c1ccb 100644
--- a/shardingsphere-elasticjob-cloud-ui/shardingsphere-elasticjob-cloud-ui-backend/src/main/java/org/apache/shardingsphere/elasticjob/cloud/ui/web/controller/CloudOperationController.java
+++ b/shardingsphere-elasticjob-cloud-ui/shardingsphere-elasticjob-cloud-ui-backend/src/main/java/org/apache/shardingsphere/elasticjob/cloud/ui/web/controller/CloudOperationController.java
@@ -22,7 +22,9 @@ import com.google.common.base.Strings;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shardingsphere.elasticjob.cloud.scheduler.mesos.MesosStateService;
 import org.apache.shardingsphere.elasticjob.cloud.scheduler.mesos.ReconcileService;
+import org.apache.shardingsphere.elasticjob.infra.exception.JobSystemException;
 import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
+import org.codehaus.jettison.json.JSONException;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -91,6 +93,10 @@ public final class CloudOperationController {
     @GetMapping("/sandbox")
     public Collection<Map<String, String>> sandbox(@RequestParam("appName") final String appName) {
         Preconditions.checkArgument(!Strings.isNullOrEmpty(appName), "Lack param 'appName'");
-        return mesosStateService.sandbox(appName);
+        try {
+            return mesosStateService.sandbox(appName);
+        } catch (final JSONException ex) {
+            throw new JobSystemException(ex);
+        }
     }
 }