mukund-thakur commented on a change in pull request #1851: HADOOP-16858.
S3Guard fsck: Add option to remove orphaned entries
URL: https://github.com/apache/hadoop/pull/1851#discussion_r383743260
##########
File path:
hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/s3guard/S3GuardFsckViolationHandler.java
##########
@@ -60,28 +66,51 @@ public void handle(S3GuardFsck.ComparePair comparePair) {
sB.append(newLine)
.append("On path: ").append(comparePair.getPath()).append(newLine);
- handleComparePair(comparePair, sB);
+ handleComparePair(comparePair, sB, HandleMode.LOG);
LOG.error(sB.toString());
}
+ public void doFix(S3GuardFsck.ComparePair comparePair) throws IOException {
+ if (!comparePair.containsViolation()) {
+ LOG.debug("There is no violation in the compare pair: {}", comparePair);
+ return;
+ }
+
+ StringBuilder sB = new StringBuilder();
+ sB.append(newLine)
+ .append("On path: ").append(comparePair.getPath()).append(newLine);
+
+ handleComparePair(comparePair, sB, HandleMode.FIX);
+
+ LOG.info(sB.toString());
+ }
+
/**
* Create a new instance of the violation handler for all the violations
* found in the compare pair and use it.
*
* @param comparePair the compare pair with violations
* @param sB StringBuilder to append error strings from violations.
*/
- protected static void handleComparePair(S3GuardFsck.ComparePair comparePair,
- StringBuilder sB) {
+ protected void handleComparePair(S3GuardFsck.ComparePair comparePair,
+ StringBuilder sB, HandleMode handleMode) throws IOException {
for (S3GuardFsck.Violation violation : comparePair.getViolations()) {
try {
ViolationHandler handler = violation.getHandler()
.getDeclaredConstructor(S3GuardFsck.ComparePair.class)
.newInstance(comparePair);
- final String errorStr = handler.getError();
- sB.append(errorStr);
+
+ if (handleMode == HandleMode.LOG) {
Review comment:
Don't you think CASE statements would be better option here.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]