You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@submarine.apache.org by pi...@apache.org on 2022/11/01 04:03:35 UTC
[submarine] branch master updated: SUBMARINE-1343. Unified Version Definition [JAVA]
This is an automated email from the ASF dual-hosted git repository.
pingsutw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/submarine.git
The following commit(s) were added to refs/heads/master by this push:
new 1704b4eb SUBMARINE-1343. Unified Version Definition [JAVA]
1704b4eb is described below
commit 1704b4ebe304de7cd6a6e05b1111ecc320094a4e
Author: cdmikechen <cd...@apache.org>
AuthorDate: Tue Oct 18 08:30:52 2022 +0800
SUBMARINE-1343. Unified Version Definition [JAVA]
### What is this PR for?
Unified version definition for java
### What type of PR is it?
Refactoring
### Todos
* [x] - Remove some versions that can be skipped in maven
* [x] - Defining a uniform version number in java
### What is the Jira issue?
https://issues.apache.org/jira/browse/SUBMARINE-1343
### How should this be tested?
* Add a version check test case
* Maven build check
### Screenshots (if appropriate)
NA
### Questions:
* Do the license files need updating? No
* Are there breaking changes for older versions? No
* Does this need new documentation? No
Author: cdmikechen <cd...@apache.org>
Signed-off-by: Kevin <pi...@apache.org>
Closes #1010 from cdmikechen/SUBMARINE-1343 and squashes the following commits:
08f7e7bd [cdmikechen] fix length check
54dceed8 [cdmikechen] fix checkstyle
2459766b [cdmikechen] Unified Version Definition [JAVA]
---
submarine-all/pom.xml | 5 ++-
submarine-client/pom.xml | 1 -
submarine-commons/commons-runtime/pom.xml | 1 -
submarine-commons/commons-utils/pom.xml | 9 +++--
.../commons/utils/SubmarineConfiguration.java | 21 +++++++++++-
.../src/main/resources/submarine.properties | 20 ++++++++++++
.../submarine/commons/utils/TestVersionUtils.java | 38 ++++++++++++++++++++++
submarine-commons/pom.xml | 1 -
submarine-dist/pom.xml | 3 +-
submarine-serve/pom.xml | 5 ++-
submarine-server/pom.xml | 1 -
.../org/apache/submarine/server/Bootstrap.java | 3 +-
submarine-server/server-submitter/pom.xml | 1 -
.../server-submitter/submitter-k8s/pom.xml | 1 -
.../server/submitter/k8s/model/AgentPod.java | 3 +-
.../server/submitter/k8s/model/mljob/MLJob.java | 32 +++++++++---------
submarine-test/pom.xml | 1 -
submarine-test/test-e2e/pom.xml | 1 -
submarine-test/test-k8s/pom.xml | 1 -
submarine-workbench/pom.xml | 1 -
submarine-workbench/workbench-web/pom.xml | 2 --
21 files changed, 111 insertions(+), 40 deletions(-)
diff --git a/submarine-all/pom.xml b/submarine-all/pom.xml
index 5f080240..5e389539 100644
--- a/submarine-all/pom.xml
+++ b/submarine-all/pom.xml
@@ -24,12 +24,11 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.submarine</groupId>
- <artifactId>submarine</artifactId>
<version>0.8.0-SNAPSHOT</version>
- <relativePath>..</relativePath>
+ <artifactId>submarine</artifactId>
+ <relativePath>../pom.xml</relativePath>
</parent>
<artifactId>submarine-all</artifactId>
- <version>0.8.0-SNAPSHOT</version>
<name>Submarine: All</name>
<dependencyManagement>
diff --git a/submarine-client/pom.xml b/submarine-client/pom.xml
index 1483155a..44401128 100644
--- a/submarine-client/pom.xml
+++ b/submarine-client/pom.xml
@@ -29,7 +29,6 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>submarine-client</artifactId>
- <version>0.8.0-SNAPSHOT</version>
<name>Submarine: Client</name>
<dependencies>
diff --git a/submarine-commons/commons-runtime/pom.xml b/submarine-commons/commons-runtime/pom.xml
index b68be00e..71a5374c 100644
--- a/submarine-commons/commons-runtime/pom.xml
+++ b/submarine-commons/commons-runtime/pom.xml
@@ -30,7 +30,6 @@
<groupId>org.apache.submarine</groupId>
<artifactId>submarine-commons-runtime</artifactId>
- <version>0.8.0-SNAPSHOT</version>
<name>Submarine: Commons Runtime</name>
<dependencies>
diff --git a/submarine-commons/commons-utils/pom.xml b/submarine-commons/commons-utils/pom.xml
index 640d3004..a4d664db 100644
--- a/submarine-commons/commons-utils/pom.xml
+++ b/submarine-commons/commons-utils/pom.xml
@@ -29,9 +29,7 @@
<relativePath>../pom.xml</relativePath>
</parent>
- <groupId>org.apache.submarine</groupId>
<artifactId>submarine-commons-utils</artifactId>
- <version>0.8.0-SNAPSHOT</version>
<name>Submarine: Commons Utils</name>
<dependencies>
@@ -73,6 +71,13 @@
</dependencies>
<build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
diff --git a/submarine-commons/commons-utils/src/main/java/org/apache/submarine/commons/utils/SubmarineConfiguration.java b/submarine-commons/commons-utils/src/main/java/org/apache/submarine/commons/utils/SubmarineConfiguration.java
index fa5895ec..4bd5eace 100644
--- a/submarine-commons/commons-utils/src/main/java/org/apache/submarine/commons/utils/SubmarineConfiguration.java
+++ b/submarine-commons/commons-utils/src/main/java/org/apache/submarine/commons/utils/SubmarineConfiguration.java
@@ -27,10 +27,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
+import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
public class SubmarineConfiguration extends XMLConfiguration {
private static final Logger LOG = LoggerFactory.getLogger(SubmarineConfiguration.class);
@@ -42,7 +44,24 @@ public class SubmarineConfiguration extends XMLConfiguration {
private static volatile SubmarineConfiguration conf;
- private Map<String, String> properties = new HashMap<>();
+ private final Map<String, String> properties = new HashMap<>();
+
+ public static final String SUBMARINE_VERSION;
+
+ public static String getSubmarineVersion() {
+ return SUBMARINE_VERSION;
+ }
+
+ static {
+ Properties properties = new Properties();
+ try {
+ properties.load(SubmarineConfiguration.class.getClassLoader()
+ .getResourceAsStream("submarine.properties"));
+ SUBMARINE_VERSION = properties.getProperty("project.version");
+ } catch (IOException e) {
+ throw new RuntimeException("Can not get submarine version!");
+ }
+ }
private SubmarineConfiguration(URL url) throws ConfigurationException {
setDelimiterParsingDisabled(true);
diff --git a/submarine-commons/commons-utils/src/main/resources/submarine.properties b/submarine-commons/commons-utils/src/main/resources/submarine.properties
new file mode 100644
index 00000000..a1f4e34e
--- /dev/null
+++ b/submarine-commons/commons-utils/src/main/resources/submarine.properties
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+
+project.version=${project.version}
diff --git a/submarine-commons/commons-utils/src/test/java/org/apache/submarine/commons/utils/TestVersionUtils.java b/submarine-commons/commons-utils/src/test/java/org/apache/submarine/commons/utils/TestVersionUtils.java
new file mode 100644
index 00000000..ca2a8879
--- /dev/null
+++ b/submarine-commons/commons-utils/src/test/java/org/apache/submarine/commons/utils/TestVersionUtils.java
@@ -0,0 +1,38 @@
+/*
+ * 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.submarine.commons.utils;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.regex.Pattern;
+
+public class TestVersionUtils {
+
+ @Test
+ public void testProjectVersion() {
+ System.out.println(SubmarineConfiguration.SUBMARINE_VERSION);
+ // like x.y.z or x.y.z-SNAPSHOT
+ String versionPattern = "^\\d+\\.\\d+\\.\\d+.*";
+ Assert.assertTrue(Pattern.matches(versionPattern, "0.8.0"));
+ Assert.assertTrue(Pattern.matches(versionPattern, "0.8.0-SNAPSHOT"));
+ Assert.assertTrue(Pattern.matches(versionPattern, SubmarineConfiguration.SUBMARINE_VERSION));
+ }
+}
diff --git a/submarine-commons/pom.xml b/submarine-commons/pom.xml
index 80724fe3..5545e7a9 100644
--- a/submarine-commons/pom.xml
+++ b/submarine-commons/pom.xml
@@ -30,7 +30,6 @@
<groupId>org.apache.submarine</groupId>
<artifactId>submarine-commons</artifactId>
- <version>0.8.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Submarine: Commons</name>
diff --git a/submarine-dist/pom.xml b/submarine-dist/pom.xml
index 91077cb7..5211bdca 100644
--- a/submarine-dist/pom.xml
+++ b/submarine-dist/pom.xml
@@ -26,10 +26,9 @@
<groupId>org.apache.submarine</groupId>
<artifactId>submarine</artifactId>
<version>0.8.0-SNAPSHOT</version>
- <relativePath>..</relativePath>
+ <relativePath>../pom.xml</relativePath>
</parent>
<artifactId>submarine-dist</artifactId>
- <version>0.8.0-SNAPSHOT</version>
<name>Submarine: Dist</name>
<packaging>pom</packaging>
diff --git a/submarine-serve/pom.xml b/submarine-serve/pom.xml
index f29d3b7c..72559da0 100644
--- a/submarine-serve/pom.xml
+++ b/submarine-serve/pom.xml
@@ -28,7 +28,6 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>submarine-serve</artifactId>
- <version>0.8.0-SNAPSHOT</version>
<name>Submarine: Serve</name>
<dependencies>
@@ -50,14 +49,14 @@
<dependency>
<groupId>org.apache.submarine</groupId>
<artifactId>submarine-commons-utils</artifactId>
- <version>0.8.0-SNAPSHOT</version>
+ <version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.submarine</groupId>
<artifactId>submarine-k8s-utils</artifactId>
- <version>0.8.0-SNAPSHOT</version>
+ <version>${project.version}</version>
</dependency>
<dependency>
diff --git a/submarine-server/pom.xml b/submarine-server/pom.xml
index 7e18f870..e74da5ca 100644
--- a/submarine-server/pom.xml
+++ b/submarine-server/pom.xml
@@ -29,7 +29,6 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>submarine-server</artifactId>
- <version>0.8.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Submarine: Server</name>
diff --git a/submarine-server/server-core/src/main/java/org/apache/submarine/server/Bootstrap.java b/submarine-server/server-core/src/main/java/org/apache/submarine/server/Bootstrap.java
index 2b2b28ba..c4fbbf07 100644
--- a/submarine-server/server-core/src/main/java/org/apache/submarine/server/Bootstrap.java
+++ b/submarine-server/server-core/src/main/java/org/apache/submarine/server/Bootstrap.java
@@ -26,6 +26,7 @@ import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.servers.Server;
+import org.apache.submarine.commons.utils.SubmarineConfiguration;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@@ -50,7 +51,7 @@ public class Bootstrap extends HttpServlet {
.termsOfService("http://swagger.io/terms/")
.contact(new Contact()
.email("dev@submarine.apache.org"))
- .version("0.8.0-SNAPSHOT")
+ .version(SubmarineConfiguration.SUBMARINE_VERSION)
.license(new License()
.name("Apache 2.0")
.url("http://www.apache.org/licenses/LICENSE-2.0.html"));
diff --git a/submarine-server/server-submitter/pom.xml b/submarine-server/server-submitter/pom.xml
index 089cb909..15c443fc 100644
--- a/submarine-server/server-submitter/pom.xml
+++ b/submarine-server/server-submitter/pom.xml
@@ -25,7 +25,6 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>submarine-server-submitter</artifactId>
- <version>0.8.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Submarine: Submitter</name>
diff --git a/submarine-server/server-submitter/submitter-k8s/pom.xml b/submarine-server/server-submitter/submitter-k8s/pom.xml
index 810090b2..609126e3 100644
--- a/submarine-server/server-submitter/submitter-k8s/pom.xml
+++ b/submarine-server/server-submitter/submitter-k8s/pom.xml
@@ -29,7 +29,6 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>submarine-submitter-k8s</artifactId>
- <version>0.8.0-SNAPSHOT</version>
<name>Submarine: Kubernetes Submitter</name>
<dependencies>
diff --git a/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/model/AgentPod.java b/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/model/AgentPod.java
index d1f7c8d9..d3ad1bbf 100644
--- a/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/model/AgentPod.java
+++ b/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/model/AgentPod.java
@@ -42,7 +42,8 @@ public class AgentPod extends V1Pod implements K8sResource<AgentPod> {
private static final Logger LOG = LoggerFactory.getLogger(AgentPod.class);
private static final SubmarineConfiguration conf = SubmarineConfiguration.getInstance();
- private static final String AGENT_IMAGE = "apache/submarine:agent-0.8.0-SNAPSHOT";
+ private static final String AGENT_IMAGE = "apache/submarine:agent-"
+ + SubmarineConfiguration.SUBMARINE_VERSION;
private static final String CONTAINER_NAME = "agent";
public AgentPod(String namespace, String name,
diff --git a/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/model/mljob/MLJob.java b/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/model/mljob/MLJob.java
index f026bc3d..24915067 100644
--- a/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/model/mljob/MLJob.java
+++ b/submarine-server/server-submitter/submitter-k8s/src/main/java/org/apache/submarine/server/submitter/k8s/model/mljob/MLJob.java
@@ -33,6 +33,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import org.apache.submarine.commons.utils.SubmarineConfiguration;
import org.apache.submarine.commons.utils.exception.SubmarineRuntimeException;
import org.apache.submarine.server.api.common.CustomResourceType;
import org.apache.submarine.server.api.experiment.Experiment;
@@ -214,69 +215,70 @@ public abstract class MLJob implements KubernetesObject, K8sResource<Experiment>
public V1Container getExperimentHandlerContainer(ExperimentSpec spec) {
Map<String, String> handlerSpec = spec.getExperimentHandlerSpec();
-
+
if (checkExperimentHanderArg(handlerSpec)) {
V1Container initContainer = new V1Container();
- initContainer.setImage("apache/submarine:experiment-prehandler-0.8.0-SNAPSHOT");
+ initContainer.setImage("apache/submarine:experiment-prehandler-"
+ + SubmarineConfiguration.SUBMARINE_VERSION);
initContainer.setName("ExperimentHandler".toLowerCase());
List<V1EnvVar> envVar = new ArrayList<>();
-
+
V1EnvVar hdfsHostVar = new V1EnvVar();
hdfsHostVar.setName("HDFS_HOST");
hdfsHostVar.setValue(handlerSpec.get("HDFS_HOST"));
envVar.add(hdfsHostVar);
-
+
V1EnvVar hdfsPortVar = new V1EnvVar();
hdfsPortVar.setName("HDFS_PORT");
hdfsPortVar.setValue(handlerSpec.get("HDFS_PORT"));
envVar.add(hdfsPortVar);
-
+
V1EnvVar hdfsSourceVar = new V1EnvVar();
hdfsSourceVar.setName("HDFS_SOURCE");
hdfsSourceVar.setValue(handlerSpec.get("HDFS_SOURCE"));
envVar.add(hdfsSourceVar);
-
+
V1EnvVar hdfsEnableKerberosVar = new V1EnvVar();
hdfsEnableKerberosVar.setName("ENABLE_KERBEROS");
hdfsEnableKerberosVar.setValue(handlerSpec.get("ENABLE_KERBEROS"));
envVar.add(hdfsEnableKerberosVar);
-
+
V1EnvVar destMinIOHostVar = new V1EnvVar();
destMinIOHostVar.setName("DEST_MINIO_HOST");
destMinIOHostVar.setValue("submarine-minio-service");
envVar.add(destMinIOHostVar);
-
+
V1EnvVar destMinIOPortVar = new V1EnvVar();
destMinIOPortVar.setName("DEST_MINIO_PORT");
destMinIOPortVar.setValue("9000");
envVar.add(destMinIOPortVar);
-
+
V1EnvVar minIOAccessKeyVar = new V1EnvVar();
minIOAccessKeyVar.setName("MINIO_ACCESS_KEY");
minIOAccessKeyVar.setValue("submarine_minio");
envVar.add(minIOAccessKeyVar);
-
+
V1EnvVar minIOSecretKeyVar = new V1EnvVar();
minIOSecretKeyVar.setName("MINIO_SECRET_KEY");
minIOSecretKeyVar.setValue("submarine_minio");
envVar.add(minIOSecretKeyVar);
-
+
V1EnvVar fileSystemTypeVar = new V1EnvVar();
fileSystemTypeVar.setName("FILE_SYSTEM_TYPE");
fileSystemTypeVar.setValue(handlerSpec.get("FILE_SYSTEM_TYPE"));
envVar.add(fileSystemTypeVar);
-
+
V1EnvVar experimentIdVar = new V1EnvVar();
experimentIdVar.setName("EXPERIMENT_ID");
experimentIdVar.setValue(this.experimentId);
envVar.add(experimentIdVar);
-
+
initContainer.setEnv(envVar);
return initContainer;
}
return null;
}
-
+
private boolean checkExperimentHanderArg(Map<String, String> handlerSpec) {
if (handlerSpec == null)
return false;
@@ -290,7 +292,7 @@ public abstract class MLJob implements KubernetesObject, K8sResource<Experiment>
}
return true;
}
-
+
/**
* Convert MLJob object to return Experiment object
*/
diff --git a/submarine-test/pom.xml b/submarine-test/pom.xml
index eec26a10..829ccf40 100644
--- a/submarine-test/pom.xml
+++ b/submarine-test/pom.xml
@@ -28,7 +28,6 @@
<version>0.8.0-SNAPSHOT</version>
</parent>
<artifactId>submarine-test</artifactId>
- <version>0.8.0-SNAPSHOT</version>
<name>Submarine: Test</name>
<packaging>pom</packaging>
diff --git a/submarine-test/test-e2e/pom.xml b/submarine-test/test-e2e/pom.xml
index 8f14bb79..b0da6f53 100644
--- a/submarine-test/test-e2e/pom.xml
+++ b/submarine-test/test-e2e/pom.xml
@@ -29,7 +29,6 @@
</parent>
<artifactId>submarine-test-e2e</artifactId>
- <version>0.8.0-SNAPSHOT</version>
<name>Submarine: E2E Test</name>
<properties>
diff --git a/submarine-test/test-k8s/pom.xml b/submarine-test/test-k8s/pom.xml
index e5fefdad..f8f2abe7 100644
--- a/submarine-test/test-k8s/pom.xml
+++ b/submarine-test/test-k8s/pom.xml
@@ -29,7 +29,6 @@
</parent>
<artifactId>submarine-test-k8s</artifactId>
- <version>0.8.0-SNAPSHOT</version>
<name>Submarine: Kubernetes Test</name>
<properties>
diff --git a/submarine-workbench/pom.xml b/submarine-workbench/pom.xml
index 6632c426..71b1df7f 100644
--- a/submarine-workbench/pom.xml
+++ b/submarine-workbench/pom.xml
@@ -31,7 +31,6 @@
</parent>
<artifactId>submarine-workbench</artifactId>
- <version>0.8.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Submarine: Workbench</name>
<description>Submarine Workbench</description>
diff --git a/submarine-workbench/workbench-web/pom.xml b/submarine-workbench/workbench-web/pom.xml
index 1709a63b..5e2827dc 100644
--- a/submarine-workbench/workbench-web/pom.xml
+++ b/submarine-workbench/workbench-web/pom.xml
@@ -29,10 +29,8 @@
<relativePath>../pom.xml</relativePath>
</parent>
- <groupId>org.apache.submarine</groupId>
<artifactId>submarine-workbench-web</artifactId>
<packaging>war</packaging>
- <version>0.8.0-SNAPSHOT</version>
<name>Submarine: Workbench Web Angular</name>
<!-- See https://github.com/eirslett/frontend-maven-plugin/issues/229 -->
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@submarine.apache.org
For additional commands, e-mail: dev-help@submarine.apache.org