diff options
Diffstat (limited to 'src/main/java/com/geedge/common')
| -rw-r--r-- | src/main/java/com/geedge/common/config/ScheduledPoolConfig.java | 2 | ||||
| -rw-r--r-- | src/main/java/com/geedge/common/util/TsgUtil.java | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/src/main/java/com/geedge/common/config/ScheduledPoolConfig.java b/src/main/java/com/geedge/common/config/ScheduledPoolConfig.java index d538ca7..3cb0d29 100644 --- a/src/main/java/com/geedge/common/config/ScheduledPoolConfig.java +++ b/src/main/java/com/geedge/common/config/ScheduledPoolConfig.java @@ -19,7 +19,7 @@ public class ScheduledPoolConfig implements SchedulingConfigurer { @Override public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler(); - scheduler.setPoolSize(16); + scheduler.setPoolSize(32); scheduler.initialize(); taskRegistrar.setScheduler(scheduler); } diff --git a/src/main/java/com/geedge/common/util/TsgUtil.java b/src/main/java/com/geedge/common/util/TsgUtil.java index 3e5b995..9bf9134 100644 --- a/src/main/java/com/geedge/common/util/TsgUtil.java +++ b/src/main/java/com/geedge/common/util/TsgUtil.java @@ -57,6 +57,25 @@ public class TsgUtil { throw new IllegalArgumentException("failed to get TSG system token."); } + public static JSONObject getObjectItemList(Integer objectId, String objectType) { + Stopwatch watch = Stopwatch.createStarted(); + String response = HttpRequest.get(TSG_URL + "/v1/policy/object/" + objectId + "/item?page_no=1&page_size=1&type=" + objectType) + .header(Header.AUTHORIZATION, getToken()) + .timeout(httpTimeOut) + .execute().body(); + log.info("get tsg-api, cost {} seconds", watch.elapsed(TimeUnit.SECONDS)); + if (StrUtil.isBlank(response)) { + log.error("get {} Object error, response: {}", objectId, response); + throw new RuntimeException("get " + objectId + " Object error, response: " + response); + } + JSONObject jsonObject = JSONUtil.parseObj(response); + if (!"200".equals(jsonObject.get("code").toString())) { + log.error("get {} Object error, response: {}", objectId, response); + throw new RuntimeException("get " + objectId + " Object error, response: " + response); + } + return jsonObject; + } + public static void updateObjectById(Integer id, Map<String, Object> body) { Stopwatch watch = Stopwatch.createStarted(); String response = HttpRequest.put(TSG_URL + "/v1/policy/object/" + id) |
