Search in sources :

Example 1 with ReplicationStoreMeta

use of com.ctrip.xpipe.redis.core.store.ReplicationStoreMeta in project x-pipe by ctripcorp.

the class SimpleTest method testJson.

@Test
public void testJson() {
    ReplicationStoreMeta meta = new ReplicationStoreMeta();
    meta.setBeginOffset(100L);
    String json = JSON.toJSONString(meta);
    System.out.println(json);
    meta = JSON.parseObject(null, ReplicationStoreMeta.class);
    System.out.println(meta);
}
Also used : ReplicationStoreMeta(com.ctrip.xpipe.redis.core.store.ReplicationStoreMeta) Test(org.junit.Test) AbstractRedisTest(com.ctrip.xpipe.redis.core.AbstractRedisTest)

Example 2 with ReplicationStoreMeta

use of com.ctrip.xpipe.redis.core.store.ReplicationStoreMeta in project x-pipe by ctripcorp.

the class AbstractMetaStore method rdbUpdated.

@Override
public ReplicationStoreMeta rdbUpdated(String rdbFile, EofType eofType, long rdbOffset) throws IOException {
    synchronized (metaRef) {
        ReplicationStoreMeta metaDup = dupReplicationStoreMeta();
        metaDup.setRdbFile(rdbFile);
        setRdbFileInfo(metaDup, eofType);
        metaDup.setRdbLastOffset(rdbOffset);
        logger.info("[rdbUpdated] update rdbLastOffset to {}", rdbOffset);
        saveMeta(metaDup);
        return metaDup;
    }
}
Also used : ReplicationStoreMeta(com.ctrip.xpipe.redis.core.store.ReplicationStoreMeta)

Example 3 with ReplicationStoreMeta

use of com.ctrip.xpipe.redis.core.store.ReplicationStoreMeta in project x-pipe by ctripcorp.

the class AbstractMetaStore method updateKeeperRunid.

@Override
public void updateKeeperRunid(String keeperRunid) throws IOException {
    synchronized (metaRef) {
        ReplicationStoreMeta metaDup = dupReplicationStoreMeta();
        if (metaDup.getKeeperRunid() != null && !metaDup.getKeeperRunid().equals(keeperRunid)) {
            logger.warn("[keeperRunIdChanged]{}->{}", metaDup.getKeeperRunid(), keeperRunid);
        }
        metaDup.setKeeperRunid(keeperRunid);
        saveMeta(metaDup);
    }
}
Also used : ReplicationStoreMeta(com.ctrip.xpipe.redis.core.store.ReplicationStoreMeta)

Example 4 with ReplicationStoreMeta

use of com.ctrip.xpipe.redis.core.store.ReplicationStoreMeta in project x-pipe by ctripcorp.

the class DefaultMetaStore method shiftReplicationId.

@Override
public ReplicationStoreMeta shiftReplicationId(String newReplId, Long currentOffset) throws IOException {
    synchronized (metaRef) {
        ReplicationStoreMeta metaDup = dupReplicationStoreMeta();
        String currentReplId = metaDup.getReplId();
        if (ObjectUtils.equals(currentReplId, newReplId)) {
            logger.info("[shiftReplicationId][repidEqual]{}", newReplId);
            return metaDup;
        }
        metaDup.setReplId(newReplId);
        metaDup.setReplId2(currentReplId);
        metaDup.setSecondReplIdOffset(currentOffset + 1);
        saveMeta(metaDup);
        return metaDup;
    }
}
Also used : ReplicationStoreMeta(com.ctrip.xpipe.redis.core.store.ReplicationStoreMeta)

Example 5 with ReplicationStoreMeta

use of com.ctrip.xpipe.redis.core.store.ReplicationStoreMeta in project x-pipe by ctripcorp.

the class DefaultMetaStore method rdbBegun.

@Override
public ReplicationStoreMeta rdbBegun(String replId, long beginOffset, String rdbFile, EofType eofType, String cmdFilePrefix) throws IOException {
    synchronized (metaRef) {
        ReplicationStoreMeta metaDup = dupReplicationStoreMeta();
        metaDup.setReplId(replId);
        metaDup.setBeginOffset(beginOffset);
        metaDup.setRdbFile(rdbFile);
        setRdbFileInfo(metaDup, eofType);
        metaDup.setCmdFilePrefix(cmdFilePrefix);
        metaDup.setRdbLastOffset(beginOffset - 1);
        clearReplicationId2(metaDup);
        saveMeta(metaDup);
        return metaDup;
    }
}
Also used : ReplicationStoreMeta(com.ctrip.xpipe.redis.core.store.ReplicationStoreMeta)

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