From 5f82214b2bd78889d85f36e732ffd19f96447c20 Mon Sep 17 00:00:00 2001 From: maxisvest <1447829379@qq.com> Date: Fri, 5 Aug 2022 10:42:39 +0800 Subject: [PATCH] format code --- .../cn/hippo4j/common/toolkit/Singleton.java | 10 +++++----- .../cn/hippo4j/monitor/es/EsClientHolder.java | 17 +++++++++++++++++ .../hippo4j/monitor/es/EsMonitorHandler.java | 8 ++++---- .../es/model/EsThreadPoolRunStateInfo.java | 19 ++++++++++++++++++- 4 files changed, 44 insertions(+), 10 deletions(-) diff --git a/hippo4j-common/src/main/java/cn/hippo4j/common/toolkit/Singleton.java b/hippo4j-common/src/main/java/cn/hippo4j/common/toolkit/Singleton.java index 44a23934..4e5ef959 100644 --- a/hippo4j-common/src/main/java/cn/hippo4j/common/toolkit/Singleton.java +++ b/hippo4j-common/src/main/java/cn/hippo4j/common/toolkit/Singleton.java @@ -28,9 +28,9 @@ import java.util.function.Supplier; */ @NoArgsConstructor(access = AccessLevel.PRIVATE) public final class Singleton { - + private static final ConcurrentHashMap SINGLE_OBJECT_POOL = new ConcurrentHashMap(); - + /** * Get a singleton object by key. * @@ -42,7 +42,7 @@ public final class Singleton { Object result = SINGLE_OBJECT_POOL.get(key); return result == null ? null : (T) result; } - + /** * Get a singleton object by key. * @@ -60,7 +60,7 @@ public final class Singleton { } return result != null ? (T) result : null; } - + /** * Object into container. * @@ -69,7 +69,7 @@ public final class Singleton { public static void put(Object value) { put(value.getClass().getName(), value); } - + /** * Object into container. * diff --git a/hippo4j-monitor/hippo4j-monitor-es/src/main/java/cn/hippo4j/monitor/es/EsClientHolder.java b/hippo4j-monitor/hippo4j-monitor-es/src/main/java/cn/hippo4j/monitor/es/EsClientHolder.java index d100c2a1..0d67adb2 100644 --- a/hippo4j-monitor/hippo4j-monitor-es/src/main/java/cn/hippo4j/monitor/es/EsClientHolder.java +++ b/hippo4j-monitor/hippo4j-monitor-es/src/main/java/cn/hippo4j/monitor/es/EsClientHolder.java @@ -1,3 +1,20 @@ +/* + * 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 cn.hippo4j.monitor.es; import cn.hippo4j.common.config.ApplicationContextHolder; diff --git a/hippo4j-monitor/hippo4j-monitor-es/src/main/java/cn/hippo4j/monitor/es/EsMonitorHandler.java b/hippo4j-monitor/hippo4j-monitor-es/src/main/java/cn/hippo4j/monitor/es/EsMonitorHandler.java index e3c8e407..6a668fb7 100644 --- a/hippo4j-monitor/hippo4j-monitor-es/src/main/java/cn/hippo4j/monitor/es/EsMonitorHandler.java +++ b/hippo4j-monitor/hippo4j-monitor-es/src/main/java/cn/hippo4j/monitor/es/EsMonitorHandler.java @@ -66,7 +66,7 @@ public class EsMonitorHandler extends AbstractDynamicThreadPoolMonitor { if (!this.isExists(indexName)) { List rawMapping = FileUtil.readLines(new File(Thread.currentThread().getContextClassLoader().getResource("mapping.json").getPath()), StandardCharsets.UTF_8); String mapping = String.join(" ", rawMapping); - //if index doesn't exsit, this function may try to create one, but recommend to create index manually. + // if index doesn't exsit, this function may try to create one, but recommend to create index manually. this.createIndex(indexName, "_doc", mapping, null, null, null); } @@ -96,7 +96,7 @@ public class EsMonitorHandler extends AbstractDynamicThreadPoolMonitor { } public synchronized boolean isExists(String index) { - //cache check result + // cache check result if (Objects.isNull(isIndexExist)) { boolean exists = false; GetIndexRequest request = new GetIndexRequest(); @@ -121,8 +121,8 @@ public class EsMonitorHandler extends AbstractDynamicThreadPoolMonitor { } if (!Objects.isNull(shards) && !Objects.isNull(replicas)) { request.settings(Settings.builder() - .put("index.number_of_shards", shards) //5 - .put("index.number_of_replicas", replicas));//1 + .put("index.number_of_shards", shards) // 5 + .put("index.number_of_replicas", replicas));// 1 } if (StringUtils.hasText(alias)) { request.alias(new Alias(alias)); diff --git a/hippo4j-monitor/hippo4j-monitor-es/src/main/java/cn/hippo4j/monitor/es/model/EsThreadPoolRunStateInfo.java b/hippo4j-monitor/hippo4j-monitor-es/src/main/java/cn/hippo4j/monitor/es/model/EsThreadPoolRunStateInfo.java index de5688f0..3fc0deb7 100644 --- a/hippo4j-monitor/hippo4j-monitor-es/src/main/java/cn/hippo4j/monitor/es/model/EsThreadPoolRunStateInfo.java +++ b/hippo4j-monitor/hippo4j-monitor-es/src/main/java/cn/hippo4j/monitor/es/model/EsThreadPoolRunStateInfo.java @@ -1,3 +1,20 @@ +/* + * 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 cn.hippo4j.monitor.es.model; import cn.hippo4j.common.model.ThreadPoolRunStateInfo; @@ -10,7 +27,7 @@ import lombok.Setter; */ @Getter @Setter -public class EsThreadPoolRunStateInfo extends ThreadPoolRunStateInfo{ +public class EsThreadPoolRunStateInfo extends ThreadPoolRunStateInfo { private String Id;