diff --git a/atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/sweep/SweeperService.java b/atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/sweep/SweeperService.java index b9c9e69b27f..1a68449d9c4 100644 --- a/atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/sweep/SweeperService.java +++ b/atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/sweep/SweeperService.java @@ -18,7 +18,6 @@ import java.util.Optional; import javax.ws.rs.Consumes; -import javax.ws.rs.DefaultValue; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; @@ -60,7 +59,7 @@ default SweepTableResponse sweepTableFrom(String tableName, String startRow) { SweepTableResponse sweepTable( @QueryParam("tablename") String tableName, @QueryParam("startRow") Optional startRow, - @Safe @QueryParam("fullSweep") @DefaultValue("true") Optional fullSweep, + @Safe @QueryParam("fullSweep") Optional fullSweep, @Safe @QueryParam("maxCellTsPairsToExamine") Optional maxCellTsPairsToExamine, @Safe @QueryParam("candidateBatchSize") Optional candidateBatchSize, @Safe @QueryParam("deleteBatchSize") Optional deleteBatchSize); diff --git a/atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/sweep/SweeperServiceImpl.java b/atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/sweep/SweeperServiceImpl.java index dd65bcf05c6..99db582e62f 100644 --- a/atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/sweep/SweeperServiceImpl.java +++ b/atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/sweep/SweeperServiceImpl.java @@ -17,13 +17,21 @@ import java.util.Optional; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.google.common.base.Preconditions; import com.palantir.atlasdb.encoding.PtBytes; import com.palantir.atlasdb.keyvalue.api.SweepResults; import com.palantir.atlasdb.keyvalue.api.TableReference; +import com.palantir.atlasdb.logging.LoggingArgs; +import com.palantir.logsafe.SafeArg; +import com.palantir.logsafe.UnsafeArg; import com.palantir.remoting3.servers.jersey.WebPreconditions; public final class SweeperServiceImpl implements SweeperService { + private static final Logger log = LoggerFactory.getLogger(SweeperServiceImpl.class); + private final SpecificTableSweeper specificTableSweeper; private final AdjustableSweepBatchConfigSource sweepBatchConfigSource; @@ -48,17 +56,36 @@ public SweepTableResponse sweepTable( SweepBatchConfig config = buildConfigWithOverrides(maxCellTsPairsToExamine, candidateBatchSize, deleteBatchSize); - SweepResults sweepResults = fullSweep.orElse(true) - ? runFullSweepWithoutSavingResults( - tableRef, - decodedStartRow, - config) - : runOneBatchWithoutSavingResults( - tableRef, - decodedStartRow, - config); - - return SweepTableResponse.from(sweepResults); + return SweepTableResponse.from(runSweep(fullSweep, tableRef, decodedStartRow, config)); + } + + private SweepResults runSweep(Optional fullSweep, TableReference tableRef, byte[] decodedStartRow, + SweepBatchConfig config) { + if (!fullSweep.isPresent()) { + log.warn("fullSweep parameter was not specified, defaulting to true"); + } + + if (fullSweep.orElse(true)) { + log.info("Running sweep of full table {}, " + + "with maxCellTsPairsToExamine: {}, candidateBatchSize: {}, deleteBatchSize: {}, " + + "starting from row {}", + LoggingArgs.tableRef(tableRef), + SafeArg.of("maxCellTsPairsToExamine", config.maxCellTsPairsToExamine()), + SafeArg.of("candidateBatchSize", config.candidateBatchSize()), + SafeArg.of("deleteBatchSize", config.deleteBatchSize()), + UnsafeArg.of("decodedStartRow", decodedStartRow)); + return runFullSweepWithoutSavingResults(tableRef, decodedStartRow, config); + } else { + log.info("Running sweep of a single batch on table {}, " + + "with maxCellTsPairsToExamine: {}, candidateBatchSize: {}, deleteBatchSize: {}, " + + "starting from row {}", + LoggingArgs.tableRef(tableRef), + SafeArg.of("maxCellTsPairsToExamine", config.maxCellTsPairsToExamine()), + SafeArg.of("candidateBatchSize", config.candidateBatchSize()), + SafeArg.of("deleteBatchSize", config.deleteBatchSize()), + UnsafeArg.of("decodedStartRow", decodedStartRow)); + return runOneBatchWithoutSavingResults(tableRef, decodedStartRow, config); + } } private SweepBatchConfig buildConfigWithOverrides( diff --git a/docs/source/release_notes/release-notes.rst b/docs/source/release_notes/release-notes.rst index 303899307b2..f607d7a212e 100644 --- a/docs/source/release_notes/release-notes.rst +++ b/docs/source/release_notes/release-notes.rst @@ -66,6 +66,12 @@ develop - AtlasDB can now tag RC releases. (`Pull Request `__) + * - |improved| |logs| + - ``SweeperServiceImpl`` now logs when it starts sweeping and makes it clear if it is running full sweep or not + + * - + - + .. <<<<------------------------------------------------------------------------------------------------------------->>>> =======