Search in sources :

Example 56 with KVEntry

use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.

the class ParserTest method testSetParser4.

@Test
public void testSetParser4() {
    String command = "set key value PX 100 XX";
    KVEntry builder = new SetParser().parse(parseCommand(command));
    Assert.assertEquals("set", builder.getCommand());
    Assert.assertEquals("key", builder.getKey());
    Assert.assertEquals("value", builder.getValue());
    Assert.assertTrue(100L == builder.getParam(Options.REDIS_PX));
    Assert.assertEquals(true, builder.getParam(Options.REDIS_XX));
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) LSetParser(org.apache.rocketmq.connect.redis.parser.LSetParser) SetParser(org.apache.rocketmq.connect.redis.parser.SetParser) HmSetParser(org.apache.rocketmq.connect.redis.parser.HmSetParser) MSetParser(org.apache.rocketmq.connect.redis.parser.MSetParser) HSetParser(org.apache.rocketmq.connect.redis.parser.HSetParser) Test(org.junit.Test)

Example 57 with KVEntry

use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.

the class ParserTest method testXGroupParser.

@Test
public void testXGroupParser() {
    String command = "XGroup [CREATE key groupname id-or-$] [SETID key id-or-$] [DESTROY key groupname] [DELCONSUMER key groupname consumername]";
    KVEntry builder = new XGroupParser().parse(parseCommand(command));
    Assert.assertEquals("XGroup", builder.getCommand());
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) XGroupParser(org.apache.rocketmq.connect.redis.parser.XGroupParser) Test(org.junit.Test)

Example 58 with KVEntry

use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.

the class KVEntryTest method testConstruct.

@Test
public void testConstruct() {
    KVEntry entry = new RedisEntry(FieldType.STRING);
    entry.value("value");
    Assert.assertEquals(String.class, entry.getValue().getClass());
    entry = new RedisEntry("partition", FieldType.ARRAY);
    entry.value(new ArrayList<>());
    Assert.assertEquals(ArrayList.class, entry.getValue().getClass());
    Assert.assertEquals("partition", entry.getPartition());
    entry = RedisEntry.newEntry(FieldType.MAP);
    entry.value(new HashMap());
    Assert.assertEquals(HashMap.class, entry.getValue().getClass());
    entry = RedisEntry.newEntry("partition", FieldType.INT64);
    entry.value(123L);
    Assert.assertEquals(Long.class, entry.getValue().getClass());
    Assert.assertTrue(123L == (long) entry.getValue());
    Assert.assertEquals("partition", entry.getPartition());
    Assert.assertNotNull(entry.toString());
    List<SourceDataEntry> entries = getConverter().kVEntryToDataEntries(entry);
    Assert.assertNotNull(entries);
}
Also used : RedisEntry(org.apache.rocketmq.connect.redis.pojo.RedisEntry) KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) SourceDataEntry(io.openmessaging.connector.api.data.SourceDataEntry) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 59 with KVEntry

use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.

the class ProcessorTest method testHandler.

@Test
public void testHandler() throws Exception {
    processor = getProcessor();
    DefaultRedisEventProcessor defaultRedisEventProcessor = (DefaultRedisEventProcessor) processor;
    RedisEvent event = new RedisEvent();
    event.setEvent(getKeyValuePair());
    event.setReplOffset(123L);
    event.setStreamDB(0);
    event.setReplId("asdfsdfa");
    defaultRedisEventProcessor.commit(event);
    KVEntry res = null;
    try {
        res = defaultRedisEventProcessor.poll();
    } catch (Exception e) {
        e.printStackTrace();
    }
    Assert.assertNotNull(res);
    event.setEvent(getKVCommandPair());
    defaultRedisEventProcessor.commit(event);
    try {
        res = defaultRedisEventProcessor.poll();
    } catch (Exception e) {
        e.printStackTrace();
    }
    Assert.assertNotNull(res);
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) RedisEvent(org.apache.rocketmq.connect.redis.pojo.RedisEvent) DefaultRedisEventProcessor(org.apache.rocketmq.connect.redis.processor.DefaultRedisEventProcessor) IOException(java.io.IOException) JedisConnectionException(redis.clients.jedis.exceptions.JedisConnectionException) Test(org.junit.Test)

Example 60 with KVEntry

use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.

the class RedisEntryConverterTest method getArrayKVEntry.

private KVEntry getArrayKVEntry(int size) {
    KVEntry entry = new RedisEntry(FieldType.ARRAY);
    List<String> values = new ArrayList<>(size);
    for (int i = 0; i < size; i++) {
        values.add(Integer.toString(i));
    }
    return entry.key("key").value(values).command("set").sourceId("replId").offset(6000L);
}
Also used : RedisEntry(org.apache.rocketmq.connect.redis.pojo.RedisEntry) KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) ArrayList(java.util.ArrayList)

Aggregations

KVEntry (org.apache.rocketmq.connect.redis.pojo.KVEntry)118 Test (org.junit.Test)114 List (java.util.List)34 Map (java.util.Map)20 BatchedKeyStringValueString (com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyStringValueString)13 KeyStringValueString (com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueString)12 HashMap (java.util.HashMap)8 KeyStringValueList (com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueList)6 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)5 HSetParser (org.apache.rocketmq.connect.redis.parser.HSetParser)5 HmSetParser (org.apache.rocketmq.connect.redis.parser.HmSetParser)5 LSetParser (org.apache.rocketmq.connect.redis.parser.LSetParser)5 MSetParser (org.apache.rocketmq.connect.redis.parser.MSetParser)5 ZSetEntry (com.moilioncircle.redis.replicator.rdb.datatype.ZSetEntry)3 BatchedKeyValuePair (com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyValuePair)3 SourceDataEntry (io.openmessaging.connector.api.data.SourceDataEntry)3 IOException (java.io.IOException)3 Config (org.apache.rocketmq.connect.redis.common.Config)3 DefaultRedisEventHandler (org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler)3