Skip to content

Commit

Permalink
optimzie_some_code
Browse files Browse the repository at this point in the history
  • Loading branch information
zackyoungh committed Nov 29, 2024
1 parent 0ee8278 commit 91e873a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,26 @@

@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 {
Class.forName("org.apache.hadoop.fs.FsUrlStreamHandlerFactory");
} catch (Exception e) {
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 @@ -19,6 +19,7 @@

package org.dinky.url;

import java.net.MalformedURLException;
import java.net.URLStreamHandler;
import java.net.URLStreamHandlerFactory;
import java.util.Arrays;
Expand All @@ -28,15 +29,21 @@

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 +52,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 91e873a

Please sign in to comment.