This is an automated email from the ASF dual-hosted git repository.
agoncharuk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new d3fc970 IGNITE-13100 Fix exceptions raised when cache group metrics
are read on client node - Fixes #7875.
d3fc970 is described below
commit d3fc970cc96b6665303433c2ff3eacb58fb0ed51
Author: Alexey Goncharuk <[email protected]>
AuthorDate: Tue Jun 2 16:38:24 2020 +0300
IGNITE-13100 Fix exceptions raised when cache group metrics are read on
client node - Fixes #7875.
Signed-off-by: Alexey Goncharuk <[email protected]>
---
.../processors/cache/CacheGroupMetricsImpl.java | 10 +++-
.../processors/cache/CacheGroupMetricsTest.java | 68 +++++++++++++++++++++-
2 files changed, 74 insertions(+), 4 deletions(-)
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsImpl.java
index cde838b..15a989d 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsImpl.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsImpl.java
@@ -92,7 +92,7 @@ public class CacheGroupMetricsImpl {
DataStorageConfiguration dsCfg =
ctx.shared().kernalContext().config().getDataStorageConfiguration();
- boolean persistentEnabled = CU.isPersistentCache(cacheCfg, dsCfg);
+ boolean persistentEnabled = !ctx.shared().kernalContext().clientNode()
&& CU.isPersistentCache(cacheCfg, dsCfg);
MetricRegistry mreg =
ctx.shared().kernalContext().metric().registry(metricGroupName());
@@ -464,12 +464,16 @@ public class CacheGroupMetricsImpl {
/** */
public long getTotalAllocatedPages() {
- return grpPageAllocationTracker.value();
+ return ctx.shared().kernalContext().clientNode() ?
+ 0 :
+ grpPageAllocationTracker.value();
}
/** */
public long getTotalAllocatedSize() {
- return getTotalAllocatedPages() *
ctx.dataRegion().pageMemory().pageSize();
+ return ctx.shared().kernalContext().clientNode() ?
+ 0 :
+ getTotalAllocatedPages() *
ctx.dataRegion().pageMemory().pageSize();
}
/** */
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsTest.java
index e403843..8270d91 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupMetricsTest.java
@@ -26,13 +26,17 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.Consumer;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.IgniteException;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.affinity.AffinityFunction;
import org.apache.ignite.cache.affinity.AffinityFunctionContext;
import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.cluster.ClusterState;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.DataRegionConfiguration;
import org.apache.ignite.configuration.DataStorageConfiguration;
@@ -50,8 +54,10 @@ import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.mxbean.CacheGroupMetricsMXBean;
import org.apache.ignite.spi.metric.IntMetric;
import org.apache.ignite.spi.metric.LongMetric;
+import org.apache.ignite.spi.metric.Metric;
import org.apache.ignite.spi.metric.ObjectMetric;
import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.ListeningTestLogger;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
@@ -64,7 +70,10 @@ import static
org.apache.ignite.internal.processors.metric.impl.MetricUtils.metr
*/
public class CacheGroupMetricsTest extends GridCommonAbstractTest implements
Serializable {
/** */
- protected boolean pds = false;
+ protected boolean pds;
+
+ /** */
+ private final ListeningTestLogger testLog = new ListeningTestLogger(log);
/** */
private static class RoundRobinVariableSizeAffinityFunction implements
AffinityFunction {
@@ -160,6 +169,8 @@ public class CacheGroupMetricsTest extends
GridCommonAbstractTest implements Ser
cfg.setCacheConfiguration(cCfg1, cCfg2, cCfg3, cCfg4);
+ cfg.setGridLogger(testLog);
+
if (pds) {
cfg.setDataStorageConfiguration(new DataStorageConfiguration()
.setDefaultDataRegionConfiguration(new
DataRegionConfiguration()
@@ -404,6 +415,61 @@ public class CacheGroupMetricsTest extends
GridCommonAbstractTest implements Ser
}
/**
+ * @throws Exception if failed.
+ */
+ @Test
+ public void testClientNodePds() throws Exception {
+ checkClientNode(true);
+ }
+
+ /**
+ * @throws Exception if failed.
+ */
+ @Test
+ public void testClientNodeNoPds() throws Exception {
+ checkClientNode(false);
+ }
+
+ /**
+ * @throws Exception if failed.
+ */
+ public void checkClientNode(boolean pds) throws Exception {
+ this.pds = pds;
+
+ startGrid(0);
+
+ IgniteEx client = startClientGrid(1);
+
+ if (pds)
+ client.cluster().state(ClusterState.ACTIVE);
+
+ AtomicReference<Exception> err = new AtomicReference<>();
+
+ Consumer<String> lsnr = new Consumer<String>() {
+ @Override public void accept(String s) {
+ if (s.contains("Exception"))
+ err.set(new IgniteException("Error was logged: " + s));
+ }
+ };
+
+ testLog.registerListener(lsnr);
+
+ String[] names = new String[] {"group1", "group2", "cache4"};
+
+ for (String name : names) {
+ T2<CacheGroupMetricsMXBean, MetricRegistry> grp1 =
cacheGroupMetrics(1, name);
+
+ for (Metric metric : grp1.get2())
+ metric.getAsString();
+ }
+
+ testLog.unregisterListener(lsnr);
+
+ if (err.get() != null)
+ throw err.get();
+ }
+
+ /**
* Verifies metric for initialized local partitions.
* It is incremented when partition is actually created on node and
decremented when it is destroyed.
*