beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ieme...@apache.org
Subject [1/3] beam git commit: Make SerializableConfiguration more robust by using Hadoop based serialization
Date Wed, 31 May 2017 07:18:28 GMT
Repository: beam
Updated Branches:
  refs/heads/master 2fa24d89c -> 006fde46c


Make SerializableConfiguration more robust by using Hadoop based serialization


Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/185deeba
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/185deeba
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/185deeba

Branch: refs/heads/master
Commit: 185deebaa52bbf34592a21d86f316b4204fa09ba
Parents: 636eaff
Author: Ismaël Mejía <iemejia@apache.org>
Authored: Sun May 28 11:38:08 2017 +0200
Committer: Ismaël Mejía <iemejia@apache.org>
Committed: Wed May 31 09:17:00 2017 +0200

----------------------------------------------------------------------
 .../sdk/io/hadoop/SerializableConfiguration.java  | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/185deeba/sdks/java/io/hadoop-common/src/main/java/org/apache/beam/sdk/io/hadoop/SerializableConfiguration.java
----------------------------------------------------------------------
diff --git a/sdks/java/io/hadoop-common/src/main/java/org/apache/beam/sdk/io/hadoop/SerializableConfiguration.java
b/sdks/java/io/hadoop-common/src/main/java/org/apache/beam/sdk/io/hadoop/SerializableConfiguration.java
index 8101f4b..33c660a 100644
--- a/sdks/java/io/hadoop-common/src/main/java/org/apache/beam/sdk/io/hadoop/SerializableConfiguration.java
+++ b/sdks/java/io/hadoop-common/src/main/java/org/apache/beam/sdk/io/hadoop/SerializableConfiguration.java
@@ -49,21 +49,21 @@ public class SerializableConfiguration implements Externalizable {
     return conf;
   }
 
+
   @Override
   public void writeExternal(ObjectOutput out) throws IOException {
-    out.writeInt(conf.size());
-    for (Map.Entry<String, String> entry : conf) {
-      out.writeUTF(entry.getKey());
-      out.writeUTF(entry.getValue());
-    }
+    out.writeUTF(conf.getClass().getCanonicalName());
+    conf.write(out);
   }
 
   @Override
   public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-    conf = new Configuration(false);
-    int size = in.readInt();
-    for (int i = 0; i < size; i++) {
-      conf.set(in.readUTF(), in.readUTF());
+    String className = in.readUTF();
+    try {
+      conf = (Configuration) Class.forName(className).newInstance();
+      conf.readFields(in);
+    } catch (InstantiationException | IllegalAccessException e) {
+      throw new IOException("Unable to create configuration: " + e);
     }
   }
 


Mime
View raw message