AbstractMetaStore implements MetaStore { protected void saveMetaToFile(File file, ReplicationStoreMeta replicationStoreMeta) throws IOException { logger.info("[saveMetaToFile]{}, {}", file, replicationStoreMeta); IO.INSTANCE.writeTo(file, Codec.DEFAULT.encode(replicationStoreMeta)); } AbstractMetaStore(File baseDir, String keeperRunid); static ReplicationStoreMeta deserializeFromString(String str); @Override void updateKeeperRunid(String keeperRunid); @Override final ReplicationStoreMeta dupReplicationStoreMeta(); @Override final void loadMeta(); static ReplicationStoreMeta loadMetaCreateIfEmpty(File baseDir, String fileName); @Override void setRdbFileSize(long rdbFileSize); @Override ReplicationStoreMeta rdbUpdated(String rdbFile, EofType eofType, long rdbOffset); @Override void setMasterAddress(DefaultEndPoint endpoint); @Override boolean isFresh(); @Override void becomeActive(); @Override void becomeBackup(); @Override String toString();  }
@Test public void testSaveMetaToFile() throws Exception { ReplicationStoreMeta meta = metaStore.deserializeFromString(readFileAsString(PERSIST_META_JSON_FILE)); metaStore.saveMetaToFile(new File(TMP_META_JSON_FILE), meta); metaStore = new DefaultMetaStore(new File("/tmp/xpipe/test"), "20180118165046194-20180118165046194-294c90b4c9ed4d747a77b1b0f22ec28a8068013b"); metaStore.loadMeta(); logger.info("[result] {}", readFileAsString(TMP_META_JSON_FILE)); Assert.assertEquals(meta, metaStore.getMeta()); }