public boolean load() { String fileName = null; try { fileName = this.configFilePath(); String jsonString = MixAll.file2String(fileName); if (null == jsonString || jsonString.length() == 0) { return this.loadBak(); } else { this.decode(jsonString); log.info("load " + fileName + " OK"); return true; } } catch (Exception e) { log.error("load " + fileName + " failed, and try to load backup file", e); return this.loadBak(); } }
public synchronized void persist() { String jsonString = this.encode(true); if (jsonString != null) { String fileName = this.configFilePath(); try { MixAll.string2File(jsonString, fileName); } catch (IOException e) { log.error("persist file " + fileName + " exception", e); } } }
public boolean load() { boolean result = super.load(); result = result && this.parseDelayLevel(); return result; }
private boolean loadBak() { String fileName = null; try { fileName = this.configFilePath(); String jsonString = MixAll.file2String(fileName + ".bak"); if (jsonString != null && jsonString.length() > 0) { this.decode(jsonString); log.info("load " + fileName + " OK"); return true; } } catch (Exception e) { log.error("load " + fileName + " Failed", e); return false; } return true; }
private synchronized void doPersist() { String jsonString = lastConfig.getAndSet(null); if (jsonString != null) { String fileName = this.configFilePath(); try { MixAll.string2File(jsonString, fileName); } catch (IOException e) { log.error("persist file [{}] exception", fileName, e); } } }
public ConfigManager() { if (MixAll.MQTT_MODE) { getScheduler().scheduleWithFixedDelay(new Runnable() { @Override public void run() { ConfigManager.this.doPersist(); } }, persistInterval, persistInterval, TimeUnit.SECONDS); } }
private boolean loadBak() { String fileName = null; try { fileName = this.configFilePath(); String jsonString = MixAll.file2String(fileName + ".bak"); if (jsonString != null && jsonString.length() > 0) { this.decode(jsonString); log.info("load [{}] OK", fileName); return true; } } catch (Exception e) { log.error("load [{}] Failed", fileName, e); return false; } return true; }
public boolean load() { String fileName = null; try { fileName = this.configFilePath(); String jsonString = MixAll.file2String(fileName); if (null == jsonString || jsonString.length() == 0) { return this.loadBak(); } else { this.decode(jsonString); log.info("load {} OK", fileName); return true; } } catch (Exception e) { log.error("load [{}] failed, and try to load backup file", fileName, e); return this.loadBak(); } }
private boolean loadBak() { String fileName = null; try { fileName = this.configFilePath(); String jsonString = MixAll.file2String(fileName + ".bak"); if (jsonString != null && jsonString.length() > 0) { this.decode(jsonString); log.info("load " + fileName + " OK"); return true; } } catch (Exception e) { log.error("load " + fileName + " Failed", e); return false; } return true; }
public synchronized void persist() { String jsonString = this.encode(true); if (jsonString != null) { String fileName = this.configFilePath(); try { MixAll.string2File(jsonString, fileName); } catch (IOException e) { log.error("persist file " + fileName + " exception", e); } } }
public boolean load() { boolean result = super.load(); result = result && this.parseDelayLevel(); return result; }
public boolean load() { String fileName = null; try { fileName = this.configFilePath(); String jsonString = MixAll.file2String(fileName); if (null == jsonString || jsonString.length() == 0) { return this.loadBak(); } else { this.decode(jsonString); log.info("load " + fileName + " OK"); return true; } } catch (Exception e) { log.error("load " + fileName + " failed, and try to load backup file", e); return this.loadBak(); } }
public boolean load() { boolean result = super.load(); result = result && this.parseDelayLevel(); return result; }