IGNITE-4988 Cleanup code.

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

Branch: refs/heads/ignite-2893
Commit: 36e7e19830dc53c0ed02a0d83806b2cb5a7c7ce5
Parents: f82ed01
Author: Alexey Kuznetsov <akuznet...@apache.org>
Authored: Wed Apr 19 11:34:16 2017 +0700
Committer: Alexey Kuznetsov <akuznet...@apache.org>
Committed: Wed Apr 19 11:34:16 2017 +0700

----------------------------------------------------------------------
 .../JettyRestProcessorAbstractSelfTest.java     | 10 +++
 .../visor/cache/VisorCachePartition.java        | 87 -------------------
 .../visor/cache/VisorCachePartitions.java       | 28 +++---
 .../visor/cache/VisorCachePartitionsTask.java   | 20 +++--
 .../cache/VisorCachePartitionsTaskArg.java      | 72 ++++++++++++++++
 .../visor/compute/VisorGatewayTask.java         | 91 ++++++++++++--------
 .../resources/META-INF/classnames.properties    |  2 +-
 7 files changed, 164 insertions(+), 146 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/36e7e198/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
 
b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
index e5d9997..1321929 100644
--- 
a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
+++ 
b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
@@ -66,6 +66,8 @@ import 
org.apache.ignite.internal.visor.cache.VisorCacheMetadataTask;
 import org.apache.ignite.internal.visor.cache.VisorCacheMetricsCollectorTask;
 import 
org.apache.ignite.internal.visor.cache.VisorCacheMetricsCollectorTaskArg;
 import org.apache.ignite.internal.visor.cache.VisorCacheNodesTask;
+import org.apache.ignite.internal.visor.cache.VisorCachePartitionsTask;
+import org.apache.ignite.internal.visor.cache.VisorCachePartitionsTaskArg;
 import org.apache.ignite.internal.visor.cache.VisorCacheRebalanceTask;
 import org.apache.ignite.internal.visor.cache.VisorCacheResetMetricsTask;
 import org.apache.ignite.internal.visor.cache.VisorCacheStartTaskArg;
@@ -1283,6 +1285,14 @@ public abstract class JettyRestProcessorAbstractSelfTest 
extends AbstractRestPro
 
         jsonTaskResult(ret);
 
+        ret = content(new VisorGatewayArgument(VisorCachePartitionsTask.class)
+            .forNode(locNode)
+            .argument(VisorCachePartitionsTaskArg.class, "person"));
+
+        info("VisorCachePartitionsTask result: " + ret);
+
+        jsonTaskResult(ret);
+
         ret = content(new VisorGatewayArgument(VisorCacheLoadTask.class)
             .forNode(locNode)
             .argument(VisorCacheLoadTaskArg.class, "person", 0, "null"));

