You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mapreduce-user@hadoop.apache.org by tim robertson <ti...@gmail.com> on 2009/10/27 11:34:30 UTC
How to use MultipleTextOutputFormat ?
Hi all,
Using 0.20.1 I have a MultipleTextOutputFormat with the following:
protected String generateFileNameForKeyValue(Object key, Object
value, String name) {
return BASE_FILE + "/resource-" + key.toString();
}
But when I run this on a 9 node cluster with 9 reducers I get issues
with nodes saying the file is already being created, and eventually
the job fails with half written output
Can someone please tell me if I am using this incorrectly? I suspect
it is because my reducer is generating a new key, so multiple reducers
are indeed creating the same file... could someone please verify this
suspicion?
Full stacktrace on a TT below.
Thanks,
Tim
2009-10-27 10:56:32,844 WARN org.apache.hadoop.mapred.TaskTracker:
Error running child
org.apache.hadoop.ipc.RemoteException:
org.apache.hadoop.hdfs.protocol.AlreadyBeingCreatedException: failed
to create file /user/root/delme2/resource-101 for
DFSClient_attempt_200910191701_0042_r_000005_1 on client 192.168.76.1,
bec
ause this file is already being created by
DFSClient_attempt_200910191701_0042_r_000005_2 on 192.168.76.3
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.startFileInternal(FSNamesystem.java:1064)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.startFile(FSNamesystem.java:977)
at org.apache.hadoop.hdfs.server.namenode.NameNode.create(NameNode.java:377)
at sun.reflect.GeneratedMethodAccessor75.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:508)
at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:959)
at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:955)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:396)
at org.apache.hadoop.ipc.Server$Handler.run(Server.java:953)
at org.apache.hadoop.ipc.Client.call(Client.java:739)
at org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:220)
at $Proxy1.create(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:82)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:59)
at $Proxy1.create(Unknown Source)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.<init>(DFSClient.java:2674)
at org.apache.hadoop.hdfs.DFSClient.create(DFSClient.java:488)
at org.apache.hadoop.hdfs.DistributedFileSystem.create(DistributedFileSystem.java:195)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:479)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:379)
at org.apache.hadoop.mapred.TextOutputFormat.getRecordWriter(TextOutputFormat.java:121)
at org.apache.hadoop.mapred.lib.MultipleTextOutputFormat.getBaseRecordWriter(MultipleTextOutputFormat.java:44)
at org.apache.hadoop.mapred.lib.MultipleOutputFormat$1.write(MultipleOutputFormat.java:99)
at org.apache.hadoop.mapred.ReduceTask$3.collect(ReduceTask.java:440)
at org.gbif.occurrencestore.mapreduce.classification.ClassificationMapReduce$Transpose.reduce(ClassificationMapReduce.java:203)
at org.gbif.occurrencestore.mapreduce.classification.ClassificationMapReduce$Transpose.reduce(ClassificationMapReduce.java:191)
at org.apache.hadoop.mapred.ReduceTask.runOldReducer(ReduceTask.java:463)
at org.apache.hadoop.mapred.ReduceTask.run(ReduceTask.java:411)
at org.apache.hadoop.mapred.Child.main(Child.java:170)
Re: How to use MultipleTextOutputFormat ?
Posted by Amogh Vasekar <am...@yahoo-inc.com>.
Hi,
The file name generated depends on the output <k,v> pair and hence, if you are modifying the key from mapper to reducer output, collisions are possible. You may split and append 'name' (* from part-*) to get unique reducer files, which can be merged later. Or see if multipleoutputs fits your bill.
Hope this helps.
Amogh
On 10/27/09 4:04 PM, "tim robertson" <ti...@gmail.com> wrote:
Hi all,
Using 0.20.1 I have a MultipleTextOutputFormat with the following:
protected String generateFileNameForKeyValue(Object key, Object
value, String name) {
return BASE_FILE + "/resource-" + key.toString();
}
But when I run this on a 9 node cluster with 9 reducers I get issues
with nodes saying the file is already being created, and eventually
the job fails with half written output
Can someone please tell me if I am using this incorrectly? I suspect
it is because my reducer is generating a new key, so multiple reducers
are indeed creating the same file... could someone please verify this
suspicion?
Full stacktrace on a TT below.
Thanks,
Tim
2009-10-27 10:56:32,844 WARN org.apache.hadoop.mapred.TaskTracker:
Error running child
org.apache.hadoop.ipc.RemoteException:
org.apache.hadoop.hdfs.protocol.AlreadyBeingCreatedException: failed
to create file /user/root/delme2/resource-101 for
DFSClient_attempt_200910191701_0042_r_000005_1 on client 192.168.76.1,
bec
ause this file is already being created by
DFSClient_attempt_200910191701_0042_r_000005_2 on 192.168.76.3
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.startFileInternal(FSNamesystem.java:1064)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.startFile(FSNamesystem.java:977)
at org.apache.hadoop.hdfs.server.namenode.NameNode.create(NameNode.java:377)
at sun.reflect.GeneratedMethodAccessor75.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:508)
at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:959)
at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:955)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:396)
at org.apache.hadoop.ipc.Server$Handler.run(Server.java:953)
at org.apache.hadoop.ipc.Client.call(Client.java:739)
at org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:220)
at $Proxy1.create(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:82)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:59)
at $Proxy1.create(Unknown Source)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.<init>(DFSClient.java:2674)
at org.apache.hadoop.hdfs.DFSClient.create(DFSClient.java:488)
at org.apache.hadoop.hdfs.DistributedFileSystem.create(DistributedFileSystem.java:195)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:479)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:379)
at org.apache.hadoop.mapred.TextOutputFormat.getRecordWriter(TextOutputFormat.java:121)
at org.apache.hadoop.mapred.lib.MultipleTextOutputFormat.getBaseRecordWriter(MultipleTextOutputFormat.java:44)
at org.apache.hadoop.mapred.lib.MultipleOutputFormat$1.write(MultipleOutputFormat.java:99)
at org.apache.hadoop.mapred.ReduceTask$3.collect(ReduceTask.java:440)
at org.gbif.occurrencestore.mapreduce.classification.ClassificationMapReduce$Transpose.reduce(ClassificationMapReduce.java:203)
at org.gbif.occurrencestore.mapreduce.classification.ClassificationMapReduce$Transpose.reduce(ClassificationMapReduce.java:191)
at org.apache.hadoop.mapred.ReduceTask.runOldReducer(ReduceTask.java:463)
at org.apache.hadoop.mapred.ReduceTask.run(ReduceTask.java:411)
at org.apache.hadoop.mapred.Child.main(Child.java:170)
Re: How to use MultipleTextOutputFormat ?
Posted by Allen Wittenauer <aw...@linkedin.com>.
On 10/27/09 3:34 AM, "tim robertson" <ti...@gmail.com> wrote:
> to create file /user/root/delme2/resource-101 for
I wouldn't recommend running your grid/jobs as root. :)