Search in sources :

Example 1 with PreRdbSyncEvent

use of com.moilioncircle.redis.replicator.event.PreRdbSyncEvent in project rocketmq-externals by apache.

the class KryoEventSerializerTest method test.

@Test
public void test() {
    Event e = new PreRdbSyncEvent();
    Serializer<Event> serializer = new KryoEventSerializer();
    System.out.println(serializer.read(serializer.write(e)));
    KeyStringValueHash x = new KeyStringValueHash();
    x.setKey("key".getBytes());
    Map<byte[], byte[]> map1 = new ByteArrayMap();
    map1.put("field1".getBytes(), "value1".getBytes());
    map1.put("field2".getBytes(), "value2".getBytes());
    x.setValue(map1);
    KeyStringValueHash kv = (KeyStringValueHash) serializer.read(serializer.write(x));
    ByteArrayMap map2 = (ByteArrayMap) kv.getValue();
    assertNotNull(map2.get("field1".getBytes()));
    ZUnionStoreParser parser = new ZUnionStoreParser();
    ZUnionStoreCommand cmd = parser.parse(toObjectArray("zunionstore des 2 k1 k2 WEIGHTS 2 3 AGGREGATE min".split(" ")));
    ZUnionStoreCommand cmd1 = (ZUnionStoreCommand) serializer.read(serializer.write(cmd));
    for (byte[] bytes : cmd1.getKeys()) {
        System.out.println(new String(bytes));
    }
    System.out.println(cmd1);
}
Also used : ZUnionStoreParser(com.moilioncircle.redis.replicator.cmd.parser.ZUnionStoreParser) Event(com.moilioncircle.redis.replicator.event.Event) PreRdbSyncEvent(com.moilioncircle.redis.replicator.event.PreRdbSyncEvent) KeyStringValueHash(com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueHash) ZUnionStoreCommand(com.moilioncircle.redis.replicator.cmd.impl.ZUnionStoreCommand) PreRdbSyncEvent(com.moilioncircle.redis.replicator.event.PreRdbSyncEvent) ByteArrayMap(com.moilioncircle.redis.replicator.util.ByteArrayMap) Test(org.junit.Test)

Aggregations

ZUnionStoreCommand (com.moilioncircle.redis.replicator.cmd.impl.ZUnionStoreCommand)1 ZUnionStoreParser (com.moilioncircle.redis.replicator.cmd.parser.ZUnionStoreParser)1 Event (com.moilioncircle.redis.replicator.event.Event)1 PreRdbSyncEvent (com.moilioncircle.redis.replicator.event.PreRdbSyncEvent)1 KeyStringValueHash (com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueHash)1 ByteArrayMap (com.moilioncircle.redis.replicator.util.ByteArrayMap)1 Test (org.junit.Test)1