IGNITE-6397 .NET thin client: basic cache operations. This closes #2725.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/97b91e9c Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/97b91e9c Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/97b91e9c Branch: refs/heads/ignite-3478 Commit: 97b91e9c18ef89feef8ecc68f3d26f5e3727eff6 Parents: 218416c Author: Pavel Tupitsyn <[email protected]> Authored: Mon Oct 9 17:33:46 2017 +0300 Committer: devozerov <[email protected]> Committed: Mon Oct 9 17:33:46 2017 +0300 ---------------------------------------------------------------------- .../platform/client/ClientIntResponse.java | 46 ++ .../platform/client/ClientLongResponse.java | 46 ++ .../platform/client/ClientMessageParser.java | 133 ++++ .../cache/ClientCacheClearKeyRequest.java | 44 ++ .../cache/ClientCacheClearKeysRequest.java | 44 ++ .../client/cache/ClientCacheClearRequest.java | 44 ++ .../cache/ClientCacheContainsKeyRequest.java | 45 ++ .../cache/ClientCacheContainsKeysRequest.java | 45 ++ .../client/cache/ClientCacheGetAllRequest.java | 46 ++ .../client/cache/ClientCacheGetAllResponse.java | 57 ++ .../ClientCacheGetAndPutIfAbsentRequest.java | 45 ++ .../cache/ClientCacheGetAndPutRequest.java | 45 ++ .../cache/ClientCacheGetAndRemoveRequest.java | 45 ++ .../cache/ClientCacheGetAndReplaceRequest.java | 45 ++ .../client/cache/ClientCacheGetRequest.java | 9 +- .../client/cache/ClientCacheGetSizeRequest.java | 57 ++ .../client/cache/ClientCacheKeyRequest.java | 48 ++ .../cache/ClientCacheKeyValueRequest.java | 48 ++ .../client/cache/ClientCacheKeysRequest.java | 68 +++ .../client/cache/ClientCachePutAllRequest.java | 57 ++ .../cache/ClientCachePutIfAbsentRequest.java | 45 ++ .../client/cache/ClientCachePutRequest.java | 13 +- .../cache/ClientCacheRemoveAllRequest.java | 44 ++ .../cache/ClientCacheRemoveIfEqualsRequest.java | 45 ++ .../cache/ClientCacheRemoveKeyRequest.java | 45 ++ .../cache/ClientCacheRemoveKeysRequest.java | 44 ++ .../ClientCacheReplaceIfEqualsRequest.java | 50 ++ .../client/cache/ClientCacheReplaceRequest.java | 45 ++ .../client/cache/ClientCacheRequest.java | 2 +- .../Client/Cache/CacheTest.cs | 611 ++++++++++++++++++- .../Client/Cache/CacheTestNoMeta.cs | 4 +- .../Client/ClientTestBase.cs | 9 + .../Client/Cache/ICacheClient.cs | 155 +++++ .../Client/IgniteClientException.cs | 8 + .../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 24 +- .../Impl/Client/Cache/CacheClient.cs | 260 +++++++- .../Apache.Ignite.Core/Impl/Client/ClientOp.cs | 21 +- .../Apache.Ignite.Core/Impl/IgniteUtils.cs | 21 + 38 files changed, 2418 insertions(+), 45 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientIntResponse.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientIntResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientIntResponse.java new file mode 100644 index 0000000..b8debf1 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientIntResponse.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client; + +import org.apache.ignite.internal.binary.BinaryRawWriterEx; + +/** + * Int response. + */ +public class ClientIntResponse extends ClientResponse { + /** */ + private final int val; + + /** + * Constructor. + * + * @param reqId Request id. + */ + public ClientIntResponse(long reqId, int val) { + super(reqId); + + this.val = val; + } + + /** {@inheritDoc} */ + @Override public void encode(BinaryRawWriterEx writer) { + super.encode(writer); + + writer.writeInt(val); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientLongResponse.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientLongResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientLongResponse.java new file mode 100644 index 0000000..a116157 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientLongResponse.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client; + +import org.apache.ignite.internal.binary.BinaryRawWriterEx; + +/** + * Long response. + */ +public class ClientLongResponse extends ClientResponse { + /** */ + private final long val; + + /** + * Constructor. + * + * @param reqId Request id. + */ + public ClientLongResponse(long reqId, long val) { + super(reqId); + + this.val = val; + } + + /** {@inheritDoc} */ + @Override public void encode(BinaryRawWriterEx writer) { + super.encode(writer); + + writer.writeLong(val); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/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 84d3eee..f0f0f4c 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 @@ -32,8 +32,27 @@ import org.apache.ignite.internal.processors.platform.client.binary.ClientBinary import org.apache.ignite.internal.processors.platform.client.binary.ClientBinaryTypeNameGetRequest; import org.apache.ignite.internal.processors.platform.client.binary.ClientBinaryTypeNamePutRequest; import org.apache.ignite.internal.processors.platform.client.binary.ClientBinaryTypePutRequest; +import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheClearKeyRequest; +import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheClearKeysRequest; +import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheClearRequest; +import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheContainsKeyRequest; +import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheContainsKeysRequest; +import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheGetAllRequest; +import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheGetAndPutIfAbsentRequest; +import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheGetAndPutRequest; +import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheGetAndRemoveRequest; +import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheGetAndReplaceRequest; import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheGetRequest; +import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheGetSizeRequest; +import org.apache.ignite.internal.processors.platform.client.cache.ClientCachePutAllRequest; +import org.apache.ignite.internal.processors.platform.client.cache.ClientCachePutIfAbsentRequest; import org.apache.ignite.internal.processors.platform.client.cache.ClientCachePutRequest; +import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheRemoveIfEqualsRequest; +import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheRemoveAllRequest; +import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheRemoveKeysRequest; +import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheRemoveKeyRequest; +import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheReplaceIfEqualsRequest; +import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheReplaceRequest; import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheScanQueryNextPageRequest; import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheScanQueryRequest; @@ -68,6 +87,63 @@ public class ClientMessageParser implements ClientListenerMessageParser { /** */ private static final short OP_RESOURCE_CLOSE = 9; + /** */ + private static final short OP_CACHE_CONTAINS_KEY = 10; + + /** */ + private static final short OP_CACHE_CONTAINS_KEYS = 11; + + /** */ + private static final short OP_CACHE_GET_ALL = 12; + + /** */ + private static final short OP_CACHE_GET_AND_PUT = 13; + + /** */ + private static final short OP_CACHE_GET_AND_REPLACE = 14; + + /** */ + private static final short OP_CACHE_GET_AND_REMOVE = 15; + + /** */ + private static final short OP_CACHE_PUT_IF_ABSENT = 16; + + /** */ + private static final short OP_CACHE_GET_AND_PUT_IF_ABSENT = 17; + + /** */ + private static final short OP_CACHE_REPLACE = 18; + + /** */ + private static final short OP_CACHE_REPLACE_IF_EQUALS = 19; + + /** */ + private static final short OP_CACHE_PUT_ALL = 20; + + /** */ + private static final short OP_CACHE_CLEAR = 21; + + /** */ + private static final short OP_CACHE_CLEAR_KEY = 22; + + /** */ + private static final short OP_CACHE_CLEAR_KEYS = 23; + + /** */ + private static final short OP_CACHE_REMOVE_KEY = 24; + + /** */ + private static final short OP_CACHE_REMOVE_IF_EQUALS = 25; + + /** */ + private static final short OP_CACHE_GET_SIZE = 26; + + /** */ + private static final short OP_CACHE_REMOVE_KEYS = 27; + + /** */ + private static final short OP_CACHE_REMOVE_ALL = 28; + /** Marshaller. */ private final GridBinaryMarshaller marsh; @@ -129,6 +205,63 @@ public class ClientMessageParser implements ClientListenerMessageParser { case OP_RESOURCE_CLOSE: return new ClientResourceCloseRequest(reader); + + case OP_CACHE_CONTAINS_KEY: + return new ClientCacheContainsKeyRequest(reader); + + case OP_CACHE_CONTAINS_KEYS: + return new ClientCacheContainsKeysRequest(reader); + + case OP_CACHE_GET_ALL: + return new ClientCacheGetAllRequest(reader); + + case OP_CACHE_GET_AND_PUT: + return new ClientCacheGetAndPutRequest(reader); + + case OP_CACHE_GET_AND_REPLACE: + return new ClientCacheGetAndReplaceRequest(reader); + + case OP_CACHE_GET_AND_REMOVE: + return new ClientCacheGetAndRemoveRequest(reader); + + case OP_CACHE_PUT_IF_ABSENT: + return new ClientCachePutIfAbsentRequest(reader); + + case OP_CACHE_GET_AND_PUT_IF_ABSENT: + return new ClientCacheGetAndPutIfAbsentRequest(reader); + + case OP_CACHE_REPLACE: + return new ClientCacheReplaceRequest(reader); + + case OP_CACHE_REPLACE_IF_EQUALS: + return new ClientCacheReplaceIfEqualsRequest(reader); + + case OP_CACHE_PUT_ALL: + return new ClientCachePutAllRequest(reader); + + case OP_CACHE_CLEAR: + return new ClientCacheClearRequest(reader); + + case OP_CACHE_CLEAR_KEY: + return new ClientCacheClearKeyRequest(reader); + + case OP_CACHE_CLEAR_KEYS: + return new ClientCacheClearKeysRequest(reader); + + case OP_CACHE_REMOVE_KEY: + return new ClientCacheRemoveKeyRequest(reader); + + case OP_CACHE_REMOVE_IF_EQUALS: + return new ClientCacheRemoveIfEqualsRequest(reader); + + case OP_CACHE_GET_SIZE: + return new ClientCacheGetSizeRequest(reader); + + case OP_CACHE_REMOVE_KEYS: + return new ClientCacheRemoveKeysRequest(reader); + + case OP_CACHE_REMOVE_ALL: + return new ClientCacheRemoveAllRequest(reader); } return new ClientRawRequest(reader.readLong(), ClientStatus.INVALID_OP_CODE, http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearKeyRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearKeyRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearKeyRequest.java new file mode 100644 index 0000000..6bcbbe8 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearKeyRequest.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import org.apache.ignite.internal.binary.BinaryRawReaderEx; +import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; +import org.apache.ignite.internal.processors.platform.client.ClientResponse; + +/** + * Clear key request. + */ +public class ClientCacheClearKeyRequest extends ClientCacheKeyRequest { + /** + * Constructor. + * + * @param reader Reader. + */ + public ClientCacheClearKeyRequest(BinaryRawReaderEx reader) { + super(reader); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public ClientResponse process(ClientConnectionContext ctx) { + cache(ctx).clear(key()); + + return super.process(ctx); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearKeysRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearKeysRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearKeysRequest.java new file mode 100644 index 0000000..04eb7f6 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearKeysRequest.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import org.apache.ignite.internal.binary.BinaryRawReaderEx; +import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; +import org.apache.ignite.internal.processors.platform.client.ClientResponse; + +/** + * Clear keys request. + */ +public class ClientCacheClearKeysRequest extends ClientCacheKeysRequest { + /** + * Constructor. + * + * @param reader Reader. + */ + public ClientCacheClearKeysRequest(BinaryRawReaderEx reader) { + super(reader); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public ClientResponse process(ClientConnectionContext ctx) { + cache(ctx).clearAll(keys()); + + return super.process(ctx); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearRequest.java new file mode 100644 index 0000000..0e5f20d --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearRequest.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import org.apache.ignite.binary.BinaryRawReader; +import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; +import org.apache.ignite.internal.processors.platform.client.ClientResponse; + +/** + * Cache clear request. + */ +public class ClientCacheClearRequest extends ClientCacheRequest { + /** + * Constructor. + * + * @param reader Reader. + */ + public ClientCacheClearRequest(BinaryRawReader reader) { + super(reader); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public ClientResponse process(ClientConnectionContext ctx) { + cache(ctx).clear(); + + return super.process(ctx); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheContainsKeyRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheContainsKeyRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheContainsKeyRequest.java new file mode 100644 index 0000000..8470828 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheContainsKeyRequest.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import org.apache.ignite.internal.binary.BinaryRawReaderEx; +import org.apache.ignite.internal.processors.platform.client.ClientBooleanResponse; +import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; +import org.apache.ignite.internal.processors.platform.client.ClientResponse; + +/** + * ContainsKey request. + */ +public class ClientCacheContainsKeyRequest extends ClientCacheKeyRequest { + /** + * Constructor. + * + * @param reader Reader. + */ + public ClientCacheContainsKeyRequest(BinaryRawReaderEx reader) { + super(reader); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public ClientResponse process(ClientConnectionContext ctx) { + boolean val = cache(ctx).containsKey(key()); + + return new ClientBooleanResponse(requestId(), val); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheContainsKeysRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheContainsKeysRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheContainsKeysRequest.java new file mode 100644 index 0000000..41e1306 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheContainsKeysRequest.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import org.apache.ignite.internal.binary.BinaryRawReaderEx; +import org.apache.ignite.internal.processors.platform.client.ClientBooleanResponse; +import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; +import org.apache.ignite.internal.processors.platform.client.ClientResponse; + +/** + * ContainsKeys request. + */ +public class ClientCacheContainsKeysRequest extends ClientCacheKeysRequest { + /** + * Constructor. + * + * @param reader Reader. + */ + public ClientCacheContainsKeysRequest(BinaryRawReaderEx reader) { + super(reader); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public ClientResponse process(ClientConnectionContext ctx) { + boolean val = cache(ctx).containsKeys(keys()); + + return new ClientBooleanResponse(requestId(), val); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAllRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAllRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAllRequest.java new file mode 100644 index 0000000..2b33af1 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAllRequest.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import org.apache.ignite.internal.binary.BinaryRawReaderEx; +import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; +import org.apache.ignite.internal.processors.platform.client.ClientResponse; + +import java.util.Map; + +/** + * GetAll request. + */ +public class ClientCacheGetAllRequest extends ClientCacheKeysRequest { + /** + * Constructor. + * + * @param reader Reader. + */ + public ClientCacheGetAllRequest(BinaryRawReaderEx reader) { + super(reader); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public ClientResponse process(ClientConnectionContext ctx) { + Map val = cache(ctx).getAll(keys()); + + return new ClientCacheGetAllResponse(requestId(), val); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAllResponse.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAllResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAllResponse.java new file mode 100644 index 0000000..2ee2d5b --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAllResponse.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import org.apache.ignite.internal.binary.BinaryRawWriterEx; +import org.apache.ignite.internal.processors.platform.client.ClientResponse; + +import java.util.Map; + +/** + * GetAll response. + */ +class ClientCacheGetAllResponse extends ClientResponse { + /** Result. */ + private final Map<Object, Object> res; + + /** + * Ctor. + * + * @param requestId Request id. + * @param res Result. + */ + ClientCacheGetAllResponse(long requestId, Map<Object, Object> res) { + super(requestId); + + assert res != null; + + this.res = res; + } + + /** {@inheritDoc} */ + @Override public void encode(BinaryRawWriterEx writer) { + super.encode(writer); + + writer.writeInt(res.size()); + + for (Map.Entry e : res.entrySet()) { + writer.writeObjectDetached(e.getKey()); + writer.writeObjectDetached(e.getValue()); + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndPutIfAbsentRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndPutIfAbsentRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndPutIfAbsentRequest.java new file mode 100644 index 0000000..8360213 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndPutIfAbsentRequest.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import org.apache.ignite.internal.binary.BinaryRawReaderEx; +import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; +import org.apache.ignite.internal.processors.platform.client.ClientObjectResponse; +import org.apache.ignite.internal.processors.platform.client.ClientResponse; + +/** + * Cache get and put if absent request. + */ +public class ClientCacheGetAndPutIfAbsentRequest extends ClientCacheKeyValueRequest { + /** + * Ctor. + * + * @param reader Reader. + */ + public ClientCacheGetAndPutIfAbsentRequest(BinaryRawReaderEx reader) { + super(reader); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public ClientResponse process(ClientConnectionContext ctx) { + Object res = cache(ctx).getAndPutIfAbsent(key(), val()); + + return new ClientObjectResponse(requestId(), res); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndPutRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndPutRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndPutRequest.java new file mode 100644 index 0000000..7a540e8 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndPutRequest.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import org.apache.ignite.internal.binary.BinaryRawReaderEx; +import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; +import org.apache.ignite.internal.processors.platform.client.ClientObjectResponse; +import org.apache.ignite.internal.processors.platform.client.ClientResponse; + +/** + * Cache get and put request. + */ +public class ClientCacheGetAndPutRequest extends ClientCacheKeyValueRequest { + /** + * Ctor. + * + * @param reader Reader. + */ + public ClientCacheGetAndPutRequest(BinaryRawReaderEx reader) { + super(reader); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public ClientResponse process(ClientConnectionContext ctx) { + Object res = cache(ctx).getAndPut(key(), val()); + + return new ClientObjectResponse(requestId(), res); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndRemoveRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndRemoveRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndRemoveRequest.java new file mode 100644 index 0000000..e4fd735 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndRemoveRequest.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import org.apache.ignite.internal.binary.BinaryRawReaderEx; +import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; +import org.apache.ignite.internal.processors.platform.client.ClientObjectResponse; +import org.apache.ignite.internal.processors.platform.client.ClientResponse; + +/** + * Cache get and remove request. + */ +public class ClientCacheGetAndRemoveRequest extends ClientCacheKeyRequest { + /** + * Constructor. + * + * @param reader Reader. + */ + public ClientCacheGetAndRemoveRequest(BinaryRawReaderEx reader) { + super(reader); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public ClientResponse process(ClientConnectionContext ctx) { + Object val = cache(ctx).getAndRemove(key()); + + return new ClientObjectResponse(requestId(), val); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndReplaceRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndReplaceRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndReplaceRequest.java new file mode 100644 index 0000000..dba8639 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndReplaceRequest.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import org.apache.ignite.internal.binary.BinaryRawReaderEx; +import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; +import org.apache.ignite.internal.processors.platform.client.ClientObjectResponse; +import org.apache.ignite.internal.processors.platform.client.ClientResponse; + +/** + * Cache get and replace request. + */ +public class ClientCacheGetAndReplaceRequest extends ClientCacheKeyValueRequest { + /** + * Ctor. + * + * @param reader Reader. + */ + public ClientCacheGetAndReplaceRequest(BinaryRawReaderEx reader) { + super(reader); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public ClientResponse process(ClientConnectionContext ctx) { + Object res = cache(ctx).getAndReplace(key(), val()); + + return new ClientObjectResponse(requestId(), res); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetRequest.java index e2d261a..41558c2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetRequest.java @@ -25,10 +25,7 @@ import org.apache.ignite.internal.processors.platform.client.ClientResponse; /** * Cache get request. */ -public class ClientCacheGetRequest extends ClientCacheRequest { - /** Key. */ - private final Object key; - +public class ClientCacheGetRequest extends ClientCacheKeyRequest { /** * Constructor. * @@ -36,14 +33,12 @@ public class ClientCacheGetRequest extends ClientCacheRequest { */ public ClientCacheGetRequest(BinaryRawReaderEx reader) { super(reader); - - key = reader.readObjectDetached(); } /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public ClientResponse process(ClientConnectionContext ctx) { - Object val = cache(ctx).get(key); + Object val = cache(ctx).get(key()); return new ClientObjectResponse(requestId(), val); } http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetSizeRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetSizeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetSizeRequest.java new file mode 100644 index 0000000..ba185bf --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetSizeRequest.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import org.apache.ignite.binary.BinaryRawReader; +import org.apache.ignite.cache.CachePeekMode; +import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; +import org.apache.ignite.internal.processors.platform.client.ClientLongResponse; +import org.apache.ignite.internal.processors.platform.client.ClientResponse; + +/** + * Cache size request. + */ +public class ClientCacheGetSizeRequest extends ClientCacheRequest { + /** Peek modes. */ + private final CachePeekMode[] modes; + + /** + * Constructor. + * + * @param reader Reader. + */ + public ClientCacheGetSizeRequest(BinaryRawReader reader) { + super(reader); + + int cnt = reader.readInt(); + + modes = new CachePeekMode[cnt]; + + for (int i = 0; i < cnt; i++) { + modes[i] = CachePeekMode.fromOrdinal(reader.readByte()); + } + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public ClientResponse process(ClientConnectionContext ctx) { + long res = cache(ctx).sizeLong(modes); + + return new ClientLongResponse(requestId(), res); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeyRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeyRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeyRequest.java new file mode 100644 index 0000000..e888236 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeyRequest.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import org.apache.ignite.internal.binary.BinaryRawReaderEx; + +/** + * Cache request involving key. + */ +public abstract class ClientCacheKeyRequest extends ClientCacheRequest { + /** Key. */ + private final Object key; + + /** + * Ctor. + * + * @param reader Reader. + */ + ClientCacheKeyRequest(BinaryRawReaderEx reader) { + super(reader); + + key = reader.readObjectDetached(); + } + + /** + * Gets the key. + * + * @return Key. + */ + public Object key() { + return key; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeyValueRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeyValueRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeyValueRequest.java new file mode 100644 index 0000000..03b85d6 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeyValueRequest.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import org.apache.ignite.internal.binary.BinaryRawReaderEx; + +/** + * Cache request involving key and value. + */ +public class ClientCacheKeyValueRequest extends ClientCacheKeyRequest { + /** Value. */ + private final Object val; + + /** + * Ctor. + * + * @param reader Reader. + */ + ClientCacheKeyValueRequest(BinaryRawReaderEx reader) { + super(reader); + + val = reader.readObjectDetached(); + } + + /** + * Gets the value. + * + * @return Value. + */ + public Object val() { + return val; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeysRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeysRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeysRequest.java new file mode 100644 index 0000000..526ee5b --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeysRequest.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import org.apache.ignite.internal.binary.BinaryRawReaderEx; + +import java.util.LinkedHashSet; +import java.util.Set; + +/** + * Key set request. + */ +public class ClientCacheKeysRequest extends ClientCacheRequest { + /** Keys. */ + private final Set<Object> keys; + + /** + * Constructor. + * + * @param reader Reader. + */ + ClientCacheKeysRequest(BinaryRawReaderEx reader) { + super(reader); + + keys = readSet(reader); + } + + /** + * Gets the set of keys. + * + * @return Keys. + */ + public Set<Object> keys() { + return keys; + } + + /** + * Reads a set of objects. + * + * @param reader Reader. + * @return Set of objects. + */ + private static Set<Object> readSet(BinaryRawReaderEx reader) { + int cnt = reader.readInt(); + + Set<Object> keys = new LinkedHashSet<>(cnt); + + for (int i = 0; i < cnt; i++) + keys.add(reader.readObjectDetached()); + + return keys; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutAllRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutAllRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutAllRequest.java new file mode 100644 index 0000000..28a7fa5 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutAllRequest.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import org.apache.ignite.internal.binary.BinaryRawReaderEx; +import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; +import org.apache.ignite.internal.processors.platform.client.ClientResponse; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * PutAll request. + */ +public class ClientCachePutAllRequest extends ClientCacheRequest { + /** Map. */ + private final Map<Object, Object> map; + + /** + * Constructor. + * + * @param reader Reader. + */ + public ClientCachePutAllRequest(BinaryRawReaderEx reader) { + super(reader); + + int cnt = reader.readInt(); + + map = new LinkedHashMap<>(cnt); + + for (int i = 0; i < cnt; i++) + map.put(reader.readObjectDetached(), reader.readObjectDetached()); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public ClientResponse process(ClientConnectionContext ctx) { + cache(ctx).putAll(map); + + return super.process(ctx); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutIfAbsentRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutIfAbsentRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutIfAbsentRequest.java new file mode 100644 index 0000000..4dd2cde --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutIfAbsentRequest.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import org.apache.ignite.internal.binary.BinaryRawReaderEx; +import org.apache.ignite.internal.processors.platform.client.ClientBooleanResponse; +import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; +import org.apache.ignite.internal.processors.platform.client.ClientResponse; + +/** + * Cache put if absent request. + */ +public class ClientCachePutIfAbsentRequest extends ClientCacheKeyValueRequest { + /** + * Ctor. + * + * @param reader Reader. + */ + public ClientCachePutIfAbsentRequest(BinaryRawReaderEx reader) { + super(reader); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public ClientResponse process(ClientConnectionContext ctx) { + boolean res = cache(ctx).putIfAbsent(key(), val()); + + return new ClientBooleanResponse(requestId(), res); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutRequest.java index 04e3961..94c2b25 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutRequest.java @@ -24,13 +24,7 @@ import org.apache.ignite.internal.processors.platform.client.ClientResponse; /** * Cache put request. */ -public class ClientCachePutRequest extends ClientCacheRequest { - /** Key. */ - private final Object key; - - /** Value. */ - private final Object val; - +public class ClientCachePutRequest extends ClientCacheKeyValueRequest { /** * Ctor. * @@ -38,15 +32,12 @@ public class ClientCachePutRequest extends ClientCacheRequest { */ public ClientCachePutRequest(BinaryRawReaderEx reader) { super(reader); - - key = reader.readObjectDetached(); - val = reader.readObjectDetached(); } /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public ClientResponse process(ClientConnectionContext ctx) { - cache(ctx).put(key, val); + cache(ctx).put(key(), val()); return super.process(ctx); } http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveAllRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveAllRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveAllRequest.java new file mode 100644 index 0000000..f5adc63 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveAllRequest.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import org.apache.ignite.binary.BinaryRawReader; +import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; +import org.apache.ignite.internal.processors.platform.client.ClientResponse; + +/** + * Cache removeAll request. + */ +public class ClientCacheRemoveAllRequest extends ClientCacheRequest { + /** + * Constructor. + * + * @param reader Reader. + */ + public ClientCacheRemoveAllRequest(BinaryRawReader reader) { + super(reader); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public ClientResponse process(ClientConnectionContext ctx) { + cache(ctx).removeAll(); + + return super.process(ctx); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveIfEqualsRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveIfEqualsRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveIfEqualsRequest.java new file mode 100644 index 0000000..b86f2f8 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveIfEqualsRequest.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import org.apache.ignite.internal.binary.BinaryRawReaderEx; +import org.apache.ignite.internal.processors.platform.client.ClientBooleanResponse; +import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; +import org.apache.ignite.internal.processors.platform.client.ClientResponse; + +/** + * Cache remove request with value. + */ +public class ClientCacheRemoveIfEqualsRequest extends ClientCacheKeyValueRequest { + /** + * Ctor. + * + * @param reader Reader. + */ + public ClientCacheRemoveIfEqualsRequest(BinaryRawReaderEx reader) { + super(reader); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public ClientResponse process(ClientConnectionContext ctx) { + boolean res = cache(ctx).remove(key(), val()); + + return new ClientBooleanResponse(requestId(), res); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveKeyRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveKeyRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveKeyRequest.java new file mode 100644 index 0000000..a68c327 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveKeyRequest.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import org.apache.ignite.internal.binary.BinaryRawReaderEx; +import org.apache.ignite.internal.processors.platform.client.ClientBooleanResponse; +import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; +import org.apache.ignite.internal.processors.platform.client.ClientResponse; + +/** + * Remove request. + */ +public class ClientCacheRemoveKeyRequest extends ClientCacheKeyRequest { + /** + * Constructor. + * + * @param reader Reader. + */ + public ClientCacheRemoveKeyRequest(BinaryRawReaderEx reader) { + super(reader); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public ClientResponse process(ClientConnectionContext ctx) { + boolean val = cache(ctx).remove(key()); + + return new ClientBooleanResponse(requestId(), val); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveKeysRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveKeysRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveKeysRequest.java new file mode 100644 index 0000000..043b568 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveKeysRequest.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import org.apache.ignite.internal.binary.BinaryRawReaderEx; +import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; +import org.apache.ignite.internal.processors.platform.client.ClientResponse; + +/** + * Remove keys request. + */ +public class ClientCacheRemoveKeysRequest extends ClientCacheKeysRequest { + /** + * Constructor. + * + * @param reader Reader. + */ + public ClientCacheRemoveKeysRequest(BinaryRawReaderEx reader) { + super(reader); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public ClientResponse process(ClientConnectionContext ctx) { + cache(ctx).removeAll(keys()); + + return super.process(ctx); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheReplaceIfEqualsRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheReplaceIfEqualsRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheReplaceIfEqualsRequest.java new file mode 100644 index 0000000..8645fbb --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheReplaceIfEqualsRequest.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import org.apache.ignite.internal.binary.BinaryRawReaderEx; +import org.apache.ignite.internal.processors.platform.client.ClientBooleanResponse; +import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; +import org.apache.ignite.internal.processors.platform.client.ClientResponse; + +/** + * Cache replace request. + */ +public class ClientCacheReplaceIfEqualsRequest extends ClientCacheKeyValueRequest { + /** New value. */ + private final Object newVal; + + /** + * Ctor. + * + * @param reader Reader. + */ + public ClientCacheReplaceIfEqualsRequest(BinaryRawReaderEx reader) { + super(reader); + + newVal = reader.readObjectDetached(); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public ClientResponse process(ClientConnectionContext ctx) { + boolean res = cache(ctx).replace(key(), val(), newVal); + + return new ClientBooleanResponse(requestId(), res); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheReplaceRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheReplaceRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheReplaceRequest.java new file mode 100644 index 0000000..bd7a642 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheReplaceRequest.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.platform.client.cache; + +import org.apache.ignite.internal.binary.BinaryRawReaderEx; +import org.apache.ignite.internal.processors.platform.client.ClientBooleanResponse; +import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; +import org.apache.ignite.internal.processors.platform.client.ClientResponse; + +/** + * Cache replace request. + */ +public class ClientCacheReplaceRequest extends ClientCacheKeyValueRequest { + /** + * Ctor. + * + * @param reader Reader. + */ + public ClientCacheReplaceRequest(BinaryRawReaderEx reader) { + super(reader); + } + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override public ClientResponse process(ClientConnectionContext ctx) { + boolean res = cache(ctx).replace(key(), val()); + + return new ClientBooleanResponse(requestId(), res); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRequest.java index 8f81e94..1aaa22c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRequest.java @@ -21,9 +21,9 @@ import org.apache.ignite.IgniteCache; import org.apache.ignite.binary.BinaryRawReader; import org.apache.ignite.internal.processors.cache.GridCacheContext; import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext; -import org.apache.ignite.internal.processors.platform.client.IgniteClientException; import org.apache.ignite.internal.processors.platform.client.ClientRequest; import org.apache.ignite.internal.processors.platform.client.ClientStatus; +import org.apache.ignite.internal.processors.platform.client.IgniteClientException; /** * Cache get request.
