Fix LogFileCompressor scheduling

Since: I1e665848cd7cd5f93628db97c0af17900d243f9d initial delay for the
scheduled task was not being calculated correctly, leading to the task
initially being run much later than expected.

Change-Id: I88dc9b10785b15f46eb21463a48e49d4416cd651
This commit is contained in:
Owen Li 2017-10-16 10:56:11 -04:00
parent 24796d957a
commit 0253aa223d

View File

@ -29,8 +29,9 @@ import java.io.OutputStream;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.concurrent.Future;
import java.util.zip.GZIPOutputStream;
import org.slf4j.Logger;
@ -62,8 +63,9 @@ public class LogFileCompressor implements Runnable {
//compress log once and then schedule compression every day at 11:00pm
queue.getDefaultQueue().execute(compressor);
ZoneId zone = ZoneId.systemDefault();
LocalDate now = LocalDate.now(zone);
long milliSecondsUntil11pm = now.atStartOfDay(zone).plusHours(23).toInstant().toEpochMilli();
LocalDateTime now = LocalDateTime.now(zone);
long milliSecondsUntil11pm =
now.until(now.withHour(23).withMinute(0).withSecond(0).withNano(0), ChronoUnit.MILLIS);
@SuppressWarnings("unused")
Future<?> possiblyIgnoredError =
queue