提交 cd899f3b 编写于 作者: F Fabian Hueske

[FLINK-2972] [JavaAPI] Remove Chill dependency from flink-java.

This closes #1331
上级 d5a6b13a
......@@ -52,12 +52,6 @@ under the License.
<artifactId>kryo</artifactId>
</dependency>
<dependency>
<groupId>com.twitter</groupId>
<artifactId>chill_${scala.binary.version}</artifactId>
<version>${chill.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
......
......@@ -65,13 +65,7 @@ under the License.
<dependency>
<groupId>com.twitter</groupId>
<artifactId>chill_${scala.binary.version}</artifactId>
<version>${chill.version}</version>
</dependency>
<dependency>
<groupId>com.twitter</groupId>
<artifactId>chill-avro_${scala.binary.version}</artifactId>
<artifactId>chill-java</artifactId>
<version>${chill.version}</version>
</dependency>
......@@ -110,6 +104,15 @@ under the License.
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.twitter</groupId>
<artifactId>chill_${scala.binary.version}</artifactId>
<version>${chill.version}</version>
<!-- For execution, Chill is added to the classpath through flink-runtime. -->
<scope>test</scope>
</dependency>
</dependencies>
<!-- Because flink-scala and flink-avro uses it in tests -->
......
......@@ -26,7 +26,6 @@ import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.esotericsoftware.kryo.serializers.JavaSerializer;
import com.google.common.base.Preconditions;
import com.twitter.chill.ScalaKryoInstantiator;
import org.apache.avro.generic.GenericData;
import org.apache.flink.api.common.ExecutionConfig;
......@@ -42,6 +41,8 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.EOFException;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
......@@ -281,9 +282,29 @@ public class KryoSerializer<T> extends TypeSerializer<T> {
// --------------------------------------------------------------------------------------------
private Kryo getKryoInstance() {
try {
// check if ScalaKryoInstantiator is in class path (coming from Twitter's Chill library).
// This will be true if Flink's Scala API is used.
Class<?> chillInstantiatorClazz = Class.forName("com.twitter.chill.ScalaKryoInstantiator");
Object chillInstantiator = chillInstantiatorClazz.newInstance();
// obtain a Kryo instance through Twitter Chill
Method m = chillInstantiatorClazz.getMethod("newKryo");
return (Kryo) m.invoke(chillInstantiator);
}
catch(ClassNotFoundException | InstantiationException | NoSuchMethodException |
IllegalAccessException | InvocationTargetException e ) {
// Chill must be in the classpath. It is added as a dependency to flink-runtime.
throw new RuntimeException("Could not instantiate Kryo instance from Chill.", e);
}
}
private void checkKryoInitialized() {
if (this.kryo == null) {
this.kryo = new ScalaKryoInstantiator().newKryo();
this.kryo = getKryoInstance();
// Throwable and all subclasses should be serialized via java serialization
kryo.addDefaultSerializer(Throwable.class, new JavaSerializer());
......
......@@ -180,6 +180,18 @@ under the License.
<artifactId>zookeeper</artifactId>
</dependency>
<!--
The KryoSerializer dynamically loads Kryo instances via Chill and requires that Chill
is in the classpath. Because we do not want to have transitive Scala dependencies
in Flink's API modules (such as flink-java) due to Chill, Chill is added to flink-runtime
to ensure that Chill is always present in the classpath.
-->
<dependency>
<groupId>com.twitter</groupId>
<artifactId>chill_${scala.binary.version}</artifactId>
<version>${chill.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-shaded-curator-recipes</artifactId>
......
......@@ -69,7 +69,7 @@ under the License.
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>${asm.version}</version>
<version>${asm.version}</version>
</dependency>
<dependency>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册