ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shro...@apache.org
Subject ignite git commit: IGNITE-3066: Review, 2nd round.
Date Tue, 08 Nov 2016 09:46:50 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-2788 f8a6dc1df -> c827e0428


IGNITE-3066: Review, 2nd round.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c827e042
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c827e042
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c827e042

Branch: refs/heads/ignite-2788
Commit: c827e042847237762c109e6e7d55001b2a9c69ae
Parents: f8a6dc1
Author: shtykh_roman <rshtykh@yahoo.com>
Authored: Tue Nov 8 18:45:53 2016 +0900
Committer: shtykh_roman <rshtykh@yahoo.com>
Committed: Tue Nov 8 18:45:53 2016 +0900

----------------------------------------------------------------------
 .../tcp/redis/RedisProtocolSelfTest.java        |  2 +-
 .../redis/GridRedisThruRestCommandHandler.java  |  4 +--
 .../redis/key/GridRedisDelCommandHandler.java   |  5 ++--
 .../key/GridRedisExistsCommandHandler.java      |  5 ++--
 .../server/GridRedisDbSizeCommandHandler.java   |  5 ++--
 .../string/GridRedisAppendCommandHandler.java   | 14 +++++-----
 .../string/GridRedisGetCommandHandler.java      |  5 ++--
 .../string/GridRedisGetRangeCommandHandler.java | 21 +++++----------
 .../string/GridRedisGetSetCommandHandler.java   |  5 ++--
 .../string/GridRedisIncrDecrCommandHandler.java | 13 ++++-----
 .../string/GridRedisMGetCommandHandler.java     |  5 ++--
 .../string/GridRedisMSetCommandHandler.java     |  5 ++--
 .../string/GridRedisSetCommandHandler.java      |  5 ++--
 .../string/GridRedisSetRangeCommandHandler.java | 28 +++++++++++---------
 .../string/GridRedisStrlenCommandHandler.java   |  5 ++--
 .../tcp/redis/GridRedisNioListener.java         | 26 +++++++++---------
 16 files changed, 69 insertions(+), 84 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c827e042/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolSelfTest.java
b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolSelfTest.java
index d686b5c..19111e6 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/RedisProtocolSelfTest.java
@@ -122,7 +122,7 @@ public class RedisProtocolSelfTest extends GridCommonAbstractTest {
     }
 
     /** {@inheritDoc} */
