Skip to content

Commit

Permalink
[Optimize][Admin] Optimized the package size of the App and the rs pr…
Browse files Browse the repository at this point in the history
…otocol (#3985)

Co-authored-by: zackyoungh <[email protected]>
  • Loading branch information
zackyoungh and zackyoungh authored Dec 1, 2024
1 parent ccda836 commit 780e8df
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,30 @@

import java.net.URLStreamHandler;
import java.net.URLStreamHandlerFactory;
import java.util.Arrays;
import java.util.List;

import org.springframework.context.annotation.Profile;

import cn.hutool.core.lang.Singleton;
import cn.hutool.core.util.StrUtil;

@Profile("!test")
public class RsURLStreamHandlerFactory implements URLStreamHandlerFactory {
private final List<String> notContains = Arrays.asList("jar", "file", "http", "https");
private static final String PREFIX = "sun.net.www.protocol";

@Override
public URLStreamHandler createURLStreamHandler(String protocol) {
if ("rs".equals(protocol)) {
if ("rs".equalsIgnoreCase(protocol)) {
return new RsURLStreamHandler();
}
for (String tempProtocol : notContains) {
if (tempProtocol.equals(StrUtil.sub(protocol, 0, tempProtocol.length()))) {
return null;
}
String name = PREFIX + "." + protocol + ".Handler";
try {
@SuppressWarnings("deprecation")
Object o = Class.forName(name).newInstance();
return (URLStreamHandler) o;
} catch (ClassNotFoundException x) {
// ignore
} catch (Exception e) {
// For compatibility, all Exceptions are ignored.
// any number of exceptions can get thrown here
}

try {
Expand Down
57 changes: 44 additions & 13 deletions dinky-app/dinky-app-1.14/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,56 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<artifactId>maven-shade-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<!-- 可以设置jar包的入口类(可选) -->
<mainClass>org.dinky.app.MainApp</mainClass>
</manifest>
</archive>
<finalName>${project.build.finalName}-jar-with-dependencies</finalName>
<outputDirectory>${project.parent.parent.basedir}/build/extends</outputDirectory>
<minimizeJar>true</minimizeJar>
<createDependencyReducedPom>false</createDependencyReducedPom>
<filters>
<filter>
<artifact>org.dinky:*</artifact>
<includes>
<include>org/dinky/**</include>
<include>org/apache/flink/**</include>
<include>org/apache/calcite/**</include>
<include>META-INF/**</include>
</includes>
</filter>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>tpch/**</exclude>
<exclude>tpcds/**</exclude>
<exclude>support/**</exclude>
<exclude>springfox/**</exclude>
<exclude>org/slf4j/**</exclude>
<exclude>org/springframework/**</exclude>
<exclude>javax/**</exclude>
<exclude>javassist/**</exclude>
<exclude>Class50/**</exclude>
<exclude>lombok/**</exclude>
<exclude>freemarker/**</exclude>
<exclude>META-INF/resources/**</exclude>
<exclude>META-INF/spring/**</exclude>
<exclude>META-INF/services/javax**</exclude>
<exclude>META-INF/services/lombok**</exclude>
<exclude>META-INF/services/org.apache.logging**</exclude>
</excludes>
</filter>
</filters>

<transformers>
<!--设置主函数-->
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.dinky.app.MainApp</mainClass>
</transformer>
</transformers>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<goals>
<goal>single</goal>
<goal>shade</goal>
</goals>
<phase>package</phase>
</execution>
Expand Down
7 changes: 6 additions & 1 deletion dinky-app/dinky-app-1.15/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
<artifact>org.dinky:*</artifact>
<includes>
<include>org/dinky/**</include>
<include>org/apache/flink/**</include>
<include>org/apache/calcite/**</include>
<include>META-INF/**</include>
</includes>
</filter>
Expand All @@ -91,8 +93,11 @@
<exclude>Class50/**</exclude>
<exclude>lombok/**</exclude>
<exclude>freemarker/**</exclude>
<exclude>com.sun/**</exclude>
<exclude>META-INF/resources/**</exclude>
<exclude>META-INF/spring/**</exclude>
<exclude>META-INF/services/javax**</exclude>
<exclude>META-INF/services/lombok**</exclude>
<exclude>META-INF/services/org.apache.logging**</exclude>
</excludes>
</filter>
</filters>
Expand Down
7 changes: 6 additions & 1 deletion dinky-app/dinky-app-1.16/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<artifact>org.dinky:*</artifact>
<includes>
<include>org/dinky/**</include>
<include>org/apache/flink/**</include>
<include>org/apache/calcite/**</include>
<include>META-INF/**</include>
</includes>
</filter>
Expand All @@ -75,8 +77,11 @@
<exclude>Class50/**</exclude>
<exclude>lombok/**</exclude>
<exclude>freemarker/**</exclude>
<exclude>com.sun/**</exclude>
<exclude>META-INF/resources/**</exclude>
<exclude>META-INF/spring/**</exclude>
<exclude>META-INF/services/javax**</exclude>
<exclude>META-INF/services/lombok**</exclude>
<exclude>META-INF/services/org.apache.logging**</exclude>
</excludes>
</filter>
</filters>
Expand Down
7 changes: 6 additions & 1 deletion dinky-app/dinky-app-1.17/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<artifact>org.dinky:*</artifact>
<includes>
<include>org/dinky/**</include>
<include>org/apache/flink/**</include>
<include>org/apache/calcite/**</include>
<include>META-INF/**</include>
</includes>
</filter>
Expand All @@ -75,8 +77,11 @@
<exclude>Class50/**</exclude>
<exclude>lombok/**</exclude>
<exclude>freemarker/**</exclude>
<exclude>com.sun/**</exclude>
<exclude>META-INF/resources/**</exclude>
<exclude>META-INF/spring/**</exclude>
<exclude>META-INF/services/javax**</exclude>
<exclude>META-INF/services/lombok**</exclude>
<exclude>META-INF/services/org.apache.logging**</exclude>
</excludes>
</filter>
</filters>
Expand Down
7 changes: 6 additions & 1 deletion dinky-app/dinky-app-1.18/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<artifact>org.dinky:*</artifact>
<includes>
<include>org/dinky/**</include>
<include>org/apache/flink/**</include>
<include>org/apache/calcite/**</include>
<include>META-INF/**</include>
</includes>
</filter>
Expand All @@ -75,8 +77,11 @@
<exclude>Class50/**</exclude>
<exclude>lombok/**</exclude>
<exclude>freemarker/**</exclude>
<exclude>com.sun/**</exclude>
<exclude>META-INF/resources/**</exclude>
<exclude>META-INF/spring/**</exclude>
<exclude>META-INF/services/javax**</exclude>
<exclude>META-INF/services/lombok**</exclude>
<exclude>META-INF/services/org.apache.logging**</exclude>
</excludes>
</filter>
</filters>
Expand Down
7 changes: 6 additions & 1 deletion dinky-app/dinky-app-1.19/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<artifact>org.dinky:*</artifact>
<includes>
<include>org/dinky/**</include>
<include>org/apache/flink/**</include>
<include>org/apache/calcite/**</include>
<include>META-INF/**</include>
</includes>
</filter>
Expand All @@ -75,8 +77,11 @@
<exclude>Class50/**</exclude>
<exclude>lombok/**</exclude>
<exclude>freemarker/**</exclude>
<exclude>com.sun/**</exclude>
<exclude>META-INF/resources/**</exclude>
<exclude>META-INF/spring/**</exclude>
<exclude>META-INF/services/javax**</exclude>
<exclude>META-INF/services/lombok**</exclude>
<exclude>META-INF/services/org.apache.logging**</exclude>
</excludes>
</filter>
</filters>
Expand Down
7 changes: 6 additions & 1 deletion dinky-app/dinky-app-1.20/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<artifact>org.dinky:*</artifact>
<includes>
<include>org/dinky/**</include>
<include>org/apache/flink/**</include>
<include>org/apache/calcite/**</include>
<include>META-INF/**</include>
</includes>
</filter>
Expand All @@ -75,8 +77,11 @@
<exclude>Class50/**</exclude>
<exclude>lombok/**</exclude>
<exclude>freemarker/**</exclude>
<exclude>com.sun/**</exclude>
<exclude>META-INF/resources/**</exclude>
<exclude>META-INF/spring/**</exclude>
<exclude>META-INF/services/javax**</exclude>
<exclude>META-INF/services/lombok**</exclude>
<exclude>META-INF/services/org.apache.logging**</exclude>
</excludes>
</filter>
</filters>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public static Optional<JobClient> executeJarJob(String type, Executor executor,
ReadableConfig configuration =
executor.getStreamExecutionEnvironment().getConfiguration();
List<String> jars = configuration.get(PipelineOptions.JARS);
List<URL> jarsUrl = jars.stream().map(URLUtil::getURL).collect(Collectors.toList());
List<URL> jarsUrl = jars.stream().map(URLUtil::url).collect(Collectors.toList());
Pipeline pipeline = executeJarOperation.getStreamGraph(executor.getCustomTableEnvironment(), jarsUrl);
if (pipeline instanceof StreamGraph) {
// stream job
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,24 @@

import java.net.URLStreamHandler;
import java.net.URLStreamHandlerFactory;
import java.util.Arrays;
import java.util.List;

import cn.hutool.core.util.StrUtil;

public class RsURLStreamHandlerFactory implements URLStreamHandlerFactory {
private static final String PREFIX = "sun.net.www.protocol";
private final List<String> notContains = Arrays.asList("jar", "file", "http", "https");

@Override
public URLStreamHandler createURLStreamHandler(String protocol) {
for (String tempProtocol : notContains) {
if (tempProtocol.equals(StrUtil.sub(protocol, 0, tempProtocol.length()))) {
return null;
}
String name = PREFIX + "." + protocol + ".Handler";
try {
@SuppressWarnings("deprecation")
Object o = Class.forName(name).newInstance();
return (URLStreamHandler) o;
} catch (ClassNotFoundException x) {
// ignore
} catch (Exception e) {
// For compatibility, all Exceptions are ignored.
// any number of exceptions can get thrown here
}

if (ResourceFileSystem.URI_SCHEMA.getScheme().equals(protocol)) {
return new RsURLStreamHandler();
}
Expand All @@ -45,7 +47,6 @@ public URLStreamHandler createURLStreamHandler(String protocol) {
} catch (Throwable e) {
return null;
}
String name = PREFIX + "." + protocol + ".Handler";
try {
@SuppressWarnings("deprecation")
Object o = Class.forName(name).newInstance();
Expand Down
2 changes: 1 addition & 1 deletion dinky-metadata/dinky-metadata-paimon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<dependency>
<groupId>org.apache.paimon</groupId>
<artifactId>paimon-bundle</artifactId>
<version>0.8.1</version>
<version>0.9.0</version>
<scope>${scope.runtime}</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.paimon/paimon-s3 -->
Expand Down

0 comments on commit 780e8df

Please sign in to comment.