Fail compactionTask if it fails to run one of indexTaskSpecs (#6428)

* Fail compactionTask if it fails to run one of indexTaskSpecs

* add log
This commit is contained in:
Jihoon Son 2018-10-08 08:53:32 -07:00 committed by Fangjin Yang
parent 88d23b77b7
commit 2b76d57347
1 changed files with 7 additions and 2 deletions

View File

@ -261,8 +261,10 @@ public class CompactionTask extends AbstractTask
log.warn("Interval[%s] has no segments, nothing to do.", interval);
return TaskStatus.failure(getId());
} else {
log.info("Generated [%d] compaction task specs", indexTaskSpecs.size());
final int totalNumSpecs = indexTaskSpecs.size();
log.info("Generated [%d] compaction task specs", totalNumSpecs);
int failCnt = 0;
for (IndexTask eachSpec : indexTaskSpecs) {
final String json = jsonMapper.writerWithDefaultPrettyPrinter().writeValueAsString(eachSpec);
log.info("Running indexSpec: " + json);
@ -270,15 +272,18 @@ public class CompactionTask extends AbstractTask
try {
final TaskStatus eachResult = eachSpec.run(toolbox);
if (!eachResult.isSuccess()) {
failCnt++;
log.warn("Failed to run indexSpec: [%s].\nTrying the next indexSpec.", json);
}
}
catch (Exception e) {
failCnt++;
log.warn(e, "Failed to run indexSpec: [%s].\nTrying the next indexSpec.", json);
}
}
return TaskStatus.success(getId());
log.info("Run [%d] specs, [%d] succeeded, [%d] failed", totalNumSpecs, totalNumSpecs - failCnt, failCnt);
return failCnt == 0 ? TaskStatus.success(getId()) : TaskStatus.failure(getId());
}
}