|
@@ -18,10 +18,8 @@
|
|
|
|
|
|
package org.apache.hadoop.fs.s3a.commit;
|
|
|
|
|
|
-import java.io.FileNotFoundException;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InterruptedIOException;
|
|
|
-import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -53,7 +51,6 @@ import org.apache.hadoop.mapreduce.v2.util.MRBuilderUtils;
|
|
|
import static org.apache.hadoop.fs.s3a.Constants.*;
|
|
|
import static org.apache.hadoop.fs.s3a.MultipartTestUtils.listMultipartUploads;
|
|
|
import static org.apache.hadoop.fs.s3a.S3ATestUtils.*;
|
|
|
-import static org.apache.hadoop.fs.s3a.S3AUtils.applyLocatedFiles;
|
|
|
import static org.apache.hadoop.fs.s3a.commit.CommitConstants.*;
|
|
|
|
|
|
/**
|
|
@@ -109,6 +106,13 @@ public abstract class AbstractCommitITest extends AbstractS3ATestBase {
|
|
|
@Override
|
|
|
protected Configuration createConfiguration() {
|
|
|
Configuration conf = super.createConfiguration();
|
|
|
+ String bucketName = getTestBucketName(conf);
|
|
|
+ removeBucketOverrides(bucketName, conf,
|
|
|
+ MAGIC_COMMITTER_ENABLED,
|
|
|
+ S3A_COMMITTER_FACTORY_KEY,
|
|
|
+ FS_S3A_COMMITTER_NAME,
|
|
|
+ FS_S3A_COMMITTER_STAGING_CONFLICT_MODE);
|
|
|
+
|
|
|
conf.setBoolean(MAGIC_COMMITTER_ENABLED, true);
|
|
|
conf.setLong(MIN_MULTIPART_THRESHOLD, MULTIPART_MIN_SIZE);
|
|
|
conf.setInt(MULTIPART_SIZE, MULTIPART_MIN_SIZE);
|
|
@@ -355,25 +359,7 @@ public abstract class AbstractCommitITest extends AbstractS3ATestBase {
|
|
|
* @throws IOException IO Failure
|
|
|
*/
|
|
|
protected SuccessData verifySuccessMarker(Path dir) throws IOException {
|
|
|
- assertPathExists("Success marker",
|
|
|
- new Path(dir, _SUCCESS));
|
|
|
- SuccessData successData = loadSuccessMarker(dir);
|
|
|
- log().info("Success data {}", successData.toString());
|
|
|
- log().info("Metrics\n{}",
|
|
|
- successData.dumpMetrics(" ", " = ", "\n"));
|
|
|
- log().info("Diagnostics\n{}",
|
|
|
- successData.dumpDiagnostics(" ", " = ", "\n"));
|
|
|
- return successData;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Load the success marker and return the data inside it.
|
|
|
- * @param dir directory containing the marker
|
|
|
- * @return the loaded data
|
|
|
- * @throws IOException on any failure to load or validate the data
|
|
|
- */
|
|
|
- protected SuccessData loadSuccessMarker(Path dir) throws IOException {
|
|
|
- return SuccessData.load(getFileSystem(), new Path(dir, _SUCCESS));
|
|
|
+ return validateSuccessFile(dir, "", getFileSystem(), "query");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -447,32 +433,18 @@ public abstract class AbstractCommitITest extends AbstractS3ATestBase {
|
|
|
/**
|
|
|
* Load in the success data marker: this guarantees that an S3A
|
|
|
* committer was used.
|
|
|
- * @param fs filesystem
|
|
|
* @param outputPath path of job
|
|
|
- * @param committerName name of committer to match
|
|
|
+ * @param committerName name of committer to match, or ""
|
|
|
+ * @param fs filesystem
|
|
|
+ * @param origin origin (e.g. "teragen" for messages)
|
|
|
* @return the success data
|
|
|
* @throws IOException IO failure
|
|
|
*/
|
|
|
- public static SuccessData validateSuccessFile(final S3AFileSystem fs,
|
|
|
- final Path outputPath, final String committerName) throws IOException {
|
|
|
- SuccessData successData = null;
|
|
|
- try {
|
|
|
- successData = loadSuccessFile(fs, outputPath);
|
|
|
- } catch (FileNotFoundException e) {
|
|
|
- // either the output path is missing or, if its the success file,
|
|
|
- // somehow the relevant committer wasn't picked up.
|
|
|
- String dest = outputPath.toString();
|
|
|
- LOG.error("No _SUCCESS file found under {}", dest);
|
|
|
- List<String> files = new ArrayList<>();
|
|
|
- applyLocatedFiles(fs.listFiles(outputPath, true),
|
|
|
- (status) -> {
|
|
|
- files.add(status.getPath().toString());
|
|
|
- LOG.error("{} {}", status.getPath(), status.getLen());
|
|
|
- });
|
|
|
- throw new AssertionError("No _SUCCESS file in " + dest
|
|
|
- + "; found : " + files.stream().collect(Collectors.joining("\n")),
|
|
|
- e);
|
|
|
- }
|
|
|
+ public static SuccessData validateSuccessFile(final Path outputPath,
|
|
|
+ final String committerName,
|
|
|
+ final S3AFileSystem fs,
|
|
|
+ final String origin) throws IOException {
|
|
|
+ SuccessData successData = loadSuccessFile(fs, outputPath, origin);
|
|
|
String commitDetails = successData.toString();
|
|
|
LOG.info("Committer name " + committerName + "\n{}",
|
|
|
commitDetails);
|
|
@@ -480,8 +452,10 @@ public abstract class AbstractCommitITest extends AbstractS3ATestBase {
|
|
|
successData.dumpMetrics(" ", " = ", "\n"));
|
|
|
LOG.info("Diagnostics\n{}",
|
|
|
successData.dumpDiagnostics(" ", " = ", "\n"));
|
|
|
- assertEquals("Wrong committer in " + commitDetails,
|
|
|
- committerName, successData.getCommitter());
|
|
|
+ if (!committerName.isEmpty()) {
|
|
|
+ assertEquals("Wrong committer in " + commitDetails,
|
|
|
+ committerName, successData.getCommitter());
|
|
|
+ }
|
|
|
return successData;
|
|
|
}
|
|
|
|
|
@@ -489,16 +463,29 @@ public abstract class AbstractCommitITest extends AbstractS3ATestBase {
|
|
|
* Load a success file; fail if the file is empty/nonexistent.
|
|
|
* @param fs filesystem
|
|
|
* @param outputPath directory containing the success file.
|
|
|
+ * @param origin origin of the file
|
|
|
* @return the loaded file.
|
|
|
* @throws IOException failure to find/load the file
|
|
|
- * @throws AssertionError file is 0-bytes long
|
|
|
+ * @throws AssertionError file is 0-bytes long,
|
|
|
*/
|
|
|
public static SuccessData loadSuccessFile(final S3AFileSystem fs,
|
|
|
- final Path outputPath) throws IOException {
|
|
|
+ final Path outputPath, final String origin) throws IOException {
|
|
|
+ ContractTestUtils.assertPathExists(fs,
|
|
|
+ "Output directory " + outputPath
|
|
|
+ + " from " + origin
|
|
|
+ + " not found: Job may not have executed",
|
|
|
+ outputPath);
|
|
|
Path success = new Path(outputPath, _SUCCESS);
|
|
|
- ContractTestUtils.assertIsFile(fs, success);
|
|
|
- FileStatus status = fs.getFileStatus(success);
|
|
|
- assertTrue("0 byte success file - not a s3guard committer " + success,
|
|
|
+ FileStatus status = ContractTestUtils.verifyPathExists(fs,
|
|
|
+ "job completion marker " + success
|
|
|
+ + " from " + origin
|
|
|
+ + " not found: Job may have failed",
|
|
|
+ success);
|
|
|
+ assertTrue("_SUCCESS outout from " + origin + " is not a file " + status,
|
|
|
+ status.isFile());
|
|
|
+ assertTrue("0 byte success file "
|
|
|
+ + success + " from " + origin
|
|
|
+ + "; a s3guard committer was not used",
|
|
|
status.getLen() > 0);
|
|
|
return SuccessData.load(fs, success);
|
|
|
}
|