luchnikovbsk commented on code in PR #10508:
URL: https://github.com/apache/ignite/pull/10508#discussion_r1118620641
##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IoDatastorageMetricsTest.java:
##########
@@ -0,0 +1,123 @@
+package org.apache.ignite.internal.processors.cache;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.stream.Collectors;
+import javax.management.DynamicMBean;
+import org.apache.ignite.cluster.ClusterState;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.WALMode;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.spi.metric.jmx.JmxMetricExporterSpi;
+import org.apache.ignite.spi.metric.log.LogExporterSpi;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static
org.apache.ignite.configuration.DataStorageConfiguration.DFLT_WAL_PATH;
+import static org.junit.Assert.assertNotEquals;
+
+/**
+ *
+ * The test shows that the WalWritingRate metric is not calculated when
walMode is in (LOG_ONLY, BACKGROUND).
+ * After the tests are completed, you can see the report with grep by ">>>
REPORT"
+ */
+@RunWith(Parameterized.class)
+public class IoDatastorageMetricsTest extends GridCommonAbstractTest {
+ @Parameterized.Parameter
+ public WALMode walMode;
+
+ @Parameterized.Parameters(name = "walMode={0}")
+ public static Collection<Object[]> parameters() {
+ return Arrays.asList(
+ new Object[] {WALMode.FSYNC},
+ new Object[] {WALMode.BACKGROUND},
+ new Object[] {WALMode.LOG_ONLY}
+ );
+ }
+
+ private static final long MULTIPLICATOR = U.MB;
+ private static final int MAX_SEGMENTS = 20;
+
+ private static final Map<String, List<Long>> report = new HashMap<>();
+
+ @Override protected void beforeTest() throws Exception {
+ super.beforeTest();
+
+ stopAllGrids();
+ cleanPersistenceDir();
+ }
+
+ @Override protected void afterTestsStopped() throws Exception {
+ super.afterTestsStopped();
+
+ log().warning(">>> REPORT: " + report.toString());
+ }
+
+ @Override protected IgniteConfiguration getConfiguration(String
igniteInstanceName) throws Exception {
+ //for debug
+ LogExporterSpi exporterSpi = new LogExporterSpi();
+ exporterSpi.setPeriod(1000);
+ exporterSpi.setExportFilter(mgrp ->
mgrp.name().startsWith("io.datastorage"));
+
+ return super.getConfiguration(igniteInstanceName)
+ .setMetricExporterSpi(exporterSpi, new JmxMetricExporterSpi())
+ .setCacheConfiguration(new
CacheConfiguration<>(DEFAULT_CACHE_NAME))
+ .setDataStorageConfiguration(
+ new DataStorageConfiguration()
+ .setMetricsEnabled(true)
+ .setWalArchivePath(DFLT_WAL_PATH)
+ .setWalSegments(10)
+ .setWalSegmentSize((int)(1 * MULTIPLICATOR))
+ .setMaxWalArchiveSize(20 * MULTIPLICATOR)
Review Comment:
done
##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IoDatastorageMetricsTest.java:
##########
@@ -0,0 +1,168 @@
+/*
+ * 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.processors.cache;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.stream.Collectors;
+import javax.management.DynamicMBean;
+import org.apache.ignite.cluster.ClusterState;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.WALMode;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.spi.metric.jmx.JmxMetricExporterSpi;
+import org.apache.ignite.spi.metric.log.LogExporterSpi;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static
org.apache.ignite.configuration.DataStorageConfiguration.DFLT_WAL_PATH;
+import static org.junit.Assert.assertNotEquals;
+
+/**
+ * The test shows that the WalWritingRate metric is not calculated when
walMode is in (LOG_ONLY, BACKGROUND).
+ * After the tests are completed, you can see the report with grep by ">>>
REPORT"
+ */
+@RunWith(Parameterized.class)
+public class IoDatastorageMetricsTest extends GridCommonAbstractTest {
+
+ /**
+ * WALMode.
+ */
+ @Parameterized.Parameter
+ public WALMode walMode;
+
+ /**
+ * WALMode values.
+ */
+ @Parameterized.Parameters(name = "walMode={0}")
+ public static Collection<Object[]> parameters() {
+ return Arrays.asList(
+ new Object[] {WALMode.FSYNC},
+ new Object[] {WALMode.BACKGROUND},
+ new Object[] {WALMode.LOG_ONLY}
+ );
+ }
+
+ /**
+ * MULTIPLICATOR.
+ */
+ private static final long MULTIPLICATOR = U.MB;
+
+ /**
+ * Тumber of segments.
+ */
+ private static final int MAX_SEGMENTS = 20;
+
+ /**
+ * Small report for debug.
+ */
+ private static final Map<String, List<Long>> report = new HashMap<>();
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override protected void beforeTest() throws Exception {
+ super.beforeTest();
+
+ stopAllGrids();
+ cleanPersistenceDir();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override protected void afterTestsStopped() throws Exception {
+ super.afterTestsStopped();
+
+ log().warning(">>> REPORT: " + report.toString());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override protected IgniteConfiguration getConfiguration(String
igniteInstanceName) throws Exception {
+ //for debug
+ LogExporterSpi exporterSpi = new LogExporterSpi();
+ exporterSpi.setPeriod(1000);
+ exporterSpi.setExportFilter(mgrp ->
mgrp.name().startsWith("io.datastorage"));
+
+ return super.getConfiguration(igniteInstanceName)
+ .setMetricExporterSpi(exporterSpi, new JmxMetricExporterSpi())
+ .setCacheConfiguration(new
CacheConfiguration<>(DEFAULT_CACHE_NAME))
+ .setDataStorageConfiguration(
+ new DataStorageConfiguration()
+ .setMetricsEnabled(true)
+ .setWalArchivePath(DFLT_WAL_PATH)
+ .setWalSegments(10)
+ .setWalSegmentSize((int)(1 * MULTIPLICATOR))
+ .setMaxWalArchiveSize(20 * MULTIPLICATOR)
+ .setWalMode(walMode)
+ .setDefaultDataRegionConfiguration(
+ new DataRegionConfiguration()
+ .setPersistenceEnabled(true)
+ .setMaxSize(20 * MULTIPLICATOR)
+ .setCheckpointPageBufferSize(2 * MULTIPLICATOR)
+ )
+ );
+ }
+
+ /**
+ * The test shows that the WalWritingRate metric is not calculated when
walMode is in (LOG_ONLY, BACKGROUND).
+ * After the tests are completed, you can see the report with grep by ">>>
REPORT"
+ */
+ @Test
+ public void WalWritingRate() throws Exception {
+ IgniteEx ignite = startGrid(0);
+ ignite.cluster().state(ClusterState.ACTIVE);
+
+ AtomicLong key = new AtomicLong();
+ List<Long> walWritingRates = new ArrayList<>();
+
+ long lastSegment = walMgr(ignite).currentSegment() + MAX_SEGMENTS;
+ long prewSegment = walMgr(ignite).currentSegment();
Review Comment:
done 0_o
##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IoDatastorageMetricsTest.java:
##########
@@ -0,0 +1,168 @@
+/*
+ * 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.processors.cache;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.stream.Collectors;
+import javax.management.DynamicMBean;
+import org.apache.ignite.cluster.ClusterState;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.WALMode;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.spi.metric.jmx.JmxMetricExporterSpi;
+import org.apache.ignite.spi.metric.log.LogExporterSpi;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static
org.apache.ignite.configuration.DataStorageConfiguration.DFLT_WAL_PATH;
+import static org.junit.Assert.assertNotEquals;
+
+/**
+ * The test shows that the WalWritingRate metric is not calculated when
walMode is in (LOG_ONLY, BACKGROUND).
+ * After the tests are completed, you can see the report with grep by ">>>
REPORT"
+ */
+@RunWith(Parameterized.class)
+public class IoDatastorageMetricsTest extends GridCommonAbstractTest {
+
+ /**
+ * WALMode.
+ */
+ @Parameterized.Parameter
+ public WALMode walMode;
+
+ /**
+ * WALMode values.
+ */
+ @Parameterized.Parameters(name = "walMode={0}")
+ public static Collection<Object[]> parameters() {
+ return Arrays.asList(
+ new Object[] {WALMode.FSYNC},
+ new Object[] {WALMode.BACKGROUND},
+ new Object[] {WALMode.LOG_ONLY}
+ );
+ }
+
+ /**
+ * MULTIPLICATOR.
+ */
+ private static final long MULTIPLICATOR = U.MB;
+
+ /**
+ * Тumber of segments.
+ */
+ private static final int MAX_SEGMENTS = 20;
+
+ /**
+ * Small report for debug.
+ */
+ private static final Map<String, List<Long>> report = new HashMap<>();
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override protected void beforeTest() throws Exception {
+ super.beforeTest();
+
+ stopAllGrids();
+ cleanPersistenceDir();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override protected void afterTestsStopped() throws Exception {
+ super.afterTestsStopped();
+
+ log().warning(">>> REPORT: " + report.toString());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override protected IgniteConfiguration getConfiguration(String
igniteInstanceName) throws Exception {
+ //for debug
+ LogExporterSpi exporterSpi = new LogExporterSpi();
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]