use of com.ctrip.xpipe.redis.core.store.ReplicationStoreMeta in project x-pipe by ctripcorp.
the class KinfoCommand method format.
protected ReplicationStoreMeta format(Object payload) {
ByteArrayOutputStreamPayload data = (ByteArrayOutputStreamPayload) payload;
String buff = new String(data.getBytes(), Codec.defaultCharset);
logger.info("[format]{}", buff);
ReplicationStoreMeta meta = null;
meta = JSON.parseObject(buff, ReplicationStoreMeta.class);
if (valid(meta)) {
return meta;
} else {
throw new XpipeRuntimeException("[format][wrong meta]" + meta);
}
}
use of com.ctrip.xpipe.redis.core.store.ReplicationStoreMeta in project x-pipe by ctripcorp.
the class SimpleTest method test.
@Test
public void test() throws IOException {
String file = "//Users/mengwenchao/tmp/tmpdir/file1";
ReplicationStoreMeta meta = new ReplicationStoreMeta();
long begin = System.currentTimeMillis();
// String json = JSON.toJSONString(meta);
long endJson = System.currentTimeMillis();
logger.info("[begin]");
Files.IO.INSTANCE.writeTo(new File(file), JSON.toJSONString(meta));
logger.info("[end]");
long end = System.currentTimeMillis();
logger.info("cost json:{}, costSave:{} ", endJson - begin, end - endJson);
logger.info("total:{}", end - begin);
System.out.println("nihaoma");
}
use of com.ctrip.xpipe.redis.core.store.ReplicationStoreMeta in project x-pipe by ctripcorp.
the class AbstractMetaStore method setKeeperState.
private void setKeeperState(KeeperState keeperState) throws IOException {
synchronized (metaRef) {
ReplicationStoreMeta metaDup = dupReplicationStoreMeta();
metaDup.setKeeperState(keeperState);
saveMeta(metaDup);
}
}
use of com.ctrip.xpipe.redis.core.store.ReplicationStoreMeta in project x-pipe by ctripcorp.
the class AbstractMetaStore method setMasterAddress.
@Override
public void setMasterAddress(DefaultEndPoint endpoint) throws IOException {
synchronized (metaRef) {
ReplicationStoreMeta metaDup = dupReplicationStoreMeta();
doSetMasterAddress(metaDup, endpoint);
saveMeta(metaDup);
}
}
use of com.ctrip.xpipe.redis.core.store.ReplicationStoreMeta in project x-pipe by ctripcorp.
the class AbstractMetaStore method checkOrSaveKeeperRunid.
private final void checkOrSaveKeeperRunid(String keeperRunid) throws IOException {
synchronized (metaRef) {
String oldRunId = metaRef.get().getKeeperRunid();
if (oldRunId != null) {
if (!oldRunId.equals(keeperRunid)) {
throw new BadMetaStoreException(oldRunId, keeperRunid);
}
} else {
ReplicationStoreMeta newMeta = dupReplicationStoreMeta();
newMeta.setKeeperRunid(keeperRunid);
saveMeta(newMeta);
}
}
}
Aggregations