-    protected void beforeTest() throws Exception {
+    @Override protected void beforeTest() throws Exception {
         assert grid(0).cluster().nodes().size() == gridCount();
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/c827e042/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/GridRedisThruRestCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/GridRedisThruRestCommandHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/GridRedisThruRestCommandHandler.java
index 668d00f..6248520 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/GridRedisThruRestCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/GridRedisThruRestCommandHandler.java
@@ -20,7 +20,6 @@ package org.apache.ignite.internal.processors.rest.handlers.redis;
 import java.nio.ByteBuffer;
 import java.util.List;
 import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.processors.rest.GridRestProtocolHandler;
 import org.apache.ignite.internal.processors.rest.GridRestResponse;
@@ -41,10 +40,9 @@ public abstract class GridRedisThruRestCommandHandler implements GridRedisComman
     /**
      * Constructor.
      *
-     * @param ctx Context.
      * @param hnd REST protocol handler.
      */
-    public GridRedisThruRestCommandHandler(final GridKernalContext ctx, final GridRestProtocolHandler
hnd) {
+    public GridRedisThruRestCommandHandler(final GridRestProtocolHandler hnd) {
         this.hnd = hnd;
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/c827e042/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/key/GridRedisDelCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/key/GridRedisDelCommandHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/key/GridRedisDelCommandHandler.java
index 62fa2b0..a444d91 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/key/GridRedisDelCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/key/GridRedisDelCommandHandler.java
@@ -23,7 +23,6 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.processors.rest.GridRestProtocolHandler;
 import org.apache.ignite.internal.processors.rest.GridRestResponse;
 import org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRedisCommand;
@@ -48,8 +47,8 @@ public class GridRedisDelCommandHandler extends GridRedisThruRestCommandHandler
     );
 
     /** {@inheritDoc} */
-    public GridRedisDelCommandHandler(final GridKernalContext ctx, final GridRestProtocolHandler
hnd) {
-        super(ctx, hnd);
+    public GridRedisDelCommandHandler(final GridRestProtocolHandler hnd) {
+        super(hnd);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/c827e042/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/key/GridRedisExistsCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/key/GridRedisExistsCommandHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/key/GridRedisExistsCommandHandler.java
index 3802517..3649580 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/key/GridRedisExistsCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/key/GridRedisExistsCommandHandler.java
@@ -23,7 +23,6 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.processors.rest.GridRestProtocolHandler;
 import org.apache.ignite.internal.processors.rest.GridRestResponse;
 import org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRedisCommand;
@@ -48,8 +47,8 @@ public class GridRedisExistsCommandHandler extends GridRedisThruRestCommandHandl
     );
 
     /** {@inheritDoc} */
-    public GridRedisExistsCommandHandler(final GridKernalContext ctx, final GridRestProtocolHandler
hnd) {
-        super(ctx, hnd);
+    public GridRedisExistsCommandHandler(final GridRestProtocolHandler hnd) {
+        super(hnd);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/c827e042/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/server/GridRedisDbSizeCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/server/GridRedisDbSizeCommandHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/server/GridRedisDbSizeCommandHandler.java
index 27daad4..bde9a81 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/server/GridRedisDbSizeCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/server/GridRedisDbSizeCommandHandler.java
@@ -21,7 +21,6 @@ import java.nio.ByteBuffer;
 import java.util.Collection;
 import java.util.List;
 import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.processors.rest.GridRestProtocolHandler;
 import org.apache.ignite.internal.processors.rest.GridRestResponse;
 import org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRedisCommand;
@@ -45,8 +44,8 @@ public class GridRedisDbSizeCommandHandler extends GridRedisThruRestCommandHandl
     );
 
     /** {@inheritDoc} */
-    public GridRedisDbSizeCommandHandler(final GridKernalContext ctx, final GridRestProtocolHandler
hnd) {
-        super(ctx, hnd);
+    public GridRedisDbSizeCommandHandler(final GridRestProtocolHandler hnd) {
+        super(hnd);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/c827e042/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisAppendCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisAppendCommandHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisAppendCommandHandler.java
index 331f7fe..78fc8d3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisAppendCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisAppendCommandHandler.java
@@ -21,14 +21,13 @@ import java.nio.ByteBuffer;
 import java.util.Collection;
 import java.util.List;
 import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.processors.rest.GridRestProtocolHandler;
 import org.apache.ignite.internal.processors.rest.GridRestResponse;
+import org.apache.ignite.internal.processors.rest.handlers.redis.GridRedisThruRestCommandHandler;
+import org.apache.ignite.internal.processors.rest.handlers.redis.exception.GridRedisGenericException;
 import org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRedisCommand;
 import org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRedisMessage;
 import org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRedisProtocolParser;
-import org.apache.ignite.internal.processors.rest.handlers.redis.GridRedisThruRestCommandHandler;
-import org.apache.ignite.internal.processors.rest.handlers.redis.exception.GridRedisGenericException;
 import org.apache.ignite.internal.processors.rest.request.GridRestCacheRequest;
 import org.apache.ignite.internal.processors.rest.request.GridRestRequest;
 import org.apache.ignite.internal.util.typedef.internal.U;
@@ -51,8 +50,8 @@ public class GridRedisAppendCommandHandler extends GridRedisThruRestCommandHandl
     private static final int VAL_POS = 2;
 
     /** {@inheritDoc} */
-    public GridRedisAppendCommandHandler(final GridKernalContext ctx, final GridRestProtocolHandler
hnd) {
-        super(ctx, hnd);
+    public GridRedisAppendCommandHandler(final GridRestProtocolHandler hnd) {
+        super(hnd);
     }
 
     /** {@inheritDoc} */
@@ -77,8 +76,9 @@ public class GridRedisAppendCommandHandler extends GridRedisThruRestCommandHandl
         appendReq.value(val);
         appendReq.command(CACHE_APPEND);
 
-        if ((boolean)hnd.handle(appendReq).getResponse() == false) {
-            // append on on-existing key in REST returns false.
+        Object resp = hnd.handle(appendReq).getResponse();
+        if (resp != null && !(boolean)resp) {
+            // append on existing key.
             GridRestCacheRequest setReq = new GridRestCacheRequest();
 
             setReq.clientId(msg.clientId());

http://git-wip-us.apache.org/repos/asf/ignite/blob/c827e042/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisGetCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisGetCommandHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisGetCommandHandler.java
index b06e411..1a75a76 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisGetCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisGetCommandHandler.java
@@ -21,7 +21,6 @@ import java.nio.ByteBuffer;
 import java.util.Collection;
 import java.util.List;
 import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.processors.rest.GridRestProtocolHandler;
 import org.apache.ignite.internal.processors.rest.GridRestResponse;
 import org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRedisCommand;
@@ -45,8 +44,8 @@ public class GridRedisGetCommandHandler extends GridRedisThruRestCommandHandler
     );
 
     /** {@inheritDoc} */
-    public GridRedisGetCommandHandler(final GridKernalContext ctx, final GridRestProtocolHandler
hnd) {
-        super(ctx, hnd);
+    public GridRedisGetCommandHandler(final GridRestProtocolHandler hnd) {
+        super(hnd);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/c827e042/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisGetRangeCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisGetRangeCommandHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisGetRangeCommandHandler.java
index 481e07a..8850ecf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisGetRangeCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisGetRangeCommandHandler.java
@@ -21,14 +21,13 @@ import java.nio.ByteBuffer;
 import java.util.Collection;
 import java.util.List;
 import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.processors.rest.GridRestProtocolHandler;
 import org.apache.ignite.internal.processors.rest.GridRestResponse;
+import org.apache.ignite.internal.processors.rest.handlers.redis.GridRedisThruRestCommandHandler;
+import org.apache.ignite.internal.processors.rest.handlers.redis.exception.GridRedisGenericException;
 import org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRedisCommand;
 import org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRedisMessage;
 import org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRedisProtocolParser;
-import org.apache.ignite.internal.processors.rest.handlers.redis.GridRedisThruRestCommandHandler;
-import org.apache.ignite.internal.processors.rest.handlers.redis.exception.GridRedisGenericException;
 import org.apache.ignite.internal.processors.rest.request.GridRestCacheRequest;
 import org.apache.ignite.internal.processors.rest.request.GridRestRequest;
 import org.apache.ignite.internal.util.typedef.internal.U;
@@ -52,8 +51,8 @@ public class GridRedisGetRangeCommandHandler extends GridRedisThruRestCommandHan
     private static final int END_OFFSET_POS = 2;
 
     /** {@inheritDoc} */
-    public GridRedisGetRangeCommandHandler(final GridKernalContext ctx, final GridRestProtocolHandler
hnd) {
-        super(ctx, hnd);
+    public GridRedisGetRangeCommandHandler(final GridRestProtocolHandler hnd) {
+        super(hnd);
     }
 
     /** {@inheritDoc} */
@@ -90,7 +89,7 @@ public class GridRedisGetRangeCommandHandler extends GridRedisThruRestCommandHan
                 startOffset = boundedStartOffset(Integer.parseInt(params.get(START_OFFSET_POS)),
res.length());
                 endOffset = boundedEndOffset(Integer.parseInt(params.get(END_OFFSET_POS)),
res.length());
             }
-            catch (NumberFormatException e) {
+            catch (NumberFormatException ignored) {
                 return GridRedisProtocolParser.toGenericError("Offset is not an integer!");
             }
 
@@ -104,10 +103,7 @@ public class GridRedisGetRangeCommandHandler extends GridRedisThruRestCommandHan
      * @return Offset within the bounds.
      */
     private int boundedStartOffset(int idx, int size) {
-        if (idx >= 0)
-            return Math.min(idx, size);
-        else
-            return size + idx;
+        return idx >= 0 ? Math.min(idx, size) : size + idx;
     }
 
     /**
@@ -116,9 +112,6 @@ public class GridRedisGetRangeCommandHandler extends GridRedisThruRestCommandHan
      * @return Offset within the bounds.
      */
     private int boundedEndOffset(int idx, int size) {
-        if (idx >= 0)
-            return Math.min(idx + 1, size);
-        else
-            return size + idx + 1;
+        return idx >= 0 ? Math.min(idx + 1, size) : size + idx + 1;
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/c827e042/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisGetSetCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisGetSetCommandHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisGetSetCommandHandler.java
index 0f302e5..80d678e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisGetSetCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisGetSetCommandHandler.java
@@ -21,7 +21,6 @@ import java.nio.ByteBuffer;
 import java.util.Collection;
 import java.util.List;
 import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.processors.rest.GridRestProtocolHandler;
 import org.apache.ignite.internal.processors.rest.GridRestResponse;
 import org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRedisCommand;
@@ -49,8 +48,8 @@ public class GridRedisGetSetCommandHandler extends GridRedisThruRestCommandHandl
     private static final int VAL_POS = 2;
 
     /** {@inheritDoc} */
-    public GridRedisGetSetCommandHandler(final GridKernalContext ctx, final GridRestProtocolHandler
hnd) {
-        super(ctx, hnd);
+    public GridRedisGetSetCommandHandler(final GridRestProtocolHandler hnd) {
+        super(hnd);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/c827e042/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisIncrDecrCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisIncrDecrCommandHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisIncrDecrCommandHandler.java
index 34d4b31..f713562 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisIncrDecrCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisIncrDecrCommandHandler.java
@@ -22,14 +22,13 @@ import java.nio.ByteBuffer;
 import java.util.Collection;
 import java.util.List;
 import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.processors.rest.GridRestProtocolHandler;
 import org.apache.ignite.internal.processors.rest.GridRestResponse;
+import org.apache.ignite.internal.processors.rest.handlers.redis.GridRedisThruRestCommandHandler;
+import org.apache.ignite.internal.processors.rest.handlers.redis.exception.GridRedisGenericException;
 import org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRedisCommand;
 import org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRedisMessage;
 import org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRedisProtocolParser;
-import org.apache.ignite.internal.processors.rest.handlers.redis.GridRedisThruRestCommandHandler;
-import org.apache.ignite.internal.processors.rest.handlers.redis.exception.GridRedisGenericException;
 import org.apache.ignite.internal.processors.rest.request.DataStructuresRequest;
 import org.apache.ignite.internal.processors.rest.request.GridRestCacheRequest;
 import org.apache.ignite.internal.processors.rest.request.GridRestRequest;
@@ -59,8 +58,8 @@ public class GridRedisIncrDecrCommandHandler extends GridRedisThruRestCommandHan
     private static final int DELTA_POS = 2;
 
     /** {@inheritDoc} */
-    public GridRedisIncrDecrCommandHandler(final GridKernalContext ctx, final GridRestProtocolHandler
hnd) {
-        super(ctx, hnd);
+    public GridRedisIncrDecrCommandHandler(final GridRestProtocolHandler hnd) {
+        super(hnd);
     }
 
     /** {@inheritDoc} */
@@ -100,7 +99,7 @@ public class GridRedisIncrDecrCommandHandler extends GridRedisThruRestCommandHan
             try {
                 restReq.delta(Long.valueOf(msg.aux(DELTA_POS)));
             }
-            catch (NumberFormatException e) {
+            catch (NumberFormatException ignored) {
                 throw new GridRedisGenericException("An increment value must be numeric and
in range!");
             }
         }
@@ -115,6 +114,8 @@ public class GridRedisIncrDecrCommandHandler extends GridRedisThruRestCommandHan
             case DECRBY:
                 restReq.command(ATOMIC_DECREMENT);
                 break;
+            default:
+                assert false : "Unexpected command received!";
         }
 
         return restReq;

http://git-wip-us.apache.org/repos/asf/ignite/blob/c827e042/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisMGetCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisMGetCommandHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisMGetCommandHandler.java
index 4cf8345..5c46e86 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisMGetCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisMGetCommandHandler.java
@@ -23,7 +23,6 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.processors.rest.GridRestProtocolHandler;
 import org.apache.ignite.internal.processors.rest.GridRestResponse;
 import org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRedisCommand;
@@ -48,8 +47,8 @@ public class GridRedisMGetCommandHandler extends GridRedisThruRestCommandHandler
     );
 
     /** {@inheritDoc} */
-    public GridRedisMGetCommandHandler(final GridKernalContext ctx, final GridRestProtocolHandler
hnd) {
-        super(ctx, hnd);
+    public GridRedisMGetCommandHandler(final GridRestProtocolHandler hnd) {
+        super(hnd);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/c827e042/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisMSetCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisMSetCommandHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisMSetCommandHandler.java
index 783fed5..7f5449a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisMSetCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisMSetCommandHandler.java
@@ -23,7 +23,6 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.processors.rest.GridRestProtocolHandler;
 import org.apache.ignite.internal.processors.rest.GridRestResponse;
 import org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRedisCommand;
@@ -47,8 +46,8 @@ public class GridRedisMSetCommandHandler extends GridRedisThruRestCommandHandler
     );
 
     /** {@inheritDoc} */
-    public GridRedisMSetCommandHandler(final GridKernalContext ctx, final GridRestProtocolHandler
hnd) {
-        super(ctx, hnd);
+    public GridRedisMSetCommandHandler(final GridRestProtocolHandler hnd) {
+        super(hnd);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/c827e042/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisSetCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisSetCommandHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisSetCommandHandler.java
index 2906f1b..1d447f1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisSetCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisSetCommandHandler.java
@@ -21,7 +21,6 @@ import java.nio.ByteBuffer;
 import java.util.Collection;
 import java.util.List;
 import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.processors.rest.GridRestProtocolHandler;
 import org.apache.ignite.internal.processors.rest.GridRestResponse;
 import org.apache.ignite.internal.processors.rest.handlers.redis.GridRedisThruRestCommandHandler;
@@ -50,8 +49,8 @@ public class GridRedisSetCommandHandler extends GridRedisThruRestCommandHandler
     private static final int VAL_POS = 2;
 
     /** {@inheritDoc} */
-    public GridRedisSetCommandHandler(final GridKernalContext ctx, final GridRestProtocolHandler
hnd) {
-        super(ctx, hnd);
+    public GridRedisSetCommandHandler(final GridRestProtocolHandler hnd) {
+        super(hnd);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/c827e042/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisSetRangeCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisSetRangeCommandHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisSetRangeCommandHandler.java
index 0063c66..901f510 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisSetRangeCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisSetRangeCommandHandler.java
@@ -21,14 +21,13 @@ import java.nio.ByteBuffer;
 import java.util.Collection;
 import java.util.List;
 import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.processors.rest.GridRestProtocolHandler;
 import org.apache.ignite.internal.processors.rest.GridRestResponse;
+import org.apache.ignite.internal.processors.rest.handlers.redis.GridRedisThruRestCommandHandler;
+import org.apache.ignite.internal.processors.rest.handlers.redis.exception.GridRedisGenericException;
 import org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRedisCommand;
 import org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRedisMessage;
 import org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRedisProtocolParser;
-import org.apache.ignite.internal.processors.rest.handlers.redis.GridRedisThruRestCommandHandler;
-import org.apache.ignite.internal.processors.rest.handlers.redis.exception.GridRedisGenericException;
 import org.apache.ignite.internal.processors.rest.request.GridRestCacheRequest;
 import org.apache.ignite.internal.processors.rest.request.GridRestRequest;
 import org.apache.ignite.internal.util.typedef.internal.U;
@@ -52,9 +51,12 @@ public class GridRedisSetRangeCommandHandler extends GridRedisThruRestCommandHan
     /** Value position in Redis message. */
     private static final int VAL_POS = 3;
 
+    /** Maximum offset. */
+    private static final int MAX_OFFSET = 536870911;
+
     /** {@inheritDoc} */
-    public GridRedisSetRangeCommandHandler(final GridKernalContext ctx, final GridRestProtocolHandler
hnd) {
-        super(ctx, hnd);
+    public GridRedisSetRangeCommandHandler(final GridRestProtocolHandler hnd) {
+        super(hnd);
     }
 
     /** {@inheritDoc} */
@@ -69,11 +71,11 @@ public class GridRedisSetRangeCommandHandler extends GridRedisThruRestCommandHan
         if (msg.messageSize() < 4)
             throw new GridRedisGenericException("Wrong number of arguments");
 
-        int offset;
+        int off;
         try {
-            offset = Integer.parseInt(msg.aux(OFFSET_POS));
+            off = Integer.parseInt(msg.aux(OFFSET_POS));
         }
-        catch (NumberFormatException e) {
+        catch (NumberFormatException ignored) {
             throw new GridRedisGenericException("Offset is not an integer!");
         }
 
@@ -85,13 +87,13 @@ public class GridRedisSetRangeCommandHandler extends GridRedisThruRestCommandHan
         getReq.key(msg.key());
         getReq.command(CACHE_GET);
 
-        if (val.length() == 0)
+        if (val.isEmpty())
             return getReq;
 
         Object resp = hnd.handle(getReq).getResponse();
 
-        int totalLen = offset + val.length();
-        if (offset < 0 || totalLen > 536870911)
+        int totalLen = off + val.length();
+        if (off < 0 || totalLen > MAX_OFFSET)
             throw new GridRedisGenericException("Offset is out of range!");
 
         GridRestCacheRequest putReq = new GridRestCacheRequest();
@@ -102,14 +104,14 @@ public class GridRedisSetRangeCommandHandler extends GridRedisThruRestCommandHan
 
         if (resp == null) {
             byte[] dst = new byte[totalLen];
-            System.arraycopy(val.getBytes(), 0, dst, offset, val.length());
+            System.arraycopy(val.getBytes(), 0, dst, off, val.length());
 
             putReq.value(new String(dst));
         }
         else {
             String cacheVal = String.valueOf(resp);
 
-            cacheVal = cacheVal.substring(0, offset) + val;
+            cacheVal = cacheVal.substring(0, off) + val;
 
             putReq.value(cacheVal);
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/c827e042/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisStrlenCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisStrlenCommandHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisStrlenCommandHandler.java
index 441bf42..23ee02f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisStrlenCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/redis/string/GridRedisStrlenCommandHandler.java
@@ -21,7 +21,6 @@ import java.nio.ByteBuffer;
 import java.util.Collection;
 import java.util.List;
 import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.processors.rest.GridRestProtocolHandler;
 import org.apache.ignite.internal.processors.rest.GridRestResponse;
 import org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRedisCommand;
@@ -45,8 +44,8 @@ public class GridRedisStrlenCommandHandler extends GridRedisThruRestCommandHandl
     );
 
     /** {@inheritDoc} */
-    public GridRedisStrlenCommandHandler(final GridKernalContext ctx, final GridRestProtocolHandler
hnd) {
-        super(ctx, hnd);
+    public GridRedisStrlenCommandHandler(final GridRestProtocolHandler hnd) {
+        super(hnd);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/c827e042/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/GridRedisNioListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/GridRedisNioListener.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/GridRedisNioListener.java
index 1ff4a4a..cebf2ca 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/GridRedisNioListener.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/redis/GridRedisNioListener.java
@@ -67,23 +67,23 @@ public class GridRedisNioListener extends GridNioServerListenerAdapter<GridRedis
         addCommandHandler(new GridRedisConnectionCommandHandler());
 
         // string commands.
-        addCommandHandler(new GridRedisGetCommandHandler(ctx, hnd));
-        addCommandHandler(new GridRedisSetCommandHandler(ctx, hnd));
-        addCommandHandler(new GridRedisMSetCommandHandler(ctx, hnd));
-        addCommandHandler(new GridRedisMGetCommandHandler(ctx, hnd));
-        addCommandHandler(new GridRedisIncrDecrCommandHandler(ctx, hnd));
-        addCommandHandler(new GridRedisAppendCommandHandler(ctx, hnd));
-        addCommandHandler(new GridRedisGetSetCommandHandler(ctx, hnd));
-        addCommandHandler(new GridRedisStrlenCommandHandler(ctx, hnd));
-        addCommandHandler(new GridRedisSetRangeCommandHandler(ctx, hnd));
-        addCommandHandler(new GridRedisGetRangeCommandHandler(ctx, hnd));
+        addCommandHandler(new GridRedisGetCommandHandler(hnd));
+        addCommandHandler(new GridRedisSetCommandHandler(hnd));
+        addCommandHandler(new GridRedisMSetCommandHandler(hnd));
+        addCommandHandler(new GridRedisMGetCommandHandler(hnd));
+        addCommandHandler(new GridRedisIncrDecrCommandHandler(hnd));
+        addCommandHandler(new GridRedisAppendCommandHandler(hnd));
+        addCommandHandler(new GridRedisGetSetCommandHandler(hnd));
+        addCommandHandler(new GridRedisStrlenCommandHandler(hnd));
+        addCommandHandler(new GridRedisSetRangeCommandHandler(hnd));
+        addCommandHandler(new GridRedisGetRangeCommandHandler(hnd));
 
         // key commands.
-        addCommandHandler(new GridRedisDelCommandHandler(ctx, hnd));
-        addCommandHandler(new GridRedisExistsCommandHandler(ctx, hnd));
+        addCommandHandler(new GridRedisDelCommandHandler(hnd));
+        addCommandHandler(new GridRedisExistsCommandHandler(hnd));
 
         // server commands.
-        addCommandHandler(new GridRedisDbSizeCommandHandler(ctx, hnd));
+        addCommandHandler(new GridRedisDbSizeCommandHandler(hnd));
     }
 
     /**


Mime
View raw message