Example #1
0
 private static void reloadMachineConfig(String configDir) throws Exception {
   File configFile = new File(configDir, "machine.json");
   if (configFile.exists()) {
     machineMap.clear();
     logger.info("load config from:" + configFile.getAbsolutePath());
     String ss = FileUtil.getContent(configFile);
     List<Machine> machines = JSONUtil.fromJsonList(ss, Machine.class);
     machines.forEach(in -> machineMap.put(in.id, in));
   } else {
     logErrorMessage("can not find :" + configFile);
   }
 }
Example #2
0
 private static void reloadUserConfig(String configDir) throws Exception {
   File configFile = new File(configDir, "user.json");
   if (configFile.exists()) {
     userMap.clear();
     logger.info("load user from:" + configFile.getAbsolutePath());
     String ss = FileUtil.getContent(configFile);
     List<User> apps = JSONUtil.fromJsonList(ss, User.class);
     apps.forEach(
         in -> {
           userMap.put(in.id, in);
         });
   } else {
     logErrorMessage("can not find :" + configFile);
   }
 }
Example #3
0
 private static void reloadInstanceConfig(String configDir) throws Exception {
   File configFile = new File(configDir, "instance.json");
   if (configFile.exists()) {
     instanceMap.clear();
     logger.info("load config from:" + configFile.getAbsolutePath());
     String ss = FileUtil.getContent(configFile);
     List<Instance> instances = JSONUtil.fromJsonList(ss, Instance.class);
     AtomicInteger ai = new AtomicInteger();
     instances.forEach(
         in -> {
           if (in.user == null) {
             in.user = ("");
           }
           if (in.password == null) {
             in.password = ("");
           }
           if (in.packageVersion == null) {
             in.packageVersion = ("1.0.0");
           }
           in.priority = (ai.incrementAndGet());
           Machine m = machineMap.get(in.machineId);
           if (m == null) {
             logErrorMessage(
                 "can not find machine " + in.machineId + " for instance " + in.id + "");
           } else {
             in.machine = (m);
           }
           Application app = applicationMap.get(in.appId);
           if (app == null) {
             logErrorMessage(
                 "can not find application " + in.appId + " for instance " + in.id + "");
           } else {
             in.application = (app);
           }
           instanceMap.put(in.id, in);
         });
   } else {
     logErrorMessage("can not find :" + configFile);
   }
 }