http://git-wip-us.apache.org/repos/asf/ignite/blob/36e7e198/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartition.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartition.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartition.java
deleted file mode 100644
index b57bc53..0000000
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartition.java
+++ /dev/null
@@ -1,87 +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 java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.visor.VisorDataTransferObject;
-
-/**
- * Data transfer object for information about keys in cache partition.
- */
-public class VisorCachePartition extends VisorDataTransferObject {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** */
-    private int partId;
-
-    /** */
-    private long cnt;
-
-    /**
-     * Default constructor.
-     */
-    public VisorCachePartition() {
-        // No-op.
-    }
-
-    /**
-     * Full constructor.
-     *
-     * @param partId Partition id.
-     * @param cnt Number of keys in partition.
-     */
-    public VisorCachePartition(int partId, long cnt) {
-        this.partId = partId;
-        this.cnt = cnt;
-    }
-
-    /**
-     * @return Partition id.
-     */
-    public int getPartitionId() {
-        return partId;
-    }
-
-    /**
-     * @return Number of keys in partition.
-     */
-    public long getCount() {
-        return cnt;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void writeExternalData(ObjectOutput out) throws 
IOException {
-        out.writeInt(partId);
-        out.writeLong(cnt);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void readExternalData(byte protoVer, ObjectInput in) 
throws IOException, ClassNotFoundException {
-        partId = in.readInt();
-        cnt = in.readLong();
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(VisorCachePartition.class, this);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/36e7e198/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitions.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitions.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitions.java
index 2713179..505d98e 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitions.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitions.java
@@ -20,8 +20,8 @@ package org.apache.ignite.internal.visor.cache;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
 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,17 +34,17 @@ public class VisorCachePartitions extends 
VisorDataTransferObject {
     private static final long serialVersionUID = 0L;
 
     /** */
-    private List<VisorCachePartition> primary;
+    private Map<Integer, Long> primary;
 
     /** */
-    private List<VisorCachePartition> backup;
+    private Map<Integer, Long> backup;
 
     /**
      * Default constructor.
      */
     public VisorCachePartitions() {
-        primary = new ArrayList<>();
-        backup = new ArrayList<>();
+        primary = new HashMap<>();
+        backup = new HashMap<>();
     }
 
     /**
@@ -54,7 +54,7 @@ public class VisorCachePartitions extends 
VisorDataTransferObject {
      * @param cnt Number of primary keys in partition.
      */
     public void addPrimary(int partId, long cnt) {
-       primary.add(new VisorCachePartition(partId, cnt));
+       primary.put(partId, cnt);
     }
 
     /**
@@ -64,33 +64,33 @@ public class VisorCachePartitions extends 
VisorDataTransferObject {
      * @param cnt Number of backup keys in partition.
      */
     public void addBackup(int partId, long cnt) {
-       backup.add(new VisorCachePartition(partId, cnt));
+       backup.put(partId, cnt);
     }
 
     /**
      * @return Get list of primary partitions.
      */
-    public List<VisorCachePartition> getPrimary() {
+    public Map<Integer, Long> getPrimary() {
         return primary;
     }
 
     /**
      * @return Get list of backup partitions.
      */
-    public List<VisorCachePartition> getBackup() {
+    public Map<Integer, Long> getBackup() {
         return backup;
     }
 
     /** {@inheritDoc} */
     @Override protected void writeExternalData(ObjectOutput out) throws 
IOException {
-        U.writeCollection(out, primary);
-        U.writeCollection(out, backup);
+        U.writeMap(out, primary);
+        U.writeMap(out, backup);
     }
 
     /** {@inheritDoc} */
     @Override protected void readExternalData(byte protoVer, ObjectInput in) 
throws IOException, ClassNotFoundException {
-        primary = U.readList(in);
-        backup = U.readList(in);
+        primary = U.readMap(in);
+        backup = U.readMap(in);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/36e7e198/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitionsTask.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitionsTask.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitionsTask.java
index b7ca975..c9339b7 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitionsTask.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitionsTask.java
@@ -45,13 +45,13 @@ import static 
org.apache.ignite.internal.visor.util.VisorTaskUtils.escapeName;
  * Task that collect keys distribution in partitions.
  */
 @GridInternal
-public class VisorCachePartitionsTask extends VisorMultiNodeTask<String,
+public class VisorCachePartitionsTask extends 
VisorMultiNodeTask<VisorCachePartitionsTaskArg,
     Map<UUID, VisorCachePartitions>, VisorCachePartitions> {
     /** */
     private static final long serialVersionUID = 0L;
 
     /** {@inheritDoc} */
-    @Override protected VisorCachePartitionsJob job(String arg) {
+    @Override protected VisorCachePartitionsJob 
job(VisorCachePartitionsTaskArg arg) {
         return new VisorCachePartitionsJob(arg, debug);
     }
 
@@ -72,22 +72,24 @@ public class VisorCachePartitionsTask extends 
VisorMultiNodeTask<String,
     /**
      * Job that collect cache metrics from node.
      */
-    private static class VisorCachePartitionsJob extends VisorJob<String, 
VisorCachePartitions> {
+    private static class VisorCachePartitionsJob extends 
VisorJob<VisorCachePartitionsTaskArg, VisorCachePartitions> {
         /** */
         private static final long serialVersionUID = 0L;
 
         /**
          * Create job with given argument.
          *
-         * @param cacheName Cache name.
+         * @param arg Tasks arguments.
          * @param debug Debug flag.
          */
-        private VisorCachePartitionsJob(String cacheName, boolean debug) {
-            super(cacheName, debug);
+        private VisorCachePartitionsJob(VisorCachePartitionsTaskArg arg, 
boolean debug) {
+            super(arg, debug);
         }
 
         /** {@inheritDoc} */
-        @Override protected VisorCachePartitions run(final String cacheName) 
throws IgniteException {
+        @Override protected VisorCachePartitions 
run(VisorCachePartitionsTaskArg arg) throws IgniteException {
+            String cacheName = arg.getCacheName();
+
             if (debug)
                 log(ignite.log(), "Collecting partitions for cache: " + 
escapeName(cacheName));
 
@@ -122,9 +124,9 @@ public class VisorCachePartitionsTask extends 
VisorMultiNodeTask<String,
                     for (GridDhtLocalPartition part : locParts) {
                         int p = part.id();
 
-                        int sz = part.publicSize();
+                        long sz = part.publicSize();
 
-                        // Pass -1 as topology version in order not to wait 
for topology version.
+                        // Pass NONE as topology version in order not to wait 
for topology version.
                         if (part.primary(AffinityTopologyVersion.NONE))
                             parts.addPrimary(p, sz);
                         else if (part.state() == GridDhtPartitionState.OWNING 
&& part.backup(AffinityTopologyVersion.NONE))

http://git-wip-us.apache.org/repos/asf/ignite/blob/36e7e198/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitionsTaskArg.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitionsTaskArg.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitionsTaskArg.java
new file mode 100644
index 0000000..957f071
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCachePartitionsTaskArg.java
@@ -0,0 +1,72 @@
+/*
+ * 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 java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+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;
+
+/**
+ * Arguments for {@link VisorCachePartitionsTask}.
+ */
+public class VisorCachePartitionsTaskArg extends VisorDataTransferObject {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** */
+    private String cacheName;
+
+    /**
+     * Default constructor.
+     */
+    public VisorCachePartitionsTaskArg() {
+        // No-op.
+    }
+
+    /**
+     * @param cacheName Cache name.
+     */
+    public VisorCachePartitionsTaskArg(String cacheName) {
+        this.cacheName = cacheName;
+    }
+
+    /**
+     * @return Cache name.
+     */
+    public String getCacheName() {
+        return cacheName;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void writeExternalData(ObjectOutput out) throws 
IOException {
+        U.writeString(out, cacheName);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void readExternalData(byte protoVer, ObjectInput in) 
throws IOException, ClassNotFoundException {
+        cacheName = U.readString(in);
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(VisorCachePartitionsTaskArg.class, this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/36e7e198/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorGatewayTask.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorGatewayTask.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorGatewayTask.java
index 05112ed..658d6a1 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorGatewayTask.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/compute/VisorGatewayTask.java
@@ -43,6 +43,7 @@ import 
org.apache.ignite.internal.processors.task.GridInternal;
 import org.apache.ignite.internal.util.lang.GridTuple3;
 import org.apache.ignite.internal.util.typedef.CI1;
 import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.visor.VisorOneNodeTask;
 import org.apache.ignite.internal.visor.VisorTaskArgument;
 import org.apache.ignite.lang.IgniteBiTuple;
 import org.apache.ignite.lang.IgniteFuture;
@@ -59,6 +60,9 @@ public class VisorGatewayTask implements 
ComputeTask<Object[], Object> {
     /** */
     private static final long serialVersionUID = 0L;
 
+    /** */
+    private static final int JOB_ARG_IDX = 3;
+
     /** Auto-injected grid instance. */
     @IgniteInstanceResource
     protected transient IgniteEx ignite;
@@ -133,24 +137,23 @@ public class VisorGatewayTask implements 
ComputeTask<Object[], Object> {
         }
 
         /**
-         * Cast argument to target class.
+         * Construct job argument.
          *
          * @param cls Class.
-         * @param idx Argument index.
          */
-        @Nullable private Object toObject(Class cls, int idx) throws 
ClassNotFoundException {
-            String arg = argument(idx);
+        @Nullable private Object toJobArgument(Class cls) throws 
ClassNotFoundException {
+            String arg = argument(JOB_ARG_IDX);
 
             if (cls == Collection.class || cls == Set.class) {
                 Class<?> itemsCls = Class.forName(arg);
 
                 Collection<Object> res = cls == Collection.class ? new 
ArrayList<>() : new HashSet<>();
 
-                String items = argument(idx + 1);
+                String items = argument(JOB_ARG_IDX + 1);
 
                 if (items != null) {
                     for (String item : items.split(";"))
-                        res.add(toSimpleObject(itemsCls, item));
+                        res.add(toObject(itemsCls, item));
                 }
 
                 return res;
@@ -159,20 +162,20 @@ public class VisorGatewayTask implements 
ComputeTask<Object[], Object> {
             if (cls == IgniteBiTuple.class) {
                 Class<?> keyCls = Class.forName(arg);
 
-                String valClsName = argument(idx + 1);
+                String valClsName = argument(JOB_ARG_IDX + 1);
 
                 assert valClsName != null;
 
                 Class<?> valCls = Class.forName(valClsName);
 
-                return new IgniteBiTuple<>(toSimpleObject(keyCls, 
(String)argument(idx + 2)),
-                    toSimpleObject(valCls, (String)argument(idx + 3)));
+                return new IgniteBiTuple<>(toObject(keyCls, 
(String)argument(JOB_ARG_IDX + 2)),
+                    toObject(valCls, (String)argument(JOB_ARG_IDX + 3)));
             }
 
             if (cls == Map.class) {
                 Class<?> keyCls = Class.forName(arg);
 
-                String valClsName = argument(idx + 1);
+                String valClsName = argument(JOB_ARG_IDX + 1);
 
                 assert valClsName != null;
 
@@ -180,7 +183,7 @@ public class VisorGatewayTask implements 
ComputeTask<Object[], Object> {
 
                 Map<Object, Object> res = new HashMap<>();
 
-                String entries = argument(idx + 2);
+                String entries = argument(JOB_ARG_IDX + 2);
 
                 if (entries != null) {
                     for (String entry : entries.split(";")) {
@@ -189,8 +192,8 @@ public class VisorGatewayTask implements 
ComputeTask<Object[], Object> {
 
                             assert values.length >= 1;
 
-                            res.put(toSimpleObject(keyCls, values[0]),
-                                values.length > 1 ? toSimpleObject(valCls, 
values[1]) : null);
+                            res.put(toObject(keyCls, values[0]),
+                                values.length > 1 ? toObject(valCls, 
values[1]) : null);
                         }
                     }
                 }
@@ -199,8 +202,8 @@ public class VisorGatewayTask implements 
ComputeTask<Object[], Object> {
             }
 
             if (cls == GridTuple3.class) {
-                String v2ClsName = argument(idx + 1);
-                String v3ClsName = argument(idx + 2);
+                String v2ClsName = argument(JOB_ARG_IDX + 1);
+                String v3ClsName = argument(JOB_ARG_IDX + 2);
 
                 assert v2ClsName != null;
                 assert v3ClsName != null;
@@ -209,20 +212,20 @@ public class VisorGatewayTask implements 
ComputeTask<Object[], Object> {
                 Class<?> v2Cls = Class.forName(v2ClsName);
                 Class<?> v3Cls = Class.forName(v3ClsName);
 
-                return new GridTuple3<>(toSimpleObject(v1Cls, 
(String)argument(idx + 3)), toSimpleObject(v2Cls,
-                    (String)argument(idx + 4)), toSimpleObject(v3Cls, 
(String)argument(idx + 5)));
+                return new GridTuple3<>(toObject(v1Cls, 
(String)argument(JOB_ARG_IDX + 3)), toObject(v2Cls,
+                    (String)argument(JOB_ARG_IDX + 4)), toObject(v3Cls, 
(String)argument(JOB_ARG_IDX + 5)));
             }
 
-            return toSimpleObject(cls, arg);
+            return toObject(cls, arg);
         }
 
         /**
-         * Cast from string representation to target class.
+         * Construct from string representation to target class.
          *
          * @param cls Target class.
          * @return Object constructed from string.
          */
-        @Nullable private Object toSimpleObject(Class cls, String val) {
+        @Nullable private Object toObject(Class cls, String val) {
             if (val == null  || "null".equals(val))
                 return null;
 
@@ -297,6 +300,7 @@ public class VisorGatewayTask implements 
ComputeTask<Object[], Object> {
         }
 
         /** {@inheritDoc} */
+        @SuppressWarnings("unchecked")
         @Override public Object execute() throws IgniteException {
             if (fut != null)
                 return fut.get();
@@ -317,46 +321,63 @@ public class VisorGatewayTask implements 
ComputeTask<Object[], Object> {
                     if (argCls == Void.class)
                         jobArgs = null;
                     else if (isBuildInObject(argCls))
-                        jobArgs = toObject(argCls, 3);
+                        jobArgs = toJobArgument(argCls);
                     else {
-                        int beanArgsCnt = argsCnt - 3;
+                        int beanArgsCnt = argsCnt - JOB_ARG_IDX;
 
                         for (Constructor ctor : 
argCls.getDeclaredConstructors()) {
                             Class[] types = ctor.getParameterTypes();
 
                             if (types.length == beanArgsCnt) {
-                                Object[] initargs = new Object[beanArgsCnt];
+                                Object[] initArgs = new Object[beanArgsCnt];
 
                                 for (int i = 0; i < beanArgsCnt; i++) {
-                                    String val = argument(i + 3);
+                                    String val = argument(i + JOB_ARG_IDX);
 
-                                    initargs[i] = toSimpleObject(types[i], 
val);
+                                    initArgs[i] = toObject(types[i], val);
                                 }
 
-                                jobArgs = ctor.newInstance(initargs);
+                                jobArgs = ctor.newInstance(initArgs);
 
                                 break;
                             }
                         }
 
-                        if (jobArgs == null)
-                            throw new IgniteException("Failed to execute task 
[task name=" + taskName + "]");
+                        if (jobArgs == null) {
+                            Object[] args = new Object[beanArgsCnt];
+
+                            for (int i = 0; i < beanArgsCnt; i++)
+                                args[i] = argument(i + JOB_ARG_IDX);
+
+                            throw new IgniteException("Failed to find 
constructor for task argument " +
+                                "[taskName=" + taskName + ", argsCnt=" + 
args.length +
+                                ", args=" + Arrays.toString(args) + "]");
+                        }
                     }
                 }
                 catch (Exception e) {
-                    throw new IgniteException("Failed to execute task [task 
name=" + taskName + "]", e);
+                    throw new IgniteException("Failed to construct job 
argument [taskName=" + taskName + "]", e);
                 }
             }
 
             final List<UUID> nids;
 
-            if (nidsArg == null || "null".equals(nidsArg) || 
nidsArg.isEmpty()) {
-                Collection<ClusterNode> nodes = ignite.cluster().nodes();
+            if (F.isEmpty(nidsArg) || "null".equals(nidsArg)) {
+                try {
+                    if 
(VisorOneNodeTask.class.isAssignableFrom(Class.forName(taskName)))
+                        nids = 
Collections.singletonList(ignite.localNode().id());
+                    else {
+                        Collection<ClusterNode> nodes = 
ignite.cluster().nodes();
 
-                nids = new ArrayList<>(nodes.size());
+                        nids = new ArrayList<>(nodes.size());
 
-                for (ClusterNode node : nodes)
-                    nids.add(node.id());
+                        for (ClusterNode node : nodes)
+                            nids.add(node.id());
+                    }
+                }
+                catch (ClassNotFoundException e) {
+                    throw new IgniteException("Failed to find task class:" + 
taskName, e);
+                }
             }
             else {
                 String[] items = nidsArg.split(";");
@@ -367,7 +388,7 @@ public class VisorGatewayTask implements 
ComputeTask<Object[], Object> {
                     try {
                         nids.add(UUID.fromString(item));
                     } catch (IllegalArgumentException ignore) {
-                        // No-op.
+                        ignite.log().warning("Failed to parse node id 
[taskName=" + taskName + ", nid=" + item + "]");
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/36e7e198/modules/core/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties 
b/modules/core/src/main/resources/META-INF/classnames.properties
index 58679ea..6b548c7 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -1686,10 +1686,10 @@ 
org.apache.ignite.internal.visor.cache.VisorCacheMetricsCollectorTaskArg
 org.apache.ignite.internal.visor.cache.VisorCacheNearConfiguration
 org.apache.ignite.internal.visor.cache.VisorCacheNodesTask
 org.apache.ignite.internal.visor.cache.VisorCacheNodesTask$VisorCacheNodesJob
-org.apache.ignite.internal.visor.cache.VisorCachePartition
 org.apache.ignite.internal.visor.cache.VisorCachePartitions
 org.apache.ignite.internal.visor.cache.VisorCachePartitionsTask
 
org.apache.ignite.internal.visor.cache.VisorCachePartitionsTask$VisorCachePartitionsJob
+org.apache.ignite.internal.visor.cache.VisorCachePartitionsTaskArg
 org.apache.ignite.internal.visor.cache.VisorCacheRebalanceConfiguration
 org.apache.ignite.internal.visor.cache.VisorCacheRebalanceTask
 
org.apache.ignite.internal.visor.cache.VisorCacheRebalanceTask$VisorCachesRebalanceJob

Reply via email to