You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by mx...@apache.org on 2016/01/21 16:23:22 UTC
flink git commit: [FLINK-2972][java-api] remove Chill dependency from
the test scope
Repository: flink
Updated Branches:
refs/heads/master e1e577c34 -> 85ad491af
[FLINK-2972][java-api] remove Chill dependency from the test scope
This closes #1535.
Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/85ad491a
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/85ad491a
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/85ad491a
Branch: refs/heads/master
Commit: 85ad491af66ad7c19401296af66edff2d2e3d6a1
Parents: e1e577c
Author: Maximilian Michels <mx...@apache.org>
Authored: Thu Jan 21 12:26:31 2016 +0100
Committer: Maximilian Michels <mx...@apache.org>
Committed: Thu Jan 21 16:22:39 2016 +0100
----------------------------------------------------------------------
flink-java/pom.xml | 8 ------
.../typeutils/runtime/kryo/KryoSerializer.java | 27 ++++++++++++++++----
.../kryo/KryoGenericTypeSerializerTest.java | 6 +++--
3 files changed, 26 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flink/blob/85ad491a/flink-java/pom.xml
----------------------------------------------------------------------
diff --git a/flink-java/pom.xml b/flink-java/pom.xml
index 0b33de1..8383a4a 100644
--- a/flink-java/pom.xml
+++ b/flink-java/pom.xml
@@ -104,14 +104,6 @@ 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>
http://git-wip-us.apache.org/repos/asf/flink/blob/85ad491a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
index b90901c..f1287fa 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoSerializer.java
@@ -36,6 +36,9 @@ import org.apache.flink.api.java.typeutils.runtime.NoFetchingInput;
import org.apache.flink.api.java.typeutils.runtime.kryo.Serializers.SpecificInstanceCollectionSerializerForArrayList;
import org.apache.flink.core.memory.DataInputView;
import org.apache.flink.core.memory.DataOutputView;
+import org.objenesis.strategy.StdInstantiatorStrategy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -62,6 +65,8 @@ public class KryoSerializer<T> extends TypeSerializer<T> {
private static final long serialVersionUID = 3L;
+ private static final Logger LOG = LoggerFactory.getLogger(KryoSerializer.class);
+
// ------------------------------------------------------------------------
private final LinkedHashMap<Class<?>, ExecutionConfig.SerializableSerializer<?>> registeredTypesWithSerializers;
@@ -282,6 +287,11 @@ public class KryoSerializer<T> extends TypeSerializer<T> {
// --------------------------------------------------------------------------------------------
+ /**
+ * Returns the Chill Kryo Serializer which is implictly added to the classpath via flink-runtime.
+ * Falls back to the default Kryo serializer if it can't be found.
+ * @return The Kryo serializer instance.
+ */
private Kryo getKryoInstance() {
try {
@@ -292,13 +302,20 @@ public class KryoSerializer<T> extends TypeSerializer<T> {
// obtain a Kryo instance through Twitter Chill
Method m = chillInstantiatorClazz.getMethod("newKryo");
+
return (Kryo) m.invoke(chillInstantiator);
- }
- catch(ClassNotFoundException | InstantiationException | NoSuchMethodException |
- IllegalAccessException | InvocationTargetException e ) {
+ } catch (ClassNotFoundException | InstantiationException | NoSuchMethodException |
+ IllegalAccessException | InvocationTargetException e) {
+
+ LOG.warn("Falling back to default Kryo serializer because Chill serializer couldn't be found.", e);
+
+ Kryo.DefaultInstantiatorStrategy initStrategy = new Kryo.DefaultInstantiatorStrategy();
+ initStrategy.setFallbackInstantiatorStrategy(new StdInstantiatorStrategy());
+
+ Kryo kryo = new Kryo();
+ kryo.setInstantiatorStrategy(initStrategy);
- // 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);
+ return kryo;
}
}
http://git-wip-us.apache.org/repos/asf/flink/blob/85ad491a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeSerializerTest.java
----------------------------------------------------------------------
diff --git a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeSerializerTest.java b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeSerializerTest.java
index c630b06..384657f 100644
--- a/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeSerializerTest.java
+++ b/flink-java/src/test/java/org/apache/flink/api/java/typeutils/runtime/kryo/KryoGenericTypeSerializerTest.java
@@ -36,6 +36,8 @@ import java.util.Random;
@SuppressWarnings("unchecked")
public class KryoGenericTypeSerializerTest extends AbstractGenericTypeSerializerTest {
+
+ ExecutionConfig ec = new ExecutionConfig();
@Test
public void testJavaList(){
@@ -82,7 +84,7 @@ public class KryoGenericTypeSerializerTest extends AbstractGenericTypeSerializer
coll.add(49);
coll.add(1);
}
- ExecutionConfig ec = new ExecutionConfig();
+
@Override
protected <T> TypeSerializer<T> createSerializer(Class<T> type) {
return new KryoSerializer<T>(type, ec);
@@ -166,4 +168,4 @@ public class KryoGenericTypeSerializerTest extends AbstractGenericTypeSerializer
fail(e.getMessage());
}
}
-}
\ No newline at end of file
+}