Search in sources :

Example 6 with DefaultRedisEventHandler

use of org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler in project rocketmq-externals by apache.

the class ProcessorTest method getProcessor.

private RedisEventProcessor getProcessor(Config config) {
    RedisEventHandler eventHandler = new DefaultRedisEventHandler(config);
    RedisEventProcessor processor = new DefaultRedisEventProcessor(config);
    processor.registEventHandler(eventHandler);
    return processor;
}
Also used : RedisEventProcessor(org.apache.rocketmq.connect.redis.processor.RedisEventProcessor) DefaultRedisEventProcessor(org.apache.rocketmq.connect.redis.processor.DefaultRedisEventProcessor) RedisEventHandler(org.apache.rocketmq.connect.redis.handler.RedisEventHandler) DefaultRedisEventHandler(org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler) DefaultRedisEventHandler(org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler) DefaultRedisEventProcessor(org.apache.rocketmq.connect.redis.processor.DefaultRedisEventProcessor)

Example 7 with DefaultRedisEventHandler

use of org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler in project rocketmq-externals by apache.

the class ListenerTest method getExceptionProcessor.

private RedisEventProcessor getExceptionProcessor(Config config) {
    RedisEventHandler eventHandler = new DefaultRedisEventHandler(config);
    RedisEventProcessor processor = mock(DefaultRedisEventProcessor.class);
    processor.registEventHandler(eventHandler);
    try {
        when(processor.commit(any())).thenThrow(new IllegalStateException("wrong number."));
    } catch (Exception e) {
        e.printStackTrace();
    }
    return processor;
}
Also used : RedisEventProcessor(org.apache.rocketmq.connect.redis.processor.RedisEventProcessor) DefaultRedisEventProcessor(org.apache.rocketmq.connect.redis.processor.DefaultRedisEventProcessor) RedisEventHandler(org.apache.rocketmq.connect.redis.handler.RedisEventHandler) DefaultRedisEventHandler(org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler) DefaultRedisEventHandler(org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler) IOException(java.io.IOException)

Example 8 with DefaultRedisEventHandler

use of org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler 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)

Aggregations

DefaultRedisEventHandler (org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler)8 RedisEventHandler (org.apache.rocketmq.connect.redis.handler.RedisEventHandler)8 Config (org.apache.rocketmq.connect.redis.common.Config)5 DefaultRedisEventProcessor (org.apache.rocketmq.connect.redis.processor.DefaultRedisEventProcessor)5 RedisEventProcessor (org.apache.rocketmq.connect.redis.processor.RedisEventProcessor)4 BatchedKeyValuePair (com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyValuePair)3 IOException (java.io.IOException)3 KVEntry (org.apache.rocketmq.connect.redis.pojo.KVEntry)3 KeyValuePair (com.moilioncircle.redis.replicator.rdb.datatype.KeyValuePair)2 BatchedKeyStringValueString (com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyStringValueString)2 Test (org.junit.Test)2 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 KeyStringValueString (com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueString)1 ByteBuffer (java.nio.ByteBuffer)1 RedisEntryConverter (org.apache.rocketmq.connect.redis.converter.RedisEntryConverter)1