From 1f4ecff8cd0929ec3528b61a47aefbe783d2237c Mon Sep 17 00:00:00 2001 From: Nikita Date: Thu, 3 Dec 2015 16:36:08 +0300 Subject: [PATCH] new comments added --- src/main/java/org/redisson/Redisson.java | 163 ------------------ .../java/org/redisson/RedissonClient.java | 140 +++++++++++++-- .../java/org/redisson/client/codec/Codec.java | 2 +- .../java/org/redisson/codec/FstCodec.java | 2 +- .../org/redisson/codec/JsonJacksonCodec.java | 4 +- 5 files changed, 134 insertions(+), 177 deletions(-) diff --git a/src/main/java/org/redisson/Redisson.java b/src/main/java/org/redisson/Redisson.java index 5dbddd8cb..4c9430562 100755 --- a/src/main/java/org/redisson/Redisson.java +++ b/src/main/java/org/redisson/Redisson.java @@ -121,12 +121,6 @@ public class Redisson implements RedissonClient { return new RedissonReactive(config); } - /** - * Returns object holder by name - * - * @param name of object - * @return - */ @Override public RBucket getBucket(String name) { return new RedissonBucket(commandExecutor, name); @@ -137,16 +131,6 @@ public class Redisson implements RedissonClient { return new RedissonBucket(codec, commandExecutor, name); } - - /** - * Returns a list of object holder by a key pattern - * - * Supported glob-style patterns: - * h?llo subscribes to hello, hallo and hxllo - * h*llo subscribes to hllo and heeeello - * h[ae]llo subscribes to hello and hallo, but not hillo - * - */ @Override public List> getBuckets(String pattern) { Future> r = commandExecutor.readAllAsync(RedisCommands.KEYS, pattern); @@ -160,13 +144,6 @@ public class Redisson implements RedissonClient { return buckets; } - - /** - * Returns HyperLogLog object - * - * @param name of object - * @return - */ @Override public RHyperLogLog getHyperLogLog(String name) { return new RedissonHyperLogLog(commandExecutor, name); @@ -177,13 +154,6 @@ public class Redisson implements RedissonClient { return new RedissonHyperLogLog(codec, commandExecutor, name); } - - /** - * Returns distributed list instance by name. - * - * @param name of the distributed list - * @return distributed list - */ @Override public RList getList(String name) { return new RedissonList(commandExecutor, name); @@ -194,12 +164,6 @@ public class Redisson implements RedissonClient { return new RedissonList(codec, commandExecutor, name); } - /** - * Returns distributed map instance by name. - * - * @param name of the distributed map - * @return distributed map - */ @Override public RMap getMap(String name) { return new RedissonMap(commandExecutor, name); @@ -210,23 +174,11 @@ public class Redisson implements RedissonClient { return new RedissonMap(codec, commandExecutor, name); } - /** - * Returns distributed lock instance by name. - * - * @param name of the distributed lock - * @return distributed lock - */ @Override public RLock getLock(String name) { return new RedissonLock(commandExecutor, name, id); } - /** - * Returns distributed set instance by name. - * - * @param name of the distributed set - * @return distributed set - */ @Override public RSet getSet(String name) { return new RedissonSet(commandExecutor, name); @@ -237,23 +189,11 @@ public class Redisson implements RedissonClient { return new RedissonSet(codec, commandExecutor, name); } - - /** - * Returns script with eval-operations support - * - * @return - */ @Override public RScript getScript() { return new RedissonScript(commandExecutor); } - /** - * Returns distributed sorted set instance by name. - * - * @param name of the distributed set - * @return distributed set - */ @Override public RSortedSet getSortedSet(String name) { return new RedissonSortedSet(commandExecutor, name); @@ -264,13 +204,6 @@ public class Redisson implements RedissonClient { return new RedissonSortedSet(codec, commandExecutor, name); } - - /** - * Returns Redis Sorted Set instance by name - * - * @param name - * @return - */ @Override public RScoredSortedSet getScoredSortedSet(String name) { return new RedissonScoredSortedSet(commandExecutor, name); @@ -281,25 +214,11 @@ public class Redisson implements RedissonClient { return new RedissonScoredSortedSet(codec, commandExecutor, name); } - /** - * Returns String based Redis Sorted Set instance by name - * All elements are inserted with the same score during addition, - * in order to force lexicographical ordering - * - * @param name - * @return - */ @Override public RLexSortedSet getLexSortedSet(String name) { return new RedissonLexSortedSet(commandExecutor, name); } - /** - * Returns topic instance by name. - * - * @param name of the distributed topic - * @return distributed topic - */ @Override public RTopic getTopic(String name) { return new RedissonTopic(commandExecutor, name); @@ -310,17 +229,6 @@ public class Redisson implements RedissonClient { return new RedissonTopic(codec, commandExecutor, name); } - /** - * Returns topic instance satisfies by pattern name. - * - * Supported glob-style patterns: - * h?llo subscribes to hello, hallo and hxllo - * h*llo subscribes to hllo and heeeello - * h[ae]llo subscribes to hello and hallo, but not hillo - * - * @param pattern of the topic - * @return - */ @Override public RPatternTopic getPatternTopic(String pattern) { return new RedissonPatternTopic(commandExecutor, pattern); @@ -331,13 +239,6 @@ public class Redisson implements RedissonClient { return new RedissonPatternTopic(codec, commandExecutor, pattern); } - - /** - * Returns distributed queue instance by name. - * - * @param name of the distributed queue - * @return distributed queue - */ @Override public RQueue getQueue(String name) { return new RedissonQueue(commandExecutor, name); @@ -348,12 +249,6 @@ public class Redisson implements RedissonClient { return new RedissonQueue(codec, commandExecutor, name); } - /** - * Returns distributed blocking queue instance by name. - * - * @param name of the distributed blocking queue - * @return distributed queue - */ @Override public RBlockingQueue getBlockingQueue(String name) { return new RedissonBlockingQueue(commandExecutor, name); @@ -364,12 +259,6 @@ public class Redisson implements RedissonClient { return new RedissonBlockingQueue(codec, commandExecutor, name); } - /** - * Returns distributed deque instance by name. - * - * @param name of the distributed queue - * @return distributed queue - */ @Override public RDeque getDeque(String name) { return new RedissonDeque(commandExecutor, name); @@ -380,23 +269,11 @@ public class Redisson implements RedissonClient { return new RedissonDeque(codec, commandExecutor, name); } - /** - * Returns distributed "atomic long" instance by name. - * - * @param name of the distributed "atomic long" - * @return distributed "atomic long" - */ @Override public RAtomicLong getAtomicLong(String name) { return new RedissonAtomicLong(commandExecutor, name); } - /** - * Returns distributed "count down latch" instance by name. - * - * @param name of the distributed "count down latch" - * @return distributed "count down latch" - */ @Override public RCountDownLatch getCountDownLatch(String name) { return new RedissonCountDownLatch(commandExecutor, name, id); @@ -407,51 +284,25 @@ public class Redisson implements RedissonClient { return new RedissonBitSet(commandExecutor, name); } - /** - * Returns keys operations. - * Each of Redis/Redisson object associated with own key - * - * @return - */ @Override public RKeys getKeys() { return new RedissonKeys(commandExecutor); } - /** - * Shuts down Redisson instance NOT Redis server - */ @Override public void shutdown() { connectionManager.shutdown(); } - /** - * Allows to get configuration provided - * during Redisson instance creation. Further changes on - * this object not affect Redisson instance. - * - * @return Config object - */ @Override public Config getConfig() { return config; } - /** - * Get Redis nodes group for server operations - * - * @return - */ public NodesGroup getNodesGroup() { return new RedisNodes(connectionManager); } - /** - * Get Redis cluster nodes group for server operations - * - * @return - */ public NodesGroup getClusterNodesGroup() { if (!config.isClusterConfig()) { throw new IllegalStateException("Redisson not in cluster mode!"); @@ -459,30 +310,16 @@ public class Redisson implements RedissonClient { return new RedisNodes(connectionManager); } - /** - * Delete all the keys of the currently selected database - */ @Override public void flushdb() { commandExecutor.get(commandExecutor.writeAllAsync(RedisCommands.FLUSHDB)); } - /** - * Delete all the keys of all the existing databases - */ @Override public void flushall() { commandExecutor.get(commandExecutor.writeAllAsync(RedisCommands.FLUSHALL)); } - /** - * Return batch object which executes group of - * command in pipeline. - * - * See http://redis.io/topics/pipelining - * - * @return - */ @Override public RBatch createBatch() { return new RedissonBatch(connectionManager); diff --git a/src/main/java/org/redisson/RedissonClient.java b/src/main/java/org/redisson/RedissonClient.java index 58a7febf8..622d86125 100755 --- a/src/main/java/org/redisson/RedissonClient.java +++ b/src/main/java/org/redisson/RedissonClient.java @@ -42,41 +42,72 @@ import org.redisson.core.RSet; import org.redisson.core.RSortedSet; import org.redisson.core.RTopic; +/** + * Main Redisson interface for access + * to all redisson objects with sync and async interfaces. + * + * @author Nikita Koksharov + * + */ public interface RedissonClient { /** - * Returns object holder by name + * Returns object holder by name. * * @param name of object * @return */ RBucket getBucket(String name); + /** + * Returns object holder by name + * using provided codec for object. + * + * @param name of object + * @param object codec + * @return + */ RBucket getBucket(String name, Codec codec); /** - * Returns a list of object holder by a key pattern + * Returns a list of object holder by a key pattern. */ List> getBuckets(String pattern); /** - * Returns HyperLogLog object + * Returns HyperLogLog object by name. * * @param name of object * @return */ RHyperLogLog getHyperLogLog(String name); + /** + * Returns HyperLogLog object by name + * using provided codec for hll objects. + * + * @param name of object + * @param object codec + * @return + */ RHyperLogLog getHyperLogLog(String name, Codec codec); /** - * Returns list instance by name. + * Returns list object by name. * - * @param name of list + * @param name of object * @return */ RList getList(String name); + /** + * Returns list object by name + * using provided codec for list objects. + * + * @param name of object + * @param list object codec + * @return + */ RList getList(String name, Codec codec); /** @@ -87,6 +118,14 @@ public interface RedissonClient { */ RMap getMap(String name); + /** + * Returns map instance by name + * using provided codec for both map keys and values. + * + * @param name of map + * @param map key and value codec + * @return + */ RMap getMap(String name, Codec codec); /** @@ -105,26 +144,54 @@ public interface RedissonClient { */ RSet getSet(String name); + /** + * Returns set instance by name + * using provided codec for set objects. + * + * @param name of set + * @param set object codec + * @return + */ RSet getSet(String name, Codec codec); /** * Returns sorted set instance by name. + * This sorted set uses comparator to sort objects. * * @param name of sorted set * @return */ RSortedSet getSortedSet(String name); + /** + * Returns sorted set instance by name + * using provided codec for sorted set objects. + * This sorted set sorts objects using comparator. + * + * @param name of sorted set + * @param sorted set object codec + * @return + */ RSortedSet getSortedSet(String name, Codec codec); /** - * Returns Redis Sorted Set instance by name + * Returns Redis Sorted Set instance by name. + * This sorted set sorts objects by object score. * - * @param name + * @param name of scored sorted set * @return */ RScoredSortedSet getScoredSortedSet(String name); + /** + * Returns Redis Sorted Set instance by name + * using provided codec for sorted set objects. + * This sorted set sorts objects by object score. + * + * @param name of scored sorted set + * @param scored sorted set object codec + * @return + */ RScoredSortedSet getScoredSortedSet(String name, Codec codec); /** @@ -145,6 +212,14 @@ public interface RedissonClient { */ RTopic getTopic(String name); + /** + * Returns topic instance by name + * using provided codec for messages. + * + * @param name of topic + * @param message codec + * @return + */ RTopic getTopic(String name, Codec codec); /** @@ -160,6 +235,19 @@ public interface RedissonClient { */ RPatternTopic getPatternTopic(String pattern); + /** + * Returns topic instance satisfies by pattern name + * using provided codec for messages. + * + * Supported glob-style patterns: + * h?llo subscribes to hello, hallo and hxllo + * h*llo subscribes to hllo and heeeello + * h[ae]llo subscribes to hello and hallo, but not hillo + * + * @param pattern of the topic + * @param message codec + * @return + */ RPatternTopic getPatternTopic(String pattern, Codec codec); /** @@ -170,6 +258,14 @@ public interface RedissonClient { */ RQueue getQueue(String name); + /** + * Returns queue instance by name + * using provided codec for queue objects. + * + * @param name of queue + * @param queue objects codec + * @return + */ RQueue getQueue(String name, Codec codec); /** @@ -180,6 +276,14 @@ public interface RedissonClient { */ RBlockingQueue getBlockingQueue(String name); + /** + * Returns blocking queue instance by name + * using provided codec for queue objects. + * + * @param name of queue + * @param queue objects codec + * @return + */ RBlockingQueue getBlockingQueue(String name, Codec codec); /** @@ -190,24 +294,38 @@ public interface RedissonClient { */ RDeque getDeque(String name); + /** + * Returns deque instance by name + * using provided codec for deque objects. + * + * @param name of deque + * @param deque objects codec + * @return + */ RDeque getDeque(String name, Codec codec); /** - * Returns "atomic long" instance by name. + * Returns atomicLong instance by name. * - * @param name of the "atomic long" + * @param name of atomicLong * @return */ RAtomicLong getAtomicLong(String name); /** - * Returns "count down latch" instance by name. + * Returns countDownLatch instance by name. * - * @param name of the "count down latch" + * @param name of countDownLatch * @return */ RCountDownLatch getCountDownLatch(String name); + /** + * Returns bitSet instance by name. + * + * @param name of bitSet + * @return + */ RBitSet getBitSet(String name); /** diff --git a/src/main/java/org/redisson/client/codec/Codec.java b/src/main/java/org/redisson/client/codec/Codec.java index f82e13429..5b6d23ba1 100644 --- a/src/main/java/org/redisson/client/codec/Codec.java +++ b/src/main/java/org/redisson/client/codec/Codec.java @@ -19,7 +19,7 @@ import org.redisson.client.protocol.Decoder; import org.redisson.client.protocol.Encoder; /** - * Redis code + * Redis codec interface * * @author Nikita Koksharov * diff --git a/src/main/java/org/redisson/codec/FstCodec.java b/src/main/java/org/redisson/codec/FstCodec.java index 7b2ed5aa0..52e7788b2 100644 --- a/src/main/java/org/redisson/codec/FstCodec.java +++ b/src/main/java/org/redisson/codec/FstCodec.java @@ -31,7 +31,7 @@ import io.netty.buffer.ByteBufInputStream; /** * Efficient and speedy serialization codec fully - * compatible with JDK codec. + * compatible with JDK Serialization codec. * * https://github.com/RuedigerMoeller/fast-serialization * diff --git a/src/main/java/org/redisson/codec/JsonJacksonCodec.java b/src/main/java/org/redisson/codec/JsonJacksonCodec.java index aa341c930..02305d28e 100755 --- a/src/main/java/org/redisson/codec/JsonJacksonCodec.java +++ b/src/main/java/org/redisson/codec/JsonJacksonCodec.java @@ -18,7 +18,6 @@ package org.redisson.codec; import java.io.IOException; import org.redisson.client.codec.Codec; -import org.redisson.client.codec.StringCodec; import org.redisson.client.handler.State; import org.redisson.client.protocol.Decoder; import org.redisson.client.protocol.Encoder; @@ -39,6 +38,9 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufInputStream; /** + * + * @see org.redisson.codec.CborJacksonCodec + * @see org.redisson.codec.MsgPackJacksonCodec * * @author Nikita Koksharov *