HADOOP-13801 regression: ITestS3AMiniYarnCluster failing. Contributed by Steve Loughran

This commit is contained in:
Steve Loughran 2016-11-23 21:37:04 +00:00
parent 005850b28f
commit 0de0c32ddd
1 changed files with 8 additions and 3 deletions

View File

@ -24,13 +24,14 @@
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.examples.WordCount; import org.apache.hadoop.examples.WordCount;
import org.apache.hadoop.fs.CreateFlag; import org.apache.hadoop.fs.CreateFlag;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileContext; import org.apache.hadoop.fs.FileContext;
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.contract.ContractTestUtils;
import org.apache.hadoop.fs.s3a.AbstractS3ATestBase; import org.apache.hadoop.fs.s3a.AbstractS3ATestBase;
import org.apache.hadoop.fs.s3a.S3AFileSystem; import org.apache.hadoop.fs.s3a.S3AFileSystem;
import org.apache.hadoop.fs.s3a.S3ATestUtils; import org.apache.hadoop.fs.s3a.S3ATestUtils;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.io.IntWritable; import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text; import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job; import org.apache.hadoop.mapreduce.Job;
@ -140,8 +141,12 @@ private void writeStringToFile(Path path, String string) throws IOException {
* helper method. * helper method.
*/ */
private String readStringFromFile(Path path) throws IOException { private String readStringFromFile(Path path) throws IOException {
return ContractTestUtils.readBytesToString(fs, path, try (FSDataInputStream in = fs.open(path)) {
(int) fs.getFileStatus(path).getLen()); long bytesLen = fs.getFileStatus(path).getLen();
byte[] buffer = new byte[(int) bytesLen];
IOUtils.readFully(in, buffer, 0, buffer.length);
return new String(buffer);
}
} }
} }