ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [2/4] ignite git commit: IGNITE-5896: Thin client: added base client cache get/put requests.
Date Wed, 13 Sep 2017 11:17:04 GMT
IGNITE-5896: Thin client: added base client cache get/put requests.


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

Branch: refs/heads/ignite-5896
Commit: 1f43e072f0211dbd21c98e36cafe00b3f2dab9fc
Parents: 2b5224f
Author: Pavel Tupitsyn <ptupitsyn@apache.org>
Authored: Wed Sep 13 14:12:41 2017 +0300
Committer: devozerov <vozerov@gridgain.com>
Committed: Wed Sep 13 14:12:41 2017 +0300

----------------------------------------------------------------------
 .../client/cache/ClientCacheGetRequest.java     | 50 +++++++++++++++++
 .../client/cache/ClientCachePutRequest.java     | 53 ++++++++++++++++++
 .../client/cache/ClientCacheRequest.java        | 56 ++++++++++++++++++++
 3 files changed, 159 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/1f43e072/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
new file mode 100644
index 0000000..8d8487f
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetRequest.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.GridKernalContext;
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
+import org.apache.ignite.internal.processors.platform.client.ClientObjectResponse;
+import org.apache.ignite.internal.processors.platform.client.ClientResponse;
+
+/**
+ * Cache get request.
+ */
+public class ClientCacheGetRequest extends ClientCacheRequest {
+    /** Key. */
+    private final Object key;
+
+    /**
+     * Constructor.
+     *
+     * @param reader Reader.
+     */
+    public ClientCacheGetRequest(BinaryRawReaderEx reader) {
+        super(reader);
+
+        key = reader.readObjectDetached();
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public ClientResponse process(GridKernalContext ctx) {
+        Object val = cache(ctx).get(key);
+
+        return new ClientObjectResponse(requestId(), val);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/1f43e072/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
new file mode 100644
index 0000000..5597a07
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutRequest.java
@@ -0,0 +1,53 @@
+/*
+ * 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.GridKernalContext;
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
+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;
+
+    /**
+     * Ctor.
+     *
+     * @param reader Reader.
+     */
+    public ClientCachePutRequest(BinaryRawReaderEx reader) {
+        super(reader);
+
+        key = reader.readObjectDetached();
+        val = reader.readObjectDetached();
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public ClientResponse process(GridKernalContext ctx) {
+        cache(ctx).put(key, val);
+
+        return super.process(ctx);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/1f43e072/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
new file mode 100644
index 0000000..5232735
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRequest.java
@@ -0,0 +1,56 @@
+/*
+ * 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.IgniteCache;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.processors.platform.client.ClientRequest;
+
+/**
+ * Cache get request.
+ */
+class ClientCacheRequest extends ClientRequest {
+    /** Cache ID. */
+    private final int cacheId;
+
+    /**
+     * Constructor.
+     *
+     * @param reader Reader.
+     */
+    ClientCacheRequest(BinaryRawReader reader) {
+        super(reader);
+
+        cacheId = reader.readInt();
+
+        reader.readByte();  // Flags (skipStore, etc);
+    }
+
+    /**
+     * Gets the cache for current cache id.
+     *
+     * @param ctx Kernal context.
+     * @return Cache.
+     */
+    protected IgniteCache cache(GridKernalContext ctx) {
+        String cacheName = ctx.cache().context().cacheContext(cacheId).cache().name();
+
+        return ctx.grid().cache(cacheName).withKeepBinary();
+    }
+}


Mime
View raw message