Skip to content

Commit 150449c

Browse files
committed
IGNITE-6989 .NET: Thin client: Group operation codes by purpose
1 parent d5d2d32 commit 150449c

File tree

3 files changed

+100
-84
lines changed

3 files changed

+100
-84
lines changed

modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java

Lines changed: 53 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.apache.ignite.internal.GridKernalContext;
2121
import org.apache.ignite.internal.binary.BinaryRawReaderEx;
2222
import org.apache.ignite.internal.binary.BinaryRawWriterEx;
23+
import org.apache.ignite.internal.binary.BinaryReaderExImpl;
2324
import org.apache.ignite.internal.binary.GridBinaryMarshaller;
2425
import org.apache.ignite.internal.binary.streams.BinaryHeapInputStream;
2526
import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
@@ -69,122 +70,127 @@
6970
* Thin client message parser.
7071
*/
7172
public class ClientMessageParser implements ClientListenerMessageParser {
73+
/* General-purpose operations. */
7274
/** */
73-
private static final short OP_CACHE_GET = 1;
75+
private static final short OP_RESOURCE_CLOSE = 0;
7476

77+
/* Cache operations */
7578
/** */
76-
private static final short OP_GET_BINARY_TYPE_NAME = 2;
79+
private static final short OP_CACHE_GET = 1000;
7780

7881
/** */
79-
private static final short OP_GET_BINARY_TYPE = 3;
82+
private static final short OP_CACHE_PUT = 1001;
8083

8184
/** */
82-
private static final short OP_CACHE_PUT = 4;
85+
private static final short OP_CACHE_PUT_IF_ABSENT = 1002;
8386

8487
/** */
85-
private static final short OP_REGISTER_BINARY_TYPE_NAME = 5;
88+
private static final short OP_CACHE_GET_ALL = 1003;
8689

8790
/** */
88-
private static final short OP_PUT_BINARY_TYPE = 6;
91+
private static final short OP_CACHE_PUT_ALL = 1004;
8992

9093
/** */
91-
private static final short OP_QUERY_SCAN = 7;
94+
private static final short OP_CACHE_GET_AND_PUT = 1005;
9295

9396
/** */
94-
private static final short OP_QUERY_SCAN_CURSOR_GET_PAGE = 8;
97+
private static final short OP_CACHE_GET_AND_REPLACE = 1006;
9598

9699
/** */
97-
private static final short OP_RESOURCE_CLOSE = 9;
100+
private static final short OP_CACHE_GET_AND_REMOVE = 1007;
98101

99102
/** */
100-
private static final short OP_CACHE_CONTAINS_KEY = 10;
103+
private static final short OP_CACHE_GET_AND_PUT_IF_ABSENT = 1008;
101104

102105
/** */
103-
private static final short OP_CACHE_CONTAINS_KEYS = 11;
106+
private static final short OP_CACHE_REPLACE = 1009;
104107

105108
/** */
106-
private static final short OP_CACHE_GET_ALL = 12;
109+
private static final short OP_CACHE_REPLACE_IF_EQUALS = 1010;
107110

108111
/** */
109-
private static final short OP_CACHE_GET_AND_PUT = 13;
112+
private static final short OP_CACHE_CONTAINS_KEY = 1011;
110113

111114
/** */
112-
private static final short OP_CACHE_GET_AND_REPLACE = 14;
115+
private static final short OP_CACHE_CONTAINS_KEYS = 1012;
113116

114117
/** */
115-
private static final short OP_CACHE_GET_AND_REMOVE = 15;
118+
private static final short OP_CACHE_CLEAR = 1013;
116119

117120
/** */
118-
private static final short OP_CACHE_PUT_IF_ABSENT = 16;
121+
private static final short OP_CACHE_CLEAR_KEY = 1014;
119122

120123
/** */
121-
private static final short OP_CACHE_GET_AND_PUT_IF_ABSENT = 17;
124+
private static final short OP_CACHE_CLEAR_KEYS = 1015;
122125

123126
/** */
124-
private static final short OP_CACHE_REPLACE = 18;
127+
private static final short OP_CACHE_REMOVE_KEY = 1016;
125128

126129
/** */
127-
private static final short OP_CACHE_REPLACE_IF_EQUALS = 19;
130+
private static final short OP_CACHE_REMOVE_IF_EQUALS = 1017;
128131

129132
/** */
130-
private static final short OP_CACHE_PUT_ALL = 20;
133+
private static final short OP_CACHE_REMOVE_KEYS = 1018;
131134

132135
/** */
133-
private static final short OP_CACHE_CLEAR = 21;
136+
private static final short OP_CACHE_REMOVE_ALL = 1019;
134137

135138
/** */
136-
private static final short OP_CACHE_CLEAR_KEY = 22;
139+
private static final short OP_CACHE_GET_SIZE = 1020;
137140

141+
/* Cache create / destroy, configuration. */
138142
/** */
139-
private static final short OP_CACHE_CLEAR_KEYS = 23;
143+
private static final short OP_CACHE_GET_NAMES = 1050;
140144

141145
/** */
142-
private static final short OP_CACHE_REMOVE_KEY = 24;
146+
private static final short OP_CACHE_CREATE_WITH_NAME = 1051;
143147

144148
/** */
145-
private static final short OP_CACHE_REMOVE_IF_EQUALS = 25;
149+
private static final short OP_CACHE_GET_OR_CREATE_WITH_NAME = 1052;
146150

147151
/** */
148-
private static final short OP_CACHE_GET_SIZE = 26;
152+
private static final short OP_CACHE_CREATE_WITH_CONFIGURATION = 1053;
149153

150154
/** */
151-
private static final short OP_CACHE_REMOVE_KEYS = 27;
155+
private static final short OP_CACHE_GET_OR_CREATE_WITH_CONFIGURATION = 1054;
152156

153157
/** */
154-
private static final short OP_CACHE_REMOVE_ALL = 28;
158+
private static final short OP_CACHE_GET_CONFIGURATION = 1055;
155159

156160
/** */
157-
private static final short OP_CACHE_CREATE_WITH_NAME = 29;
161+
private static final short OP_CACHE_DESTROY = 1056;
158162

163+
/* Query operations. */
159164
/** */
160-
private static final short OP_CACHE_GET_OR_CREATE_WITH_NAME = 30;
165+
private static final short OP_QUERY_SCAN = 2000;
161166

162167
/** */
163-
private static final short OP_CACHE_DESTROY = 31;
168+
private static final short OP_QUERY_SCAN_CURSOR_GET_PAGE = 2001;
164169

165170
/** */
166-
private static final short OP_CACHE_GET_NAMES = 32;
171+
private static final short OP_QUERY_SQL = 2002;
167172

168173
/** */
169-
private static final short OP_CACHE_GET_CONFIGURATION = 33;
174+
private static final short OP_QUERY_SQL_CURSOR_GET_PAGE = 2003;
170175

171176
/** */
172-
private static final short OP_CACHE_CREATE_WITH_CONFIGURATION = 34;
177+
private static final short OP_QUERY_SQL_FIELDS = 2004;
173178

174179
/** */
175-
private static final short OP_CACHE_GET_OR_CREATE_WITH_CONFIGURATION = 35;
180+
private static final short OP_QUERY_SQL_FIELDS_CURSOR_GET_PAGE = 2005;
176181

182+
/* Binary metadata operations. */
177183
/** */
178-
private static final short OP_QUERY_SQL = 36;
184+
private static final short OP_BINARY_TYPE_NAME_GET = 3000;
179185

180186
/** */
181-
private static final short OP_QUERY_SQL_CURSOR_GET_PAGE = 37;
187+
private static final short OP_BINARY_TYPE_NAME_PUT = 3001;
182188

183189
/** */
184-
private static final short OP_QUERY_SQL_FIELDS = 38;
190+
private static final short OP_BINARY_TYPE_GET = 3002;
185191

186192
/** */
187-
private static final short OP_QUERY_SQL_FIELDS_CURSOR_GET_PAGE = 39;
193+
private static final short OP_BINARY_TYPE_PUT = 3003;
188194

189195
/** Marshaller. */
190196
private final GridBinaryMarshaller marsh;
@@ -206,7 +212,10 @@ public class ClientMessageParser implements ClientListenerMessageParser {
206212
assert msg != null;
207213

208214
BinaryInputStream inStream = new BinaryHeapInputStream(msg);
209-
BinaryRawReaderEx reader = marsh.reader(inStream);
215+
216+
// skipHdrCheck must be true (we have 103 op code).
217+
BinaryRawReaderEx reader = new BinaryReaderExImpl(marsh.context(), inStream,
218+
null, null, true, true);
210219

211220
return decode(reader);
212221
}
@@ -224,19 +233,19 @@ public ClientListenerRequest decode(BinaryRawReaderEx reader) {
224233
case OP_CACHE_GET:
225234
return new ClientCacheGetRequest(reader);
226235

227-
case OP_GET_BINARY_TYPE_NAME:
236+
case OP_BINARY_TYPE_NAME_GET:
228237
return new ClientBinaryTypeNameGetRequest(reader);
229238

230-
case OP_GET_BINARY_TYPE:
239+
case OP_BINARY_TYPE_GET:
231240
return new ClientBinaryTypeGetRequest(reader);
232241

233242
case OP_CACHE_PUT:
234243
return new ClientCachePutRequest(reader);
235244

236-
case OP_REGISTER_BINARY_TYPE_NAME:
245+
case OP_BINARY_TYPE_NAME_PUT:
237246
return new ClientBinaryTypeNamePutRequest(reader);
238247

239-
case OP_PUT_BINARY_TYPE:
248+
case OP_BINARY_TYPE_PUT:
240249
return new ClientBinaryTypePutRequest(reader);
241250

242251
case OP_QUERY_SCAN:

modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/RawSocketTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void TestCacheGet()
5252
// Cache get.
5353
SendRequest(sock, stream =>
5454
{
55-
stream.WriteShort(1); // OP_GET
55+
stream.WriteShort(1000); // OP_GET
5656
stream.WriteLong(1); // Request id.
5757
var cacheId = BinaryUtils.GetStringHashCodeLowerCase(cache.Name);
5858
stream.WriteInt(cacheId);

modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientOp.cs

Lines changed: 46 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,44 +22,51 @@ namespace Apache.Ignite.Core.Impl.Client
2222
/// </summary>
2323
internal enum ClientOp : short
2424
{
25-
CacheGet = 1,
26-
BinaryTypeNameGet = 2,
27-
BinaryTypeGet = 3,
28-
CachePut = 4,
29-
BinaryTypeNamePut = 5,
30-
BinaryTypePut = 6,
31-
QueryScan = 7,
32-
QueryScanCursorGetPage = 8,
33-
ResourceClose = 9,
34-
CacheContainsKey = 10,
35-
CacheContainsKeys = 11,
36-
CacheGetAll = 12,
37-
CacheGetAndPut = 13,
38-
CacheGetAndReplace = 14,
39-
CacheGetAndRemove = 15,
40-
CachePutIfAbsent = 16,
41-
CacheGetAndPutIfAbsent = 17,
42-
CacheReplace = 18,
43-
CacheReplaceIfEquals = 19,
44-
CachePutAll = 20,
45-
CacheClear = 21,
46-
CacheClearKey = 22,
47-
CacheClearKeys = 23,
48-
CacheRemoveKey = 24,
49-
CacheRemoveIfEquals = 25,
50-
CacheGetSize = 26,
51-
CacheRemoveKeys = 27,
52-
CacheRemoveAll = 28,
53-
CacheCreateWithName = 29,
54-
CacheGetOrCreateWithName = 30,
55-
CacheDestroy = 31,
56-
CacheGetNames = 32,
57-
CacheGetConfiguration = 33,
58-
CacheCreateWithConfiguration = 34,
59-
CacheGetOrCreateWithConfiguration = 35,
60-
QuerySql = 36,
61-
QuerySqlCursorGetPage = 37,
62-
QuerySqlFields = 38,
63-
QuerySqlFieldsCursorGetPage = 39
25+
// General purpose.
26+
ResourceClose = 0,
27+
28+
// Cache.
29+
CacheGet = 1000,
30+
CachePut = 1001,
31+
CachePutIfAbsent = 1002,
32+
CacheGetAll = 1003,
33+
CachePutAll = 1004,
34+
CacheGetAndPut = 1005,
35+
CacheGetAndReplace = 1006,
36+
CacheGetAndRemove = 1007,
37+
CacheGetAndPutIfAbsent = 1008,
38+
CacheReplace = 1009,
39+
CacheReplaceIfEquals = 1010,
40+
CacheContainsKey = 1011,
41+
CacheContainsKeys = 1012,
42+
CacheClear = 1013,
43+
CacheClearKey = 1014,
44+
CacheClearKeys = 1015,
45+
CacheRemoveKey = 1016,
46+
CacheRemoveIfEquals = 1017,
47+
CacheRemoveKeys = 1018,
48+
CacheRemoveAll = 1019,
49+
CacheGetSize = 1020,
50+
CacheGetNames = 1050,
51+
CacheCreateWithName = 1051,
52+
CacheGetOrCreateWithName = 1052,
53+
CacheCreateWithConfiguration = 1053,
54+
CacheGetOrCreateWithConfiguration = 1054,
55+
CacheGetConfiguration = 1055,
56+
CacheDestroy = 1056,
57+
58+
// Queries.
59+
QueryScan = 2000,
60+
QueryScanCursorGetPage = 2001,
61+
QuerySql = 2002,
62+
QuerySqlCursorGetPage = 2003,
63+
QuerySqlFields = 2004,
64+
QuerySqlFieldsCursorGetPage = 2005,
65+
66+
// Metadata.
67+
BinaryTypeNameGet = 3000,
68+
BinaryTypeNamePut = 3001,
69+
BinaryTypeGet = 3002,
70+
BinaryTypePut = 3003
6471
}
6572
}

0 commit comments

Comments
 (0)