From ecdbbc1f90b7a693814ec00f972545ef14ae9637 Mon Sep 17 00:00:00 2001 From: Ivan Zlenko <241953+ivanzlenko@users.noreply.github.com> Date: Mon, 11 Mar 2024 17:44:58 +0500 Subject: [PATCH 1/6] HDDS-10503. Upgrade jgrapht dependency. --- .../ozone/graph/TestPrintableGraph.java | 75 +++++++++++++++++++ pom.xml | 2 +- 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 hadoop-hdds/rocksdb-checkpoint-differ/src/test/java/org/apache/ozone/graph/TestPrintableGraph.java diff --git a/hadoop-hdds/rocksdb-checkpoint-differ/src/test/java/org/apache/ozone/graph/TestPrintableGraph.java b/hadoop-hdds/rocksdb-checkpoint-differ/src/test/java/org/apache/ozone/graph/TestPrintableGraph.java new file mode 100644 index 000000000000..2911be5319eb --- /dev/null +++ b/hadoop-hdds/rocksdb-checkpoint-differ/src/test/java/org/apache/ozone/graph/TestPrintableGraph.java @@ -0,0 +1,75 @@ +package org.apache.ozone.graph; + +import com.google.common.graph.MutableGraph; +import org.apache.ozone.rocksdiff.CompactionNode; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.io.TempDir; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.when; + +/** + * This class is used for testing the PrintableGraph class. + * It contains methods to test the generation and printing of graphs with different types. + */ +@ExtendWith(MockitoExtension.class) +public class TestPrintableGraph { + @TempDir + private Path dir; + + @Mock + private MutableGraph mutableGraph; + + private static Stream graphTypes() { + return Stream.of( + Arguments.of(PrintableGraph.GraphType.KEY_SIZE), + Arguments.of(PrintableGraph.GraphType.CUMULATIVE_SIZE), + Arguments.of(PrintableGraph.GraphType.FILE_NAME) + ); + } + + @ParameterizedTest + @MethodSource("graphTypes") + void testPrintNoGraphMessage(PrintableGraph.GraphType graphType) { + PrintableGraph graph = new PrintableGraph(mutableGraph, graphType); + try { + graph.generateImage(dir.resolve(graphType.name()).toString()); + } catch (IOException e) { + assertEquals("Graph is empty.", e.getMessage()); + } + } + + @ParameterizedTest + @MethodSource("graphTypes") + void testPrintActualGraph(PrintableGraph.GraphType graphType) throws IOException { + Set nodes = Stream.of( + new CompactionNode("fileName1", + 100, 100, "startKey1", "endKey1", "columnFamily1"), + new CompactionNode("fileName2", + 200, 200, "startKey2", "endKey2", null), + new CompactionNode("fileName3", + 300, 300, null, "endKey3", "columnFamily3"), + new CompactionNode("fileName4", + 400, 400, "startKey4", null, "columnFamily4") + ).collect(Collectors.toSet()); + when(mutableGraph.nodes()).thenReturn(nodes); + + PrintableGraph graph = new PrintableGraph(mutableGraph, graphType); + graph.generateImage(dir.resolve(graphType.name()).toString()); + + assertTrue(Files.exists(dir.resolve(graphType.name())), "Graph hasn't been generated"); + } +} diff --git a/pom.xml b/pom.xml index d97b31046bca..86ce4bcb74aa 100644 --- a/pom.xml +++ b/pom.xml @@ -295,7 +295,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs 1.9.7 1.14.0 2.5.0 - 1.0.1 + 1.5.2 5.3.27 3.11.10 From a26ee395f35b8f6a36e8375cfe2b85c0382ae0e2 Mon Sep 17 00:00:00 2001 From: Ivan Zlenko <241953+ivanzlenko@users.noreply.github.com> Date: Mon, 11 Mar 2024 18:29:12 +0500 Subject: [PATCH 2/6] HDDS-10503. Fix license text. --- .../apache/ozone/graph/TestPrintableGraph.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/hadoop-hdds/rocksdb-checkpoint-differ/src/test/java/org/apache/ozone/graph/TestPrintableGraph.java b/hadoop-hdds/rocksdb-checkpoint-differ/src/test/java/org/apache/ozone/graph/TestPrintableGraph.java index 2911be5319eb..b0ccff8cd273 100644 --- a/hadoop-hdds/rocksdb-checkpoint-differ/src/test/java/org/apache/ozone/graph/TestPrintableGraph.java +++ b/hadoop-hdds/rocksdb-checkpoint-differ/src/test/java/org/apache/ozone/graph/TestPrintableGraph.java @@ -1,3 +1,21 @@ +/* + * 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.ozone.graph; import com.google.common.graph.MutableGraph; From 5a566810fc9faeb738308d53ac06c6b1c6da7715 Mon Sep 17 00:00:00 2001 From: Ivan Zlenko <241953+ivanzlenko@users.noreply.github.com> Date: Mon, 11 Mar 2024 18:43:32 +0500 Subject: [PATCH 3/6] HDDS-10503. Use @EnumSource instead of @MethodSource --- .../org/apache/ozone/graph/TestPrintableGraph.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/hadoop-hdds/rocksdb-checkpoint-differ/src/test/java/org/apache/ozone/graph/TestPrintableGraph.java b/hadoop-hdds/rocksdb-checkpoint-differ/src/test/java/org/apache/ozone/graph/TestPrintableGraph.java index b0ccff8cd273..180eabeb8971 100644 --- a/hadoop-hdds/rocksdb-checkpoint-differ/src/test/java/org/apache/ozone/graph/TestPrintableGraph.java +++ b/hadoop-hdds/rocksdb-checkpoint-differ/src/test/java/org/apache/ozone/graph/TestPrintableGraph.java @@ -24,6 +24,7 @@ import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.MethodSource; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; @@ -51,16 +52,8 @@ public class TestPrintableGraph { @Mock private MutableGraph mutableGraph; - private static Stream graphTypes() { - return Stream.of( - Arguments.of(PrintableGraph.GraphType.KEY_SIZE), - Arguments.of(PrintableGraph.GraphType.CUMULATIVE_SIZE), - Arguments.of(PrintableGraph.GraphType.FILE_NAME) - ); - } - @ParameterizedTest - @MethodSource("graphTypes") + @EnumSource(PrintableGraph.GraphType.class) void testPrintNoGraphMessage(PrintableGraph.GraphType graphType) { PrintableGraph graph = new PrintableGraph(mutableGraph, graphType); try { @@ -71,7 +64,7 @@ void testPrintNoGraphMessage(PrintableGraph.GraphType graphType) { } @ParameterizedTest - @MethodSource("graphTypes") + @EnumSource(PrintableGraph.GraphType.class) void testPrintActualGraph(PrintableGraph.GraphType graphType) throws IOException { Set nodes = Stream.of( new CompactionNode("fileName1", From 8f465c148040850b257c3c37ccb13d415b9d2b96 Mon Sep 17 00:00:00 2001 From: Ivan Zlenko <241953+ivanzlenko@users.noreply.github.com> Date: Mon, 11 Mar 2024 18:44:11 +0500 Subject: [PATCH 4/6] HDDS-10503. Remove redundant imports --- .../test/java/org/apache/ozone/graph/TestPrintableGraph.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/hadoop-hdds/rocksdb-checkpoint-differ/src/test/java/org/apache/ozone/graph/TestPrintableGraph.java b/hadoop-hdds/rocksdb-checkpoint-differ/src/test/java/org/apache/ozone/graph/TestPrintableGraph.java index 180eabeb8971..8031eca7b0db 100644 --- a/hadoop-hdds/rocksdb-checkpoint-differ/src/test/java/org/apache/ozone/graph/TestPrintableGraph.java +++ b/hadoop-hdds/rocksdb-checkpoint-differ/src/test/java/org/apache/ozone/graph/TestPrintableGraph.java @@ -23,9 +23,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.EnumSource; -import org.junit.jupiter.params.provider.MethodSource; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; From db3e9e1a7dc1b39579d3c72b01c873bfd9312424 Mon Sep 17 00:00:00 2001 From: Ivan Zlenko <241953+ivanzlenko@users.noreply.github.com> Date: Mon, 11 Mar 2024 18:57:19 +0500 Subject: [PATCH 5/6] HDDS-10503. Downgrade jgrapht version to the latest which supports java 1.8 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 86ce4bcb74aa..ff5f30e04825 100644 --- a/pom.xml +++ b/pom.xml @@ -295,7 +295,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs 1.9.7 1.14.0 2.5.0 - 1.5.2 + 1.4.0 5.3.27 3.11.10 From eb31ad80d1b212da216376981b470766feb23888 Mon Sep 17 00:00:00 2001 From: "Doroszlai, Attila" Date: Mon, 11 Mar 2024 18:23:09 +0100 Subject: [PATCH 6/6] fix dependency --- hadoop-ozone/dist/src/main/license/jar-report.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hadoop-ozone/dist/src/main/license/jar-report.txt b/hadoop-ozone/dist/src/main/license/jar-report.txt index 70fecc866da3..bc73aa6fe3f8 100644 --- a/hadoop-ozone/dist/src/main/license/jar-report.txt +++ b/hadoop-ozone/dist/src/main/license/jar-report.txt @@ -2,7 +2,6 @@ share/ozone/lib/animal-sniffer-annotations.jar share/ozone/lib/annotations.jar share/ozone/lib/annotations.jar share/ozone/lib/aopalliance.jar -share/ozone/lib/antlr4-runtime.jar share/ozone/lib/aopalliance-repackaged.jar share/ozone/lib/aspectjrt.jar share/ozone/lib/aspectjweaver.jar @@ -142,10 +141,10 @@ share/ozone/lib/jetty-util-ajax.jar share/ozone/lib/jetty-util.jar share/ozone/lib/jetty-webapp.jar share/ozone/lib/jetty-xml.jar -share/ozone/lib/jgraph.jar share/ozone/lib/jgrapht-core.jar share/ozone/lib/jgrapht-ext.jar share/ozone/lib/jgraphx.jar +share/ozone/lib/jheaps.jar share/ozone/lib/jmespath-java.jar share/ozone/lib/jna.jar share/ozone/lib/jna-platform.jar