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 LONGPOLLING_LINE_SEPARATOR = "\r\n";
public static final String LONG_POLLING_LINE_SEPARATOR = "\r\n";
public static final String BASE_PATH = "/v1/cs";

@ -33,7 +33,7 @@ public class ThreadPoolManager {
}
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) {

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

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

@ -13,34 +13,20 @@ import io.dynamic.threadpool.common.model.PoolParameterInfo;
*/
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) {
PoolParameterInfo poolInfo = new PoolParameterInfo();
poolInfo.setTenantId(parameter.getTenantId());
poolInfo.setItemId(parameter.getItemId());
poolInfo.setTpId(parameter.getTpId());
poolInfo.setCoreSize(parameter.getCoreSize());
poolInfo.setMaxSize(parameter.getMaxSize());
poolInfo.setQueueType(parameter.getQueueType());
poolInfo.setCapacity(parameter.getCapacity());
poolInfo.setKeepAliveTime(parameter.getKeepAliveTime());
poolInfo.setIsAlarm(parameter.getIsAlarm());
poolInfo.setCapacityAlarm(parameter.getCapacityAlarm());
poolInfo.setLivenessAlarm(parameter.getLivenessAlarm());
poolInfo.setRejectedType(parameter.getRejectedType());
poolInfo.setTenantId(parameter.getTenantId())
.setItemId(parameter.getItemId())
.setTpId(parameter.getTpId())
.setCoreSize(parameter.getCoreSize())
.setMaxSize(parameter.getMaxSize())
.setQueueType(parameter.getQueueType())
.setCapacity(parameter.getCapacity())
.setKeepAliveTime(parameter.getKeepAliveTime())
.setIsAlarm(parameter.getIsAlarm())
.setCapacityAlarm(parameter.getCapacityAlarm())
.setLivenessAlarm(parameter.getLivenessAlarm())
.setRejectedType(parameter.getRejectedType());
return JSON.toJSONString(poolInfo);
}

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

Loading…
Cancel
Save