Uses LongSupplier for nowSupplier
Rather than Supplier<Long>. This is in line with the `nowSupplier`s used in other areas of Elasticsearch
This commit is contained in:
parent
31ded906d0
commit
06958949ab
|
@ -29,7 +29,7 @@ import java.io.Closeable;
|
|||
import java.io.IOException;
|
||||
import java.time.Clock;
|
||||
import java.util.SortedMap;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.LongSupplier;
|
||||
|
||||
import static org.elasticsearch.xpack.indexlifecycle.IndexLifecycle.NAME;
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class IndexLifecycleInitialisationService extends AbstractComponent
|
|||
private Client client;
|
||||
private ClusterService clusterService;
|
||||
private ThreadPool threadPool;
|
||||
private Supplier<Long> nowSupplier;
|
||||
private LongSupplier nowSupplier;
|
||||
|
||||
public IndexLifecycleInitialisationService(Settings settings, Client client, ClusterService clusterService, Clock clock,
|
||||
ThreadPool threadPool) {
|
||||
|
@ -51,7 +51,7 @@ public class IndexLifecycleInitialisationService extends AbstractComponent
|
|||
this.clusterService = clusterService;
|
||||
this.clock = clock;
|
||||
this.threadPool = threadPool;
|
||||
this.nowSupplier = () -> System.currentTimeMillis(); // NOCOMMIT use ES now supplier.
|
||||
this.nowSupplier = () -> System.currentTimeMillis();
|
||||
clusterService.addListener(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.LongSupplier;
|
||||
|
||||
public class LifecyclePolicy extends AbstractDiffable<LifecyclePolicy> implements ToXContentObject, Writeable {
|
||||
private static final Logger logger = ESLoggerFactory.getLogger(LifecyclePolicy.class);
|
||||
|
@ -90,7 +90,7 @@ public class LifecyclePolicy extends AbstractDiffable<LifecyclePolicy> implement
|
|||
return builder;
|
||||
}
|
||||
|
||||
public void execute(IndexMetaData idxMeta, Client client, Supplier<Long> nowSupplier) {
|
||||
public void execute(IndexMetaData idxMeta, Client client, LongSupplier nowSupplier) {
|
||||
String currentPhaseName = IndexLifecycle.LIFECYCLE_TIMESERIES_PHASE_SETTING.get(idxMeta.getSettings());
|
||||
boolean currentPhaseActionsComplete = IndexLifecycle.LIFECYCLE_TIMESERIES_ACTION_SETTING.get(idxMeta.getSettings())
|
||||
.equals(Phase.PHASE_COMPLETED);
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.LongSupplier;
|
||||
|
||||
public class Phase implements ToXContentObject, Writeable {
|
||||
public static final String PHASE_COMPLETED = "ACTIONS COMPLETED";
|
||||
|
@ -91,8 +91,8 @@ public class Phase implements ToXContentObject, Writeable {
|
|||
return actions;
|
||||
}
|
||||
|
||||
protected boolean canExecute(IndexMetaData idxMeta, Supplier<Long> nowSupplier) {
|
||||
long now = nowSupplier.get();
|
||||
protected boolean canExecute(IndexMetaData idxMeta, LongSupplier nowSupplier) {
|
||||
long now = nowSupplier.getAsLong();
|
||||
long indexCreated = idxMeta.getCreationDate();
|
||||
return (indexCreated + after.millis()) <= now;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue