Search in sources :

Example 11 with Config

use of org.apache.rocketmq.connect.redis.common.Config in project rocketmq-externals by apache.

the class ListenerTest method testEventListenerRetry1.

@Test
public void testEventListenerRetry1() {
    Config config = getConfig();
    RedisEventProcessor processor = getFailedProcessor(config);
    EventListener eventListener = new RedisEventListener(config, processor);
    KeyValuePair pair = new KeyStringValueString();
    eventListener.onEvent(null, pair);
}
Also used : RedisEventProcessor(org.apache.rocketmq.connect.redis.processor.RedisEventProcessor) DefaultRedisEventProcessor(org.apache.rocketmq.connect.redis.processor.DefaultRedisEventProcessor) KeyValuePair(com.moilioncircle.redis.replicator.rdb.datatype.KeyValuePair) Config(org.apache.rocketmq.connect.redis.common.Config) KeyStringValueString(com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueString) EventListener(com.moilioncircle.redis.replicator.event.EventListener) RedisEventListener(org.apache.rocketmq.connect.redis.processor.RedisEventListener) RedisEventListener(org.apache.rocketmq.connect.redis.processor.RedisEventListener) Test(org.junit.Test)

Example 12 with Config

use of org.apache.rocketmq.connect.redis.common.Config in project rocketmq-externals by apache.

the class ListenerTest method getConfig.

private Config getConfig() {
    Config config = new Config();
    config.setRedisAddr("127.0.0.1");
    config.setRedisPort(6379);
    return config;
}
Also used : Config(org.apache.rocketmq.connect.redis.common.Config)

Example 13 with Config

use of org.apache.rocketmq.connect.redis.common.Config in project rocketmq-externals by apache.

the class RedisEventHandlerTest method test.

@Test
public void test() {
    Config config = getConfig();
    RedisEventHandler handler = new DefaultRedisEventHandler(config);
    KVEntry entry = getBuilder();
    KVEntry res = null;
    Exception ex = null;
    try {
        res = handler.handleCommand(replId, offset, entry);
    } catch (Exception e) {
        e.printStackTrace();
        ex = e;
    }
    Assert.assertEquals("c18cece63c7b16851a6f387f52dbbb9eee07e46f", res.getSourceId());
    Assert.assertTrue(res.getOffset() == 3926872L);
    Assert.assertNull(ex);
    AuxField auxField = new AuxField("a", "b");
    try {
        res = handler.handleOtherEvent(replId, offset, auxField);
    } catch (Exception e) {
        e.printStackTrace();
        ex = e;
    }
    Assert.assertNull(res);
    Assert.assertNull(ex);
    BatchedKeyValuePair pair = new BatchedKeyStringValueString();
    pair.setKey("A".getBytes());
    pair.setValue("B".getBytes());
    try {
        res = handler.handleBatchKVString(replId, offset, pair);
    } catch (Exception e) {
        e.printStackTrace();
        ex = e;
    }
    Assert.assertNull(res);
    Assert.assertNull(ex);
}
Also used : AuxField(com.moilioncircle.redis.replicator.rdb.datatype.AuxField) BatchedKeyStringValueString(com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyStringValueString) RedisEventHandler(org.apache.rocketmq.connect.redis.handler.RedisEventHandler) DefaultRedisEventHandler(org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler) KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) BatchedKeyValuePair(com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyValuePair) Config(org.apache.rocketmq.connect.redis.common.Config) DefaultRedisEventHandler(org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler) Test(org.junit.Test)

Example 14 with Config

use of org.apache.rocketmq.connect.redis.common.Config in project rocketmq-externals by apache.

the class ProcessorTest method getConfig.

private Config getConfig(SyncMod syncMod) {
    Config config = new Config();
    config.setRedisAddr("127.0.0.1");
    config.setRedisPort(6379);
    config.setOffset(100L);
    config.setPosition(200L);
    config.setCommands("SET,HSET");
    if (syncMod != null) {
        config.setSyncMod(syncMod.name());
    }
    return config;
}
Also used : Config(org.apache.rocketmq.connect.redis.common.Config)

Aggregations

Config (org.apache.rocketmq.connect.redis.common.Config)14 Test (org.junit.Test)7 DefaultRedisEventHandler (org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler)5 RedisEventHandler (org.apache.rocketmq.connect.redis.handler.RedisEventHandler)5 KeyValuePair (com.moilioncircle.redis.replicator.rdb.datatype.KeyValuePair)4 ByteBuffer (java.nio.ByteBuffer)4 DefaultRedisEventProcessor (org.apache.rocketmq.connect.redis.processor.DefaultRedisEventProcessor)4 KeyStringValueString (com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueString)3 BatchedKeyValuePair (com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyValuePair)3 KVEntry (org.apache.rocketmq.connect.redis.pojo.KVEntry)3 RedisEventProcessor (org.apache.rocketmq.connect.redis.processor.RedisEventProcessor)3 RedisURI (com.moilioncircle.redis.replicator.RedisURI)2 EventListener (com.moilioncircle.redis.replicator.event.EventListener)2 BatchedKeyStringValueString (com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyStringValueString)2 RedisEventListener (org.apache.rocketmq.connect.redis.processor.RedisEventListener)2 JSONObject (com.alibaba.fastjson.JSONObject)1 GetSetCommand (com.moilioncircle.redis.replicator.cmd.impl.GetSetCommand)1 AuxField (com.moilioncircle.redis.replicator.rdb.datatype.AuxField)1 KeyStringValueList (com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueList)1 KeyValue (io.openmessaging.KeyValue)1