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