IGNITE-6989 .NET: Thin client: Group operation codes by purpose
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/150449ca Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/150449ca Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/150449ca Branch: refs/heads/ignite-7016 Commit: 150449ca0068335461d977ba00ee425ace907f29 Parents: d5d2d32 Author: Pavel Tupitsyn <[email protected]> Authored: Mon Nov 27 12:47:44 2017 +0300 Committer: Pavel Tupitsyn <[email protected]> Committed: Mon Nov 27 12:47:44 2017 +0300 ---------------------------------------------------------------------- .../platform/client/ClientMessageParser.java | 97 +++++++++++--------- .../Client/RawSocketTest.cs | 2 +- .../Apache.Ignite.Core/Impl/Client/ClientOp.cs | 85 +++++++++-------- 3 files changed, 100 insertions(+), 84 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/150449ca/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java index 626b7ff..057995d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java @@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.platform.client; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.binary.BinaryRawReaderEx; import org.apache.ignite.internal.binary.BinaryRawWriterEx; +import org.apache.ignite.internal.binary.BinaryReaderExImpl; import org.apache.ignite.internal.binary.GridBinaryMarshaller; import org.apache.ignite.internal.binary.streams.BinaryHeapInputStream; import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream; @@ -69,122 +70,127 @@ import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheSq * Thin client message parser. */ public class ClientMessageParser implements ClientListenerMessageParser { + /* General-purpose operations. */ /** */ - private static final short OP_CACHE_GET = 1; + private static final short OP_RESOURCE_CLOSE = 0; + /* Cache operations */ /** */ - private static final short OP_GET_BINARY_TYPE_NAME = 2; + private static final short OP_CACHE_GET = 1000; /** */ - private static final short OP_GET_BINARY_TYPE = 3; + private static final short OP_CACHE_PUT = 1001; /** */ - private static final short OP_CACHE_PUT = 4; + private static final short OP_CACHE_PUT_IF_ABSENT = 1002; /** */ - private static final short OP_REGISTER_BINARY_TYPE_NAME = 5; + private static final short OP_CACHE_GET_ALL = 1003; /** */ - private static final short OP_PUT_BINARY_TYPE = 6; + private static final short OP_CACHE_PUT_ALL = 1004; /** */ - private static final short OP_QUERY_SCAN = 7; + private static final short OP_CACHE_GET_AND_PUT = 1005; /** */ - private static final short OP_QUERY_SCAN_CURSOR_GET_PAGE = 8; + private static final short OP_CACHE_GET_AND_REPLACE = 1006; /** */ - private static final short OP_RESOURCE_CLOSE = 9; + private static final short OP_CACHE_GET_AND_REMOVE = 1007; /** */ - private static final short OP_CACHE_CONTAINS_KEY = 10; + private static final short OP_CACHE_GET_AND_PUT_IF_ABSENT = 1008; /** */ - private static final short OP_CACHE_CONTAINS_KEYS = 11; + private static final short OP_CACHE_REPLACE = 1009; /** */ - private static final short OP_CACHE_GET_ALL = 12; + private static final short OP_CACHE_REPLACE_IF_EQUALS = 1010; /** */ - private static final short OP_CACHE_GET_AND_PUT = 13; + private static final short OP_CACHE_CONTAINS_KEY = 1011; /** */ - private static final short OP_CACHE_GET_AND_REPLACE = 14; + private static final short OP_CACHE_CONTAINS_KEYS = 1012; /** */ - private static final short OP_CACHE_GET_AND_REMOVE = 15; + private static final short OP_CACHE_CLEAR = 1013; /** */ - private static final short OP_CACHE_PUT_IF_ABSENT = 16; + private static final short OP_CACHE_CLEAR_KEY = 1014; /** */ - private static final short OP_CACHE_GET_AND_PUT_IF_ABSENT = 17; + private static final short OP_CACHE_CLEAR_KEYS = 1015; /** */ - private static final short OP_CACHE_REPLACE = 18; + private static final short OP_CACHE_REMOVE_KEY = 1016; /** */ - private static final short OP_CACHE_REPLACE_IF_EQUALS = 19; + private static final short OP_CACHE_REMOVE_IF_EQUALS = 1017; /** */ - private static final short OP_CACHE_PUT_ALL = 20; + private static final short OP_CACHE_REMOVE_KEYS = 1018; /** */ - private static final short OP_CACHE_CLEAR = 21; + private static final short OP_CACHE_REMOVE_ALL = 1019; /** */ - private static final short OP_CACHE_CLEAR_KEY = 22; + private static final short OP_CACHE_GET_SIZE = 1020; + /* Cache create / destroy, configuration. */ /** */ - private static final short OP_CACHE_CLEAR_KEYS = 23; + private static final short OP_CACHE_GET_NAMES = 1050; /** */ - private static final short OP_CACHE_REMOVE_KEY = 24; + private static final short OP_CACHE_CREATE_WITH_NAME = 1051; /** */ - private static final short OP_CACHE_REMOVE_IF_EQUALS = 25; + private static final short OP_CACHE_GET_OR_CREATE_WITH_NAME = 1052; /** */ - private static final short OP_CACHE_GET_SIZE = 26; + private static final short OP_CACHE_CREATE_WITH_CONFIGURATION = 1053; /** */ - private static final short OP_CACHE_REMOVE_KEYS = 27; + private static final short OP_CACHE_GET_OR_CREATE_WITH_CONFIGURATION = 1054; /** */ - private static final short OP_CACHE_REMOVE_ALL = 28; + private static final short OP_CACHE_GET_CONFIGURATION = 1055; /** */ - private static final short OP_CACHE_CREATE_WITH_NAME = 29; + private static final short OP_CACHE_DESTROY = 1056; + /* Query operations. */ /** */ - private static final short OP_CACHE_GET_OR_CREATE_WITH_NAME = 30; + private static final short OP_QUERY_SCAN = 2000; /** */ - private static final short OP_CACHE_DESTROY = 31; + private static final short OP_QUERY_SCAN_CURSOR_GET_PAGE = 2001; /** */ - private static final short OP_CACHE_GET_NAMES = 32; + private static final short OP_QUERY_SQL = 2002; /** */ - private static final short OP_CACHE_GET_CONFIGURATION = 33; + private static final short OP_QUERY_SQL_CURSOR_GET_PAGE = 2003; /** */ - private static final short OP_CACHE_CREATE_WITH_CONFIGURATION = 34; + private static final short OP_QUERY_SQL_FIELDS = 2004; /** */ - private static final short OP_CACHE_GET_OR_CREATE_WITH_CONFIGURATION = 35; + private static final short OP_QUERY_SQL_FIELDS_CURSOR_GET_PAGE = 2005; + /* Binary metadata operations. */ /** */ - private static final short OP_QUERY_SQL = 36; + private static final short OP_BINARY_TYPE_NAME_GET = 3000; /** */ - private static final short OP_QUERY_SQL_CURSOR_GET_PAGE = 37; + private static final short OP_BINARY_TYPE_NAME_PUT = 3001; /** */ - private static final short OP_QUERY_SQL_FIELDS = 38; + private static final short OP_BINARY_TYPE_GET = 3002; /** */ - private static final short OP_QUERY_SQL_FIELDS_CURSOR_GET_PAGE = 39; + private static final short OP_BINARY_TYPE_PUT = 3003; /** Marshaller. */ private final GridBinaryMarshaller marsh; @@ -206,7 +212,10 @@ public class ClientMessageParser implements ClientListenerMessageParser { assert msg != null; BinaryInputStream inStream = new BinaryHeapInputStream(msg); - BinaryRawReaderEx reader = marsh.reader(inStream); + + // skipHdrCheck must be true (we have 103 op code). + BinaryRawReaderEx reader = new BinaryReaderExImpl(marsh.context(), inStream, + null, null, true, true); return decode(reader); } @@ -224,19 +233,19 @@ public class ClientMessageParser implements ClientListenerMessageParser { case OP_CACHE_GET: return new ClientCacheGetRequest(reader); - case OP_GET_BINARY_TYPE_NAME: + case OP_BINARY_TYPE_NAME_GET: return new ClientBinaryTypeNameGetRequest(reader); - case OP_GET_BINARY_TYPE: + case OP_BINARY_TYPE_GET: return new ClientBinaryTypeGetRequest(reader); case OP_CACHE_PUT: return new ClientCachePutRequest(reader); - case OP_REGISTER_BINARY_TYPE_NAME: + case OP_BINARY_TYPE_NAME_PUT: return new ClientBinaryTypeNamePutRequest(reader); - case OP_PUT_BINARY_TYPE: + case OP_BINARY_TYPE_PUT: return new ClientBinaryTypePutRequest(reader); case OP_QUERY_SCAN: http://git-wip-us.apache.org/repos/asf/ignite/blob/150449ca/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/RawSocketTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/RawSocketTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/RawSocketTest.cs index 0f1358a..9aab341 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/RawSocketTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/RawSocketTest.cs @@ -52,7 +52,7 @@ namespace Apache.Ignite.Core.Tests.Client // Cache get. SendRequest(sock, stream => { - stream.WriteShort(1); // OP_GET + stream.WriteShort(1000); // OP_GET stream.WriteLong(1); // Request id. var cacheId = BinaryUtils.GetStringHashCodeLowerCase(cache.Name); stream.WriteInt(cacheId); http://git-wip-us.apache.org/repos/asf/ignite/blob/150449ca/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientOp.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientOp.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientOp.cs index 3af089a..fae3bb9 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientOp.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientOp.cs @@ -22,44 +22,51 @@ namespace Apache.Ignite.Core.Impl.Client /// </summary> internal enum ClientOp : short { - CacheGet = 1, - BinaryTypeNameGet = 2, - BinaryTypeGet = 3, - CachePut = 4, - BinaryTypeNamePut = 5, - BinaryTypePut = 6, - QueryScan = 7, - QueryScanCursorGetPage = 8, - ResourceClose = 9, - CacheContainsKey = 10, - CacheContainsKeys = 11, - CacheGetAll = 12, - CacheGetAndPut = 13, - CacheGetAndReplace = 14, - CacheGetAndRemove = 15, - CachePutIfAbsent = 16, - CacheGetAndPutIfAbsent = 17, - CacheReplace = 18, - CacheReplaceIfEquals = 19, - CachePutAll = 20, - CacheClear = 21, - CacheClearKey = 22, - CacheClearKeys = 23, - CacheRemoveKey = 24, - CacheRemoveIfEquals = 25, - CacheGetSize = 26, - CacheRemoveKeys = 27, - CacheRemoveAll = 28, - CacheCreateWithName = 29, - CacheGetOrCreateWithName = 30, - CacheDestroy = 31, - CacheGetNames = 32, - CacheGetConfiguration = 33, - CacheCreateWithConfiguration = 34, - CacheGetOrCreateWithConfiguration = 35, - QuerySql = 36, - QuerySqlCursorGetPage = 37, - QuerySqlFields = 38, - QuerySqlFieldsCursorGetPage = 39 + // General purpose. + ResourceClose = 0, + + // Cache. + CacheGet = 1000, + CachePut = 1001, + CachePutIfAbsent = 1002, + CacheGetAll = 1003, + CachePutAll = 1004, + CacheGetAndPut = 1005, + CacheGetAndReplace = 1006, + CacheGetAndRemove = 1007, + CacheGetAndPutIfAbsent = 1008, + CacheReplace = 1009, + CacheReplaceIfEquals = 1010, + CacheContainsKey = 1011, + CacheContainsKeys = 1012, + CacheClear = 1013, + CacheClearKey = 1014, + CacheClearKeys = 1015, + CacheRemoveKey = 1016, + CacheRemoveIfEquals = 1017, + CacheRemoveKeys = 1018, + CacheRemoveAll = 1019, + CacheGetSize = 1020, + CacheGetNames = 1050, + CacheCreateWithName = 1051, + CacheGetOrCreateWithName = 1052, + CacheCreateWithConfiguration = 1053, + CacheGetOrCreateWithConfiguration = 1054, + CacheGetConfiguration = 1055, + CacheDestroy = 1056, + + // Queries. + QueryScan = 2000, + QueryScanCursorGetPage = 2001, + QuerySql = 2002, + QuerySqlCursorGetPage = 2003, + QuerySqlFields = 2004, + QuerySqlFieldsCursorGetPage = 2005, + + // Metadata. + BinaryTypeNameGet = 3000, + BinaryTypeNamePut = 3001, + BinaryTypeGet = 3002, + BinaryTypePut = 3003 } }
