You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2017/04/17 08:21:37 UTC
[15/50] [abbrv] ignite git commit: IGNITE-4988 Cleanup and refactor
VisorXxx tasks and DTO for ignite-2.0
http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAffinityNodeTaskArg.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAffinityNodeTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAffinityNodeTaskArg.java
new file mode 100644
index 0000000..ec05733
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAffinityNodeTaskArg.java
@@ -0,0 +1,86 @@
+/*
+ * 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;
+
+/**
+ * Argument for {@link VisorCacheAffinityNodeTask}.
+ */
+public class VisorCacheAffinityNodeTaskArg extends VisorDataTransferObject {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Cache name. */
+ private String cacheName;
+
+ /** Key to map to a node. */
+ private Object key;
+
+ /**
+ * Default constructor.
+ */
+ public VisorCacheAffinityNodeTaskArg() {
+ // No-op.
+ }
+
+ /**
+ * @param cacheName Cache name.
+ * @param key Object.
+ */
+ public VisorCacheAffinityNodeTaskArg(String cacheName, Object key) {
+ this.cacheName = cacheName;
+ this.key = key;
+ }
+
+ /**
+ * @return Cache name.
+ */
+ public String getCacheName() {
+ return cacheName;
+ }
+
+ /**
+ * @return Key to map to a node.
+ */
+ public Object getKey() {
+ return key;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void writeExternalData(ObjectOutput out) throws IOException {
+ U.writeString(out, cacheName);
+ out.writeObject(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException {
+ cacheName = U.readString(in);
+ key = in.readObject();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(VisorCacheAffinityNodeTaskArg.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAggregatedMetrics.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAggregatedMetrics.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAggregatedMetrics.java
index 586fa87..21a2806 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAggregatedMetrics.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheAggregatedMetrics.java
@@ -17,19 +17,22 @@
package org.apache.ignite.internal.visor.cache;
-import java.io.Serializable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.internal.LessNamingBean;
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;
/**
* Data transfer object for aggregated cache metrics.
*/
-public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean {
+public class VisorCacheAggregatedMetrics extends VisorDataTransferObject {
/** */
private static final long serialVersionUID = 0L;
@@ -43,7 +46,7 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
private boolean sys;
/** Node IDs with cache metrics. */
- private final Map<UUID, VisorCacheMetrics> metrics = new HashMap<>();
+ private Map<UUID, VisorCacheMetrics> metrics = new HashMap<>();
/** Minimum number of elements in heap. */
private transient Long minHeapSize;
@@ -118,54 +121,56 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
private transient Integer failsQry;
/**
+ * Default constructor.
+ */
+ public VisorCacheAggregatedMetrics() {
+ // No-op.
+ }
+
+ /**
* Create data transfer object for aggregated cache metrics.
*
* @param cm Source cache metrics.
- * @return Data transfer object for aggregated cache metrics.
*/
- public static VisorCacheAggregatedMetrics from(VisorCacheMetrics cm) {
- VisorCacheAggregatedMetrics acm = new VisorCacheAggregatedMetrics();
-
- acm.name = cm.name();
- acm.mode = cm.mode();
- acm.sys = cm.system();
-
- return acm;
+ public VisorCacheAggregatedMetrics(VisorCacheMetrics cm) {
+ name = cm.getName();
+ mode = cm.getMode();
+ sys = cm.isSystem();
}
/**
* @return Cache name.
*/
- public String name() {
+ public String getName() {
return name;
}
/** @return Cache mode. */
- public CacheMode mode() {
+ public CacheMode getMode() {
return mode;
}
/** @return Cache system state. */
- public boolean system() {
+ public boolean isSystem() {
return sys;
}
/**
* @return Nodes.
*/
- public Collection<UUID> nodes() {
+ public Collection<UUID> getNodes() {
return metrics.keySet();
}
/**
* @return Minimum number of elements in heap.
*/
- public long minimumHeapSize() {
+ public long getMinimumHeapSize() {
if (minHeapSize == null) {
minHeapSize = Long.MAX_VALUE;
for (VisorCacheMetrics metric : metrics.values())
- minHeapSize = Math.min(minHeapSize, metric.keySize());
+ minHeapSize = Math.min(minHeapSize, metric.getKeySize());
}
return minHeapSize;
@@ -174,12 +179,12 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
/**
* @return Average number of elements in heap.
*/
- public double averageHeapSize() {
+ public double getAverageHeapSize() {
if (avgHeapSize == null) {
avgHeapSize = 0.0d;
for (VisorCacheMetrics metric : metrics.values())
- avgHeapSize += metric.keySize();
+ avgHeapSize += metric.getKeySize();
avgHeapSize /= metrics.size();
}
@@ -190,12 +195,12 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
/**
* @return Maximum number of elements in heap.
*/
- public long maximumHeapSize() {
+ public long getMaximumHeapSize() {
if (maxHeapSize == null) {
maxHeapSize = Long.MIN_VALUE;
for (VisorCacheMetrics metric : metrics.values())
- maxHeapSize = Math.max(maxHeapSize, metric.keySize());
+ maxHeapSize = Math.max(maxHeapSize, metric.getKeySize());
}
return maxHeapSize;
@@ -205,19 +210,19 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
* @param metric Metrics to process.
* @return Off heap entries count.
*/
- private long offHeapEntriesCount(VisorCacheMetrics metric) {
+ private long getOffHeapEntriesCount(VisorCacheMetrics metric) {
return metric.offHeapEntriesCount();
}
/**
* @return Minimum number of elements in off heap.
*/
- public long minimumOffHeapSize() {
+ public long getMinimumOffHeapSize() {
if (minOffHeapSize == null) {
minOffHeapSize = Long.MAX_VALUE;
for (VisorCacheMetrics metric : metrics.values())
- minOffHeapSize = Math.min(minOffHeapSize, offHeapEntriesCount(metric));
+ minOffHeapSize = Math.min(minOffHeapSize, getOffHeapEntriesCount(metric));
}
return minOffHeapSize;
@@ -226,12 +231,12 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
/**
* @return Average number of elements in off heap.
*/
- public double averageOffHeapSize() {
+ public double getAverageOffHeapSize() {
if (avgOffHeapSize == null) {
avgOffHeapSize = 0.0d;
for (VisorCacheMetrics metric : metrics.values())
- avgOffHeapSize += offHeapEntriesCount(metric);
+ avgOffHeapSize += getOffHeapEntriesCount(metric);
avgOffHeapSize /= metrics.size();
}
@@ -242,12 +247,12 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
/**
* @return Maximum number of elements in off heap in the cache.
*/
- public long maximumOffHeapSize() {
+ public long getMaximumOffHeapSize() {
if (maxOffHeapSize == null) {
maxOffHeapSize = Long.MIN_VALUE;
for (VisorCacheMetrics metric : metrics.values())
- maxOffHeapSize = Math.max(maxOffHeapSize, offHeapEntriesCount(metric));
+ maxOffHeapSize = Math.max(maxOffHeapSize, getOffHeapEntriesCount(metric));
}
return maxOffHeapSize;
@@ -256,12 +261,12 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
/**
* @return Minimum hits of the owning cache.
*/
- public long minimumHits() {
+ public long getMinimumHits() {
if (minHits == null) {
minHits = Long.MAX_VALUE;
for (VisorCacheMetrics metric : metrics.values())
- minHits = Math.min(minHits, metric.hits());
+ minHits = Math.min(minHits, metric.getHits());
}
return minHits;
@@ -270,12 +275,12 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
/**
* @return Average hits of the owning cache.
*/
- public double averageHits() {
+ public double getAverageHits() {
if (avgHits == null) {
avgHits = 0.0d;
for (VisorCacheMetrics metric : metrics.values())
- avgHits += metric.hits();
+ avgHits += metric.getHits();
avgHits /= metrics.size();
}
@@ -286,12 +291,12 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
/**
* @return Maximum hits of the owning cache.
*/
- public long maximumHits() {
+ public long getMaximumHits() {
if (maxHits == null) {
maxHits = Long.MIN_VALUE;
for (VisorCacheMetrics metric : metrics.values())
- maxHits = Math.max(maxHits, metric.hits());
+ maxHits = Math.max(maxHits, metric.getHits());
}
return maxHits;
@@ -300,12 +305,12 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
/**
* @return Minimum misses of the owning cache.
*/
- public long minimumMisses() {
+ public long getMinimumMisses() {
if (minMisses == null) {
minMisses = Long.MAX_VALUE;
for (VisorCacheMetrics metric : metrics.values())
- minMisses = Math.min(minMisses, metric.misses());
+ minMisses = Math.min(minMisses, metric.getMisses());
}
return minMisses;
@@ -314,12 +319,12 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
/**
* @return Average misses of the owning cache.
*/
- public double averageMisses() {
+ public double getAverageMisses() {
if (avgMisses == null) {
avgMisses = 0.0d;
for (VisorCacheMetrics metric : metrics.values())
- avgMisses += metric.misses();
+ avgMisses += metric.getMisses();
avgMisses /= metrics.size();
}
@@ -330,12 +335,12 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
/**
* @return Maximum misses of the owning cache.
*/
- public long maximumMisses() {
+ public long getMaximumMisses() {
if (maxMisses == null) {
maxMisses = Long.MIN_VALUE;
for (VisorCacheMetrics metric : metrics.values())
- maxMisses = Math.max(maxMisses, metric.misses());
+ maxMisses = Math.max(maxMisses, metric.getMisses());
}
return maxMisses;
@@ -344,12 +349,12 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
/**
* @return Minimum total number of reads of the owning cache.
*/
- public long minimumReads() {
+ public long getMinimumReads() {
if (minReads == null) {
minReads = Long.MAX_VALUE;
for (VisorCacheMetrics metric : metrics.values())
- minReads = Math.min(minReads, metric.reads());
+ minReads = Math.min(minReads, metric.getReads());
}
return minReads;
@@ -358,12 +363,12 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
/**
* @return Average total number of reads of the owning cache.
*/
- public double averageReads() {
+ public double getAverageReads() {
if (avgReads == null) {
avgReads = 0.0d;
for (VisorCacheMetrics metric : metrics.values())
- avgReads += metric.reads();
+ avgReads += metric.getReads();
avgReads /= metrics.size();
}
@@ -374,12 +379,12 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
/**
* @return Maximum total number of reads of the owning cache.
*/
- public long maximumReads() {
+ public long getMaximumReads() {
if (maxReads == null) {
maxReads = Long.MIN_VALUE;
for (VisorCacheMetrics metric : metrics.values())
- maxReads = Math.max(maxReads, metric.reads());
+ maxReads = Math.max(maxReads, metric.getReads());
}
return maxReads;
@@ -388,12 +393,12 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
/**
* @return Minimum total number of writes of the owning cache.
*/
- public long minimumWrites() {
+ public long getMinimumWrites() {
if (minWrites == null) {
minWrites = Long.MAX_VALUE;
for (VisorCacheMetrics metric : metrics.values())
- minWrites = Math.min(minWrites, metric.writes());
+ minWrites = Math.min(minWrites, metric.getWrites());
}
return minWrites;
@@ -402,12 +407,12 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
/**
* @return Average total number of writes of the owning cache.
*/
- public double averageWrites() {
+ public double getAverageWrites() {
if (avgWrites == null) {
avgWrites = 0.0d;
for (VisorCacheMetrics metric : metrics.values())
- avgWrites += metric.writes();
+ avgWrites += metric.getWrites();
avgWrites /= metrics.size();
}
@@ -418,12 +423,12 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
/**
* @return Maximum total number of writes of the owning cache.
*/
- public long maximumWrites() {
+ public long getMaximumWrites() {
if (maxWrites == null) {
maxWrites = Long.MIN_VALUE;
for (VisorCacheMetrics metric : metrics.values())
- maxWrites = Math.max(maxWrites, metric.writes());
+ maxWrites = Math.max(maxWrites, metric.getWrites());
}
return maxWrites;
@@ -432,12 +437,12 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
/**
* @return Minimum execution time of query.
*/
- public long minimumQueryTime() {
+ public long getMinimumQueryTime() {
if (minQryTime == null) {
minQryTime = Long.MAX_VALUE;
for (VisorCacheMetrics metric : metrics.values())
- minQryTime = Math.min(minQryTime, metric.queryMetrics().minimumTime());
+ minQryTime = Math.min(minQryTime, metric.getQueryMetrics().getMinimumTime());
}
return minQryTime;
@@ -446,12 +451,12 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
/**
* @return Average execution time of query.
*/
- public double averageQueryTime() {
+ public double getAverageQueryTime() {
if (avgQryTime == null) {
avgQryTime = 0.0d;
for (VisorCacheMetrics metric : metrics.values())
- avgQryTime += metric.queryMetrics().averageTime();
+ avgQryTime += metric.getQueryMetrics().getAverageTime();
avgQryTime /= metrics.size();
}
@@ -462,12 +467,12 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
/**
* @return Maximum execution time of query.
*/
- public long maximumQueryTime() {
+ public long getMaximumQueryTime() {
if (maxQryTime == null) {
maxQryTime = Long.MIN_VALUE;
for (VisorCacheMetrics metric : metrics.values())
- maxQryTime = Math.max(maxQryTime, metric.queryMetrics().maximumTime());
+ maxQryTime = Math.max(maxQryTime, metric.getQueryMetrics().getMaximumTime());
}
return maxQryTime;
@@ -476,9 +481,9 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
/**
* @return Total execution time of query.
*/
- public long totalQueryTime() {
+ public long getTotalQueryTime() {
if (totalQryTime == null)
- totalQryTime = (long)(averageQueryTime() * execsQuery());
+ totalQryTime = (long)(getAverageQueryTime() * getQueryExecutions());
return totalQryTime;
}
@@ -486,12 +491,12 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
/**
* @return Number of executions.
*/
- public int execsQuery() {
+ public int getQueryExecutions() {
if (execsQry == null) {
execsQry = 0;
for (VisorCacheMetrics metric : metrics.values())
- execsQry += metric.queryMetrics().executions();
+ execsQry += metric.getQueryMetrics().getExecutions();
}
return execsQry;
@@ -500,25 +505,89 @@ public class VisorCacheAggregatedMetrics implements Serializable, LessNamingBean
/**
* @return Total number of times a query execution failed.
*/
- public int failsQuery() {
+ public int getQueryFailures() {
if (failsQry == null) {
failsQry = 0;
for (VisorCacheMetrics metric : metrics.values())
- failsQry += metric.queryMetrics().fails();
+ failsQry += metric.getQueryMetrics().getFailures();
}
return failsQry;
}
/**
- * @return Node IDs with cache metrics.
+ * @return Map of Node IDs to cache metrics.
*/
- public Map<UUID, VisorCacheMetrics> metrics() {
+ public Map<UUID, VisorCacheMetrics> getMetrics() {
return metrics;
}
/** {@inheritDoc} */
+ @Override protected void writeExternalData(ObjectOutput out) throws IOException {
+ U.writeString(out, name);
+ U.writeEnum(out, mode);
+ out.writeBoolean(sys);
+ U.writeMap(out, metrics);
+ out.writeObject(minHeapSize);
+ out.writeObject(avgHeapSize);
+ out.writeObject(maxHeapSize);
+ out.writeObject(minOffHeapSize);
+ out.writeObject(avgOffHeapSize);
+ out.writeObject(maxOffHeapSize);
+ out.writeObject(minHits);
+ out.writeObject(avgHits);
+ out.writeObject(maxHits);
+ out.writeObject(minMisses);
+ out.writeObject(avgMisses);
+ out.writeObject(maxMisses);
+ out.writeObject(minReads);
+ out.writeObject(avgReads);
+ out.writeObject(maxReads);
+ out.writeObject(minWrites);
+ out.writeObject(avgWrites);
+ out.writeObject(maxWrites);
+ out.writeObject(minQryTime);
+ out.writeObject(avgQryTime);
+ out.writeObject(maxQryTime);
+ out.writeObject(totalQryTime);
+ out.writeObject(execsQry);
+ out.writeObject(failsQry);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException {
+ name = U.readString(in);
+ mode = CacheMode.fromOrdinal(in.readByte());
+ sys = in.readBoolean();
+ metrics = U.readMap(in);
+ minHeapSize = (Long)in.readObject();
+ avgHeapSize = (Double)in.readObject();
+ maxHeapSize = (Long)in.readObject();
+ minOffHeapSize = (Long)in.readObject();
+ avgOffHeapSize = (Double)in.readObject();
+ maxOffHeapSize = (Long)in.readObject();
+ minHits = (Long)in.readObject();
+ avgHits = (Double)in.readObject();
+ maxHits = (Long)in.readObject();
+ minMisses = (Long)in.readObject();
+ avgMisses = (Double)in.readObject();
+ maxMisses = (Long)in.readObject();
+ minReads = (Long)in.readObject();
+ avgReads = (Double)in.readObject();
+ maxReads = (Long)in.readObject();
+ minWrites = (Long)in.readObject();
+ avgWrites = (Double)in.readObject();
+ maxWrites = (Long)in.readObject();
+ minQryTime = (Long)in.readObject();
+ avgQryTime = (Double)in.readObject();
+ maxQryTime = (Long)in.readObject();
+ totalQryTime = (Long)in.readObject();
+ execsQry = (Integer)in.readObject();
+ failsQry = (Integer)in.readObject();
+ }
+
+ /** {@inheritDoc} */
@Override public String toString() {
return S.toString(VisorCacheAggregatedMetrics.class, this);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java
index 7556e7c..6d14939 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTask.java
@@ -24,8 +24,6 @@ import org.apache.ignite.internal.processors.task.GridInternal;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.visor.VisorJob;
import org.apache.ignite.internal.visor.VisorOneNodeTask;
-import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.lang.IgniteCallable;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.resources.JobContextResource;
@@ -34,7 +32,7 @@ import org.apache.ignite.resources.JobContextResource;
* Task that clears specified caches on specified node.
*/
@GridInternal
-public class VisorCacheClearTask extends VisorOneNodeTask<String, IgniteBiTuple<Integer, Integer>> {
+public class VisorCacheClearTask extends VisorOneNodeTask<String, VisorCacheClearTaskResult> {
/** */
private static final long serialVersionUID = 0L;
@@ -46,18 +44,15 @@ public class VisorCacheClearTask extends VisorOneNodeTask<String, IgniteBiTuple<
/**
* Job that clear specified caches.
*/
- private static class VisorCacheClearJob extends VisorJob<String, IgniteBiTuple<Integer, Integer>> {
+ private static class VisorCacheClearJob extends VisorJob<String, VisorCacheClearTaskResult> {
/** */
private static final long serialVersionUID = 0L;
/** */
- private final String cacheName;
+ private final IgniteInClosure<IgniteFuture> lsnr;
/** */
- private final IgniteInClosure<IgniteFuture<Integer>> lsnr;
-
- /** */
- private IgniteFuture<Integer>[] futs;
+ private IgniteFuture<Long>[] futs;
/** */
@JobContextResource
@@ -72,13 +67,11 @@ public class VisorCacheClearTask extends VisorOneNodeTask<String, IgniteBiTuple<
private VisorCacheClearJob(String cacheName, boolean debug) {
super(cacheName, debug);
- this.cacheName = cacheName;
-
- lsnr = new IgniteInClosure<IgniteFuture<Integer>>() {
+ lsnr = new IgniteInClosure<IgniteFuture>() {
/** */
private static final long serialVersionUID = 0L;
- @Override public void apply(IgniteFuture<Integer> f) {
+ @Override public void apply(IgniteFuture f) {
assert futs[0].isDone();
assert futs[1] == null || futs[1].isDone();
assert futs[2] == null || futs[2].isDone();
@@ -89,13 +82,10 @@ public class VisorCacheClearTask extends VisorOneNodeTask<String, IgniteBiTuple<
}
/**
- * @param fut Future for asynchronous cache operation.
- * @param idx Index.
- * @return {@code true} If subJob was not completed and this job should be suspended.
+ * @param fut Future to listen.
+ * @return {@code true} If future was not completed and this job should holdCC.
*/
- private boolean callAsync(IgniteFuture<Integer> fut, int idx) {
- futs[idx] = fut;
-
+ private boolean callAsync(IgniteFuture fut) {
if (fut.isDone())
return false;
@@ -107,7 +97,7 @@ public class VisorCacheClearTask extends VisorOneNodeTask<String, IgniteBiTuple<
}
/** {@inheritDoc} */
- @Override protected IgniteBiTuple<Integer, Integer> run(final String cacheName) {
+ @Override protected VisorCacheClearTaskResult run(final String cacheName) {
if (futs == null)
futs = new IgniteFuture[3];
@@ -115,24 +105,30 @@ public class VisorCacheClearTask extends VisorOneNodeTask<String, IgniteBiTuple<
IgniteCache cache = ignite.cache(cacheName);
if (futs[0] == null) {
- if (callAsync(cache.sizeAsync(CachePeekMode.PRIMARY), 0))
+ futs[0] = cache.sizeLongAsync(CachePeekMode.PRIMARY);
+
+ if (callAsync(futs[0]))
return null;
}
if (futs[1] == null) {
- if (callAsync(cache.clearAsync(), 1))
+ futs[1] = cache.clearAsync();
+
+ if (callAsync(futs[1]))
return null;
}
-
+
if (futs[2] == null) {
- if (callAsync(cache.sizeAsync(CachePeekMode.PRIMARY), 2))
+ futs[2] = cache.sizeLongAsync(CachePeekMode.PRIMARY);
+
+ if (callAsync(futs[2]))
return null;
}
}
assert futs[0].isDone() && futs[1].isDone() && futs[2].isDone();
- return new IgniteBiTuple<>(futs[0].get(), futs[2].get());
+ return new VisorCacheClearTaskResult(futs[0].get(), futs[2].get());
}
/** {@inheritDoc} */
@@ -140,58 +136,4 @@ public class VisorCacheClearTask extends VisorOneNodeTask<String, IgniteBiTuple<
return S.toString(VisorCacheClearJob.class, this);
}
}
-
- /**
- * Callable to get cache size.
- *
- * @deprecated This class needed only for compatibility.
- */
- @GridInternal @Deprecated
- private static class VisorCacheSizeCallable implements IgniteCallable<Integer> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- private final IgniteCache cache;
-
- /**
- * @param cache Cache to take size from.
- */
- private VisorCacheSizeCallable(IgniteCache cache) {
- this.cache = cache;
- }
-
- /** {@inheritDoc} */
- @Override public Integer call() throws Exception {
- return cache.size(CachePeekMode.PRIMARY);
- }
- }
-
- /**
- * Callable to clear cache.
- *
- * @deprecated This class needed only for compatibility.
- */
- @GridInternal @Deprecated
- private static class VisorCacheClearCallable implements IgniteCallable<Integer> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- private final IgniteCache cache;
-
- /**
- * @param cache Cache to clear.
- */
- private VisorCacheClearCallable(IgniteCache cache) {
- this.cache = cache;
- }
-
- /** {@inheritDoc} */
- @Override public Integer call() throws Exception {
- cache.clear();
-
- return 0;
- }
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTaskResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTaskResult.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTaskResult.java
new file mode 100644
index 0000000..c7249f7
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheClearTaskResult.java
@@ -0,0 +1,85 @@
+/*
+ * 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;
+
+/**
+ * Result for {@link VisorCacheClearTask}.
+ */
+public class VisorCacheClearTaskResult extends VisorDataTransferObject {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Cache size before clearing. */
+ private long sizeBefore;
+
+ /** Cache size after clearing. */
+ private long sizeAfter;
+
+ /**
+ * Default constructor.
+ */
+ public VisorCacheClearTaskResult() {
+ // No-op.
+ }
+
+ /**
+ * @param sizeBefore Cache size before clearing.
+ * @param sizeAfter Cache size after clearing.
+ */
+ public VisorCacheClearTaskResult(long sizeBefore, long sizeAfter) {
+ this.sizeBefore = sizeBefore;
+ this.sizeAfter = sizeAfter;
+ }
+
+ /**
+ * @return Cache size before clearing.
+ */
+ public long getSizeBefore() {
+ return sizeBefore;
+ }
+
+ /**
+ * @return Cache size after clearing.
+ */
+ public long getSizeAfter() {
+ return sizeAfter;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void writeExternalData(ObjectOutput out) throws IOException {
+ out.writeLong(sizeBefore);
+ out.writeLong(sizeAfter);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException {
+ sizeBefore = in.readLong();
+ sizeAfter = in.readLong();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(VisorCacheClearTaskResult.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
index e087881..91a501c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
@@ -17,16 +17,22 @@
package org.apache.ignite.internal.visor.cache;
-import java.io.Serializable;
-import java.util.Collection;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.List;
import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.cache.PartitionLossPolicy;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.internal.IgniteEx;
-import org.apache.ignite.internal.LessNamingBean;
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;
+import org.apache.ignite.internal.visor.query.VisorQueryConfiguration;
+import org.apache.ignite.internal.visor.query.VisorQueryEntity;
import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.internal.visor.util.VisorTaskUtils.compactClass;
@@ -34,7 +40,7 @@ import static org.apache.ignite.internal.visor.util.VisorTaskUtils.compactClass;
/**
* Data transfer object for cache configuration properties.
*/
-public class VisorCacheConfiguration implements Serializable, LessNamingBean {
+public class VisorCacheConfiguration extends VisorDataTransferObject {
/** */
private static final long serialVersionUID = 0L;
@@ -62,16 +68,16 @@ public class VisorCacheConfiguration implements Serializable, LessNamingBean {
/** Start size. */
private int startSize;
- /** Off-heap max memory. */
- private long offHeapMaxMemory;
-
/** Max concurrent async operations. */
private int maxConcurrentAsyncOps;
/** Cache interceptor. */
private String interceptor;
- /** Cache affinityCfg config. */
+ /** Default lock acquisition timeout. */
+ private long dfltLockTimeout;
+
+ /** Cache affinity config. */
private VisorCacheAffinityConfiguration affinityCfg;
/** Preload config. */
@@ -83,14 +89,14 @@ public class VisorCacheConfiguration implements Serializable, LessNamingBean {
/** Near cache config. */
private VisorCacheNearConfiguration nearCfg;
- /** Default config. */
- private VisorCacheDefaultConfiguration dfltCfg;
-
/** Store config. */
private VisorCacheStoreConfiguration storeCfg;
+ /** Collection of query entities. */
+ private List<VisorQueryEntity> qryEntities;
+
/** Collection of type metadata. */
- private Collection<VisorCacheTypeMetadata> typeMeta;
+ private List<VisorCacheJdbcType> jdbcTypes;
/** Whether statistics collection is enabled. */
private boolean statisticsEnabled;
@@ -108,17 +114,37 @@ public class VisorCacheConfiguration implements Serializable, LessNamingBean {
private String expiryPlcFactory;
/** Query configuration. */
- private VisorCacheQueryConfiguration qryCfg;
+ private VisorQueryConfiguration qryCfg;
/** System cache flag. */
private boolean sys;
+ /** Keep binary in store flag. */
+ private boolean storeKeepBinary;
+
+ /** On-heap cache enabled flag. */
+ private boolean onheapCache;
+
+ /** Partition loss policy. */
+ private PartitionLossPolicy partLossPlc;
+
+ /** Query parallelism. */
+ private int qryParallelism;
+
+ /**
+ * Default constructor.
+ */
+ public VisorCacheConfiguration() {
+ // No-op.
+ }
+
/**
+ * Create data transfer object for cache configuration properties.
+ *
* @param ignite Grid.
* @param ccfg Cache configuration.
- * @return Data transfer object for cache configuration properties.
*/
- public VisorCacheConfiguration from(IgniteEx ignite, CacheConfiguration ccfg) {
+ public VisorCacheConfiguration(IgniteEx ignite, CacheConfiguration ccfg) {
name = ccfg.getName();
mode = ccfg.getCacheMode();
atomicityMode = ccfg.getAtomicityMode();
@@ -129,200 +155,305 @@ public class VisorCacheConfiguration implements Serializable, LessNamingBean {
startSize = ccfg.getStartSize();
maxConcurrentAsyncOps = ccfg.getMaxConcurrentAsyncOperations();
interceptor = compactClass(ccfg.getInterceptor());
- typeMeta = VisorCacheTypeMetadata.list(ccfg.getQueryEntities(), ccfg.getCacheStoreFactory());
+ dfltLockTimeout = ccfg.getDefaultLockTimeout();
+ qryEntities = VisorQueryEntity.list(ccfg.getQueryEntities());
+ jdbcTypes = VisorCacheJdbcType.list(ccfg.getCacheStoreFactory());
statisticsEnabled = ccfg.isStatisticsEnabled();
mgmtEnabled = ccfg.isManagementEnabled();
ldrFactory = compactClass(ccfg.getCacheLoaderFactory());
writerFactory = compactClass(ccfg.getCacheWriterFactory());
expiryPlcFactory = compactClass(ccfg.getExpiryPolicyFactory());
- sys = ignite.context().cache().systemCache(ccfg.getName());
- affinityCfg = VisorCacheAffinityConfiguration.from(ccfg);
- rebalanceCfg = VisorCacheRebalanceConfiguration.from(ccfg);
- evictCfg = VisorCacheEvictionConfiguration.from(ccfg);
- nearCfg = VisorCacheNearConfiguration.from(ccfg);
- dfltCfg = VisorCacheDefaultConfiguration.from(ccfg);
+ sys = ignite.context().cache().systemCache(ccfg.getName());
+ storeKeepBinary = ccfg.isStoreKeepBinary();
+ onheapCache = ccfg.isOnheapCacheEnabled();
+ partLossPlc = ccfg.getPartitionLossPolicy();
+ qryParallelism = ccfg.getQueryParallelism();
- storeCfg = new VisorCacheStoreConfiguration().from(ignite, ccfg);
+ affinityCfg = new VisorCacheAffinityConfiguration(ccfg);
+ rebalanceCfg = new VisorCacheRebalanceConfiguration(ccfg);
+ evictCfg = new VisorCacheEvictionConfiguration(ccfg);
+ nearCfg = new VisorCacheNearConfiguration(ccfg);
- qryCfg = new VisorCacheQueryConfiguration().from(ccfg);
+ storeCfg = new VisorCacheStoreConfiguration(ignite, ccfg);
- return this;
+ qryCfg = new VisorQueryConfiguration(ccfg);
}
/**
* @return Cache name.
*/
- @Nullable public String name() {
+ @Nullable public String getName() {
return name;
}
/**
* @return Cache mode.
*/
- public CacheMode mode() {
+ public CacheMode getMode() {
return mode;
}
/**
- * @return Cache atomicity mode
+ * @return Cache atomicity mode.
*/
- public CacheAtomicityMode atomicityMode() {
+ public CacheAtomicityMode getAtomicityMode() {
return atomicityMode;
}
/**
* @return Cache atomicity write ordering mode.
*/
- public CacheAtomicWriteOrderMode atomicWriteOrderMode() {
+ public CacheAtomicWriteOrderMode getAtomicWriteOrderMode() {
return atomicWriteOrderMode;
}
/**
- * @return Eager ttl flag
- */
- public boolean eagerTtl() {
- return eagerTtl;
- }
-
- /**
* @return Write synchronization mode.
*/
- public CacheWriteSynchronizationMode writeSynchronizationMode() {
+ public CacheWriteSynchronizationMode getWriteSynchronizationMode() {
return writeSynchronizationMode;
}
/**
* @return Invalidate.
*/
- public boolean invalidate() {
+ public boolean isInvalidate() {
return invalidate;
}
/**
* @return Start size.
*/
- public int startSize() {
+ public int getStartSize() {
return startSize;
}
/**
- * @return Off-heap max memory.
- */
- public long offsetHeapMaxMemory() {
- return offHeapMaxMemory;
- }
-
- /**
* @return Max concurrent async operations
*/
- public int maxConcurrentAsyncOperations() {
+ public int getMaxConcurrentAsyncOperations() {
return maxConcurrentAsyncOps;
}
/**
* @return Cache interceptor.
*/
- @Nullable public String interceptor() {
+ @Nullable public String getInterceptor() {
return interceptor;
}
/**
+ * @return Gets default lock acquisition timeout.
+ */
+ public long getDefaultLockTimeout() {
+ return dfltLockTimeout;
+ }
+
+ /**
* @return Collection of type metadata.
*/
- public Collection<VisorCacheTypeMetadata> typeMeta() {
- return typeMeta;
+ public List<VisorCacheJdbcType> getJdbcTypes() {
+ return jdbcTypes;
+ }
+
+ /**
+ * @return Near cache config.
+ */
+ public VisorCacheNearConfiguration getNearConfiguration() {
+ return nearCfg;
+ }
+
+ /**
+ * @return Eager ttl flag.
+ */
+ public boolean isEagerTtl() {
+ return eagerTtl;
}
/**
- * @return {@code true} if cache statistics enabled.
+ * @return Default lock acquisition timeout.
*/
- public boolean statisticsEnabled() {
+ public long getDfltLockTimeout() {
+ return dfltLockTimeout;
+ }
+
+ /**
+ * @return {@code true} if cache statistics collection enabled.
+ */
+ public boolean isStatisticsEnabled() {
return statisticsEnabled;
}
/**
* @return Whether management is enabled.
*/
- public boolean managementEnabled() {
+ public boolean isManagementEnabled() {
return mgmtEnabled;
}
/**
* @return Class name of cache loader factory.
*/
- public String loaderFactory() {
+ public String getLoaderFactory() {
return ldrFactory;
}
/**
* @return Class name of cache writer factory.
*/
- public String writerFactory() {
+ public String getWriterFactory() {
return writerFactory;
}
/**
* @return Class name of expiry policy factory.
*/
- public String expiryPolicyFactory() {
+ public String getExpiryPolicyFactory() {
return expiryPlcFactory;
}
/**
- * @return Cache affinityCfg config.
+ * @return Cache affinity config.
*/
- public VisorCacheAffinityConfiguration affinityConfiguration() {
+ public VisorCacheAffinityConfiguration getAffinityConfiguration() {
return affinityCfg;
}
/**
* @return Preload config.
*/
- public VisorCacheRebalanceConfiguration rebalanceConfiguration() {
+ public VisorCacheRebalanceConfiguration getRebalanceConfiguration() {
return rebalanceCfg;
}
/**
* @return Eviction config.
*/
- public VisorCacheEvictionConfiguration evictConfiguration() {
+ public VisorCacheEvictionConfiguration getEvictionConfiguration() {
return evictCfg;
}
/**
- * @return Near cache config.
+ * @return Store config
*/
- public VisorCacheNearConfiguration nearConfiguration() {
- return nearCfg;
+ public VisorCacheStoreConfiguration getStoreConfiguration() {
+ return storeCfg;
}
/**
- * @return Dgc config
+ * @return Collection of query entities.
*/
- public VisorCacheDefaultConfiguration defaultConfiguration() {
- return dfltCfg;
+ public List<VisorQueryEntity> getQueryEntities() {
+ return qryEntities;
}
/**
- * @return Store config
+ * @return Collection of query entities.
*/
- public VisorCacheStoreConfiguration storeConfiguration() {
- return storeCfg;
+ public VisorQueryConfiguration getQueryConfiguration() {
+ return qryCfg;
}
/**
- * @return Cache query configuration.
+ * @return System cache flag.
*/
- public VisorCacheQueryConfiguration queryConfiguration() {
- return qryCfg;
+ public boolean isSystem() {
+ return sys;
}
/**
- * @return System cache state.
+ * @return Keep binary in store flag.
*/
- public boolean system() {
- return sys;
+ public Boolean isStoreKeepBinary() {
+ return storeKeepBinary;
+ }
+
+ /**
+ * @return On-heap cache enabled flag.
+ */
+ public boolean isOnheapCacheEnabled() {
+ return onheapCache;
+ }
+
+ /**
+ * @return Partition loss policy.
+ */
+ public PartitionLossPolicy getPartitionLossPolicy() {
+ return partLossPlc;
+ }
+
+ /**
+ * @return Query parallelism.
+ */
+ public int getQueryParallelism() {
+ return qryParallelism;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void writeExternalData(ObjectOutput out) throws IOException {
+ U.writeString(out, name);
+ U.writeEnum(out, mode);
+ U.writeEnum(out, atomicityMode);
+ U.writeEnum(out, atomicWriteOrderMode);
+ out.writeBoolean(eagerTtl);
+ U.writeEnum(out, writeSynchronizationMode);
+ out.writeBoolean(invalidate);
+ out.writeInt(startSize);
+ out.writeInt(maxConcurrentAsyncOps);
+ U.writeString(out, interceptor);
+ out.writeLong(dfltLockTimeout);
+ out.writeObject(affinityCfg);
+ out.writeObject(rebalanceCfg);
+ out.writeObject(evictCfg);
+ out.writeObject(nearCfg);
+ out.writeObject(storeCfg);
+ U.writeCollection(out, qryEntities);
+ U.writeCollection(out, jdbcTypes);
+ out.writeBoolean(statisticsEnabled);
+ out.writeBoolean(mgmtEnabled);
+ U.writeString(out, ldrFactory);
+ U.writeString(out, writerFactory);
+ U.writeString(out, expiryPlcFactory);
+ out.writeObject(qryCfg);
+ out.writeBoolean(sys);
+ out.writeBoolean(storeKeepBinary);
+ out.writeBoolean(onheapCache);
+ U.writeEnum(out, partLossPlc);
+ out.writeInt(qryParallelism);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void readExternalData(byte protoVer,
+ ObjectInput in) throws IOException, ClassNotFoundException {
+ name = U.readString(in);
+ mode = CacheMode.fromOrdinal(in.readByte());
+ atomicityMode = CacheAtomicityMode.fromOrdinal(in.readByte());
+ atomicWriteOrderMode = CacheAtomicWriteOrderMode.fromOrdinal(in.readByte());
+ eagerTtl = in.readBoolean();
+ writeSynchronizationMode = CacheWriteSynchronizationMode.fromOrdinal(in.readByte());
+ invalidate = in.readBoolean();
+ startSize = in.readInt();
+ maxConcurrentAsyncOps = in.readInt();
+ interceptor = U.readString(in);
+ dfltLockTimeout = in.readLong();
+ affinityCfg = (VisorCacheAffinityConfiguration)in.readObject();
+ rebalanceCfg = (VisorCacheRebalanceConfiguration)in.readObject();
+ evictCfg = (VisorCacheEvictionConfiguration)in.readObject();
+ nearCfg = (VisorCacheNearConfiguration)in.readObject();
+ storeCfg = (VisorCacheStoreConfiguration)in.readObject();
+ qryEntities = U.readList(in);
+ jdbcTypes = U.readList(in);
+ statisticsEnabled = in.readBoolean();
+ mgmtEnabled = in.readBoolean();
+ ldrFactory = U.readString(in);
+ writerFactory = U.readString(in);
+ expiryPlcFactory = U.readString(in);
+ qryCfg = (VisorQueryConfiguration)in.readObject();
+ sys = in.readBoolean();
+ onheapCache = in.readBoolean();
+ partLossPlc = PartitionLossPolicy.fromOrdinal(in.readByte());
+ qryParallelism = in.readInt();
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfigurationCollectorJob.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfigurationCollectorJob.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfigurationCollectorJob.java
index c872d98..c2a3c02 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfigurationCollectorJob.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfigurationCollectorJob.java
@@ -67,11 +67,11 @@ public class VisorCacheConfigurationCollectorJob
* @return Data transfer object to send it to Visor.
*/
protected VisorCacheConfiguration config(CacheConfiguration ccfg) {
- return new VisorCacheConfiguration().from(ignite, ccfg);
+ return new VisorCacheConfiguration(ignite, ccfg);
}
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(VisorCacheConfigurationCollectorJob.class, this);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheDefaultConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheDefaultConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheDefaultConfiguration.java
deleted file mode 100644
index 03b5020..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheDefaultConfiguration.java
+++ /dev/null
@@ -1,58 +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.Serializable;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.internal.LessNamingBean;
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-/**
- * Data transfer object for default cache configuration properties.
- */
-public class VisorCacheDefaultConfiguration implements Serializable, LessNamingBean {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Default transaction timeout. */
- private long txLockTimeout;
-
- /**
- * @param ccfg Cache configuration.
- * @return Data transfer object for default cache configuration properties.
- */
- public static VisorCacheDefaultConfiguration from(CacheConfiguration ccfg) {
- VisorCacheDefaultConfiguration cfg = new VisorCacheDefaultConfiguration();
-
- cfg.txLockTimeout = ccfg.getDefaultLockTimeout();
-
- return cfg;
- }
-
- /**
- * @return Default transaction timeout.
- */
- public long txLockTimeout() {
- return txLockTimeout;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(VisorCacheDefaultConfiguration.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheEvictionConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheEvictionConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheEvictionConfiguration.java
index b6f72c4..7792d8e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheEvictionConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheEvictionConfiguration.java
@@ -17,11 +17,14 @@
package org.apache.ignite.internal.visor.cache;
-import java.io.Serializable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import org.apache.ignite.cache.eviction.EvictionPolicy;
import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.internal.LessNamingBean;
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;
import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.internal.visor.util.VisorTaskUtils.compactClass;
@@ -30,7 +33,7 @@ import static org.apache.ignite.internal.visor.util.VisorTaskUtils.evictionPolic
/**
* Data transfer object for eviction configuration properties.
*/
-public class VisorCacheEvictionConfiguration implements Serializable, LessNamingBean {
+public class VisorCacheEvictionConfiguration extends VisorDataTransferObject {
/** */
private static final long serialVersionUID = 0L;
@@ -44,43 +47,60 @@ public class VisorCacheEvictionConfiguration implements Serializable, LessNaming
private String filter;
/**
- * @param ccfg Cache configuration.
- * @return Data transfer object for eviction configuration properties.
+ * Default constructor.
*/
- public static VisorCacheEvictionConfiguration from(CacheConfiguration ccfg) {
- VisorCacheEvictionConfiguration cfg = new VisorCacheEvictionConfiguration();
-
- final EvictionPolicy plc = ccfg.getEvictionPolicy();
+ public VisorCacheEvictionConfiguration() {
+ // No-op.
+ }
- cfg.plc = compactClass(plc);
- cfg.plcMaxSize = evictionPolicyMaxSize(plc);
- cfg.filter = compactClass(ccfg.getEvictionFilter());
+ /**
+ * Create data transfer object for eviction configuration properties.
+ * @param ccfg Cache configuration.
+ */
+ public VisorCacheEvictionConfiguration(CacheConfiguration ccfg) {
+ final EvictionPolicy evictionPlc = ccfg.getEvictionPolicy();
- return cfg;
+ plc = compactClass(evictionPlc);
+ plcMaxSize = evictionPolicyMaxSize(evictionPlc);
+ filter = compactClass(ccfg.getEvictionFilter());
}
/**
* @return Eviction policy.
*/
- @Nullable public String policy() {
+ @Nullable public String getPolicy() {
return plc;
}
/**
* @return Cache eviction policy max size.
*/
- @Nullable public Integer policyMaxSize() {
+ @Nullable public Integer getPolicyMaxSize() {
return plcMaxSize;
}
/**
* @return Eviction filter to specify which entries should not be evicted.
*/
- @Nullable public String filter() {
+ @Nullable public String getFilter() {
return filter;
}
/** {@inheritDoc} */
+ @Override protected void writeExternalData(ObjectOutput out) throws IOException {
+ U.writeString(out, plc);
+ out.writeObject(plcMaxSize);
+ U.writeString(out, filter);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException {
+ plc = U.readString(in);
+ plcMaxSize = (Integer)in.readObject();
+ filter = U.readString(in);
+ }
+
+ /** {@inheritDoc} */
@Override public String toString() {
return S.toString(VisorCacheEvictionConfiguration.class, this);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheJdbcType.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheJdbcType.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheJdbcType.java
new file mode 100644
index 0000000..e50402c
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheJdbcType.java
@@ -0,0 +1,189 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreFactory;
+import org.apache.ignite.cache.store.jdbc.JdbcType;
+import org.apache.ignite.cache.store.jdbc.JdbcTypeField;
+import org.apache.ignite.internal.util.typedef.F;
+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;
+
+import javax.cache.configuration.Factory;
+
+/**
+ * Data transfer object for {@link JdbcType}.
+ */
+public class VisorCacheJdbcType extends VisorDataTransferObject {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Schema name in database. */
+ private String dbSchema;
+
+ /** Table name in database. */
+ private String dbTbl;
+
+ /** Key class used to store key in cache. */
+ private String keyType;
+
+ /** Value class used to store value in cache. */
+ private String valType;
+
+ /** Key fields. */
+ private List<VisorCacheJdbcTypeField> keyFields;
+
+ /** Value fields. */
+ private List<VisorCacheJdbcTypeField> valFields;
+
+ /**
+ * @param factory Store factory to extract JDBC types info.
+ * @return Data transfer object for cache type metadata configurations.
+ */
+ public static List<VisorCacheJdbcType> list(Factory factory) {
+ List<VisorCacheJdbcType> res = new ArrayList<>();
+
+ if (factory != null || factory instanceof CacheJdbcPojoStoreFactory) {
+ CacheJdbcPojoStoreFactory jdbcFactory = (CacheJdbcPojoStoreFactory) factory;
+
+ JdbcType[] jdbcTypes = jdbcFactory.getTypes();
+
+ if (!F.isEmpty(jdbcTypes)) {
+ for (JdbcType jdbcType : jdbcTypes)
+ res.add(new VisorCacheJdbcType(jdbcType));
+ }
+ }
+
+ return res;
+ }
+
+ /**
+ * Create data transfer object for given cache type metadata.
+ */
+ public VisorCacheJdbcType() {
+ // No-op.
+ }
+
+ /**
+ * Create data transfer object for given cache type metadata.
+ *
+ * @param jdbcType JDBC type.
+ */
+ public VisorCacheJdbcType(JdbcType jdbcType) {
+ keyType = jdbcType.getKeyType();
+ valType = jdbcType.getValueType();
+
+ dbSchema = jdbcType.getDatabaseSchema();
+ dbTbl = jdbcType.getDatabaseTable();
+
+ JdbcTypeField[] kFields = jdbcType.getKeyFields();
+
+ if (kFields != null) {
+ keyFields = new ArrayList<>(kFields.length);
+
+ for (JdbcTypeField fld : kFields)
+ keyFields.add(new VisorCacheJdbcTypeField(
+ fld.getDatabaseFieldName(), fld.getDatabaseFieldType(),
+ fld.getDatabaseFieldName(), U.compact(fld.getJavaFieldType().getName())));
+ }
+
+ JdbcTypeField[] vFields = jdbcType.getValueFields();
+
+ if (vFields != null) {
+ valFields = new ArrayList<>(vFields.length);
+
+ for (JdbcTypeField fld : vFields)
+ valFields.add(new VisorCacheJdbcTypeField(
+ fld.getDatabaseFieldName(), fld.getDatabaseFieldType(),
+ fld.getDatabaseFieldName(), U.compact(fld.getJavaFieldType().getName())));
+ }
+ }
+
+ /**
+ * @return Schema name in database.
+ */
+ public String getDatabaseSchema() {
+ return dbSchema;
+ }
+
+ /**
+ * @return Table name in database.
+ */
+ public String getDatabaseTable() {
+ return dbTbl;
+ }
+
+ /**
+ * @return Key class used to store key in cache.
+ */
+ public String getKeyType() {
+ return keyType;
+ }
+
+ /**
+ * @return Value class used to store value in cache.
+ */
+ public String getValueType() {
+ return valType;
+ }
+
+ /**
+ * @return Key fields.
+ */
+ public List<VisorCacheJdbcTypeField> getKeyFields() {
+ return keyFields;
+ }
+
+ /**
+ * @return Value fields.
+ */
+ public List<VisorCacheJdbcTypeField> getValueFields() {
+ return valFields;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void writeExternalData(ObjectOutput out) throws IOException {
+ U.writeString(out, dbSchema);
+ U.writeString(out, dbTbl);
+ U.writeString(out, keyType);
+ U.writeString(out, valType);
+ U.writeCollection(out, keyFields);
+ U.writeCollection(out, valFields);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException {
+ dbSchema = U.readString(in);
+ dbTbl = U.readString(in);
+ keyType = U.readString(in);
+ valType = U.readString(in);
+ keyFields = U.readList(in);
+ valFields = U.readList(in);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(VisorCacheJdbcType.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheJdbcTypeField.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheJdbcTypeField.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheJdbcTypeField.java
new file mode 100644
index 0000000..5486aaf
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheJdbcTypeField.java
@@ -0,0 +1,117 @@
+/*
+ * 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.cache.store.jdbc.JdbcTypeField;
+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;
+
+/**
+ * Data transfer object for {@link JdbcTypeField}.
+ */
+public class VisorCacheJdbcTypeField extends VisorDataTransferObject {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Column name in database. */
+ private String dbName;
+
+ /** Column JDBC type in database. */
+ private int dbType;
+
+ /** Field name in java object. */
+ private String javaName;
+
+ /** Corresponding java type. */
+ private String javaType;
+
+ /**
+ * Empty constructor.
+ */
+ public VisorCacheJdbcTypeField() {
+ // No-op.
+ }
+
+ /**
+ * Full constructor.
+ *
+ * @param dbName Column name in database.
+ * @param dbType Column JDBC type in database.
+ * @param javaName Field name in java object.
+ * @param javaType Corresponding java type.
+ */
+ public VisorCacheJdbcTypeField(String dbName, int dbType, String javaName, String javaType) {
+ this.dbName = dbName;
+ this.dbType = dbType;
+ this.javaName = javaName;
+ this.javaType = javaType;
+ }
+
+ /**
+ * @return Column name in database.
+ */
+ public String getDatabaseName() {
+ return dbName;
+ }
+
+ /**
+ * @return Column JDBC type in database.
+ */
+ public int getDatabaseType() {
+ return dbType;
+ }
+
+ /**
+ * @return Field name in java object.
+ */
+ public String getJavaName() {
+ return javaName;
+ }
+
+ /**
+ * @return Corresponding java type.
+ */
+ public String getJavaType() {
+ return javaType;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void writeExternalData(ObjectOutput out) throws IOException {
+ U.writeString(out, dbName);
+ out.writeInt(dbType);
+ U.writeString(out, javaName);
+ U.writeString(out, javaType);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException {
+ dbName = U.readString(in);
+ dbType = in.readInt();
+ javaName = U.readString(in);
+ javaType = U.readString(in);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(VisorCacheJdbcTypeField.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLoadTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLoadTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLoadTask.java
index 212aaa9..34ae12c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLoadTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLoadTask.java
@@ -26,7 +26,6 @@ import javax.cache.expiry.ExpiryPolicy;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CachePeekMode;
import org.apache.ignite.internal.processors.task.GridInternal;
-import org.apache.ignite.internal.util.lang.GridTuple3;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.internal.visor.VisorJob;
@@ -37,18 +36,18 @@ import org.apache.ignite.internal.visor.VisorOneNodeTask;
*/
@GridInternal
public class VisorCacheLoadTask extends
- VisorOneNodeTask<GridTuple3<Set<String>, Long, Object[]>, Map<String, Integer>> {
+ VisorOneNodeTask<VisorCacheLoadTaskArg, Map<String, Integer>> {
/** */
private static final long serialVersionUID = 0L;
/** {@inheritDoc} */
- @Override protected VisorCachesLoadJob job(GridTuple3<Set<String>, Long, Object[]> arg) {
+ @Override protected VisorCachesLoadJob job(VisorCacheLoadTaskArg arg) {
return new VisorCachesLoadJob(arg, debug);
}
/** Job that load caches. */
private static class VisorCachesLoadJob extends
- VisorJob<GridTuple3<Set<String>, Long, Object[]>, Map<String, Integer>> {
+ VisorJob<VisorCacheLoadTaskArg, Map<String, Integer>> {
/** */
private static final long serialVersionUID = 0L;
@@ -56,18 +55,17 @@ public class VisorCacheLoadTask extends
* @param arg Cache names, ttl and loader arguments.
* @param debug Debug flag.
*/
- private VisorCachesLoadJob(GridTuple3<Set<String>, Long, Object[]> arg, boolean debug) {
+ private VisorCachesLoadJob(VisorCacheLoadTaskArg arg, boolean debug) {
super(arg, debug);
}
/** {@inheritDoc} */
- @Override protected Map<String, Integer> run(GridTuple3<Set<String>, Long, Object[]> arg) {
- Set<String> cacheNames = arg.get1();
- Long ttl = arg.get2();
- Object[] ldrArgs = arg.get3();
+ @Override protected Map<String, Integer> run(VisorCacheLoadTaskArg arg) {
+ Set<String> cacheNames = arg.getCacheNames();
+ long ttl = arg.getTtl();
+ Object[] ldrArgs = arg.getLdrArgs();
assert cacheNames != null && !cacheNames.isEmpty();
- assert ttl != null;
Map<String, Integer> res = U.newHashMap(cacheNames.size());
@@ -96,4 +94,4 @@ public class VisorCacheLoadTask extends
return S.toString(VisorCachesLoadJob.class, this);
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLoadTaskArg.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLoadTaskArg.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLoadTaskArg.java
new file mode 100644
index 0000000..831446a
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheLoadTaskArg.java
@@ -0,0 +1,101 @@
+/*
+ * 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 java.util.Set;
+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;
+
+/**
+ * Argument for task returns cache load results.
+ */
+public class VisorCacheLoadTaskArg extends VisorDataTransferObject {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Cache names to load data. */
+ private Set<String> cacheNames;
+
+ /** Duration a Cache Entry should exist be before it expires after being modified. */
+ private long ttl;
+
+ /** Optional user arguments to be passed into CacheStore.loadCache(IgniteBiInClosure, Object...) method. */
+ private Object[] ldrArgs;
+
+ /**
+ * Default constructor.
+ */
+ public VisorCacheLoadTaskArg() {
+ // No-op.
+ }
+
+ /**
+ * @param cacheNames Cache names to load data.
+ * @param ttl Duration a Cache Entry should exist be before it expires after being modified.
+ * @param ldrArgs Optional user arguments to be passed into CacheStore.loadCache(IgniteBiInClosure, Object...) method.
+ */
+ public VisorCacheLoadTaskArg(Set<String> cacheNames, long ttl, Object[] ldrArgs) {
+ this.cacheNames = cacheNames;
+ this.ttl = ttl;
+ this.ldrArgs = ldrArgs;
+ }
+
+ /**
+ * @return Cache names to load data.
+ */
+ public Set<String> getCacheNames() {
+ return cacheNames;
+ }
+
+ /**
+ * @return Duration a Cache Entry should exist be before it expires after being modified.
+ */
+ public long getTtl() {
+ return ttl;
+ }
+
+ /**
+ * @return Optional user arguments to be passed into CacheStore.loadCache(IgniteBiInClosure, Object...) method.
+ */
+ public Object[] getLdrArgs() {
+ return ldrArgs;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void writeExternalData(ObjectOutput out) throws IOException {
+ U.writeCollection(out, cacheNames);
+ out.writeLong(ttl);
+ U.writeArray(out, ldrArgs);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException {
+ cacheNames = U.readSet(in);
+ ttl = in.readLong();
+ ldrArgs = U.readArray(in);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(VisorCacheLoadTaskArg.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/12dfe9e8/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetadataTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetadataTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetadataTask.java
index 6ba783c..598c8cf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetadataTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetadataTask.java
@@ -34,7 +34,7 @@ import static org.apache.ignite.internal.visor.util.VisorTaskUtils.escapeName;
* Task to get cache SQL metadata.
*/
@GridInternal
-public class VisorCacheMetadataTask extends VisorOneNodeTask<String, GridCacheSqlMetadata> {
+public class VisorCacheMetadataTask extends VisorOneNodeTask<String, VisorCacheSqlMetadata> {
/** */
private static final long serialVersionUID = 0L;
@@ -46,7 +46,7 @@ public class VisorCacheMetadataTask extends VisorOneNodeTask<String, GridCacheSq
/**
* Job to get cache SQL metadata.
*/
- private static class VisorCacheMetadataJob extends VisorJob<String, GridCacheSqlMetadata> {
+ private static class VisorCacheMetadataJob extends VisorJob<String, VisorCacheSqlMetadata> {
/** */
private static final long serialVersionUID = 0L;
@@ -59,12 +59,18 @@ public class VisorCacheMetadataTask extends VisorOneNodeTask<String, GridCacheSq
}
/** {@inheritDoc} */
- @Override protected GridCacheSqlMetadata run(String cacheName) {
+ @Override protected VisorCacheSqlMetadata run(String cacheName) {
try {
IgniteInternalCache<Object, Object> cache = ignite.cachex(cacheName);
- if (cache != null)
- return F.first(cache.context().queries().sqlMetadata());
+ if (cache != null) {
+ GridCacheSqlMetadata meta = F.first(cache.context().queries().sqlMetadata());
+
+ if (meta != null)
+ return new VisorCacheSqlMetadata(meta);
+
+ return null;
+ }
throw new IgniteException("Cache not found: " + escapeName(cacheName));
}
@@ -78,4 +84,4 @@ public class VisorCacheMetadataTask extends VisorOneNodeTask<String, GridCacheSq
return S.toString(VisorCacheMetadataJob.class, this);
}
}
-}
\ No newline at end of file
+}