ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yzhda...@apache.org
Subject [36/51] incubator-ignite git commit: # IGNITE-789 review.
Date Wed, 29 Apr 2015 15:31:46 GMT
# IGNITE-789 review.


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

Branch: refs/heads/ignite-786
Commit: a06f5faf6e0fe509a9fed339c32002834aa672a9
Parents: be7bfda
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Wed Apr 29 18:54:55 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Wed Apr 29 18:54:55 2015 +0700

----------------------------------------------------------------------
 .../visor/cache/VisorCacheStartTask.java        | 86 ++++++++++++++++----
 1 file changed, 68 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a06f5faf/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStartTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStartTask.java
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStartTask.java
index 270c48a..2aa03a2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStartTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStartTask.java
@@ -25,7 +25,6 @@ import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.internal.visor.*;
 import org.apache.ignite.internal.visor.util.*;
-import org.apache.ignite.lang.*;
 import org.jetbrains.annotations.*;
 
 import java.io.*;
@@ -36,12 +35,12 @@ import java.util.*;
  */
 @GridInternal
 public class VisorCacheStartTask extends
-    VisorMultiNodeTask<IgniteBiTuple<String, String>, Map<UUID, IgniteException>,
Void> {
+    VisorMultiNodeTask<VisorCacheStartTask.VisorCacheStartArg, Map<UUID, IgniteException>,
Void> {
     /** */
     private static final long serialVersionUID = 0L;
 
     /** {@inheritDoc} */
-    @Override protected VisorCacheStartJob job(IgniteBiTuple<String, String> arg) {
+    @Override protected VisorCacheStartJob job(VisorCacheStartArg arg) {
         return new VisorCacheStartJob(arg, debug);
     }
 
@@ -57,9 +56,59 @@ public class VisorCacheStartTask extends
     }
 
     /**
+     * Cache start arguments.
+     */
+    @SuppressWarnings("PublicInnerClass")
+    public static class VisorCacheStartArg implements Serializable {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /** */
+        private final boolean near;
+
+        /** */
+        private final String name;
+
+        /** */
+        private final String cfg;
+
+        /**
+         * @param near {@code true} if near cache should be started.
+         * @param name Name for near cache.
+         * @param cfg Cache XML configuration.
+         */
+        public VisorCacheStartArg(boolean near, String name, String cfg) {
+            this.near = near;
+            this.name = name;
+            this.cfg = cfg;
+        }
+
+        /**
+         * @return {@code true} if near cache should be started.
+         */
+        public boolean near() {
+            return near;
+        }
+
+        /**
+         * @return Name for near cache.
+         */
+        public String name() {
+            return name;
+        }
+
+        /**
+         * @return Cache XML configuration.
+         */
+        public String configuration() {
+            return cfg;
+        }
+    }
+
+    /**
      * Job that start cache or near cache with specified configuration.
      */
-    private static class VisorCacheStartJob extends VisorJob<IgniteBiTuple<String,
String>, Void> {
+    private static class VisorCacheStartJob extends VisorJob<VisorCacheStartArg, Void>
{
         /** */
         private static final long serialVersionUID = 0L;
 
@@ -69,29 +118,30 @@ public class VisorCacheStartTask extends
          * @param arg Contains cache name and XML configurations of cache.
          * @param debug Debug flag.
          */
-        private VisorCacheStartJob(IgniteBiTuple<String, String> arg, boolean debug)
{
+        private VisorCacheStartJob(VisorCacheStartArg arg, boolean debug) {
             super(arg, debug);
         }
 
         /** {@inheritDoc} */
-        @Override protected Void run(IgniteBiTuple<String, String> arg) {
-            String name = arg.get1();
-
-            String cfg = arg.get2();
+        @Override protected Void run(VisorCacheStartArg arg) throws IgniteException {
+            String cfg = arg.configuration();
 
             assert !F.isEmpty(cfg);
 
-            if (name == null) {
-                CacheConfiguration cacheCfg = Ignition.loadSpringBean(new ByteArrayInputStream(cfg.getBytes()),
-                    "cacheConfiguration");
+            try (ByteArrayInputStream bais = new ByteArrayInputStream(cfg.getBytes())) {
+                if (arg.near) {
+                    NearCacheConfiguration nearCfg = Ignition.loadSpringBean(bais, "nearCacheConfiguration");
 
-                ignite.createCache(cacheCfg);
-            }
-            else {
-                NearCacheConfiguration nearCfg = Ignition.loadSpringBean(
-                    new ByteArrayInputStream(arg.get2().getBytes()), "nearCacheConfiguration");
+                    ignite.createNearCache(VisorTaskUtils.unescapeName(arg.name()), nearCfg);
+                }
+                else {
+                    CacheConfiguration cacheCfg = Ignition.loadSpringBean(bais, "cacheConfiguration");
 
-                ignite.createNearCache(VisorTaskUtils.unescapeName(name), nearCfg);
+                    ignite.createCache(cacheCfg);
+                }
+            }
+            catch (IOException e) {
+                throw new  IgniteException(e);
             }
 
             return null;


Mime
View raw message