You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by na...@apache.org on 2021/10/08 13:17:14 UTC
[ignite] branch master updated: IGNITE-15549: Fixed the data
structures system views registration on inactive cluster start (#9430)
This is an automated email from the ASF dual-hosted git repository.
namelchev 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 b939bcf IGNITE-15549: Fixed the data structures system views registration on inactive cluster start (#9430)
b939bcf is described below
commit b939bcf2e5ac07c93d8c22f81410e455c4756e13
Author: Sergei Ryzhov <s....@gmail.com>
AuthorDate: Fri Oct 8 16:16:49 2021 +0300
IGNITE-15549: Fixed the data structures system views registration on inactive cluster start (#9430)
---
.../apache/ignite/util/SystemViewCommandTest.java | 11 +-
.../datastructures/DataStructuresProcessor.java | 166 +++++++++++----------
.../metric/SystemViewClusterActivationTest.java | 111 ++++++++++++++
.../ignite/testsuites/IgniteCacheTestSuite9.java | 2 +
.../cache/metric/SqlViewExporterSpiTest.java | 11 +-
5 files changed, 220 insertions(+), 81 deletions(-)
diff --git a/modules/control-utility/src/test/java/org/apache/ignite/util/SystemViewCommandTest.java b/modules/control-utility/src/test/java/org/apache/ignite/util/SystemViewCommandTest.java
index 49da903..ca5470c 100644
--- a/modules/control-utility/src/test/java/org/apache/ignite/util/SystemViewCommandTest.java
+++ b/modules/control-utility/src/test/java/org/apache/ignite/util/SystemViewCommandTest.java
@@ -448,7 +448,16 @@ public class SystemViewCommandTest extends GridCommandHandlerClusterByClassAbstr
"DISTRIBUTED_METASTORAGE",
"STATISTICS_CONFIGURATION",
"STATISTICS_PARTITION_DATA",
- "STATISTICS_LOCAL_DATA"
+ "STATISTICS_LOCAL_DATA",
+ "DS_ATOMICLONGS",
+ "DS_ATOMICREFERENCES",
+ "DS_ATOMICSTAMPED",
+ "DS_ATOMICSEQUENCES",
+ "DS_COUNTDOWNLATCHES",
+ "DS_REENTRANTLOCKS",
+ "DS_SETS",
+ "DS_SEMAPHORES",
+ "DS_QUEUES"
));
Set<String> viewNames = new HashSet<>();
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
index aae3358..a0b2559 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
@@ -263,88 +263,13 @@ public final class DataStructuresProcessor extends GridProcessorAdapter implemen
/** {@inheritDoc} */
@Override public void onKernalStart(boolean active) {
- if (ctx.config().isDaemon() || !active)
+ if (ctx.config().isDaemon())
return;
- ctx.systemView().registerView(
- SEQUENCES_VIEW,
- SEQUENCES_VIEW_DESC,
- new AtomicSequenceViewWalker(),
- new PredicateCollectionView<>(dsMap.values(), v -> v instanceof IgniteAtomicSequence),
- AtomicSequenceView::new
- );
-
- ctx.systemView().registerView(
- LONGS_VIEW,
- LONGS_VIEW_DESC,
- new AtomicLongViewWalker(),
- new PredicateCollectionView<>(dsMap.values(), v -> v instanceof IgniteAtomicLong),
- AtomicLongView::new
- );
-
- ctx.systemView().registerView(
- REFERENCES_VIEW,
- REFERENCES_VIEW_DESC,
- new AtomicReferenceViewWalker(),
- new PredicateCollectionView<>(dsMap.values(), v -> v instanceof IgniteAtomicReference),
- AtomicReferenceView::new
- );
-
- ctx.systemView().registerView(
- STAMPED_VIEW,
- STAMPED_VIEW_DESC,
- new AtomicStampedViewWalker(),
- new PredicateCollectionView<>(dsMap.values(), v -> v instanceof IgniteAtomicStamped),
- AtomicStampedView::new
- );
-
- ctx.systemView().registerView(
- LATCHES_VIEW,
- LATCHES_VIEW_DESC,
- new CountDownLatchViewWalker(),
- new PredicateCollectionView<>(dsMap.values(), v -> v instanceof IgniteCountDownLatch),
- CountDownLatchView::new
- );
-
- ctx.systemView().registerView(
- SEMAPHORES_VIEW,
- SEMAPHORES_VIEW_DESC,
- new SemaphoreViewWalker(),
- new PredicateCollectionView<>(dsMap.values(), v -> v instanceof IgniteSemaphore),
- SemaphoreView::new
- );
-
- ctx.systemView().registerView(
- LOCKS_VIEW,
- LOCKS_VIEW_DESC,
- new ReentrantLockViewWalker(),
- new PredicateCollectionView<>(dsMap.values(), v -> v instanceof IgniteLock),
- ReentrantLockView::new
- );
-
- ctx.systemView().registerInnerCollectionView(
- QUEUES_VIEW,
- QUEUES_VIEW_DESC,
- new QueueViewWalker(),
- new TransformCollectionView<>(
- ctx.cache().cacheDescriptors().values(),
- desc -> ctx.cache().cache(desc.cacheName()).context().dataStructures(),
- desc -> desc.cacheType() == CacheType.DATA_STRUCTURES),
- cctx -> cctx.queues().values(),
- (cctx, queue) -> new QueueView(queue)
- );
+ registerSystemViews();
- ctx.systemView().registerInnerCollectionView(
- SETS_VIEW,
- SETS_VIEW_DESC,
- new SetViewWalker(),
- F.viewReadOnly(
- ctx.cache().cacheDescriptors().values(),
- desc -> ctx.cache().cache(desc.cacheName()).context().dataStructures(),
- desc -> desc.cacheType() == CacheType.DATA_STRUCTURES),
- cctx -> cctx.sets().values(),
- (cctx, set) -> new SetView(set)
- );
+ if (!active)
+ return;
onKernalStart0();
}
@@ -440,6 +365,89 @@ public final class DataStructuresProcessor extends GridProcessorAdapter implemen
onKernalStart0();
}
+ /** Register system views. */
+ private void registerSystemViews() {
+ ctx.systemView().registerView(
+ SEQUENCES_VIEW,
+ SEQUENCES_VIEW_DESC,
+ new AtomicSequenceViewWalker(),
+ new PredicateCollectionView<>(dsMap.values(), v -> v instanceof IgniteAtomicSequence),
+ AtomicSequenceView::new
+ );
+
+ ctx.systemView().registerView(
+ LONGS_VIEW,
+ LONGS_VIEW_DESC,
+ new AtomicLongViewWalker(),
+ new PredicateCollectionView<>(dsMap.values(), v -> v instanceof IgniteAtomicLong),
+ AtomicLongView::new
+ );
+
+ ctx.systemView().registerView(
+ REFERENCES_VIEW,
+ REFERENCES_VIEW_DESC,
+ new AtomicReferenceViewWalker(),
+ new PredicateCollectionView<>(dsMap.values(), v -> v instanceof IgniteAtomicReference),
+ AtomicReferenceView::new
+ );
+
+ ctx.systemView().registerView(
+ STAMPED_VIEW,
+ STAMPED_VIEW_DESC,
+ new AtomicStampedViewWalker(),
+ new PredicateCollectionView<>(dsMap.values(), v -> v instanceof IgniteAtomicStamped),
+ AtomicStampedView::new
+ );
+
+ ctx.systemView().registerView(
+ LATCHES_VIEW,
+ LATCHES_VIEW_DESC,
+ new CountDownLatchViewWalker(),
+ new PredicateCollectionView<>(dsMap.values(), v -> v instanceof IgniteCountDownLatch),
+ CountDownLatchView::new
+ );
+
+ ctx.systemView().registerView(
+ SEMAPHORES_VIEW,
+ SEMAPHORES_VIEW_DESC,
+ new SemaphoreViewWalker(),
+ new PredicateCollectionView<>(dsMap.values(), v -> v instanceof IgniteSemaphore),
+ SemaphoreView::new
+ );
+
+ ctx.systemView().registerView(
+ LOCKS_VIEW,
+ LOCKS_VIEW_DESC,
+ new ReentrantLockViewWalker(),
+ new PredicateCollectionView<>(dsMap.values(), v -> v instanceof IgniteLock),
+ ReentrantLockView::new
+ );
+
+ ctx.systemView().registerInnerCollectionView(
+ QUEUES_VIEW,
+ QUEUES_VIEW_DESC,
+ new QueueViewWalker(),
+ new TransformCollectionView<>(
+ ctx.cache().cacheDescriptors().values(),
+ desc -> ctx.cache().cache(desc.cacheName()).context().dataStructures(),
+ desc -> desc.cacheType() == CacheType.DATA_STRUCTURES),
+ cctx -> cctx.queues().values(),
+ (cctx, queue) -> new QueueView(queue)
+ );
+
+ ctx.systemView().registerInnerCollectionView(
+ SETS_VIEW,
+ SETS_VIEW_DESC,
+ new SetViewWalker(),
+ F.viewReadOnly(
+ ctx.cache().cacheDescriptors().values(),
+ desc -> ctx.cache().cache(desc.cacheName()).context().dataStructures(),
+ desc -> desc.cacheType() == CacheType.DATA_STRUCTURES),
+ cctx -> cctx.sets().values(),
+ (cctx, set) -> new SetView(set)
+ );
+ }
+
/**
* @param ctx Context.
*/
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/metric/SystemViewClusterActivationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/metric/SystemViewClusterActivationTest.java
new file mode 100644
index 0000000..30a559d
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/metric/SystemViewClusterActivationTest.java
@@ -0,0 +1,111 @@
+/*
+ * 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.metric;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
+import org.apache.ignite.cluster.ClusterState;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.spi.systemview.view.SystemView;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+import static org.apache.ignite.internal.managers.discovery.GridDiscoveryManager.NODES_SYS_VIEW;
+import static org.apache.ignite.internal.managers.discovery.GridDiscoveryManager.NODE_ATTRIBUTES_SYS_VIEW;
+import static org.apache.ignite.internal.managers.discovery.GridDiscoveryManager.NODE_METRICS_SYS_VIEW;
+import static org.apache.ignite.internal.managers.systemview.ScanQuerySystemView.SCAN_QRY_SYS_VIEW;
+import static org.apache.ignite.internal.processors.cache.ClusterCachesInfo.CACHES_VIEW;
+import static org.apache.ignite.internal.processors.cache.ClusterCachesInfo.CACHE_GRPS_VIEW;
+import static org.apache.ignite.internal.processors.cache.GridCacheProcessor.CACHE_GRP_IO_VIEW;
+import static org.apache.ignite.internal.processors.cache.GridCacheProcessor.CACHE_GRP_PAGE_LIST_VIEW;
+import static org.apache.ignite.internal.processors.cache.GridCacheProcessor.PART_STATES_VIEW;
+import static org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.BINARY_METADATA_VIEW;
+import static org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager.DATA_REGION_PAGE_LIST_VIEW;
+import static org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager.TXS_MON_LIST;
+import static org.apache.ignite.internal.processors.cluster.GridClusterStateProcessor.BASELINE_NODES_SYS_VIEW;
+import static org.apache.ignite.internal.processors.cluster.GridClusterStateProcessor.BASELINE_NODE_ATTRIBUTES_SYS_VIEW;
+import static org.apache.ignite.internal.processors.continuous.GridContinuousProcessor.CQ_SYS_VIEW;
+import static org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.LATCHES_VIEW;
+import static org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.LOCKS_VIEW;
+import static org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.LONGS_VIEW;
+import static org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.QUEUES_VIEW;
+import static org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.REFERENCES_VIEW;
+import static org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.SEMAPHORES_VIEW;
+import static org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.SEQUENCES_VIEW;
+import static org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.SETS_VIEW;
+import static org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.STAMPED_VIEW;
+import static org.apache.ignite.internal.processors.job.GridJobProcessor.JOBS_VIEW;
+import static org.apache.ignite.internal.processors.metastorage.persistence.DistributedMetaStorageImpl.DISTRIBUTED_METASTORE_VIEW;
+import static org.apache.ignite.internal.processors.odbc.ClientListenerProcessor.CLI_CONN_VIEW;
+import static org.apache.ignite.internal.processors.pool.PoolProcessor.STREAM_POOL_QUEUE_VIEW;
+import static org.apache.ignite.internal.processors.pool.PoolProcessor.SYS_POOL_QUEUE_VIEW;
+import static org.apache.ignite.internal.processors.service.IgniteServiceProcessor.SVCS_VIEW;
+import static org.apache.ignite.internal.processors.task.GridTaskProcessor.TASKS_VIEW;
+
+/** Tests for {@link SystemView}. */
+public class SystemViewClusterActivationTest extends GridCommonAbstractTest {
+ /** @throws Exception If failed. */
+ @Test
+ public void testStartInactiveCluster() throws Exception {
+ Set<String> expViews = new HashSet<>(Arrays.asList(
+ BASELINE_NODE_ATTRIBUTES_SYS_VIEW,
+ BASELINE_NODES_SYS_VIEW,
+ BINARY_METADATA_VIEW,
+ CACHE_GRP_PAGE_LIST_VIEW,
+ CACHE_GRPS_VIEW,
+ CACHES_VIEW,
+ CLI_CONN_VIEW,
+ CQ_SYS_VIEW,
+ DATA_REGION_PAGE_LIST_VIEW,
+ STREAM_POOL_QUEUE_VIEW,
+ DISTRIBUTED_METASTORE_VIEW,
+ JOBS_VIEW,
+ CACHE_GRP_IO_VIEW,
+ NODE_ATTRIBUTES_SYS_VIEW,
+ NODE_METRICS_SYS_VIEW,
+ NODES_SYS_VIEW,
+ PART_STATES_VIEW,
+ SCAN_QRY_SYS_VIEW,
+ SVCS_VIEW,
+ SYS_POOL_QUEUE_VIEW,
+ TASKS_VIEW,
+ TXS_MON_LIST,
+ QUEUES_VIEW,
+ SETS_VIEW,
+ LOCKS_VIEW,
+ SEMAPHORES_VIEW,
+ LATCHES_VIEW,
+ STAMPED_VIEW,
+ REFERENCES_VIEW,
+ LONGS_VIEW,
+ SEQUENCES_VIEW
+ ));
+
+ IgniteEx ignite = startGrid(getConfiguration().setClusterStateOnStart(ClusterState.INACTIVE));
+
+ ignite.cluster().state(ClusterState.ACTIVE);
+
+ Set<String> views = StreamSupport.stream(ignite.context().systemView().spliterator(), false)
+ .map(SystemView::name).collect(Collectors.toSet());
+
+ assertTrue(views.containsAll(expViews));
+ }
+}
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite9.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite9.java
index 87c77a8..a15885a 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite9.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite9.java
@@ -31,6 +31,7 @@ import org.apache.ignite.internal.metric.MetricsConfigurationTest;
import org.apache.ignite.internal.metric.MetricsSelfTest;
import org.apache.ignite.internal.metric.ReadMetricsOnNodeStartupTest;
import org.apache.ignite.internal.metric.SystemMetricsTest;
+import org.apache.ignite.internal.metric.SystemViewClusterActivationTest;
import org.apache.ignite.internal.metric.SystemViewComputeJobTest;
import org.apache.ignite.internal.metric.SystemViewSelfTest;
import org.apache.ignite.internal.processors.cache.CachePutIfAbsentTest;
@@ -127,6 +128,7 @@ public class IgniteCacheTestSuite9 {
GridTestUtils.addTestIfNeeded(suite, SystemMetricsTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, MetricsConfigurationTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, SystemViewSelfTest.class, ignoredTests);
+ GridTestUtils.addTestIfNeeded(suite, SystemViewClusterActivationTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, SystemViewComputeJobTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, CacheMetricsAddRemoveTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, JmxExporterSpiTest.class, ignoredTests);
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/metric/SqlViewExporterSpiTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/metric/SqlViewExporterSpiTest.java
index 5d38b01..09ada17 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/metric/SqlViewExporterSpiTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/metric/SqlViewExporterSpiTest.java
@@ -433,7 +433,16 @@ public class SqlViewExporterSpiTest extends AbstractExporterSpiTest {
"DISTRIBUTED_METASTORAGE",
"STATISTICS_CONFIGURATION",
"STATISTICS_PARTITION_DATA",
- "STATISTICS_LOCAL_DATA"
+ "STATISTICS_LOCAL_DATA",
+ "DS_ATOMICLONGS",
+ "DS_ATOMICREFERENCES",
+ "DS_ATOMICSTAMPED",
+ "DS_ATOMICSEQUENCES",
+ "DS_COUNTDOWNLATCHES",
+ "DS_REENTRANTLOCKS",
+ "DS_SETS",
+ "DS_SEMAPHORES",
+ "DS_QUEUES"
));
Set<String> actViews = new HashSet<>();