示例#1
0
 public static String getConfigFile(String file) {
   String configDir = workSpaceDir + "config";
   try {
     return FileUtil.getContent(new File(configDir, file));
   } catch (IOException e) {
     logger.catching(e);
     return null;
   }
 }
示例#2
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);
   }
 }
示例#3
0
 public static String getTemplate(String appId) {
   String templateDir = workSpaceDir;
   templateDir += "template";
   File file = new File(templateDir + "/" + appId + ".vm");
   if (!file.exists()) {
     return null;
   }
   try {
     return FileUtil.getContent(file);
   } catch (IOException e) {
     logger.catching(e);
     return null;
   }
 }
示例#4
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);
   }
 }
示例#5
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);
   }
 }
示例#6
0
 public static String getScript(String name) throws IOException {
   File scriptFile = new File(workSpaceDir + "script/" + name);
   return FileUtil.getContent(scriptFile);
 }