Search in sources :

Example 1 with KeyValuePair

use of com.moilioncircle.redis.replicator.rdb.datatype.KeyValuePair in project rocketmq-externals by apache.

the class RedisEventHandlerTest method handlerTest.

private <T> KVEntry handlerTest(int rdbType, ValueSetter<T> setter) {
    KVEntry res = null;
    Exception ex = null;
    Config config = getConfig();
    RedisEventHandler handler = new DefaultRedisEventHandler(config);
    KeyValuePair keyValuePair = new KeyStringValueList();
    keyValuePair.setValueRdbType(rdbType);
    keyValuePair.setKey("key".getBytes());
    Object value = setter.getValue();
    keyValuePair.setValue(value);
    try {
        res = handler.handleKVString(replId, offset, keyValuePair);
    } catch (Exception e) {
        e.printStackTrace();
        ex = e;
    }
    Assert.assertNull(ex);
    return res;
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) RedisEventHandler(org.apache.rocketmq.connect.redis.handler.RedisEventHandler) DefaultRedisEventHandler(org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler) BatchedKeyValuePair(com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyValuePair) KeyValuePair(com.moilioncircle.redis.replicator.rdb.datatype.KeyValuePair) Config(org.apache.rocketmq.connect.redis.common.Config) KeyStringValueList(com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueList) DefaultRedisEventHandler(org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler)

Example 2 with KeyValuePair

use of com.moilioncircle.redis.replicator.rdb.datatype.KeyValuePair in project rocketmq-externals by apache.

the class RedisEventHandlerTest method testNull.

@Test
public void testNull() {
    Config config = getConfig();
    RedisEventHandler handler = new DefaultRedisEventHandler(config);
    KVEntry res = null;
    Exception ex = null;
    // 测试increment下的rdb数据处理
    config.setSyncMod(SyncMod.LAST_OFFSET.name());
    KeyValuePair keyValuePair = new KeyStringValueString();
    keyValuePair.setKey("key".getBytes());
    keyValuePair.setValue("value".getBytes());
    try {
        res = handler.handleKVString(replId, offset, keyValuePair);
    } catch (Exception e) {
        e.printStackTrace();
        ex = e;
    }
    Assert.assertNull(res);
    Assert.assertNull(ex);
    // 测试未指定的command
    GetSetCommand command = new GetSetCommand();
    command.setKey("key".getBytes());
    command.setValue("value".getBytes());
    try {
        res = handler.handleCommand(replId, offset, command);
    } catch (Exception e) {
        ex = e;
    }
    Assert.assertNull(res);
    Assert.assertNull(ex);
}
Also used : 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) KeyValuePair(com.moilioncircle.redis.replicator.rdb.datatype.KeyValuePair) Config(org.apache.rocketmq.connect.redis.common.Config) BatchedKeyStringValueString(com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyStringValueString) KeyStringValueString(com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueString) DefaultRedisEventHandler(org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler) GetSetCommand(com.moilioncircle.redis.replicator.cmd.impl.GetSetCommand) Test(org.junit.Test)

Example 3 with KeyValuePair

use of com.moilioncircle.redis.replicator.rdb.datatype.KeyValuePair in project rocketmq-externals by apache.

the class ListenerTest method exceptionListenerTest.

@Test
public void exceptionListenerTest() {
    ExceptionListener exceptionListener = new RedisExceptionListener(processor);
    KeyValuePair pair = new KeyStringValueString();
    exceptionListener.handle(null, new NullPointerException("adsf"), pair);
}
Also used : RedisExceptionListener(org.apache.rocketmq.connect.redis.processor.RedisExceptionListener) KeyValuePair(com.moilioncircle.redis.replicator.rdb.datatype.KeyValuePair) KeyStringValueString(com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueString) RedisExceptionListener(org.apache.rocketmq.connect.redis.processor.RedisExceptionListener) ExceptionListener(com.moilioncircle.redis.replicator.ExceptionListener) Test(org.junit.Test)

Example 4 with KeyValuePair

use of com.moilioncircle.redis.replicator.rdb.datatype.KeyValuePair in project rocketmq-externals by apache.

the class ListenerTest method testEventListenerRetry2.

@Test
public void testEventListenerRetry2() {
    Config config = getConfig();
    RedisEventProcessor processor = getExceptionProcessor(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 5 with KeyValuePair

use of com.moilioncircle.redis.replicator.rdb.datatype.KeyValuePair 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)

Aggregations

KeyValuePair (com.moilioncircle.redis.replicator.rdb.datatype.KeyValuePair)9 KeyStringValueString (com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueString)7 Test (org.junit.Test)5 Config (org.apache.rocketmq.connect.redis.common.Config)4 EventListener (com.moilioncircle.redis.replicator.event.EventListener)3 RedisEventListener (org.apache.rocketmq.connect.redis.processor.RedisEventListener)3 BatchedKeyValuePair (com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyValuePair)2 DefaultRedisEventHandler (org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler)2 RedisEventHandler (org.apache.rocketmq.connect.redis.handler.RedisEventHandler)2 KVEntry (org.apache.rocketmq.connect.redis.pojo.KVEntry)2 DefaultRedisEventProcessor (org.apache.rocketmq.connect.redis.processor.DefaultRedisEventProcessor)2 RedisEventProcessor (org.apache.rocketmq.connect.redis.processor.RedisEventProcessor)2 ExceptionListener (com.moilioncircle.redis.replicator.ExceptionListener)1 GetSetCommand (com.moilioncircle.redis.replicator.cmd.impl.GetSetCommand)1 KeyStringValueList (com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueList)1 KeyStringValueSet (com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueSet)1 BatchedKeyStringValueString (com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyStringValueString)1 HashSet (java.util.HashSet)1 RedisExceptionListener (org.apache.rocketmq.connect.redis.processor.RedisExceptionListener)1