Search in sources :

Example 6 with ReplicationStoreMeta

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);
    }
}
Also used : ReplicationStoreMeta(com.ctrip.xpipe.redis.core.store.ReplicationStoreMeta) ByteArrayOutputStreamPayload(com.ctrip.xpipe.payload.ByteArrayOutputStreamPayload) XpipeRuntimeException(com.ctrip.xpipe.exception.XpipeRuntimeException)

Example 7 with ReplicationStoreMeta

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");
}
Also used : ReplicationStoreMeta(com.ctrip.xpipe.redis.core.store.ReplicationStoreMeta) File(java.io.File) Test(org.junit.Test)

Example 8 with ReplicationStoreMeta

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);
    }
}
Also used : ReplicationStoreMeta(com.ctrip.xpipe.redis.core.store.ReplicationStoreMeta)

Example 9 with ReplicationStoreMeta

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);
    }
}
Also used : ReplicationStoreMeta(com.ctrip.xpipe.redis.core.store.ReplicationStoreMeta)

Example 10 with ReplicationStoreMeta

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);
        }
    }
}
Also used : ReplicationStoreMeta(com.ctrip.xpipe.redis.core.store.ReplicationStoreMeta) BadMetaStoreException(com.ctrip.xpipe.redis.core.store.exception.BadMetaStoreException)

Aggregations

ReplicationStoreMeta (com.ctrip.xpipe.redis.core.store.ReplicationStoreMeta)12 Test (org.junit.Test)2 XpipeRuntimeException (com.ctrip.xpipe.exception.XpipeRuntimeException)1 ByteArrayOutputStreamPayload (com.ctrip.xpipe.payload.ByteArrayOutputStreamPayload)1 AbstractRedisTest (com.ctrip.xpipe.redis.core.AbstractRedisTest)1 BadMetaStoreException (com.ctrip.xpipe.redis.core.store.exception.BadMetaStoreException)1 File (java.io.File)1