Unverified Commit 2be2d6d4 authored by ZackYoung's avatar ZackYoung Committed by GitHub

[Optimize][pom]optimize pom module code (#1234)

* 模块优化 1. optimize app module * 1. optimize module code 2. add flink version compatible * 1. change 13 to 14 * 1. change 13 to 14 * 1. change udf PythonFunctionFactory code * 1. delete admin module static dir * 1. delete admin module static dir * 1. delete more includes tags * 1. change web clean phase * 1. change web package order * 1. change web package order * change pulsar module
parent 7f501245
......@@ -212,10 +212,28 @@
<build>
<finalName>${project.artifactId}-${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<directory>${project.basedir}/src/main/resources/static</directory>
</fileset>
</filesets>
</configuration>
<executions>
<execution>
<goals>
<goal>clean</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
......@@ -242,7 +260,7 @@
<goals>
<goal>copy-resources</goal>
</goals>
<phase>validate</phase>
<phase>initialize</phase>
<configuration>
<outputDirectory>src/main/resources/static</outputDirectory>
<overwrite>true</overwrite>
......@@ -259,15 +277,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<executions>
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<classesDirectory>target/classes/</classesDirectory>
<excludes>
......@@ -276,6 +285,15 @@
<exclude>/mybatis*.xml</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>default-jar</id>
<goals>
<goal>jar</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
......
......@@ -39,13 +39,10 @@
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-app-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<!-- <scope>provided</scope>-->
<version>8.0.21</version>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
......@@ -81,7 +78,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${target.java.version}</source>
<target>${target.java.version}</target>
......@@ -93,7 +90,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<version>${maven-assembly-plugin.version}</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
......
......@@ -39,13 +39,10 @@
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-app-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<!-- <scope>provided</scope>-->
<version>8.0.21</version>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
......@@ -81,7 +78,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${target.java.version}</source>
<target>${target.java.version}</target>
......@@ -93,7 +90,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<version>${maven-assembly-plugin.version}</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
......
......@@ -39,13 +39,10 @@
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-app-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<!-- <scope>provided</scope>-->
<version>8.0.21</version>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
......@@ -81,7 +78,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${target.java.version}</source>
<target>${target.java.version}</target>
......@@ -93,7 +90,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<version>${maven-assembly-plugin.version}</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
......
......@@ -39,13 +39,10 @@
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-app-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<!-- <scope>provided</scope>-->
<version>8.0.21</version>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
......@@ -81,7 +78,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${target.java.version}</source>
<target>${target.java.version}</target>
......@@ -93,7 +90,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<version>${maven-assembly-plugin.version}</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
......
......@@ -22,13 +22,10 @@
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-app-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<!-- <scope>provided</scope>-->
<version>8.0.21</version>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
......@@ -64,7 +61,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${target.java.version}</source>
<target>${target.java.version}</target>
......@@ -76,7 +73,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<version>${maven-assembly-plugin.version}</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
......
......@@ -37,27 +37,112 @@
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<!-- <scope>provided</scope>-->
<version>8.0.21</version>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-${dlink.flink.version}</artifactId>
<artifactId>dlink-client-base</artifactId>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-executor</artifactId>
</dependency>
</dependencies>
<profiles>
<profile>
<id>flink-1.11</id>
<dependencies>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-1.11</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-${dlink.flink.version}</artifactId>
<artifactId>dlink-flink-1.11</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>flink-1.12</id>
<dependencies>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-base</artifactId>
<artifactId>dlink-client-1.12</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-executor</artifactId>
<artifactId>dlink-flink-1.12</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>flink-1.13</id>
<dependencies>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-1.13</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.13</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>flink-1.14</id>
<dependencies>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-1.14</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.14</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>flink-1.15</id>
<dependencies>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-1.15</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.15</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>flink-1.16</id>
<dependencies>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-1.16</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.16</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
......@@ -56,5 +56,19 @@
<module>dlink-app-1.15</module>
</modules>
</profile>
<profile>
<id>flink-1.16</id>
<modules>
<module>dlink-app-1.16</module>
</modules>
</profile>
<profile>
<id>web</id>
<modules>
<module>../dlink-web</module>
</modules>
</profile>
</profiles>
</project>
......@@ -54,12 +54,4 @@
</plugins>
</build>
<profiles>
<profile>
<id>web</id>
<modules>
<module>../dlink-web</module>
</modules>
</profile>
</profiles>
</project>
\ No newline at end of file
......@@ -37,10 +37,9 @@
<directory>${project.parent.basedir}/dlink-admin/target/classes</directory>
<outputDirectory>config</outputDirectory>
<includes>
<include>*.properties</include>
<include>*.yml</include>
<include>*.yaml</include>
<include>*.xml</include>
<include>**/*.yml</include>
<include>**/*.yaml</include>
<include>**/log4j2.xml</include>
</includes>
</fileSet>
<fileSet>
......
......@@ -41,7 +41,6 @@
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.13</artifactId>
<!-- <scope>provided</scope>-->
</dependency>
<dependency>
<groupId>junit</groupId>
......
......@@ -39,7 +39,6 @@
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.14</artifactId>
<!-- <scope>provided</scope>-->
</dependency>
<dependency>
<groupId>junit</groupId>
......
......@@ -41,7 +41,6 @@
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.15</artifactId>
<!-- <scope>provided</scope>-->
</dependency>
<dependency>
<groupId>junit</groupId>
......
......@@ -24,7 +24,6 @@
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.16</artifactId>
<!-- <scope>provided</scope>-->
</dependency>
<dependency>
<groupId>junit</groupId>
......
......@@ -28,7 +28,6 @@
<artifactId>dlink-client-1.11</artifactId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>${target.java.version}</maven.compiler.source>
<maven.compiler.target>${target.java.version}</maven.compiler.target>
......@@ -38,7 +37,6 @@
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
......
/*
* 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.flink.client.python;
import static org.apache.flink.client.python.PythonEnvUtils.getGatewayServer;
import static org.apache.flink.client.python.PythonEnvUtils.launchPy4jPythonClient;
import static org.apache.flink.client.python.PythonEnvUtils.setGatewayServer;
import static org.apache.flink.client.python.PythonEnvUtils.startGatewayServer;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.python.shaded.py4j.GatewayServer;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.ReadableConfig;
import org.apache.flink.table.functions.python.PythonFunction;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
/**
* The factory which creates the PythonFunction objects from given module name and object name.
*/
public interface PythonFunctionFactory {
long CHECK_INTERVAL = 100;
long TIMEOUT_MILLIS = 10000;
AtomicReference<PythonFunctionFactory> PYTHON_FUNCTION_FACTORY_REF = new AtomicReference<>();
/**
* Returns PythonFunction according to moduleName and objectName.
*
* @param moduleName The module name of the Python UDF.
* @param objectName The function name / class name of the Python UDF.
* @return The PythonFunction object which represents the Python UDF.
*/
PythonFunction getPythonFunction(String moduleName, String objectName);
/**
* Returns PythonFunction according to the fully qualified name of the Python UDF i.e
* ${moduleName}.${functionName} or ${moduleName}.${className}.
*
* @param fullyQualifiedName The fully qualified name of the Python UDF.
* @param config The configuration of python dependencies.
* @return The PythonFunction object which represents the Python UDF.
*/
static PythonFunction getPythonFunction(String fullyQualifiedName, ReadableConfig config)
throws IOException, ExecutionException, InterruptedException {
int splitIndex = fullyQualifiedName.lastIndexOf(".");
if (splitIndex <= 0) {
throw new IllegalArgumentException(
String.format("The fully qualified name is invalid: '%s'", fullyQualifiedName));
}
String moduleName = fullyQualifiedName.substring(0, splitIndex);
String objectName = fullyQualifiedName.substring(splitIndex + 1);
Configuration mergedConfig =
new Configuration(
ExecutionEnvironment.getExecutionEnvironment().getConfiguration());
mergedConfig.addAll((Configuration) config);
PythonFunctionFactory pythonFunctionFactory = getPythonFunctionFactory(mergedConfig);
return pythonFunctionFactory.getPythonFunction(moduleName, objectName);
}
static PythonFunction getPythonFunction(String fullyQualifiedName, ReadableConfig config, ClassLoader classLoader) throws ExecutionException, IOException, InterruptedException {
return getPythonFunction(fullyQualifiedName, config);
}
static PythonFunctionFactory getPythonFunctionFactory(ReadableConfig config)
throws ExecutionException, InterruptedException, IOException {
synchronized (PythonFunctionFactory.class) {
if (PYTHON_FUNCTION_FACTORY_REF.get() != null) {
return PYTHON_FUNCTION_FACTORY_REF.get();
} else {
Map<String, Object> entryPoint;
if (getGatewayServer() == null) {
GatewayServer gatewayServer = null;
Process pythonProcess = null;
try {
gatewayServer = startGatewayServer();
setGatewayServer(gatewayServer);
List<String> commands = new ArrayList<>();
commands.add("-m");
commands.add("pyflink.pyflink_callback_server");
String tmpDir =
System.getProperty("java.io.tmpdir")
+ File.separator
+ "pyflink"
+ File.separator
+ UUID.randomUUID();
pythonProcess =
launchPy4jPythonClient(
gatewayServer, config, commands, null, tmpDir, false);
entryPoint =
(Map<String, Object>) gatewayServer.getGateway().getEntryPoint();
int i = 0;
while (!entryPoint.containsKey("PythonFunctionFactory")) {
if (!pythonProcess.isAlive()) {
throw new RuntimeException("Python callback server start failed!");
}
try {
Thread.sleep(CHECK_INTERVAL);
} catch (InterruptedException e) {
throw new RuntimeException(
"Interrupted while waiting for the python process to start.",
e);
}
i++;
if (i > TIMEOUT_MILLIS / CHECK_INTERVAL) {
throw new RuntimeException("Python callback server start failed!");
}
}
} catch (Throwable e) {
try {
setGatewayServer(null);
if (gatewayServer != null) {
gatewayServer.shutdown();
}
} catch (Throwable e2) {
// ignore, do not swallow the origin exception.
}
try {
if (pythonProcess != null) {
shutdownPythonProcess(pythonProcess, TIMEOUT_MILLIS);
}
} catch (Throwable e3) {
// ignore, do not swallow the origin exception.
}
throw e;
}
Runtime.getRuntime()
.addShutdownHook(new PythonProcessShutdownHook(pythonProcess));
} else {
entryPoint =
(Map<String, Object>) getGatewayServer().getGateway().getEntryPoint();
}
PythonFunctionFactory pythonFunctionFactory =
(PythonFunctionFactory) entryPoint.get("PythonFunctionFactory");
PYTHON_FUNCTION_FACTORY_REF.set(pythonFunctionFactory);
return pythonFunctionFactory;
}
}
}
static void shutdownPythonProcess(Process pythonProcess, long timeoutMillis) {
pythonProcess.destroy();
try {
pythonProcess.waitFor(timeoutMillis, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
throw new RuntimeException(
"Interrupt while waiting for the python process to stop.", e);
}
if (pythonProcess.isAlive()) {
pythonProcess.destroyForcibly();
}
}
/**
* The shutdown hook used to destroy the Python process.
*/
class PythonProcessShutdownHook extends Thread {
private Process process;
public PythonProcessShutdownHook(Process process) {
this.process = process;
}
@Override
public void run() {
shutdownPythonProcess(process, TIMEOUT_MILLIS);
}
}
}
/*
* 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.flink.configuration;
import static org.apache.flink.configuration.ConfigurationUtils.canBePrefixMap;
import static org.apache.flink.configuration.ConfigurationUtils.containsPrefixMap;
import static org.apache.flink.configuration.ConfigurationUtils.convertToPropertiesPrefixed;
import static org.apache.flink.configuration.ConfigurationUtils.removePrefixMap;
import static org.apache.flink.util.Preconditions.checkNotNull;
import org.apache.flink.annotation.Public;
import org.apache.flink.annotation.PublicEvolving;
import org.apache.flink.api.common.ExecutionConfig;
import org.apache.flink.core.io.IOReadableWritable;
import org.apache.flink.core.memory.DataInputView;
import org.apache.flink.core.memory.DataOutputView;
import org.apache.flink.types.StringValue;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.Set;
import java.util.function.BiFunction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** Lightweight configuration object which stores key/value pairs. */
@Public
public class Configuration extends ExecutionConfig.GlobalJobParameters
implements IOReadableWritable,
java.io.Serializable,
Cloneable,
ReadableConfig,
WritableConfig {
private static final long serialVersionUID = 1L;
private static final byte TYPE_STRING = 0;
private static final byte TYPE_INT = 1;
private static final byte TYPE_LONG = 2;
private static final byte TYPE_BOOLEAN = 3;
private static final byte TYPE_FLOAT = 4;
private static final byte TYPE_DOUBLE = 5;
private static final byte TYPE_BYTES = 6;
/** The log object used for debugging. */
private static final Logger LOG = LoggerFactory.getLogger(Configuration.class);
/** Stores the concrete key/value pairs of this configuration object. */
protected final HashMap<String, Object> confData;
// --------------------------------------------------------------------------------------------
/** Creates a new empty configuration. */
public Configuration() {
this.confData = new HashMap<>();
}
/**
* Creates a new configuration with the copy of the given configuration.
*
* @param other The configuration to copy the entries from.
*/
public Configuration(Configuration other) {
this.confData = new HashMap<>(other.confData);
}
// --------------------------------------------------------------------------------------------
/** Creates a new configuration that is initialized with the options of the given map. */
public static Configuration fromMap(Map<String, String> map) {
final Configuration configuration = new Configuration();
map.forEach(configuration::setString);
return configuration;
}
// --------------------------------------------------------------------------------------------
/**
* Returns the class associated with the given key as a string.
*
* @param <T> The type of the class to return.
* @param key The key pointing to the associated value
* @param defaultValue The optional default value returned if no entry exists
* @param classLoader The class loader used to resolve the class.
* @return The value associated with the given key, or the default value, if to entry for the
* key exists.
*/
@SuppressWarnings("unchecked")
public <T> Class<T> getClass(
String key, Class<? extends T> defaultValue, ClassLoader classLoader)
throws ClassNotFoundException {
Optional<Object> o = getRawValue(key);
if (!o.isPresent()) {
return (Class<T>) defaultValue;
}
if (o.get().getClass() == String.class) {
return (Class<T>) Class.forName((String) o.get(), true, classLoader);
}
throw new IllegalArgumentException(
"Configuration cannot evaluate object of class "
+ o.get().getClass()
+ " as a class name");
}
/**
* Adds the given key/value pair to the configuration object. The class can be retrieved by
* invoking {@link #getClass(String, Class, ClassLoader)} if it is in the scope of the class
* loader on the caller.
*
* @param key The key of the pair to be added
* @param klazz The value of the pair to be added
* @see #getClass(String, Class, ClassLoader)
*/
public void setClass(String key, Class<?> klazz) {
setValueInternal(key, klazz.getName());
}
/**
* Returns the value associated with the given key as a string.
*
* @param key the key pointing to the associated value
* @param defaultValue the default value which is returned in case there is no value associated
* with the given key
* @return the (default) value associated with the given key
* @deprecated use {@link #getString(ConfigOption, String)} or {@link
* #getOptional(ConfigOption)}
*/
@Deprecated
public String getString(String key, String defaultValue) {
return getRawValue(key).map(ConfigurationUtils::convertToString).orElse(defaultValue);
}
/**
* Returns the value associated with the given config option as a string.
*
* @param configOption The configuration option
* @return the (default) value associated with the given config option
*/
@PublicEvolving
public String getString(ConfigOption<String> configOption) {
return getOptional(configOption).orElseGet(configOption::defaultValue);
}
/**
* Returns the value associated with the given config option as a string. If no value is mapped
* under any key of the option, it returns the specified default instead of the option's default
* value.
*
* @param configOption The configuration option
* @return the (default) value associated with the given config option
*/
@PublicEvolving
public String getString(ConfigOption<String> configOption, String overrideDefault) {
return getOptional(configOption).orElse(overrideDefault);
}
/**
* Adds the given key/value pair to the configuration object.
*
* @param key the key of the key/value pair to be added
* @param value the value of the key/value pair to be added
*/
public void setString(String key, String value) {
setValueInternal(key, value);
}
/**
* Adds the given value to the configuration object. The main key of the config option will be
* used to map the value.
*
* @param key the option specifying the key to be added
* @param value the value of the key/value pair to be added
*/
@PublicEvolving
public void setString(ConfigOption<String> key, String value) {
setValueInternal(key.key(), value);
}
/**
* Returns the value associated with the given key as an integer.
*
* @param key the key pointing to the associated value
* @param defaultValue the default value which is returned in case there is no value associated
* with the given key
* @return the (default) value associated with the given key
* @deprecated use {@link #getInteger(ConfigOption, int)} or {@link #getOptional(ConfigOption)}
*/
@Deprecated
public int getInteger(String key, int defaultValue) {
return getRawValue(key).map(ConfigurationUtils::convertToInt).orElse(defaultValue);
}
/**
* Returns the value associated with the given config option as an integer.
*
* @param configOption The configuration option
* @return the (default) value associated with the given config option
*/
@PublicEvolving
public int getInteger(ConfigOption<Integer> configOption) {
return getOptional(configOption).orElseGet(configOption::defaultValue);
}
/**
* Returns the value associated with the given config option as an integer. If no value is
* mapped under any key of the option, it returns the specified default instead of the option's
* default value.
*
* @param configOption The configuration option
* @param overrideDefault The value to return if no value was mapper for any key of the option
* @return the configured value associated with the given config option, or the overrideDefault
*/
@PublicEvolving
public int getInteger(ConfigOption<Integer> configOption, int overrideDefault) {
return getOptional(configOption).orElse(overrideDefault);
}
/**
* Adds the given key/value pair to the configuration object.
*
* @param key the key of the key/value pair to be added
* @param value the value of the key/value pair to be added
*/
public void setInteger(String key, int value) {
setValueInternal(key, value);
}
/**
* Adds the given value to the configuration object. The main key of the config option will be
* used to map the value.
*
* @param key the option specifying the key to be added
* @param value the value of the key/value pair to be added
*/
@PublicEvolving
public void setInteger(ConfigOption<Integer> key, int value) {
setValueInternal(key.key(), value);
}
/**
* Returns the value associated with the given key as a long.
*
* @param key the key pointing to the associated value
* @param defaultValue the default value which is returned in case there is no value associated
* with the given key
* @return the (default) value associated with the given key
* @deprecated use {@link #getLong(ConfigOption, long)} or {@link #getOptional(ConfigOption)}
*/
@Deprecated
public long getLong(String key, long defaultValue) {
return getRawValue(key).map(ConfigurationUtils::convertToLong).orElse(defaultValue);
}
/**
* Returns the value associated with the given config option as a long integer.
*
* @param configOption The configuration option
* @return the (default) value associated with the given config option
*/
@PublicEvolving
public long getLong(ConfigOption<Long> configOption) {
return getOptional(configOption).orElseGet(configOption::defaultValue);
}
/**
* Returns the value associated with the given config option as a long integer. If no value is
* mapped under any key of the option, it returns the specified default instead of the option's
* default value.
*
* @param configOption The configuration option
* @param overrideDefault The value to return if no value was mapper for any key of the option
* @return the configured value associated with the given config option, or the overrideDefault
*/
@PublicEvolving
public long getLong(ConfigOption<Long> configOption, long overrideDefault) {
return getOptional(configOption).orElse(overrideDefault);
}
/**
* Adds the given key/value pair to the configuration object.
*
* @param key the key of the key/value pair to be added
* @param value the value of the key/value pair to be added
*/
public void setLong(String key, long value) {
setValueInternal(key, value);
}
/**
* Adds the given value to the configuration object. The main key of the config option will be
* used to map the value.
*
* @param key the option specifying the key to be added
* @param value the value of the key/value pair to be added
*/
@PublicEvolving
public void setLong(ConfigOption<Long> key, long value) {
setValueInternal(key.key(), value);
}
/**
* Returns the value associated with the given key as a boolean.
*
* @param key the key pointing to the associated value
* @param defaultValue the default value which is returned in case there is no value associated
* with the given key
* @return the (default) value associated with the given key
* @deprecated use {@link #getBoolean(ConfigOption, boolean)} or {@link
* #getOptional(ConfigOption)}
*/
@Deprecated
public boolean getBoolean(String key, boolean defaultValue) {
return getRawValue(key).map(ConfigurationUtils::convertToBoolean).orElse(defaultValue);
}
/**
* Returns the value associated with the given config option as a boolean.
*
* @param configOption The configuration option
* @return the (default) value associated with the given config option
*/
@PublicEvolving
public boolean getBoolean(ConfigOption<Boolean> configOption) {
return getOptional(configOption).orElseGet(configOption::defaultValue);
}
/**
* Returns the value associated with the given config option as a boolean. If no value is mapped
* under any key of the option, it returns the specified default instead of the option's default
* value.
*
* @param configOption The configuration option
* @param overrideDefault The value to return if no value was mapper for any key of the option
* @return the configured value associated with the given config option, or the overrideDefault
*/
@PublicEvolving
public boolean getBoolean(ConfigOption<Boolean> configOption, boolean overrideDefault) {
return getOptional(configOption).orElse(overrideDefault);
}
/**
* Adds the given key/value pair to the configuration object.
*
* @param key the key of the key/value pair to be added
* @param value the value of the key/value pair to be added
*/
public void setBoolean(String key, boolean value) {
setValueInternal(key, value);
}
/**
* Adds the given value to the configuration object. The main key of the config option will be
* used to map the value.
*
* @param key the option specifying the key to be added
* @param value the value of the key/value pair to be added
*/
@PublicEvolving
public void setBoolean(ConfigOption<Boolean> key, boolean value) {
setValueInternal(key.key(), value);
}
/**
* Returns the value associated with the given key as a float.
*
* @param key the key pointing to the associated value
* @param defaultValue the default value which is returned in case there is no value associated
* with the given key
* @return the (default) value associated with the given key
* @deprecated use {@link #getFloat(ConfigOption, float)} or {@link #getOptional(ConfigOption)}
*/
@Deprecated
public float getFloat(String key, float defaultValue) {
return getRawValue(key).map(ConfigurationUtils::convertToFloat).orElse(defaultValue);
}
/**
* Returns the value associated with the given config option as a float.
*
* @param configOption The configuration option
* @return the (default) value associated with the given config option
*/
@PublicEvolving
public float getFloat(ConfigOption<Float> configOption) {
return getOptional(configOption).orElseGet(configOption::defaultValue);
}
/**
* Returns the value associated with the given config option as a float. If no value is mapped
* under any key of the option, it returns the specified default instead of the option's default
* value.
*
* @param configOption The configuration option
* @param overrideDefault The value to return if no value was mapper for any key of the option
* @return the configured value associated with the given config option, or the overrideDefault
*/
@PublicEvolving
public float getFloat(ConfigOption<Float> configOption, float overrideDefault) {
return getOptional(configOption).orElse(overrideDefault);
}
/**
* Adds the given key/value pair to the configuration object.
*
* @param key the key of the key/value pair to be added
* @param value the value of the key/value pair to be added
*/
public void setFloat(String key, float value) {
setValueInternal(key, value);
}
/**
* Adds the given value to the configuration object. The main key of the config option will be
* used to map the value.
*
* @param key the option specifying the key to be added
* @param value the value of the key/value pair to be added
*/
@PublicEvolving
public void setFloat(ConfigOption<Float> key, float value) {
setValueInternal(key.key(), value);
}
/**
* Returns the value associated with the given key as a double.
*
* @param key the key pointing to the associated value
* @param defaultValue the default value which is returned in case there is no value associated
* with the given key
* @return the (default) value associated with the given key
* @deprecated use {@link #getDouble(ConfigOption, double)} or {@link
* #getOptional(ConfigOption)}
*/
@Deprecated
public double getDouble(String key, double defaultValue) {
return getRawValue(key).map(ConfigurationUtils::convertToDouble).orElse(defaultValue);
}
/**
* Returns the value associated with the given config option as a {@code double}.
*
* @param configOption The configuration option
* @return the (default) value associated with the given config option
*/
@PublicEvolving
public double getDouble(ConfigOption<Double> configOption) {
return getOptional(configOption).orElseGet(configOption::defaultValue);
}
/**
* Returns the value associated with the given config option as a {@code double}. If no value is
* mapped under any key of the option, it returns the specified default instead of the option's
* default value.
*
* @param configOption The configuration option
* @param overrideDefault The value to return if no value was mapper for any key of the option
* @return the configured value associated with the given config option, or the overrideDefault
*/
@PublicEvolving
public double getDouble(ConfigOption<Double> configOption, double overrideDefault) {
return getOptional(configOption).orElse(overrideDefault);
}
/**
* Adds the given key/value pair to the configuration object.
*
* @param key the key of the key/value pair to be added
* @param value the value of the key/value pair to be added
*/
public void setDouble(String key, double value) {
setValueInternal(key, value);
}
/**
* Adds the given value to the configuration object. The main key of the config option will be
* used to map the value.
*
* @param key the option specifying the key to be added
* @param value the value of the key/value pair to be added
*/
@PublicEvolving
public void setDouble(ConfigOption<Double> key, double value) {
setValueInternal(key.key(), value);
}
/**
* Returns the value associated with the given key as a byte array.
*
* @param key The key pointing to the associated value.
* @param defaultValue The default value which is returned in case there is no value associated
* with the given key.
* @return the (default) value associated with the given key.
*/
public byte[] getBytes(String key, byte[] defaultValue) {
return getRawValue(key)
.map(
o -> {
if (o.getClass().equals(byte[].class)) {
return (byte[]) o;
} else {
throw new IllegalArgumentException(
String.format(
"Configuration cannot evaluate value %s as a byte[] value",
o));
}
})
.orElse(defaultValue);
}
/**
* Adds the given byte array to the configuration object. If key is <code>null</code> then
* nothing is added.
*
* @param key The key under which the bytes are added.
* @param bytes The bytes to be added.
*/
public void setBytes(String key, byte[] bytes) {
setValueInternal(key, bytes);
}
/**
* Returns the value associated with the given config option as a string.
*
* @param configOption The configuration option
* @return the (default) value associated with the given config option
*/
@PublicEvolving
public String getValue(ConfigOption<?> configOption) {
return Optional.ofNullable(
getRawValueFromOption(configOption).orElseGet(configOption::defaultValue))
.map(String::valueOf)
.orElse(null);
}
/**
* Returns the value associated with the given config option as an enum.
*
* @param enumClass The return enum class
* @param configOption The configuration option
* @throws IllegalArgumentException If the string associated with the given config option cannot
* be parsed as a value of the provided enum class.
*/
@PublicEvolving
public <T extends Enum<T>> T getEnum(
final Class<T> enumClass, final ConfigOption<String> configOption) {
checkNotNull(enumClass, "enumClass must not be null");
checkNotNull(configOption, "configOption must not be null");
Object rawValue = getRawValueFromOption(configOption).orElseGet(configOption::defaultValue);
try {
return ConfigurationUtils.convertToEnum(rawValue, enumClass);
} catch (IllegalArgumentException ex) {
final String errorMessage =
String.format(
"Value for config option %s must be one of %s (was %s)",
configOption.key(),
Arrays.toString(enumClass.getEnumConstants()),
rawValue);
throw new IllegalArgumentException(errorMessage);
}
}
// --------------------------------------------------------------------------------------------
/**
* Returns the keys of all key/value pairs stored inside this configuration object.
*
* @return the keys of all key/value pairs stored inside this configuration object
*/
public Set<String> keySet() {
synchronized (this.confData) {
return new HashSet<>(this.confData.keySet());
}
}
/** Adds all entries in this {@code Configuration} to the given {@link Properties}. */
public void addAllToProperties(Properties props) {
synchronized (this.confData) {
for (Map.Entry<String, Object> entry : this.confData.entrySet()) {
props.put(entry.getKey(), entry.getValue());
}
}
}
public void addAll(Configuration other) {
synchronized (this.confData) {
synchronized (other.confData) {
this.confData.putAll(other.confData);
}
}
}
/**
* Adds all entries from the given configuration into this configuration. The keys are prepended
* with the given prefix.
*
* @param other The configuration whose entries are added to this configuration.
* @param prefix The prefix to prepend.
*/
public void addAll(Configuration other, String prefix) {
final StringBuilder bld = new StringBuilder();
bld.append(prefix);
final int pl = bld.length();
synchronized (this.confData) {
synchronized (other.confData) {
for (Map.Entry<String, Object> entry : other.confData.entrySet()) {
bld.setLength(pl);
bld.append(entry.getKey());
this.confData.put(bld.toString(), entry.getValue());
}
}
}
}
@Override
public Configuration clone() {
Configuration config = new Configuration();
config.addAll(this);
return config;
}
/**
* Checks whether there is an entry with the specified key.
*
* @param key key of entry
* @return true if the key is stored, false otherwise
*/
public boolean containsKey(String key) {
synchronized (this.confData) {
return this.confData.containsKey(key);
}
}
/**
* Checks whether there is an entry for the given config option.
*
* @param configOption The configuration option
* @return <tt>true</tt> if a valid (current or deprecated) key of the config option is stored,
* <tt>false</tt> otherwise
*/
@PublicEvolving
public boolean contains(ConfigOption<?> configOption) {
synchronized (this.confData) {
final BiFunction<String, Boolean, Optional<Boolean>> applier =
(key, canBePrefixMap) -> {
if (canBePrefixMap && containsPrefixMap(this.confData, key)
|| this.confData.containsKey(key)) {
return Optional.of(true);
}
return Optional.empty();
};
return applyWithOption(configOption, applier).orElse(false);
}
}
private <T> Optional<T> applyWithOption(
ConfigOption<?> option, BiFunction<String, Boolean, Optional<T>> applier) {
final boolean canBePrefixMap = canBePrefixMap(option);
final Optional<T> valueFromExactKey = applier.apply(option.key(), canBePrefixMap);
if (valueFromExactKey.isPresent()) {
return valueFromExactKey;
} else if (option.hasFallbackKeys()) {
// try the fallback keys
for (FallbackKey fallbackKey : option.fallbackKeys()) {
final Optional<T> valueFromFallbackKey =
applier.apply(fallbackKey.getKey(), canBePrefixMap);
if (valueFromFallbackKey.isPresent()) {
loggingFallback(fallbackKey, option);
return valueFromFallbackKey;
}
}
}
return Optional.empty();
}
@Override
public <T> T get(ConfigOption<T> option) {
return getOptional(option).orElseGet(option::defaultValue);
}
@Override
public <T> Optional<T> getOptional(ConfigOption<T> option) {
Optional<Object> rawValue = getRawValueFromOption(option);
Class<?> clazz = option.getClazz();
try {
if (option.isList()) {
return rawValue.map(v -> ConfigurationUtils.convertToList(v, clazz));
} else {
return rawValue.map(v -> ConfigurationUtils.convertValue(v, clazz));
}
} catch (Exception e) {
throw new IllegalArgumentException(
String.format(
"Could not parse value '%s' for key '%s'.",
rawValue.map(Object::toString).orElse(""), option.key()),
e);
}
}
@Override
public <T> Configuration set(ConfigOption<T> option, T value) {
final boolean canBePrefixMap = canBePrefixMap(option);
setValueInternal(option.key(), value, canBePrefixMap);
return this;
}
// --------------------------------------------------------------------------------------------
@Override
public Map<String, String> toMap() {
synchronized (this.confData) {
Map<String, String> ret = new HashMap<>(this.confData.size());
for (Map.Entry<String, Object> entry : confData.entrySet()) {
ret.put(entry.getKey(), ConfigurationUtils.convertToString(entry.getValue()));
}
return ret;
}
}
/**
* Removes given config option from the configuration.
*
* @param configOption config option to remove
* @param <T> Type of the config option
* @return true is config has been removed, false otherwise
*/
public <T> boolean removeConfig(ConfigOption<T> configOption) {
synchronized (this.confData) {
final BiFunction<String, Boolean, Optional<Boolean>> applier =
(key, canBePrefixMap) -> {
if (canBePrefixMap && removePrefixMap(this.confData, key)
|| this.confData.remove(key) != null) {
return Optional.of(true);
}
return Optional.empty();
};
return applyWithOption(configOption, applier).orElse(false);
}
}
// --------------------------------------------------------------------------------------------
<T> void setValueInternal(String key, T value, boolean canBePrefixMap) {
if (key == null) {
throw new NullPointerException("Key must not be null.");
}
if (value == null) {
throw new NullPointerException("Value must not be null.");
}
synchronized (this.confData) {
if (canBePrefixMap) {
removePrefixMap(this.confData, key);
}
this.confData.put(key, value);
}
}
private <T> void setValueInternal(String key, T value) {
setValueInternal(key, value, false);
}
private Optional<Object> getRawValue(String key) {
return getRawValue(key, false);
}
private Optional<Object> getRawValue(String key, boolean canBePrefixMap) {
if (key == null) {
throw new NullPointerException("Key must not be null.");
}
synchronized (this.confData) {
final Object valueFromExactKey = this.confData.get(key);
if (!canBePrefixMap || valueFromExactKey != null) {
return Optional.ofNullable(valueFromExactKey);
}
final Map<String, String> valueFromPrefixMap =
convertToPropertiesPrefixed(confData, key);
if (valueFromPrefixMap.isEmpty()) {
return Optional.empty();
}
return Optional.of(valueFromPrefixMap);
}
}
private Optional<Object> getRawValueFromOption(ConfigOption<?> configOption) {
return applyWithOption(configOption, this::getRawValue);
}
private void loggingFallback(FallbackKey fallbackKey, ConfigOption<?> configOption) {
if (fallbackKey.isDeprecated()) {
LOG.warn(
"Config uses deprecated configuration key '{}' instead of proper key '{}'",
fallbackKey.getKey(),
configOption.key());
} else {
LOG.info(
"Config uses fallback configuration key '{}' instead of key '{}'",
fallbackKey.getKey(),
configOption.key());
}
}
// --------------------------------------------------------------------------------------------
// Serialization
// --------------------------------------------------------------------------------------------
@Override
public void read(DataInputView in) throws IOException {
synchronized (this.confData) {
final int numberOfProperties = in.readInt();
for (int i = 0; i < numberOfProperties; i++) {
String key = StringValue.readString(in);
Object value;
byte type = in.readByte();
switch (type) {
case TYPE_STRING:
value = StringValue.readString(in);
break;
case TYPE_INT:
value = in.readInt();
break;
case TYPE_LONG:
value = in.readLong();
break;
case TYPE_FLOAT:
value = in.readFloat();
break;
case TYPE_DOUBLE:
value = in.readDouble();
break;
case TYPE_BOOLEAN:
value = in.readBoolean();
break;
case TYPE_BYTES:
byte[] bytes = new byte[in.readInt()];
in.readFully(bytes);
value = bytes;
break;
default:
throw new IOException(
String.format(
"Unrecognized type: %s. This method is deprecated and"
+ " might not work for all supported types.",
type));
}
this.confData.put(key, value);
}
}
}
@Override
public void write(final DataOutputView out) throws IOException {
synchronized (this.confData) {
out.writeInt(this.confData.size());
for (Map.Entry<String, Object> entry : this.confData.entrySet()) {
String key = entry.getKey();
Object val = entry.getValue();
StringValue.writeString(key, out);
Class<?> clazz = val.getClass();
if (clazz == String.class) {
out.write(TYPE_STRING);
StringValue.writeString((String) val, out);
} else if (clazz == Integer.class) {
out.write(TYPE_INT);
out.writeInt((Integer) val);
} else if (clazz == Long.class) {
out.write(TYPE_LONG);
out.writeLong((Long) val);
} else if (clazz == Float.class) {
out.write(TYPE_FLOAT);
out.writeFloat((Float) val);
} else if (clazz == Double.class) {
out.write(TYPE_DOUBLE);
out.writeDouble((Double) val);
} else if (clazz == byte[].class) {
out.write(TYPE_BYTES);
byte[] bytes = (byte[]) val;
out.writeInt(bytes.length);
out.write(bytes);
} else if (clazz == Boolean.class) {
out.write(TYPE_BOOLEAN);
out.writeBoolean((Boolean) val);
} else {
throw new IllegalArgumentException(
"Unrecognized type. This method is deprecated and might not work"
+ " for all supported types.");
}
}
}
}
// --------------------------------------------------------------------------------------------
@Override
public int hashCode() {
int hash = 0;
for (String s : this.confData.keySet()) {
hash ^= s.hashCode();
}
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
} else if (obj instanceof Configuration) {
Map<String, Object> otherConf = ((Configuration) obj).confData;
for (Map.Entry<String, Object> e : this.confData.entrySet()) {
Object thisVal = e.getValue();
Object otherVal = otherConf.get(e.getKey());
if (!thisVal.getClass().equals(byte[].class)) {
if (!thisVal.equals(otherVal)) {
return false;
}
} else if (otherVal.getClass().equals(byte[].class)) {
if (!Arrays.equals((byte[]) thisVal, (byte[]) otherVal)) {
return false;
}
} else {
return false;
}
}
return true;
} else {
return false;
}
}
@Override
public String toString() {
return this.confData.toString();
}
}
/*
* 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.flink.configuration;
import static org.apache.flink.configuration.MetricOptions.SYSTEM_RESOURCE_METRICS;
import static org.apache.flink.configuration.MetricOptions.SYSTEM_RESOURCE_METRICS_PROBING_INTERVAL;
import static org.apache.flink.configuration.StructuredOptionsSplitter.escapeWithSingleQuote;
import static org.apache.flink.util.Preconditions.checkArgument;
import org.apache.flink.annotation.VisibleForTesting;
import org.apache.flink.api.common.time.Time;
import org.apache.flink.util.Preconditions;
import org.apache.flink.util.TimeUtils;
import java.io.File;
import java.time.Duration;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
/**
* Utility class for {@link Configuration} related helper functions.
*/
public class ConfigurationUtils {
private static final String[] EMPTY = new String[0];
/**
* @return extracted {@link MetricOptions#SYSTEM_RESOURCE_METRICS_PROBING_INTERVAL} or {@code
* Optional.empty()} if {@link MetricOptions#SYSTEM_RESOURCE_METRICS} are disabled.
*/
public static Optional<Time> getSystemResourceMetricsProbingInterval(
Configuration configuration) {
if (!configuration.getBoolean(SYSTEM_RESOURCE_METRICS)) {
return Optional.empty();
} else {
return Optional.of(
Time.milliseconds(
configuration.getLong(SYSTEM_RESOURCE_METRICS_PROBING_INTERVAL)));
}
}
/**
* Extracts the task manager directories for temporary files as defined by {@link
* org.apache.flink.configuration.CoreOptions#TMP_DIRS}.
*
* @param configuration configuration object
* @return array of configured directories (in order)
*/
@Nonnull
public static String[] parseTempDirectories(Configuration configuration) {
return splitPaths(configuration.getString(CoreOptions.TMP_DIRS));
}
/**
* Picks a temporary directory randomly from the given configuration.
*
* @param configuration to extract the temp directory from
* @return a randomly picked temporary directory
*/
@Nonnull
public static File getRandomTempDirectory(Configuration configuration) {
final String[] tmpDirectories = parseTempDirectories(configuration);
Preconditions.checkState(
tmpDirectories.length > 0,
String.format(
"No temporary directory has been specified for %s",
CoreOptions.TMP_DIRS.key()));
final int randomIndex = ThreadLocalRandom.current().nextInt(tmpDirectories.length);
return new File(tmpDirectories[randomIndex]);
}
/**
* Extracts the local state directories as defined by {@link
* CheckpointingOptions#LOCAL_RECOVERY_TASK_MANAGER_STATE_ROOT_DIRS}.
*
* @param configuration configuration object
* @return array of configured directories (in order)
*/
@Nonnull
public static String[] parseLocalStateDirectories(Configuration configuration) {
String configValue =
configuration.getString(
CheckpointingOptions.LOCAL_RECOVERY_TASK_MANAGER_STATE_ROOT_DIRS, "");
return splitPaths(configValue);
}
/**
* Parses a string as a map of strings. The expected format of the map is:
*
* <pre>
* key1:value1,key2:value2
* </pre>
*
* <p>Parts of the string can be escaped by wrapping with single or double quotes.
*
* @param stringSerializedMap a string to parse
* @return parsed map
*/
public static Map<String, String> parseMap(String stringSerializedMap) {
return StructuredOptionsSplitter.splitEscaped(stringSerializedMap, ',').stream()
.map(p -> StructuredOptionsSplitter.splitEscaped(p, ':'))
.collect(
Collectors.toMap(
arr -> arr.get(0), // key name
arr -> arr.get(1) // value
));
}
public static Time getStandaloneClusterStartupPeriodTime(Configuration configuration) {
final Time timeout;
long standaloneClusterStartupPeriodTime =
configuration.getLong(
ResourceManagerOptions.STANDALONE_CLUSTER_STARTUP_PERIOD_TIME);
if (standaloneClusterStartupPeriodTime >= 0) {
timeout = Time.milliseconds(standaloneClusterStartupPeriodTime);
} else {
timeout =
Time.milliseconds(
configuration.getLong(JobManagerOptions.SLOT_REQUEST_TIMEOUT));
}
return timeout;
}
/**
* Creates a new {@link Configuration} from the given {@link Properties}.
*
* @param properties to convert into a {@link Configuration}
* @return {@link Configuration} which has been populated by the values of the given {@link
* Properties}
*/
@Nonnull
public static Configuration createConfiguration(Properties properties) {
final Configuration configuration = new Configuration();
final Set<String> propertyNames = properties.stringPropertyNames();
for (String propertyName : propertyNames) {
configuration.setString(propertyName, properties.getProperty(propertyName));
}
return configuration;
}
/**
* Replaces values whose keys are sensitive according to {@link
* GlobalConfiguration#isSensitive(String)} with {@link GlobalConfiguration#HIDDEN_CONTENT}.
*
* <p>This can be useful when displaying configuration values.
*
* @param keyValuePairs for which to hide sensitive values
* @return A map where all sensitive value are hidden
*/
@Nonnull
public static Map<String, String> hideSensitiveValues(Map<String, String> keyValuePairs) {
final HashMap<String, String> result = new HashMap<>();
for (Map.Entry<String, String> keyValuePair : keyValuePairs.entrySet()) {
if (GlobalConfiguration.isSensitive(keyValuePair.getKey())) {
result.put(keyValuePair.getKey(), GlobalConfiguration.HIDDEN_CONTENT);
} else {
result.put(keyValuePair.getKey(), keyValuePair.getValue());
}
}
return result;
}
@Nonnull
public static String[] splitPaths(@Nonnull String separatedPaths) {
return separatedPaths.length() > 0
? separatedPaths.split(",|" + File.pathSeparator)
: EMPTY;
}
/**
* Creates a dynamic parameter list {@code String} of the passed configuration map.
*
* @param config A {@code Map} containing parameter/value entries that shall be used in the
* dynamic parameter list.
* @return The dynamic parameter list {@code String}.
*/
public static String assembleDynamicConfigsStr(final Map<String, String> config) {
return config.entrySet().stream()
.map(e -> String.format("-D %s=%s", e.getKey(), e.getValue()))
.collect(Collectors.joining(" "));
}
@VisibleForTesting
public static Map<String, String> parseTmResourceDynamicConfigs(String dynamicConfigsStr) {
Map<String, String> configs = new HashMap<>();
String[] configStrs = dynamicConfigsStr.split(" ");
checkArgument(
configStrs.length % 2 == 0,
"Dynamic option string contained odd number of arguments: #arguments=%s, (%s)",
configStrs.length,
dynamicConfigsStr);
for (int i = 0; i < configStrs.length; ++i) {
String configStr = configStrs[i];
if (i % 2 == 0) {
checkArgument(configStr.equals("-D"));
} else {
String[] configKV = configStr.split("=");
checkArgument(configKV.length == 2);
configs.put(configKV[0], configKV[1]);
}
}
checkConfigContains(configs, TaskManagerOptions.CPU_CORES.key());
checkConfigContains(configs, TaskManagerOptions.FRAMEWORK_HEAP_MEMORY.key());
checkConfigContains(configs, TaskManagerOptions.FRAMEWORK_OFF_HEAP_MEMORY.key());
checkConfigContains(configs, TaskManagerOptions.TASK_HEAP_MEMORY.key());
checkConfigContains(configs, TaskManagerOptions.TASK_OFF_HEAP_MEMORY.key());
checkConfigContains(configs, TaskManagerOptions.NETWORK_MEMORY_MAX.key());
checkConfigContains(configs, TaskManagerOptions.NETWORK_MEMORY_MIN.key());
checkConfigContains(configs, TaskManagerOptions.MANAGED_MEMORY_SIZE.key());
checkConfigContains(configs, TaskManagerOptions.JVM_METASPACE.key());
checkConfigContains(configs, TaskManagerOptions.JVM_OVERHEAD_MIN.key());
checkConfigContains(configs, TaskManagerOptions.JVM_OVERHEAD_MAX.key());
checkConfigContains(configs, TaskManagerOptions.NUM_TASK_SLOTS.key());
return configs;
}
private static void checkConfigContains(Map<String, String> configs, String key) {
checkArgument(
configs.containsKey(key), "Key %s is missing present from dynamic configs.", key);
}
@VisibleForTesting
public static Map<String, String> parseJvmArgString(String jvmParamsStr) {
final String xmx = "-Xmx";
final String xms = "-Xms";
final String maxDirect = "-XX:MaxDirectMemorySize=";
final String maxMetadata = "-XX:MaxMetaspaceSize=";
Map<String, String> configs = new HashMap<>();
for (String paramStr : jvmParamsStr.split(" ")) {
if (paramStr.startsWith(xmx)) {
configs.put(xmx, paramStr.substring(xmx.length()));
} else if (paramStr.startsWith(xms)) {
configs.put(xms, paramStr.substring(xms.length()));
} else if (paramStr.startsWith(maxDirect)) {
configs.put(maxDirect, paramStr.substring(maxDirect.length()));
} else if (paramStr.startsWith(maxMetadata)) {
configs.put(maxMetadata, paramStr.substring(maxMetadata.length()));
}
}
checkArgument(configs.containsKey(xmx));
checkArgument(configs.containsKey(xms));
checkArgument(configs.containsKey(maxMetadata));
return configs;
}
/**
* Extract and parse Flink configuration properties with a given name prefix and return the
* result as a Map.
*/
public static Map<String, String> getPrefixedKeyValuePairs(
String prefix, Configuration configuration) {
Map<String, String> result = new HashMap<>();
for (Map.Entry<String, String> entry : configuration.toMap().entrySet()) {
if (entry.getKey().startsWith(prefix) && entry.getKey().length() > prefix.length()) {
String key = entry.getKey().substring(prefix.length());
result.put(key, entry.getValue());
}
}
return result;
}
// --------------------------------------------------------------------------------------------
// Type conversion
// --------------------------------------------------------------------------------------------
/**
* Tries to convert the raw value into the provided type.
*
* @param rawValue rawValue to convert into the provided type clazz
* @param clazz clazz specifying the target type
* @param <T> type of the result
* @return the converted value if rawValue is of type clazz
* @throws IllegalArgumentException if the rawValue cannot be converted in the specified target
* type clazz
*/
@SuppressWarnings("unchecked")
public static <T> T convertValue(Object rawValue, Class<?> clazz) {
if (Integer.class.equals(clazz)) {
return (T) convertToInt(rawValue);
} else if (Long.class.equals(clazz)) {
return (T) convertToLong(rawValue);
} else if (Boolean.class.equals(clazz)) {
return (T) convertToBoolean(rawValue);
} else if (Float.class.equals(clazz)) {
return (T) convertToFloat(rawValue);
} else if (Double.class.equals(clazz)) {
return (T) convertToDouble(rawValue);
} else if (String.class.equals(clazz)) {
return (T) convertToString(rawValue);
} else if (clazz.isEnum()) {
return (T) convertToEnum(rawValue, (Class<? extends Enum<?>>) clazz);
} else if (clazz == Duration.class) {
return (T) convertToDuration(rawValue);
} else if (clazz == MemorySize.class) {
return (T) convertToMemorySize(rawValue);
} else if (clazz == Map.class) {
return (T) convertToProperties(rawValue);
}
throw new IllegalArgumentException("Unsupported type: " + clazz);
}
@SuppressWarnings("unchecked")
static <T> T convertToList(Object rawValue, Class<?> atomicClass) {
if (rawValue instanceof List) {
return (T) rawValue;
} else {
return (T)
StructuredOptionsSplitter.splitEscaped(rawValue.toString(), ';').stream()
.map(s -> convertValue(s, atomicClass))
.collect(Collectors.toList());
}
}
@SuppressWarnings("unchecked")
static Map<String, String> convertToProperties(Object o) {
if (o instanceof Map) {
return (Map<String, String>) o;
} else {
List<String> listOfRawProperties =
StructuredOptionsSplitter.splitEscaped(o.toString(), ',');
return listOfRawProperties.stream()
.map(s -> StructuredOptionsSplitter.splitEscaped(s, ':'))
.peek(
pair -> {
if (pair.size() != 2) {
throw new IllegalArgumentException(
"Could not parse pair in the map " + pair);
}
})
.collect(Collectors.toMap(a -> a.get(0), a -> a.get(1)));
}
}
@SuppressWarnings("unchecked")
public static <E extends Enum<?>> E convertToEnum(Object o, Class<E> clazz) {
if (o.getClass().equals(clazz)) {
return (E) o;
}
return Arrays.stream(clazz.getEnumConstants())
.filter(
e ->
e.toString()
.toUpperCase(Locale.ROOT)
.equals(o.toString().toUpperCase(Locale.ROOT)))
.findAny()
.orElseThrow(
() ->
new IllegalArgumentException(
String.format(
"Could not parse value for enum %s. Expected one of: [%s]",
clazz, Arrays.toString(clazz.getEnumConstants()))));
}
static Duration convertToDuration(Object o) {
if (o.getClass() == Duration.class) {
return (Duration) o;
}
return TimeUtils.parseDuration(o.toString());
}
static MemorySize convertToMemorySize(Object o) {
if (o.getClass() == MemorySize.class) {
return (MemorySize) o;
}
return MemorySize.parse(o.toString());
}
static String convertToString(Object o) {
if (o.getClass() == String.class) {
return (String) o;
} else if (o.getClass() == Duration.class) {
Duration duration = (Duration) o;
return TimeUtils.formatWithHighestUnit(duration);
} else if (o instanceof List) {
return ((List<?>) o)
.stream()
.map(e -> escapeWithSingleQuote(convertToString(e), ";"))
.collect(Collectors.joining(";"));
} else if (o instanceof Map) {
return ((Map<?, ?>) o)
.entrySet().stream()
.map(
e -> {
String escapedKey =
escapeWithSingleQuote(e.getKey().toString(), ":");
String escapedValue =
escapeWithSingleQuote(e.getValue().toString(), ":");
return escapeWithSingleQuote(
escapedKey + ":" + escapedValue, ",");
})
.collect(Collectors.joining(","));
}
return o.toString();
}
static Integer convertToInt(Object o) {
if (o.getClass() == Integer.class) {
return (Integer) o;
} else if (o.getClass() == Long.class) {
long value = (Long) o;
if (value <= Integer.MAX_VALUE && value >= Integer.MIN_VALUE) {
return (int) value;
} else {
throw new IllegalArgumentException(
String.format(
"Configuration value %s overflows/underflows the integer type.",
value));
}
}
return Integer.parseInt(o.toString());
}
static Long convertToLong(Object o) {
if (o.getClass() == Long.class) {
return (Long) o;
} else if (o.getClass() == Integer.class) {
return ((Integer) o).longValue();
}
return Long.parseLong(o.toString());
}
static Boolean convertToBoolean(Object o) {
if (o.getClass() == Boolean.class) {
return (Boolean) o;
}
switch (o.toString().toUpperCase()) {
case "TRUE":
return true;
case "FALSE":
return false;
default:
throw new IllegalArgumentException(
String.format(
"Unrecognized option for boolean: %s. Expected either true or false(case insensitive)",
o));
}
}
static Float convertToFloat(Object o) {
if (o.getClass() == Float.class) {
return (Float) o;
} else if (o.getClass() == Double.class) {
double value = ((Double) o);
if (value == 0.0
|| (value >= Float.MIN_VALUE && value <= Float.MAX_VALUE)
|| (value >= -Float.MAX_VALUE && value <= -Float.MIN_VALUE)) {
return (float) value;
} else {
throw new IllegalArgumentException(
String.format(
"Configuration value %s overflows/underflows the float type.",
value));
}
}
return Float.parseFloat(o.toString());
}
static Double convertToDouble(Object o) {
if (o.getClass() == Double.class) {
return (Double) o;
} else if (o.getClass() == Float.class) {
return ((Float) o).doubleValue();
}
return Double.parseDouble(o.toString());
}
// --------------------------------------------------------------------------------------------
// Prefix map handling
// --------------------------------------------------------------------------------------------
/**
* Maps can be represented in two ways.
*
* <p>With constant key space:
*
* <pre>
* avro-confluent.properties = schema: 1, other-prop: 2
* </pre>
*
* <p>Or with variable key space (i.e. prefix notation):
*
* <pre>
* avro-confluent.properties.schema = 1
* avro-confluent.properties.other-prop = 2
* </pre>
*/
public static boolean canBePrefixMap(ConfigOption<?> configOption) {
return configOption.getClazz() == Map.class && !configOption.isList();
}
/**
* Filter condition for prefix map keys.
*/
public static boolean filterPrefixMapKey(String key, String candidate) {
final String prefixKey = key + ".";
return candidate.startsWith(prefixKey);
}
static Map<String, String> convertToPropertiesPrefixed(
Map<String, Object> confData, String key) {
final String prefixKey = key + ".";
return confData.keySet().stream()
.filter(k -> k.startsWith(prefixKey))
.collect(
Collectors.toMap(
k -> k.substring(prefixKey.length()),
k -> convertToString(confData.get(k))));
}
static boolean containsPrefixMap(Map<String, Object> confData, String key) {
return confData.keySet().stream().anyMatch(candidate -> filterPrefixMapKey(key, candidate));
}
static boolean removePrefixMap(Map<String, Object> confData, String key) {
final List<String> prefixKeys =
confData.keySet().stream()
.filter(candidate -> filterPrefixMapKey(key, candidate))
.collect(Collectors.toList());
prefixKeys.forEach(confData::remove);
return !prefixKeys.isEmpty();
}
// Make sure that we cannot instantiate this class
private ConfigurationUtils() {
}
}
......@@ -38,7 +38,6 @@
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
......
/*
* 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.flink.client.python;
import static org.apache.flink.client.python.PythonEnvUtils.getGatewayServer;
import static org.apache.flink.client.python.PythonEnvUtils.launchPy4jPythonClient;
import static org.apache.flink.client.python.PythonEnvUtils.setGatewayServer;
import static org.apache.flink.client.python.PythonEnvUtils.startGatewayServer;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.python.shaded.py4j.GatewayServer;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.ReadableConfig;
import org.apache.flink.python.util.PythonDependencyUtils;
import org.apache.flink.table.functions.python.PythonFunction;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
/**
* The factory which creates the PythonFunction objects from given module name and object name.
*/
public interface PythonFunctionFactory {
long CHECK_INTERVAL = 100;
long TIMEOUT_MILLIS = 10000;
AtomicReference<PythonFunctionFactory> PYTHON_FUNCTION_FACTORY_REF = new AtomicReference<>();
/**
* Returns PythonFunction according to moduleName and objectName.
*
* @param moduleName The module name of the Python UDF.
* @param objectName The function name / class name of the Python UDF.
* @return The PythonFunction object which represents the Python UDF.
*/
PythonFunction getPythonFunction(String moduleName, String objectName);
/**
* Returns PythonFunction according to the fully qualified name of the Python UDF i.e
* ${moduleName}.${functionName} or ${moduleName}.${className}.
*
* @param fullyQualifiedName The fully qualified name of the Python UDF.
* @param config The configuration of python dependencies.
* @return The PythonFunction object which represents the Python UDF.
*/
static PythonFunction getPythonFunction(String fullyQualifiedName, ReadableConfig config)
throws IOException, ExecutionException, InterruptedException {
int splitIndex = fullyQualifiedName.lastIndexOf(".");
if (splitIndex <= 0) {
throw new IllegalArgumentException(
String.format("The fully qualified name is invalid: '%s'", fullyQualifiedName));
}
String moduleName = fullyQualifiedName.substring(0, splitIndex);
String objectName = fullyQualifiedName.substring(splitIndex + 1);
Configuration mergedConfig =
new Configuration(
ExecutionEnvironment.getExecutionEnvironment().getConfiguration());
PythonDependencyUtils.merge(mergedConfig, (Configuration) config);
PythonFunctionFactory pythonFunctionFactory = getPythonFunctionFactory(mergedConfig);
return pythonFunctionFactory.getPythonFunction(moduleName, objectName);
}
static PythonFunction getPythonFunction(String fullyQualifiedName, ReadableConfig config, ClassLoader classLoader) throws ExecutionException, IOException, InterruptedException {
return getPythonFunction(fullyQualifiedName, config);
}
static PythonFunctionFactory getPythonFunctionFactory(ReadableConfig config)
throws ExecutionException, InterruptedException, IOException {
synchronized (PythonFunctionFactory.class) {
if (PYTHON_FUNCTION_FACTORY_REF.get() != null) {
return PYTHON_FUNCTION_FACTORY_REF.get();
} else {
Map<String, Object> entryPoint;
if (getGatewayServer() == null) {
GatewayServer gatewayServer = null;
Process pythonProcess = null;
try {
gatewayServer = startGatewayServer();
setGatewayServer(gatewayServer);
List<String> commands = new ArrayList<>();
commands.add("-m");
commands.add("pyflink.pyflink_callback_server");
String tmpDir =
System.getProperty("java.io.tmpdir")
+ File.separator
+ "pyflink"
+ File.separator
+ UUID.randomUUID();
pythonProcess =
launchPy4jPythonClient(
gatewayServer, config, commands, null, tmpDir, false);
entryPoint =
(Map<String, Object>) gatewayServer.getGateway().getEntryPoint();
int i = 0;
while (!entryPoint.containsKey("PythonFunctionFactory")) {
if (!pythonProcess.isAlive()) {
throw new RuntimeException("Python callback server start failed!");
}
try {
Thread.sleep(CHECK_INTERVAL);
} catch (InterruptedException e) {
throw new RuntimeException(
"Interrupted while waiting for the python process to start.",
e);
}
i++;
if (i > TIMEOUT_MILLIS / CHECK_INTERVAL) {
throw new RuntimeException("Python callback server start failed!");
}
}
} catch (Throwable e) {
try {
setGatewayServer(null);
if (gatewayServer != null) {
gatewayServer.shutdown();
}
} catch (Throwable e2) {
// ignore, do not swallow the origin exception.
}
try {
if (pythonProcess != null) {
shutdownPythonProcess(pythonProcess, TIMEOUT_MILLIS);
}
} catch (Throwable e3) {
// ignore, do not swallow the origin exception.
}
throw e;
}
Runtime.getRuntime()
.addShutdownHook(new PythonProcessShutdownHook(pythonProcess));
} else {
entryPoint =
(Map<String, Object>) getGatewayServer().getGateway().getEntryPoint();
}
PythonFunctionFactory pythonFunctionFactory =
(PythonFunctionFactory) entryPoint.get("PythonFunctionFactory");
PYTHON_FUNCTION_FACTORY_REF.set(pythonFunctionFactory);
return pythonFunctionFactory;
}
}
}
static void shutdownPythonProcess(Process pythonProcess, long timeoutMillis) {
pythonProcess.destroy();
try {
pythonProcess.waitFor(timeoutMillis, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
throw new RuntimeException(
"Interrupt while waiting for the python process to stop.", e);
}
if (pythonProcess.isAlive()) {
pythonProcess.destroyForcibly();
}
}
/**
* The shutdown hook used to destroy the Python process.
*/
class PythonProcessShutdownHook extends Thread {
private Process process;
public PythonProcessShutdownHook(Process process) {
this.process = process;
}
@Override
public void run() {
shutdownPythonProcess(process, TIMEOUT_MILLIS);
}
}
}
......@@ -29,7 +29,6 @@
<artifactId>dlink-client-1.13</artifactId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>${target.java.version}</maven.compiler.source>
<maven.compiler.target>${target.java.version}</maven.compiler.target>
......@@ -49,17 +48,6 @@
<artifactId>dlink-flink-1.13</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-connector-jdbc-1.13</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.starrocks</groupId>
<artifactId>flink-connector-starrocks</artifactId>
<version>1.2.3_flink-1.13_${scala.binary.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
......
......@@ -196,6 +196,7 @@ public class CustomTableEnvironmentImpl extends TableEnvironmentImpl implements
}
}
@Override
public ObjectNode getStreamGraph(String statement) {
List<Operation> operations = super.getParser().parse(statement);
if (operations.size() != 1) {
......@@ -227,10 +228,12 @@ public class CustomTableEnvironmentImpl extends TableEnvironmentImpl implements
}
}
@Override
public JobPlanInfo getJobPlanInfo(List<String> statements) {
return new JobPlanInfo(JsonPlanGenerator.generatePlan(getJobGraphFromInserts(statements)));
}
@Override
public StreamGraph getStreamGraphFromInserts(List<String> statements) {
List<ModifyOperation> modifyOperations = new ArrayList();
for (String statement : statements) {
......@@ -258,10 +261,12 @@ public class CustomTableEnvironmentImpl extends TableEnvironmentImpl implements
}
}
@Override
public JobGraph getJobGraphFromInserts(List<String> statements) {
return getStreamGraphFromInserts(statements).getJobGraph();
}
@Override
public SqlExplainResult explainSqlRecord(String statement, ExplainDetail... extraDetails) {
SqlExplainResult record = new SqlExplainResult();
List<Operation> operations = getParser().parse(statement);
......@@ -290,6 +295,7 @@ public class CustomTableEnvironmentImpl extends TableEnvironmentImpl implements
return record;
}
@Override
public boolean parseAndLoadConfiguration(String statement, StreamExecutionEnvironment environment, Map<String, Object> setMap) {
List<Operation> operations = getParser().parse(statement);
for (Operation operation : operations) {
......
......@@ -50,12 +50,6 @@
<artifactId>jackson-datatype-jsr310</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.starrocks</groupId>
<artifactId>flink-connector-starrocks</artifactId>
<version>1.2.3_flink-1.14_${scala.binary.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
......
......@@ -29,7 +29,6 @@
<artifactId>dlink-client-1.15</artifactId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>${target.java.version}</maven.compiler.source>
<maven.compiler.target>${target.java.version}</maven.compiler.target>
......
......@@ -128,15 +128,14 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
<source>${target.java.version}</source>
<target>${target.java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
......
......@@ -38,14 +38,14 @@
<dependencies>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-api-java-bridge_2.12</artifactId>
<artifactId>flink-table-api-java-bridge_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.doris</groupId>
<artifactId>flink-doris-connector-1.13_2.12</artifactId>
<artifactId>flink-doris-connector-1.13_${scala.binary.version}</artifactId>
<version>1.0.3</version>
</dependency>
</dependencies>
......
......@@ -29,7 +29,6 @@
<artifactId>dlink-connector-jdbc-1.11</artifactId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<flink.version>1.11.6</flink.version>
<maven.compiler.source>${target.java.version}</maven.compiler.source>
......@@ -41,26 +40,10 @@
<dependencies>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-jdbc_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-api-java-bridge_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.11</artifactId>
<scope>${scope.runtime}</scope>
</dependency>
<!-- Postgres dependencies -->
<dependency>
<groupId>org.postgresql</groupId>
......@@ -76,38 +59,6 @@
<version>${flink.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-common</artifactId>
<version>${flink.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<!-- A planner dependency won't be necessary once FLIP-32 has been completed. -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner-blink_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner-blink_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>test</scope>
</dependency>
<!-- Postgres test dependencies -->
<dependency>
......
......@@ -29,7 +29,6 @@
<artifactId>dlink-connector-jdbc-1.12</artifactId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<flink.version>1.12.7</flink.version>
<maven.compiler.source>${target.java.version}</maven.compiler.source>
......@@ -41,26 +40,10 @@
<dependencies>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-jdbc_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-api-java-bridge_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.12</artifactId>
<scope>${scope.runtime}</scope>
</dependency>
<!-- Postgres dependencies -->
<dependency>
<groupId>org.postgresql</groupId>
......@@ -69,45 +52,6 @@
<scope>provided</scope>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-test-utils_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-common</artifactId>
<version>${flink.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<!-- A planner dependency won't be necessary once FLIP-32 has been completed. -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner-blink_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner-blink_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>test</scope>
</dependency>
<!-- Postgres test dependencies -->
<dependency>
......@@ -169,6 +113,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<configuration>
<!-- 指定打包的jar包输出路径 -->
<outputDirectory>${project.parent.parent.basedir}/build/extends</outputDirectory>
......
......@@ -29,7 +29,6 @@
<artifactId>dlink-connector-jdbc-1.13</artifactId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<flink.version>1.13.6</flink.version>
<maven.compiler.source>${target.java.version}</maven.compiler.source>
......@@ -41,24 +40,9 @@
<dependencies>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-jdbc_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-api-java-bridge_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.13</artifactId>
<scope>${scope.runtime}</scope>
</dependency>
<!-- Postgres dependencies -->
......@@ -69,37 +53,6 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-common</artifactId>
<version>${flink.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<!-- A planner dependency won't be necessary once FLIP-32 has been completed. -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner-blink_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner-blink_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>test</scope>
</dependency>
<!-- Postgres test dependencies -->
<dependency>
......
......@@ -38,27 +38,12 @@
</properties>
<dependencies>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-jdbc_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-api-java-bridge_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.14</artifactId>
<scope>${scope.runtime}</scope>
</dependency>
<!-- Postgres dependencies -->
<dependency>
<groupId>org.postgresql</groupId>
......@@ -67,21 +52,6 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-common</artifactId>
<version>${flink.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<!-- A planner dependency won't be necessary once FLIP-32 has been completed. -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>test</scope>
</dependency>
<!-- Postgres test dependencies -->
......
......@@ -29,7 +29,6 @@
<artifactId>dlink-connector-phoenix-1.13</artifactId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<flink.version>1.13.6</flink.version>
<maven.compiler.source>${target.java.version}</maven.compiler.source>
......@@ -40,68 +39,12 @@
</properties>
<dependencies>
<!--
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-jdbc_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
</dependency>
-->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-api-java-bridge_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<!--<scope>provided</scope>-->
<scope>${phoenix.scope.runtime}</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<!--<scope>provided</scope>-->
<scope>${phoenix.scope.runtime}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-common</artifactId>
<version>${flink.version}</version>
<type>test-jar</type>
<scope>test</scope>
<!-- <scope>${phoenix.scope.runtime}</scope>-->
</dependency>
<!-- A planner dependency won't be necessary once FLIP-32 has been completed. -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>test</scope>
<!-- <scope>${phoenix.scope.runtime}</scope>-->
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner-blink_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<type>test-jar</type>
<scope>test</scope>
<!-- <scope>${phoenix.scope.runtime}</scope>-->
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner-blink_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>test</scope>
<!--<scope>${phoenix.scope.runtime}</scope>-->
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.13</artifactId>
<scope>${scope.runtime}</scope>
</dependency>
<dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-core</artifactId>
......@@ -116,6 +59,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<configuration>
<!-- 指定打包的jar包输出路径 -->
<outputDirectory>${project.parent.parent.basedir}/build/extends</outputDirectory>
......
......@@ -27,7 +27,6 @@
<artifactId>dlink-connector-phoenix-1.14</artifactId>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<flink.version>1.14.6</flink.version>
<maven.compiler.source>${target.java.version}</maven.compiler.source>
......@@ -39,53 +38,10 @@
<dependencies>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-api-java-bridge_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>${phoenix.scope.runtime}</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<!--<scope>provided</scope>-->
<scope>${phoenix.scope.runtime}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-common</artifactId>
<version>${flink.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<!-- A planner dependency won't be necessary once FLIP-32 has been completed. -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>test</scope>
</dependency>
<!-- A planner dependency won't be necessary once FLIP-32 has been completed. -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>test</scope>
</dependency>
<!-- <dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-core</artifactId>
<version>4.14.2-HBase-1.4</version>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.14</artifactId>
<scope>${scope.runtime}</scope>
</dependency>-->
</dependency>
<dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-core</artifactId>
......@@ -105,6 +61,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<configuration>
<!-- 指定打包的jar包输出路径 -->
<outputDirectory>${project.parent.parent.basedir}/build/extends</outputDirectory>
......
......@@ -27,12 +27,9 @@
<artifactId>dlink-connector-pulsar-1.14</artifactId>
<properties>
<pulsar.version>2.8.2</pulsar.version>
<!--<scala.version>2.11.12</scala.version>-->
<scala.binary.version>2.11</scala.binary.version>
<pulsar.version>2.9.1</pulsar.version>
<hbase.version>1.4.3</hbase.version>
<hadoop.version>2.4.1</hadoop.version>
<!--<flink.shaded.version>9.0</flink.shaded.version>-->
<fastjson.version>1.2.7</fastjson.version>
<flink.version>1.14.6</flink.version>
</properties>
......@@ -67,134 +64,9 @@
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-pulsar_2.11</artifactId>
<artifactId>flink-connector-pulsar_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-json</artifactId>
<version>${flink.version}</version>
</dependency>
<!-- test -->
<!--<dependency>-->
<!--<groupId>org.apache.flink</groupId>-->
<!--<artifactId>flink-streaming-java_2.11</artifactId>-->
<!--<version>${flink.version}</version>-->
<!--&lt;!&ndash;<scope>test</scope>&ndash;&gt;-->
<!--</dependency>-->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-api-java-bridge_2.11</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner_2.11</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-scala_2.11</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-common</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
</dependency>
<!-- core dependencies -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-core</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
</dependency>
<!-- flink-java dependencies -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-java</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
</dependency>
<!-- flink-scala dependencies -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-scala_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
</dependency>
<!-- Table ecosystem -->
<!-- Projects depending on this project won't depend on flink-table-*. -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-api-java-bridge_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
<exclusions>
<!-- Remove unneeded dependency, which is conflicting with our jetty-util version. -->
<exclusion>
<groupId>io.netty</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-clients_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-hadoop-compatibility_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.apache.flink</groupId>
<artifactId>flink-shaded-include-yarn_${scala.binary.version}</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--Test dependencies are only available for Hadoop-2.-->
<!--<dependency>-->
<!--<groupId>org.apache.hbase</groupId>-->
<!--<artifactId>hbase-server</artifactId>-->
<!--<version>${hbase.version}</version>-->
<!--<type>test-jar</type>-->
<!--<scope>test</scope>-->
<!--</dependency>-->
<dependency>
<groupId>org.apache.hadoop</groupId>
......@@ -215,14 +87,6 @@
</exclusions>
</dependency>
<!--<dependency>-->
<!--<groupId>org.apache.hbase</groupId>-->
<!--<artifactId>hbase-hadoop-compat</artifactId>-->
<!--<version>${hbase.version}</version>-->
<!--<scope>test</scope>-->
<!--<type>test-jar</type>-->
<!--</dependency>-->
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs</artifactId>
......@@ -231,13 +95,6 @@
<scope>test</scope>
</dependency>
<!--<dependency>-->
<!--<groupId>org.apache.hbase</groupId>-->
<!--<artifactId>hbase-hadoop2-compat</artifactId>-->
<!--<version>${hbase.version}</version>-->
<!--<scope>test</scope>-->
<!--<type>test-jar</type>-->
<!--</dependency>-->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-test-utils_${scala.binary.version}</artifactId>
......@@ -245,11 +102,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-common</artifactId>
<version>${flink.version}</version>
<type>test-jar</type>
<scope>test</scope>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.14</artifactId>
<scope>${scope.runtime}</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
......@@ -258,18 +113,6 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<!--<dependency>-->
<!--<groupId>org.apache.pulsar</groupId>-->
<!--<artifactId>pulsar-client</artifactId>-->
<!--<version>${pulsar.version}</version>-->
<!--<exclusions>-->
<!--<exclusion>-->
<!--<groupId>com.google.protobuf</groupId>-->
<!--<artifactId>protobuf-java</artifactId>-->
<!--</exclusion>-->
<!--</exclusions>-->
<!--</dependency>-->
</dependencies>
<build>
......@@ -286,6 +129,7 @@
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
......@@ -324,6 +168,7 @@
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.2</version>
<executions>
......
......@@ -104,7 +104,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>${target.java.version}</source>
<target>${target.java.version}</target>
......@@ -112,6 +111,7 @@
</plugin>
<!--打jar包-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
......
......@@ -43,6 +43,11 @@
<artifactId>flink-python_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-common</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner-blink_${scala.binary.version}</artifactId>
......@@ -67,7 +72,7 @@
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-yarn_2.11</artifactId>
<artifactId>flink-yarn_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<exclusions>
<exclusion>
......@@ -113,8 +118,13 @@
</dependency>
<dependency>
<groupId>org.apache.doris</groupId>
<artifactId>flink-doris-connector-1.11_2.12</artifactId>
<artifactId>flink-doris-connector-1.11_${scala.binary.version}</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-jdbc_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -43,6 +43,11 @@
<artifactId>flink-python_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-common</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner-blink_${scala.binary.version}</artifactId>
......@@ -67,7 +72,7 @@
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-yarn_2.11</artifactId>
<artifactId>flink-yarn_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<exclusions>
<exclusion>
......@@ -113,9 +118,14 @@
</dependency>
<dependency>
<groupId>org.apache.doris</groupId>
<artifactId>flink-doris-connector-1.12_2.12</artifactId>
<artifactId>flink-doris-connector-1.12_${scala.binary.version}</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-jdbc_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -82,7 +82,7 @@
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-yarn_2.11</artifactId>
<artifactId>flink-yarn_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<exclusions>
<exclusion>
......@@ -138,13 +138,18 @@
</dependency>
<dependency>
<groupId>org.apache.doris</groupId>
<artifactId>flink-doris-connector-1.13_2.12</artifactId>
<artifactId>flink-doris-connector-1.13_${scala.binary.version}</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>org.apache.hudi</groupId>
<artifactId>hudi-flink_2.11</artifactId>
<artifactId>hudi-flink_${scala.binary.version}</artifactId>
<version>0.10.1</version>
</dependency>
<dependency>
<groupId>com.starrocks</groupId>
<artifactId>flink-connector-starrocks</artifactId>
<version>1.2.3_flink-1.13_${scala.binary.version}</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -53,7 +53,6 @@
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-runtime_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
......@@ -163,7 +162,6 @@
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-jdbc_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
......@@ -179,5 +177,15 @@
<artifactId>flink-doris-connector-1.14_${scala.binary.version}</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>com.starrocks</groupId>
<artifactId>flink-connector-starrocks</artifactId>
<version>1.2.3_flink-1.14_${scala.binary.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-json</artifactId>
<version>${flink.version}</version>
</dependency>
</dependencies>
</project>
......@@ -27,16 +27,6 @@
<artifactId>dlink-function</artifactId>
<dependencies>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-${dlink.flink.version}</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-${dlink.flink.version}</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
......@@ -65,10 +55,106 @@
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>2.12.7</version>
<version>${scala.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>flink-1.11</id>
<dependencies>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-1.11</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.11</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>flink-1.12</id>
<dependencies>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-1.12</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.12</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>flink-1.13</id>
<dependencies>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-1.13</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.13</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>flink-1.14</id>
<dependencies>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-1.14</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.14</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>flink-1.15</id>
<dependencies>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-1.15</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.15</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>flink-1.16</id>
<dependencies>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-1.16</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.16</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
......@@ -79,6 +79,7 @@ public class PythonFunction implements FunctionCompiler, FunctionPackage {
configuration.set(PythonOptions.PYTHON_FILES, zipFile.getAbsolutePath());
configuration.set(PythonOptions.PYTHON_CLIENT_EXECUTABLE, Env.getPath());
configuration.set(PythonOptions.PYTHON_EXECUTABLE, Env.getPath());
PythonFunctionFactory.getPythonFunction(udf.getClassName(), configuration, null);
process.info("Python udf编译成功 ; className:" + udf.getClassName());
} catch (Exception e) {
......@@ -117,6 +118,6 @@ public class PythonFunction implements FunctionCompiler, FunctionPackage {
try (ZipUtils zipWriter = new ZipUtils(file, Charset.defaultCharset())) {
zipWriter.add(paths, inputStreams);
}
return new String[]{path};
return new String[] {path};
}
}
package com.dlink.function.util;
import org.apache.flink.runtime.util.EnvironmentInformation;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil;
/**
* @author ZackYoung
* @since 0.6.8
*/
public class FlinkUtils {
public static String getFlinkVersion() {
return EnvironmentInformation.getVersion();
}
/**
* @param version flink version。如:1.14.6
* @return flink 大版本,如 14
*/
public static String getFlinkBigVersion(String version) {
return StrUtil.split(version, ".").get(1);
}
/**
*
* @return 获取当前 flink 大版本
*/
public static Integer getCurFlinkBigVersion() {
return Convert.toInt(getFlinkBigVersion(getFlinkVersion()));
}
}
......@@ -56,16 +56,6 @@
<artifactId>junit</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-${dlink.flink.version}</artifactId>
<scope>${scope.runtime}</scope>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-${dlink.flink.version}</artifactId>
<scope>${scope.runtime}</scope>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-hadoop</artifactId>
......@@ -92,4 +82,102 @@ for k8s commit tasks-->
</dependencies>
<profiles>
<profile>
<id>flink-1.11</id>
<dependencies>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-1.11</artifactId>
<scope>${scope.runtime}</scope>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.11</artifactId>
<scope>${scope.runtime}</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>flink-1.12</id>
<dependencies>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-1.12</artifactId>
<scope>${scope.runtime}</scope>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.12</artifactId>
<scope>${scope.runtime}</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>flink-1.13</id>
<dependencies>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-1.13</artifactId>
<scope>${scope.runtime}</scope>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.13</artifactId>
<scope>${scope.runtime}</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>flink-1.14</id>
<dependencies>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-1.14</artifactId>
<scope>${scope.runtime}</scope>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.14</artifactId>
<scope>${scope.runtime}</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>flink-1.15</id>
<dependencies>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-1.15</artifactId>
<scope>${scope.runtime}</scope>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.15</artifactId>
<scope>${scope.runtime}</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>flink-1.16</id>
<dependencies>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-client-1.16</artifactId>
<scope>${scope.runtime}</scope>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-flink-1.16</artifactId>
<scope>${scope.runtime}</scope>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
\ No newline at end of file
......@@ -80,6 +80,7 @@
<maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
<maven-assembly-plugin.version>3.4.2</maven-assembly-plugin.version>
<maven.resource.version>3.2.0</maven.resource.version>
<maven.clean.version>3.2.0</maven.clean.version>
<junit.version>4.12</junit.version>
<protobuf-java.version>2.5.0</protobuf-java.version>
<jedis.version>2.9.0</jedis.version>
......@@ -505,6 +506,11 @@
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>${maven.clean.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
......@@ -560,7 +566,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<goals>
......@@ -677,7 +682,6 @@
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>dev</name>
</property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment