/** * get topology configuration * * @param id String: topology id * @return String */ @Override public String getTopologyConf(String id) throws NotAliveException, TException { String rtn; try { Map<Object, Object> topologyConf = StormConfig.read_nimbus_topology_conf(conf, id); rtn = JStormUtils.to_json(topologyConf); } catch (IOException e) { // TODO Auto-generated catch block LOG.info("Failed to get configuration of " + id, e); throw new TException(e); } return rtn; }
byte[] getJSonFiles(String dir) throws Exception { Map<String, FileAttribute> fileMap = new HashMap<String, FileAttribute>(); String path = logDir; if (dir != null) { path = path + File.separator + dir; } LOG.info("List dir " + path); File file = new File(path); String[] files = file.list(); for (String fileName : files) { String logFile = Joiner.on(File.separator).join(path, fileName); FileAttribute fileAttribute = new FileAttribute(); fileAttribute.setFileName(fileName); File subFile = new File(logFile); Date modify = new Date(subFile.lastModified()); fileAttribute.setModifyTime(TimeFormat.getSecond(modify)); if (subFile.isFile()) { fileAttribute.setIsDir(String.valueOf(false)); fileAttribute.setSize(String.valueOf(subFile.length())); fileMap.put(logFile, fileAttribute); } else if (subFile.isDirectory()) { fileAttribute.setIsDir(String.valueOf(true)); fileAttribute.setSize(String.valueOf(4096)); fileMap.put(logFile, fileAttribute); } } String fileJsonStr = JStormUtils.to_json(fileMap); return fileJsonStr.getBytes(); }