refactor: Common 模块代码格式及注释调整.

pull/161/head
chen.ma 3 years ago
parent e2d01931f7
commit 6206359931

@ -26,7 +26,7 @@ public class Constants {
public static final String GENERAL_SPLIT_SYMBOL = ","; public static final String GENERAL_SPLIT_SYMBOL = ",";
public static final String LONGPOLLING_LINE_SEPARATOR = "\r\n"; public static final String LONG_POLLING_LINE_SEPARATOR = "\r\n";
public static final String BASE_PATH = "/v1/cs"; public static final String BASE_PATH = "/v1/cs";

@ -33,7 +33,7 @@ public class ThreadPoolManager {
} }
private void init() { private void init() {
resourcesManager = new ConcurrentHashMap<String, Map<String, Set<ExecutorService>>>(8); resourcesManager = new ConcurrentHashMap(8);
} }
public void register(String tenantId, String group, ExecutorService executor) { public void register(String tenantId, String group, ExecutorService executor) {

@ -1,6 +1,7 @@
package io.dynamic.threadpool.common.model; package io.dynamic.threadpool.common.model;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable; import java.io.Serializable;
@ -11,6 +12,7 @@ import java.io.Serializable;
* @date 2021/6/16 23:18 * @date 2021/6/16 23:18
*/ */
@Data @Data
@Accessors(chain = true)
public class PoolParameterInfo implements PoolParameter, Serializable { public class PoolParameterInfo implements PoolParameter, Serializable {
private static final long serialVersionUID = -7123935122108553864L; private static final long serialVersionUID = -7123935122108553864L;

@ -89,4 +89,5 @@ public class PoolRunStateInfo implements Serializable {
* Host * Host
*/ */
private String host; private String host;
} }

@ -13,34 +13,20 @@ import io.dynamic.threadpool.common.model.PoolParameterInfo;
*/ */
public class ContentUtil { public class ContentUtil {
/*public static String getPoolContent(PoolParameter parameter) {
StringBuilder stringBuilder = new StringBuilder();
String resultStr = stringBuilder.append(parameter.getCoreSize())
.append(parameter.getMaxSize())
.append(parameter.getQueueType())
.append(parameter.getCapacity())
.append(parameter.getKeepAliveTime())
.append(parameter.getIsAlarm())
.append(parameter.getCapacityAlarm())
.append(parameter.getLivenessAlarm())
.toString();
return resultStr;
}*/
public static String getPoolContent(PoolParameter parameter) { public static String getPoolContent(PoolParameter parameter) {
PoolParameterInfo poolInfo = new PoolParameterInfo(); PoolParameterInfo poolInfo = new PoolParameterInfo();
poolInfo.setTenantId(parameter.getTenantId()); poolInfo.setTenantId(parameter.getTenantId())
poolInfo.setItemId(parameter.getItemId()); .setItemId(parameter.getItemId())
poolInfo.setTpId(parameter.getTpId()); .setTpId(parameter.getTpId())
poolInfo.setCoreSize(parameter.getCoreSize()); .setCoreSize(parameter.getCoreSize())
poolInfo.setMaxSize(parameter.getMaxSize()); .setMaxSize(parameter.getMaxSize())
poolInfo.setQueueType(parameter.getQueueType()); .setQueueType(parameter.getQueueType())
poolInfo.setCapacity(parameter.getCapacity()); .setCapacity(parameter.getCapacity())
poolInfo.setKeepAliveTime(parameter.getKeepAliveTime()); .setKeepAliveTime(parameter.getKeepAliveTime())
poolInfo.setIsAlarm(parameter.getIsAlarm()); .setIsAlarm(parameter.getIsAlarm())
poolInfo.setCapacityAlarm(parameter.getCapacityAlarm()); .setCapacityAlarm(parameter.getCapacityAlarm())
poolInfo.setLivenessAlarm(parameter.getLivenessAlarm()); .setLivenessAlarm(parameter.getLivenessAlarm())
poolInfo.setRejectedType(parameter.getRejectedType()); .setRejectedType(parameter.getRejectedType());
return JSON.toJSONString(poolInfo); return JSON.toJSONString(poolInfo);
} }

@ -9,6 +9,7 @@ import org.springframework.util.StringUtils;
* @date 2021/6/24 21:12 * @date 2021/6/24 21:12
*/ */
public class GroupKey { public class GroupKey {
public static String getKey(String dataId, String group) { public static String getKey(String dataId, String group) {
return getKey(dataId, group, ""); return getKey(dataId, group, "");
} }
@ -34,12 +35,6 @@ public class GroupKey {
return sb.toString(); return sb.toString();
} }
/**
* Parse key.
*
* @param groupKey group key
* @return parsed key
*/
public static String[] parseKey(String groupKey) { public static String[] parseKey(String groupKey) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
String dataId = null; String dataId = null;
@ -88,9 +83,6 @@ public class GroupKey {
return new String[]{dataId, group, tenant}; return new String[]{dataId, group, tenant};
} }
/**
* + -> %2B % -> %25.
*/
public static void urlEncode(String str, StringBuilder sb) { public static void urlEncode(String str, StringBuilder sb) {
for (int idx = 0; idx < str.length(); ++idx) { for (int idx = 0; idx < str.length(); ++idx) {
char c = str.charAt(idx); char c = str.charAt(idx);
@ -103,4 +95,5 @@ public class GroupKey {
} }
} }
} }
} }

@ -32,4 +32,5 @@ public class Result<T> implements Serializable {
public boolean isFail() { public boolean isFail() {
return !isSuccess(); return !isSuccess();
} }
} }

Loading…
Cancel
Save