|
@@ -20,6 +20,8 @@ package org.apache.hadoop.examples.terasort;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
+import org.apache.commons.logging.Log;
|
|
|
|
+import org.apache.commons.logging.LogFactory;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.fs.FSDataOutputStream;
|
|
import org.apache.hadoop.fs.FSDataOutputStream;
|
|
import org.apache.hadoop.fs.FileStatus;
|
|
import org.apache.hadoop.fs.FileStatus;
|
|
@@ -40,6 +42,7 @@ import org.apache.hadoop.mapreduce.security.TokenCache;
|
|
* An output format that writes the key and value appended together.
|
|
* An output format that writes the key and value appended together.
|
|
*/
|
|
*/
|
|
public class TeraOutputFormat extends FileOutputFormat<Text,Text> {
|
|
public class TeraOutputFormat extends FileOutputFormat<Text,Text> {
|
|
|
|
+ private static final Log LOG = LogFactory.getLog(TeraOutputFormat.class);
|
|
private OutputCommitter committer = null;
|
|
private OutputCommitter committer = null;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -74,10 +77,22 @@ public class TeraOutputFormat extends FileOutputFormat<Text,Text> {
|
|
out.write(key.getBytes(), 0, key.getLength());
|
|
out.write(key.getBytes(), 0, key.getLength());
|
|
out.write(value.getBytes(), 0, value.getLength());
|
|
out.write(value.getBytes(), 0, value.getLength());
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void close(TaskAttemptContext context) throws IOException {
|
|
public void close(TaskAttemptContext context) throws IOException {
|
|
if (finalSync) {
|
|
if (finalSync) {
|
|
- out.hsync();
|
|
|
|
|
|
+ try {
|
|
|
|
+ out.hsync();
|
|
|
|
+ } catch (UnsupportedOperationException e) {
|
|
|
|
+ /*
|
|
|
|
+ * Currently, hsync operation on striping file with erasure code
|
|
|
|
+ * policy is not supported yet. So this is a workaround to make
|
|
|
|
+ * teragen and terasort to support directory with striping files. In
|
|
|
|
+ * future, if the hsync operation is supported on striping file, this
|
|
|
|
+ * workaround should be removed.
|
|
|
|
+ */
|
|
|
|
+ LOG.info("Operation hsync is not supported so far on path with " +
|
|
|
|
+ "erasure code policy set");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
out.close();
|
|
out.close();
|
|
}
|
|
}
|
|
@@ -135,5 +150,4 @@ public class TeraOutputFormat extends FileOutputFormat<Text,Text> {
|
|
}
|
|
}
|
|
return committer;
|
|
return committer;
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|