|
34 | 34 | import java.io.File; |
35 | 35 | import java.io.IOException; |
36 | 36 | import java.net.MalformedURLException; |
| 37 | +import java.net.URI; |
37 | 38 | import java.net.URL; |
38 | 39 | import java.nio.charset.StandardCharsets; |
39 | 40 | import java.util.ArrayList; |
|
51 | 52 |
|
52 | 53 | public class PluginUtil { |
53 | 54 |
|
54 | | - private static String SP = File.separator; |
| 55 | + private static final String SP = File.separator; |
55 | 56 |
|
56 | 57 | private static final String JAR_SUFFIX = ".jar"; |
57 | 58 |
|
58 | 59 | private static final String CLASS_PRE_STR = "com.dtstack.flink.sql"; |
59 | 60 |
|
| 61 | + private static final String DIRTY_DATA_PRE = "dirtyData"; |
| 62 | + |
60 | 63 | private static final Logger LOG = LoggerFactory.getLogger(PluginUtil.class); |
61 | 64 |
|
62 | 65 | private static final ObjectMapper objectMapper = new ObjectMapper(); |
@@ -159,27 +162,32 @@ public static URL buildFinalJarFilePath(String pluginType, String tableType, Str |
159 | 162 | * build dirty data url from plugin path |
160 | 163 | * |
161 | 164 | * @param dirtyType type of dirty type |
162 | | - * @param pluginPath plugin path |
| 165 | + * @param localPath local path |
| 166 | + * @param remotePath remote path |
163 | 167 | * @param pluginLoadMode load plugin mode |
164 | 168 | * @return dirty plugin url |
165 | 169 | * @throws Exception exception |
166 | 170 | */ |
167 | 171 | public static URL buildDirtyPluginUrl( |
168 | | - String dirtyType, |
169 | | - String pluginPath, |
170 | | - String pluginLoadMode) throws Exception { |
| 172 | + String dirtyType, |
| 173 | + String localPath, |
| 174 | + String remotePath, |
| 175 | + String pluginLoadMode) throws Exception { |
171 | 176 | if (Objects.isNull(dirtyType)) { |
172 | 177 | dirtyType = DirtyConsumerFactory.DEFAULT_DIRTY_TYPE; |
173 | 178 | } |
174 | 179 | String prefix = String.format("dirtyConsumer-%s", dirtyType.toLowerCase()).toLowerCase(); |
175 | 180 | String consumerType = DirtyConsumerFactory.DIRTY_CONSUMER_PATH + File.separator + dirtyType; |
176 | | - String consumerJar = PluginUtil.getJarFileDirPath(consumerType, pluginPath, pluginLoadMode); |
| 181 | + String consumerJar = PluginUtil.getJarFileDirPath(consumerType, localPath, pluginLoadMode); |
177 | 182 | String jarFileName = PluginUtil.getCoreJarFileName( |
178 | | - consumerJar, |
179 | | - prefix, |
180 | | - pluginLoadMode |
| 183 | + consumerJar, |
| 184 | + prefix, |
| 185 | + pluginLoadMode |
181 | 186 | ); |
182 | | - return new URL("file:" + consumerJar + SP + jarFileName); |
| 187 | + String path = remotePath == null ? localPath : remotePath; |
| 188 | + String dirtyPath = path + SP + DIRTY_DATA_PRE + SP + dirtyType; |
| 189 | + URI uri = URI.create("file:" + dirtyPath + SP + jarFileName); |
| 190 | + return uri.toURL(); |
183 | 191 | } |
184 | 192 |
|
185 | 193 | public static URL getRemoteSideJarFilePath(String pluginType, String sideOperator, String tableType, String remoteSqlRootDir, String localSqlPluginPath, String pluginLoadMode) throws Exception { |
|
0 commit comments