Created
May 12, 2012 08:03
-
-
Save ashigeru/2665136 to your computer and use it in GitHub Desktop.
S3 on EMR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.net.URI; | |
import org.apache.hadoop.conf.Configured; | |
import org.apache.hadoop.fs.FSDataOutputStream; | |
import org.apache.hadoop.fs.FileSystem; | |
import org.apache.hadoop.fs.Path; | |
import org.apache.hadoop.util.Tool; | |
import org.apache.hadoop.util.ToolRunner; | |
/* | |
prerequirements: | |
core-conf.xml | |
fs.s3n.multipart.uploads.enabled=true | |
commands: | |
javac -classpath ~/hadoop-core.jar FailTest.java | |
HADOOP_CLASSPATH=~/ hadoop FailTest | |
*/ | |
public class FailTest extends Configured implements Tool { | |
public static void main(String[] args) throws Exception { | |
int exit = ToolRunner.run(new FailTest(), args); | |
System.out.println(exit); | |
// no System.exit() | |
} | |
@Override | |
public int run(String[] args) throws Exception { | |
FileSystem fs = FileSystem.get(URI.create("s3://emr-work/"), getConf()); | |
try { | |
FSDataOutputStream output = fs.create(new Path("target/testing/check")); | |
output.close(); | |
System.out.println("closed 1"); | |
output.close(); // close duplicated | |
System.out.println("closed 2"); | |
} finally { | |
fs.close(); | |
} | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment