IGNITE-6988 .NET: Thin client: OP_CACHE_DESTROY takes cacheId instead of name
authorPavel Tupitsyn <ptupitsyn@apache.org>
Fri, 24 Nov 2017 10:41:23 +0000 (13:41 +0300)
committerPavel Tupitsyn <ptupitsyn@apache.org>
Fri, 24 Nov 2017 10:41:23 +0000 (13:41 +0300)
modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheDestroyRequest.java
modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRequest.java
modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/IgniteClient.cs

index 032116d..6645a03 100644 (file)
@@ -26,8 +26,8 @@ import org.apache.ignite.internal.processors.platform.client.ClientResponse;
  * Cache destroy request.
  */
 public class ClientCacheDestroyRequest extends ClientRequest {
-    /** Cache name. */
-    private final String cacheName;
+    /** Cache ID. */
+    private final int cacheId;
 
     /**
      * Constructor.
@@ -37,11 +37,13 @@ public class ClientCacheDestroyRequest extends ClientRequest {
     public ClientCacheDestroyRequest(BinaryRawReader reader) {
         super(reader);
 
-        cacheName = reader.readString();
+        cacheId = reader.readInt();
     }
 
     /** {@inheritDoc} */
     @Override public ClientResponse process(ClientConnectionContext ctx) {
+        String cacheName = ClientCacheRequest.cacheDescriptor(ctx, cacheId).cacheName();
+
         ctx.kernalContext().grid().destroyCache(cacheName);
 
         return super.process(ctx);
index 44416be..52b799f 100644 (file)
@@ -87,9 +87,21 @@ class ClientCacheRequest extends ClientRequest {
     /**
      * Gets the cache descriptor.
      *
+     * @param ctx Context.
      * @return Cache descriptor.
      */
     protected DynamicCacheDescriptor cacheDescriptor(ClientConnectionContext ctx) {
+        return cacheDescriptor(ctx, cacheId);
+    }
+
+    /**
+     * Gets the cache descriptor.
+     *
+     * @param ctx Context.
+     * @param cacheId Cache id.
+     * @return Cache descriptor.
+     */
+    public static DynamicCacheDescriptor cacheDescriptor(ClientConnectionContext ctx, int cacheId) {
         DynamicCacheDescriptor desc = ctx.kernalContext().cache().cacheDescriptor(cacheId);
 
         if (desc == null)
index 13a3a83..2dd18cc 100644 (file)
@@ -142,7 +142,7 @@ namespace Apache.Ignite.Core.Impl.Client
         {
             IgniteArgumentCheck.NotNull(name, "name");
 
-            DoOutOp(ClientOp.CacheDestroy, w => w.WriteString(name));
+            DoOutOp(ClientOp.CacheDestroy, w => w.WriteInt(BinaryUtils.GetCacheId(name)));
         }
 
         /** <inheritDoc /> */