ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [05/25] ignite git commit: IGNITE-5902 Implemented stop caches at once.
Date Wed, 16 Aug 2017 15:41:28 GMT
IGNITE-5902 Implemented stop caches at once.


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

Branch: refs/heads/ignite-5901
Commit: ebb8765ab6735289cc2ceb4ccba2f6fd1e9816a8
Parents: 1c62fda
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Fri Aug 11 10:25:36 2017 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Fri Aug 11 10:25:36 2017 +0700

----------------------------------------------------------------------
 .../visor/cache/VisorCacheStopTask.java         | 22 ++++++++--------
 .../visor/cache/VisorCacheStopTaskArg.java      | 27 ++++++++++++++++++++
 2 files changed, 39 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb8765a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStopTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStopTask.java
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStopTask.java
index 9f7c018..df95c5e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStopTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStopTask.java
@@ -17,8 +17,10 @@
 
 package org.apache.ignite.internal.visor.cache;
 
-import org.apache.ignite.IgniteCache;
+import java.util.Collection;
+import java.util.HashSet;
 import org.apache.ignite.internal.processors.task.GridInternal;
+import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.visor.VisorJob;
 import org.apache.ignite.internal.visor.VisorOneNodeTask;
@@ -46,23 +48,23 @@ public class VisorCacheStopTask extends VisorOneNodeTask<VisorCacheStopTaskArg,
         /**
          * Create job.
          *
-         * @param cacheName Cache name to clear.
+         * @param arg Task argument.
          * @param debug Debug flag.
          */
-        private VisorCacheStopJob(VisorCacheStopTaskArg cacheName, boolean debug) {
-            super(cacheName, debug);
+        private VisorCacheStopJob(VisorCacheStopTaskArg arg, boolean debug) {
+            super(arg, debug);
         }
 
         /** {@inheritDoc} */
         @Override protected Void run(VisorCacheStopTaskArg arg) {
-            String cacheName = arg.getCacheName();
+            Collection<String> cacheNames = F.isEmpty(arg.getCacheNames())
+                ? F.asList(arg.getCacheName())
+                : new HashSet<>(arg.getCacheNames());
 
-            IgniteCache cache = ignite.cache(cacheName);
+            if (F.isEmpty(cacheNames))
+                throw new IllegalStateException("Cache names was not specified.");
 
-            if (cache == null)
-                throw new IllegalStateException("Failed to find cache for name: " + cacheName);
-
-            cache.destroy();
+            ignite.destroyCaches(cacheNames);
 
             return null;
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ebb8765a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStopTaskArg.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStopTaskArg.java
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStopTaskArg.java
index 4976036..77156ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStopTaskArg.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStopTaskArg.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.visor.cache;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+import java.util.List;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.internal.visor.VisorDataTransferObject;
@@ -34,6 +35,9 @@ public class VisorCacheStopTaskArg extends VisorDataTransferObject {
     /** Cache name. */
     private String cacheName;
 
+    /** Cache names. */
+    private List<String> cacheNames;
+
     /**
      * Default constructor.
      */
@@ -49,20 +53,43 @@ public class VisorCacheStopTaskArg extends VisorDataTransferObject {
     }
 
     /**
+     * @param cacheNames Cache names.
+     */
+    public VisorCacheStopTaskArg(List<String> cacheNames) {
+        this.cacheNames = cacheNames;
+    }
+
+    /**
      * @return Cache name.
      */
     public String getCacheName() {
         return cacheName;
     }
 
+    /**
+     * @return Cache names.
+     */
+    public List<String> getCacheNames() {
+        return cacheNames;
+    }
+
+    /** {@inheritDoc} */
+    @Override public byte getProtocolVersion() {
+        return V2;
+    }
+
     /** {@inheritDoc} */
     @Override protected void writeExternalData(ObjectOutput out) throws IOException {
         U.writeString(out, cacheName);
+        U.writeCollection(out, cacheNames);
     }
 
     /** {@inheritDoc} */
     @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException,
ClassNotFoundException {
         cacheName = U.readString(in);
+
+        if (protoVer > V1)
+            cacheNames = U.readList(in);
     }
 
     /** {@inheritDoc} */


Mime
View raw message