From 3c8e7dd5b8026b2f2445d08140674f7627575778 Mon Sep 17 00:00:00 2001 From: Kirs Date: Fri, 15 Oct 2021 10:08:36 +0800 Subject: [PATCH] [2.0-prepare]delete microbench module (#6532) * [2.0-prepare]delete microbench module --- .github/workflows/unit-test.yml | 2 +- dolphinscheduler-microbench/pom.xml | 105 --------------- .../base/AbstractBaseBenchmark.java | 123 ------------------ .../microbench/common/EnumBenchMark.java | 112 ---------------- .../microbench/common/IUserService.java | 31 ----- .../microbench/common/RpcTest.java | 77 ----------- .../microbench/common/UserCallback.java | 30 ----- .../microbench/common/UserService.java | 37 ------ pom.xml | 1 - 9 files changed, 1 insertion(+), 517 deletions(-) delete mode 100644 dolphinscheduler-microbench/pom.xml delete mode 100644 dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/base/AbstractBaseBenchmark.java delete mode 100644 dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/common/EnumBenchMark.java delete mode 100644 dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/common/IUserService.java delete mode 100644 dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/common/RpcTest.java delete mode 100644 dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/common/UserCallback.java delete mode 100644 dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/common/UserService.java diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 3087806894..daf24fc7cc 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -85,7 +85,7 @@ jobs: -Dsonar.core.codeCoveragePlugin=jacoco -Dsonar.projectKey=apache-dolphinscheduler -Dsonar.login=e4058004bc6be89decf558ac819aa1ecbee57682 - -Dsonar.exclusions=dolphinscheduler-ui/src/**/i18n/locale/*.js,dolphinscheduler-microbench/src/**/* + -Dsonar.exclusions=dolphinscheduler-ui/src/**/i18n/locale/*.js -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/dolphinscheduler-microbench/pom.xml b/dolphinscheduler-microbench/pom.xml deleted file mode 100644 index 9355616624..0000000000 --- a/dolphinscheduler-microbench/pom.xml +++ /dev/null @@ -1,105 +0,0 @@ - - - - - dolphinscheduler - org.apache.dolphinscheduler - 2.0.0-SNAPSHOT - - 4.0.0 - - dolphinscheduler-microbench - jar - ${project.artifactId} - - - UTF-8 - 1.21 - 1.8 - benchmarks - - - - - - org.openjdk.jmh - jmh-core - ${jmh.version} - - - - org.openjdk.jmh - jmh-generator-annprocess - ${jmh.version} - provided - - - - junit - junit - compile - - - - org.slf4j - slf4j-api - - - org.apache.dolphinscheduler - dolphinscheduler-remote - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - ${javac.target} - ${javac.target} - ${javac.target} - false - - - - - org.apache.maven.plugins - maven-assembly-plugin - ${maven-assembly-plugin.version} - - - - org.openjdk.jmh.Main - - - - jar-with-dependencies - - - - - - - - - \ No newline at end of file diff --git a/dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/base/AbstractBaseBenchmark.java b/dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/base/AbstractBaseBenchmark.java deleted file mode 100644 index 25f0ae9114..0000000000 --- a/dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/base/AbstractBaseBenchmark.java +++ /dev/null @@ -1,123 +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.dolphinscheduler.microbench.base; - -import org.junit.Test; -import org.openjdk.jmh.annotations.*; -import org.openjdk.jmh.results.format.ResultFormatType; -import org.openjdk.jmh.runner.Runner; -import org.openjdk.jmh.runner.options.ChainedOptionsBuilder; -import org.openjdk.jmh.runner.options.OptionsBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.IOException; - -/** - * BaseBenchMark - * If you need to test jmh, please extend him first - */ -@Warmup(iterations = AbstractBaseBenchmark.DEFAULT_WARMUP_ITERATIONS) -@Measurement(iterations = AbstractBaseBenchmark.DEFAULT_MEASURE_ITERATIONS) -@State(Scope.Thread) -@Fork(AbstractBaseBenchmark.DEFAULT_FORKS) -public abstract class AbstractBaseBenchmark { - - static final int DEFAULT_WARMUP_ITERATIONS = 10; - - static final int DEFAULT_MEASURE_ITERATIONS = 10; - - static final int DEFAULT_FORKS = 2; - - private static Logger logger = LoggerFactory.getLogger(AbstractBaseBenchmark.class); - - - private ChainedOptionsBuilder newOptionsBuilder() { - - String className = getClass().getSimpleName(); - - ChainedOptionsBuilder optBuilder = new OptionsBuilder() - // set benchmark ClassName - .include(className); - - if (getMeasureIterations() > 0) { - optBuilder.warmupIterations(getMeasureIterations()); - } - - if (getMeasureIterations() > 0) { - optBuilder.measurementIterations(getMeasureIterations()); - } - - if (getForks() > 0) { - optBuilder.forks(getForks()); - } - - String output = getReportDir(); - if (output != null) { - boolean writeFileStatus; - String filePath = getReportDir() + className + ".json"; - File file = new File(filePath); - - if (file.exists()) { - writeFileStatus = file.delete(); - - - } else { - writeFileStatus = file.getParentFile().mkdirs(); - try { - writeFileStatus = file.createNewFile(); - } catch (IOException e) { - logger.warn("jmh test create file error" + e); - } - } - if (writeFileStatus) { - optBuilder.resultFormat(ResultFormatType.JSON) - .result(filePath); - } - } - return optBuilder; - } - - @Test - public void run() throws Exception { - new Runner(newOptionsBuilder().build()).run(); - } - - private int getWarmupIterations() { - - String value = System.getProperty("warmupIterations"); - return null != value ? Integer.parseInt(value) : -1; - } - - private int getMeasureIterations() { - String value = System.getProperty("measureIterations"); - return null != value ? Integer.parseInt(value) : -1; - } - - private static String getReportDir() { - return System.getProperty("perfReportDir"); - } - - private static int getForks() { - String value = System.getProperty("forkCount"); - return null != value ? Integer.parseInt(value) : -1; - } - - -} - diff --git a/dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/common/EnumBenchMark.java b/dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/common/EnumBenchMark.java deleted file mode 100644 index dcce5368e3..0000000000 --- a/dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/common/EnumBenchMark.java +++ /dev/null @@ -1,112 +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.dolphinscheduler.microbench.common; - - -import org.apache.dolphinscheduler.microbench.base.AbstractBaseBenchmark; -import org.openjdk.jmh.annotations.*; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -/** - *Enum values JMH test - */ -@Warmup(iterations = 2, time = 1) -@Measurement(iterations = 4, time = 1) -@State(Scope.Benchmark) -public class EnumBenchMark extends AbstractBaseBenchmark { - - @Benchmark - public boolean simpleTest(){ - return Boolean.TRUE; - } - @Param({"101", "108", "103", "104", "105", "103"}) - private int testNum; - - - @Benchmark - @BenchmarkMode(Mode.AverageTime) - @OutputTimeUnit(TimeUnit.MICROSECONDS) - public void enumValuesTest() { - TestTypeEnum.oldGetNameByType(testNum); - } - - @Benchmark - @BenchmarkMode(Mode.AverageTime) - @OutputTimeUnit(TimeUnit.MICROSECONDS) - public void enumStaticMapTest() { - TestTypeEnum.newGetNameByType(testNum); - } - - - public enum TestTypeEnum { - - TYPE_101(101, "TYPE101"), - TYPE_102(102, "TYPE102"), - TYPE_103(103, "TYPE103"), - TYPE_104(104, "TYPE104"), - TYPE_105(105, "TYPE105"), - TYPE_106(106, "TYPE106"), - TYPE_107(107, "TYPE107"), - TYPE_108(108, "TYPE108"); - - private int code; - private String name; - - public int getCode() { - return code; - } - - - public String getName() { - return name; - } - - - TestTypeEnum(int code, String name) { - this.code = code; - this.name = name; - } - - private static final Map TEST_TYPE_MAP = new HashMap<>(); - - static { - for (TestTypeEnum testTypeEnum : TestTypeEnum.values()) { - TEST_TYPE_MAP.put(testTypeEnum.code,testTypeEnum); - } - } - - public static void newGetNameByType(int code) { - if (TEST_TYPE_MAP.containsKey(code)) { - TEST_TYPE_MAP.get(code); - return; - } - throw new IllegalArgumentException("invalid code : " + code); - } - - public static void oldGetNameByType(int code) { - for (TestTypeEnum testTypeEnum : TestTypeEnum.values()) { - if (testTypeEnum.getCode() == code) { - return; - } - } - throw new IllegalArgumentException("invalid code : " + code); - } - } - -} diff --git a/dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/common/IUserService.java b/dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/common/IUserService.java deleted file mode 100644 index 3a77aa8a0d..0000000000 --- a/dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/common/IUserService.java +++ /dev/null @@ -1,31 +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.dolphinscheduler.microbench.common; - -import org.apache.dolphinscheduler.rpc.base.Rpc; - -/** - * IUserService - */ -public interface IUserService { - - @Rpc(async = true, serviceCallback = UserCallback.class, retries = 9999) - Boolean say(String s); - - Integer hi(int num); -} diff --git a/dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/common/RpcTest.java b/dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/common/RpcTest.java deleted file mode 100644 index ecc54f8f26..0000000000 --- a/dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/common/RpcTest.java +++ /dev/null @@ -1,77 +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.dolphinscheduler.microbench.common; - -import org.apache.dolphinscheduler.microbench.base.AbstractBaseBenchmark; -import org.apache.dolphinscheduler.remote.config.NettyServerConfig; -import org.apache.dolphinscheduler.remote.utils.Host; -import org.apache.dolphinscheduler.rpc.client.IRpcClient; -import org.apache.dolphinscheduler.rpc.client.RpcClient; -import org.apache.dolphinscheduler.rpc.remote.NettyClient; -import org.apache.dolphinscheduler.rpc.remote.NettyServer; - -import java.util.concurrent.TimeUnit; - -import org.openjdk.jmh.annotations.Benchmark; -import org.openjdk.jmh.annotations.BenchmarkMode; -import org.openjdk.jmh.annotations.Measurement; -import org.openjdk.jmh.annotations.Mode; -import org.openjdk.jmh.annotations.OutputTimeUnit; -import org.openjdk.jmh.annotations.Scope; -import org.openjdk.jmh.annotations.Setup; -import org.openjdk.jmh.annotations.State; -import org.openjdk.jmh.annotations.TearDown; -import org.openjdk.jmh.annotations.Warmup; - -@Warmup(iterations = 5, time = 1) -@Measurement(iterations = 10, time = 1) -@State(Scope.Benchmark) -@BenchmarkMode({Mode.Throughput, Mode.AverageTime, Mode.SampleTime}) -public class RpcTest extends AbstractBaseBenchmark { - private NettyServer nettyServer; - - private IUserService userService; - - private Host host; - private IRpcClient rpcClient = new RpcClient(); - - @Setup - public void before() throws Exception { - nettyServer = new NettyServer(new NettyServerConfig()); - IRpcClient rpcClient = new RpcClient(); - host = new Host("127.0.0.1", 12346); - userService = rpcClient.create(IUserService.class, host); - - } - - @Benchmark - @BenchmarkMode({Mode.Throughput, Mode.AverageTime, Mode.SampleTime}) - @OutputTimeUnit(TimeUnit.MILLISECONDS) - public void sendTest() throws Exception { - - userService = rpcClient.create(IUserService.class, host); - Integer result = userService.hi(1); - } - - @TearDown - public void after() { - NettyClient.getInstance().close(); - nettyServer.close(); - } - -} diff --git a/dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/common/UserCallback.java b/dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/common/UserCallback.java deleted file mode 100644 index bb32093f91..0000000000 --- a/dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/common/UserCallback.java +++ /dev/null @@ -1,30 +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.dolphinscheduler.microbench.common; - -import org.apache.dolphinscheduler.rpc.common.AbstractRpcCallBack; - -/** - * UserCallback - */ -public class UserCallback extends AbstractRpcCallBack { - @Override - public void run(Object object) { - - } -} diff --git a/dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/common/UserService.java b/dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/common/UserService.java deleted file mode 100644 index ad09a34645..0000000000 --- a/dolphinscheduler-microbench/src/main/java/org/apache/dolphinscheduler/microbench/common/UserService.java +++ /dev/null @@ -1,37 +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.dolphinscheduler.microbench.common; - -import org.apache.dolphinscheduler.rpc.base.RpcService; - -/** - * UserService - */ -@RpcService("IUserService") -public class UserService implements IUserService { - - @Override - public Boolean say(String s) { - return true; - } - - @Override - public Integer hi(int num) { - return ++num; - } -} diff --git a/pom.xml b/pom.xml index 89fa0c0434..192b41411c 100644 --- a/pom.xml +++ b/pom.xml @@ -1231,7 +1231,6 @@ dolphinscheduler-dist dolphinscheduler-remote dolphinscheduler-service - dolphinscheduler-microbench dolphinscheduler-standalone-server