Add logging to ReindexingCurator
@@ -18,6 +18,8 @@ import java.time.Duration;
import java.time.Instant;
import java.util.Map;
import java.util.function.Function;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import static java.util.Objects.requireNonNull;
import static java.util.stream.Collectors.toUnmodifiableMap;
@@ -29,6 +31,8 @@ import static java.util.stream.Collectors.toUnmodifiableMap;
*/
public class ReindexingCurator {
+ private static final Logger log = Logger.getLogger(ReindexingCurator.class.getName());
+
private final Curator curator;
private final ReindexingSerializer serializer;
private final Duration lockTimeout;
@@ -55,6 +59,7 @@ public class ReindexingCurator {
if (ready.get(type).isBefore(now))
reindexing = reindexing.with(type, Status.ready(now).running().successful(now));
+ log.log(Level.INFO, "Creating initial reindexing status at '" + statusPath(cluster) + "'");
writeReindexing(reindexing, cluster);
}
catch (ReindexingLockException ignored) {
@@ -64,11 +69,14 @@ public class ReindexingCurator {
}
public Reindexing readReindexing(String cluster) {
- return curator.getData(statusPath(cluster)).map(serializer::deserialize)
+ Reindexing reindexing = curator.getData(statusPath(cluster)).map(serializer::deserialize)
.orElse(Reindexing.empty());
+ log.log(Level.FINE, () -> "Read reindexing status '" + reindexing + "' from '" + statusPath(cluster) + "'");
+ return reindexing;
}
public void writeReindexing(Reindexing reindexing, String cluster) {
+ log.log(Level.FINE, () -> "Writing reindexing status '" + reindexing + "' to '" + statusPath(cluster) + "'");
curator.set(statusPath(cluster), serializer.serialize(reindexing));
}
