-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature][RestAPI] Add overview api (#6883)
- Loading branch information
Showing
18 changed files
with
505 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
...l-engine-common/src/main/java/org/apache/seatunnel/engine/common/env/EnvironmentUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* 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.seatunnel.engine.common.env; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.time.ZoneId; | ||
import java.time.format.DateTimeFormatter; | ||
import java.util.Properties; | ||
|
||
import static org.apache.seatunnel.engine.common.Constant.PROP_FILE; | ||
|
||
@Slf4j | ||
public class EnvironmentUtil { | ||
|
||
private static String getProperty(Properties properties, String key, String defaultValue) { | ||
String value = properties.getProperty(key); | ||
if (value == null || value.charAt(0) == '$') { | ||
return defaultValue; | ||
} | ||
return value; | ||
} | ||
|
||
public static Version getVersion() { | ||
|
||
Version version = new Version(); | ||
ClassLoader classLoader = EnvironmentUtil.class.getClassLoader(); | ||
|
||
try (InputStream propFile = classLoader.getResourceAsStream(PROP_FILE)) { | ||
|
||
if (propFile != null) { | ||
Properties properties = new Properties(); | ||
|
||
properties.load(propFile); | ||
|
||
version.setProjectVersion( | ||
getProperty(properties, "project.version", version.getProjectVersion())); | ||
version.setGitCommitId( | ||
getProperty(properties, "git.commit.id", version.getGitCommitId())); | ||
version.setGitCommitAbbrev( | ||
getProperty( | ||
properties, "git.commit.id.abbrev", version.getGitCommitAbbrev())); | ||
|
||
DateTimeFormatter gitDateTimeFormatter = | ||
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ"); | ||
|
||
DateTimeFormatter systemDefault = | ||
DateTimeFormatter.ISO_OFFSET_DATE_TIME.withZone(ZoneId.systemDefault()); | ||
|
||
version.setBuildTime( | ||
systemDefault.format( | ||
gitDateTimeFormatter.parse( | ||
getProperty( | ||
properties, | ||
"git.build.time", | ||
version.getBuildTime())))); | ||
version.setCommitTime( | ||
systemDefault.format( | ||
gitDateTimeFormatter.parse( | ||
getProperty( | ||
properties, | ||
"git.commit.time", | ||
version.getCommitTime())))); | ||
} | ||
|
||
} catch (IOException ioException) { | ||
log.info("Unable to read version property file: {}", ioException.getMessage()); | ||
} | ||
|
||
return version; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...seatunnel-engine-common/src/main/java/org/apache/seatunnel/engine/common/env/Version.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* 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.seatunnel.engine.common.env; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class Version { | ||
private String projectVersion = "<unknown>"; | ||
private String gitCommitId = "DecafC0ffeeD0d0F00d"; | ||
private String buildTime = "1970-01-01T00:00:00+0000"; | ||
private String commitTime = "1970-01-01T00:00:00+0000"; | ||
private String gitCommitAbbrev = "DeadD0d0"; | ||
} |
22 changes: 22 additions & 0 deletions
22
seatunnel-engine/seatunnel-engine-common/src/main/resources-filtered/zeta.version.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# | ||
# 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} | ||
git.commit.id=${git.commit.id} | ||
git.commit.id.abbrev=${git.commit.id.abbrev} | ||
git.commit.time=${git.commit.time} | ||
git.build.time=${git.build.time} |
40 changes: 40 additions & 0 deletions
40
...e-common/src/test/java/org/apache/seatunnel/engine/common/config/EnvironmentUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* 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.seatunnel.engine.common.config; | ||
|
||
import org.apache.seatunnel.engine.common.env.EnvironmentUtil; | ||
import org.apache.seatunnel.engine.common.env.Version; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
public class EnvironmentUtilTest { | ||
|
||
@Test | ||
public void testGetVersion() { | ||
|
||
Version version = EnvironmentUtil.getVersion(); | ||
|
||
assertNotNull(version.getProjectVersion()); | ||
assertNotNull(version.getGitCommitId()); | ||
assertNotNull(version.getGitCommitAbbrev()); | ||
assertNotNull(version.getBuildTime()); | ||
assertNotNull(version.getCommitTime()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.