private void updateToZookeeper(File file) { // TODO Auto-generated method stub if (TZUtil.isEmpty(file)) return; String monitorNodePath = file.getAbsolutePath(); monitorNodePath = TopsCommonResourceUtil.getZookeeperConfigPath() + monitorNodePath.replace(TopsConfPath.getBaseLocalHostPath(), ""); logger.info("update to zookeeper: {}", monitorNodePath); try { byte[] bytes = TopsFileUtil.getBytesFromFile(file); if (!TZUtil.isEmpty(bytes)) { try { TopsCuratorFramework.getInstance().deleteNode(monitorNodePath); TopsCuratorFramework.getInstance() .createNode(monitorNodePath, bytes, CreateMode.PERSISTENT); } catch (Exception e) { logger.error(e.getMessage()); } } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public DateTime getLastUpdateTime() { String zooKeeperUpdateTime = TopsCommonResourceUtil.getZooKeeperUpdateTime(TIME_FILE_PATH, LODING_CONFIG_TIME_KEY); if (TZUtil.isEmpty(zooKeeperUpdateTime)) return null; DateTime time = DateTimeUtil.getDate(zooKeeperUpdateTime, DATESTR); return time; }
/** 增量数据导入 true:表示有返回 遍历所有文件 */ public boolean loadUpdateConfigFile(DateTime dateTime) { File baseFilePath = new File(TopsCommonResourceUtil.getBaseLocalHostPath()); if (!TZUtil.isEmpty(baseFilePath)) { int count = updateAllFile(baseFilePath, dateTime); if (count > 0) return true; } return false; }
public void saveIndexTime(DateTime dateTime) { if (TZUtil.isEmpty(dateTime)) return; logger.info("dateTime is saving {}", dateTime); TopsCommonResourceUtil.saveZooKeeperUpdateTime( TIME_FILE_PATH, LODING_CONFIG_TIME_KEY, DateTimeUtil.format(dateTime, DATESTR)); }