package com.ld.igds.protocol.quantity.shuhan;
|
|
import java.util.HashMap;
|
import java.util.Map;
|
|
/**
|
* 工具类
|
*
|
* @author Andy
|
*/
|
public class ShuHanUtils {
|
|
/**
|
* 心跳管理MAP
|
*/
|
public static Map<String, Long> contextHeartBeat = new HashMap<>();
|
|
|
public static final String MSG_END = "<EEEE>";
|
public static final String MSG_START = "<FZZY>";
|
public static final String CHARSET = "UTF-8";
|
|
public static final String REDIS_KEY_QUANTITY = "REDIS_KEY_QUANTITY_";
|
|
/**
|
* 单次心跳间隔时间 单位:秒
|
*/
|
public static final int HEART_BEAT_TIME = 5 * 60;
|
|
|
public static String getServerKey(String ip, int port) {
|
return ip + ":" + port;
|
}
|
|
|
public static void addHeartBeat(String key) {
|
contextHeartBeat.put(key, System.currentTimeMillis());
|
}
|
|
public static void addHeartBeat(String ip, int port) {
|
contextHeartBeat.put(getServerKey(ip, port), System.currentTimeMillis());
|
}
|
|
public static Long getHeartBeat(String ip, int port) {
|
return contextHeartBeat.get(getServerKey(ip, port));
|
}
|
|
public static void delHeartBeat(String ip, int port) {
|
contextHeartBeat.remove(getServerKey(ip, port));
|
}
|
|
}
|