ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [11/42] incubator-ignite git commit: # Cleanup components layout + review.
Date Wed, 29 Apr 2015 14:28:12 GMT
# Cleanup components layout + 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/78f96a08
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/78f96a08
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/78f96a08

Branch: refs/heads/ignite-286
Commit: 78f96a08c249d676f76e5ca59988b345b9109638
Parents: 42f2a09
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Sat Apr 25 00:52:11 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Sat Apr 25 00:52:11 2015 +0700

----------------------------------------------------------------------
 .../org/apache/ignite/internal/IgnitionEx.java  |  8 +-
 .../util/spring/IgniteSpringHelper.java         |  4 +-
 .../visor/cache/VisorCacheStartNearTask.java    | 78 --------------------
 .../visor/cache/VisorCacheStartTask.java        | 26 ++++---
 .../internal/visor/util/VisorTaskUtils.java     | 10 +++
 .../util/spring/IgniteSpringHelperImpl.java     | 12 ++-
 6 files changed, 36 insertions(+), 102 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/78f96a08/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index 2cd9add..57d00da 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -918,18 +918,18 @@ public class IgnitionEx {
     /**
      * Loads spring bean by name.
      *
-     * @param springXmlCfg Spring XML input stream.
+     * @param inputStream Spring XML input stream.
      * @param beanName Bean name.
      * @return Bean instance.
      * @throws IgniteCheckedException In case of error.
      */
-    public static <T> T loadSpringBean(InputStream springXmlCfg, String beanName) throws
IgniteCheckedException {
-        A.notNull(springXmlCfg, "springXmlUrl");
+    public static <T> T loadSpringBean(InputStream inputStream, String beanName) throws
IgniteCheckedException {
+        A.notNull(inputStream, "inputStream");
         A.notNull(beanName, "beanName");
 
         IgniteSpringHelper spring = SPRING.create(false);
 
-        return spring.loadBean(springXmlCfg, beanName);
+        return spring.loadBean(inputStream, beanName);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/78f96a08/modules/core/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelper.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelper.java
index ff47937..cb84496 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelper.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelper.java
@@ -82,9 +82,9 @@ public interface IgniteSpringHelper {
     public <T> T loadBean(URL url, String beanName) throws IgniteCheckedException;
 
     /**
-     * Loads bean instance by name.
+     * Loads bean instance by name from stream.
      *
-     * @param inputStream Spring XML file URL.
+     * @param inputStream Input stream with Spring XML.
      * @param beanName Bean name.
      * @return Bean instance.
      * @throws IgniteCheckedException In case of error.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/78f96a08/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStartNearTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStartNearTask.java
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStartNearTask.java
deleted file mode 100644
index 87c3dfa..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheStartNearTask.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.visor.cache;
-
-import org.apache.ignite.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.processors.task.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.internal.visor.*;
-import org.apache.ignite.lang.*;
-
-import java.io.*;
-import java.nio.charset.*;
-
-/**
- * Task that stop specified caches on specified node.
- */
-@GridInternal
-public class VisorCacheStartNearTask extends VisorOneNodeTask<IgniteBiTuple<String,
String>, Void> {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** {@inheritDoc} */
-    @Override protected VisorCacheStartJob job(IgniteBiTuple<String, String> arg) {
-        return new VisorCacheStartJob(arg, debug);
-    }
-
-    /**
-     * Job that stop specified caches.
-     */
-    private static class VisorCacheStartJob extends VisorJob<IgniteBiTuple<String,
String>, Void> {
-        /** */
-        private static final long serialVersionUID = 0L;
-
-        /**
-         * Create job.
-         *
-         * @param arg Contains XML configurations of cache and near cache tuple.
-         * @param debug Debug flag.
-         */
-        private VisorCacheStartJob(IgniteBiTuple<String, String> arg, boolean debug)
{
-            super(arg, debug);
-        }
-
-        /** {@inheritDoc} */
-        @Override protected Void run(IgniteBiTuple<String, String> arg) {
-            assert arg.get1() != null;
-            assert arg.get2() != null;
-
-            NearCacheConfiguration nearCfg = Ignition.loadSpringBean(
-                new ByteArrayInputStream(arg.get2().getBytes(StandardCharsets.UTF_8)), "nearCacheConfiguration");
-
-            ignite.createNearCache(arg.get1(), nearCfg);
-
-            return null;
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return S.toString(VisorCacheStartJob.class, this);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/78f96a08/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 b158ca2..bb0b781 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
@@ -23,12 +23,13 @@ import org.apache.ignite.internal.processors.task.*;
 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 java.io.*;
 
 /**
- * Task that stop specified caches on specified node.
+ * Task that start cache or near cache with specified configuration.
  */
 @GridInternal
 public class VisorCacheStartTask extends VisorOneNodeTask<IgniteBiTuple<String, String>,
Void> {
@@ -41,7 +42,7 @@ public class VisorCacheStartTask extends VisorOneNodeTask<IgniteBiTuple<String,
     }
 
     /**
-     * Job that stop specified caches.
+     * Job that start cache or near cache with specified configuration.
      */
     private static class VisorCacheStartJob extends VisorJob<IgniteBiTuple<String,
String>, Void> {
         /** */
@@ -50,7 +51,7 @@ public class VisorCacheStartTask extends VisorOneNodeTask<IgniteBiTuple<String,
         /**
          * Create job.
          *
-         * @param arg Contains XML configurations of cache and near cache tuple.
+         * @param arg Contains cache name and XML configurations of cache.
          * @param debug Debug flag.
          */
         private VisorCacheStartJob(IgniteBiTuple<String, String> arg, boolean debug)
{
@@ -59,21 +60,24 @@ public class VisorCacheStartTask extends VisorOneNodeTask<IgniteBiTuple<String,
 
         /** {@inheritDoc} */
         @Override protected Void run(IgniteBiTuple<String, String> arg) {
-            String ccfg = arg.get1();
+            String name = arg.get1();
 
-            assert ccfg != null;
+            String cfg = arg.get2();
 
-            CacheConfiguration cfg = Ignition.loadSpringBean(
-                new ByteArrayInputStream(ccfg.getBytes()), "cacheConfiguration");
+            assert !F.isEmpty(cfg);
 
-            if (!F.isEmpty(arg.get2())) {
+            if (name == null) {
+                CacheConfiguration cacheCfg = Ignition.loadSpringBean(new ByteArrayInputStream(cfg.getBytes()),
+                    "cacheConfiguration");
+
+                ignite.createCache(cacheCfg);
+            }
+            else {
                 NearCacheConfiguration nearCfg = Ignition.loadSpringBean(
                     new ByteArrayInputStream(arg.get2().getBytes()), "nearCacheConfiguration");
 
-                ignite.createCache(cfg, nearCfg);
+                ignite.createNearCache(VisorTaskUtils.unescapeName(name), nearCfg);
             }
-            else
-                ignite.createCache(cfg);
 
             return null;
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/78f96a08/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorTaskUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorTaskUtils.java
b/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorTaskUtils.java
index 450b1da..79ee6f9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorTaskUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorTaskUtils.java
@@ -120,6 +120,16 @@ public class VisorTaskUtils {
     }
 
     /**
+     * @param name Escaped name.
+     * @return Name or {@code null} for default name.
+     */
+    public static String unescapeName(String name) {
+        assert name != null;
+
+        return DFLT_EMPTY_NAME.equals(name) ? null : name;
+    }
+
+    /**
      * @param a First name.
      * @param b Second name.
      * @return {@code true} if both names equals.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/78f96a08/modules/spring/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelperImpl.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelperImpl.java
b/modules/spring/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelperImpl.java
index ba88085..d654bf3 100644
--- a/modules/spring/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelperImpl.java
+++ b/modules/spring/src/main/java/org/apache/ignite/internal/util/spring/IgniteSpringHelperImpl.java
@@ -125,7 +125,7 @@ public class IgniteSpringHelperImpl implements IgniteSpringHelper {
         }
         catch (NoSuchBeanDefinitionException e) {
             throw new IgniteCheckedException("Spring bean with provided name doesn't exist
[url=" + url +
-                ", beanName=" + beanName + ']');
+                ", beanName=" + beanName + ']', e);
         }
         catch (BeansException e) {
             throw new IgniteCheckedException("Failed to load Spring bean with provided name
[url=" + url +
@@ -135,19 +135,17 @@ public class IgniteSpringHelperImpl implements IgniteSpringHelper {
 
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
-    @Override public <T> T loadBean(InputStream is, String beanName) throws IgniteCheckedException
{
-        ApplicationContext springCtx = initContext(new InputStreamResource(is));
+    @Override public <T> T loadBean(InputStream inputStream, String beanName) throws
IgniteCheckedException {
+        ApplicationContext springCtx = initContext(new InputStreamResource(inputStream));
 
         try {
             return (T)springCtx.getBean(beanName);
         }
         catch (NoSuchBeanDefinitionException e) {
-            throw new IgniteCheckedException("Spring bean with provided name doesn't exist
[stream=" + is +
-                ", beanName=" + beanName + ']');
+            throw new IgniteCheckedException("Spring bean with provided name doesn't exist:
" + beanName, e);
         }
         catch (BeansException e) {
-            throw new IgniteCheckedException("Failed to load Spring bean with provided name
[stream=" + is +
-                ", beanName=" + beanName + ']', e);
+            throw new IgniteCheckedException("Failed to load Spring bean with provided name:
" + beanName, e);
         }
     }
 


Mime
View raw message