Example #1
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;
 }