Beispiel #1
0
 @Override
 public MapResult handleMonitor(HostInfo slaveHost) {
   if (slaveHost == null) {
     return ResultUtils.mapResult(MemoryCacheErrorCode.NOTIFY_HANDLE_ARG_INVALID);
   }
   boolean found = getSlaveHost(slaveHost) != null;
   return ResultUtils.mapResult("status", found);
 }
Beispiel #2
0
 @Override
 public MapResult handleSlaveUnRegister(final HostInfo slaveHost) {
   if (slaveHost == null) {
     return ResultUtils.mapResult(MemoryCacheErrorCode.NOTIFY_HANDLE_ARG_INVALID);
   }
   T key = getSlaveHost(slaveHost);
   if (key == null) {
     return ResultUtils.mapResult(
         MemoryCacheErrorCode.NOTIFY_UNREGISTER_UNKNOWN_HOST,
         HttpUtils.hostInfoToString(slaveHost));
   }
   slaveHostMap.remove(key);
   log.info("Slave注销缓存处理完成, slaveHost: " + slaveHost);
   return ResultUtils.mapResult("msg", "注销成功");
 }
Beispiel #3
0
 @Override
 public MapResult handleSlaveRegister(final LocalRegisterParam param) {
   if (param.getSlaveHost() == null
       || param.getInterestCache() == null
       || param.getInterestCache().isEmpty()) {
     log.warn(
         "Slave注册参数不全: slaveHost: "
             + param.getSlaveHost()
             + ", interestCache: "
             + param.getInterestCache());
     return ResultUtils.mapResult(MemoryCacheErrorCode.NOTIFY_HANDLE_ARG_INVALID);
   }
   final T slaveInfo;
   try {
     slaveInfo = createSlaveInfo(param);
   } catch (Throwable e) {
     log.error("注册时创建slaveHost信息存在异常", e);
     return ResultUtils.mapResult(
         MemoryCacheErrorCode.NOTIFY_RUNTIME_ERROR, "注册时创建slaveHost信息异常: " + e.getMessage());
   }
   if (slaveInfo == null) {
     return ResultUtils.mapResult(
         MemoryCacheErrorCode.NOTIFY_RUNTIME_ERROR,
         "无法构建slaveHost: " + param.getSlaveHost() + "的信息");
   }
   Set<String> interestKeys = new HashSet<>(param.getInterestCache());
   slaveHostMap.put(slaveInfo, interestKeys);
   MapResult mapResult = wrapSlaveRegisterResult(param);
   log.info(
       "Slave注册处理成功, slaveHost: "
           + param.getSlaveHost()
           + ", interestCache: "
           + interestKeys
           + ", 返回结果: "
           + ResultUtils.resultToString(mapResult));
   return mapResult;
 }