use of java.util.function.LongPredicate in project bboxdb by jnidzwetzki.
the class SSTableCheckpointRunnable method isCheckpointNeeded.
/**
* Decide if a new checkpoint is needed
* @return
*/
protected boolean isCheckpointNeeded(final TupleStoreManager ssTableManager) {
final List<ReadOnlyTupleStore> inMemoryStores = ssTableManager.getAllInMemoryStorages();
if (inMemoryStores.isEmpty()) {
return false;
}
final long currentTime = System.currentTimeMillis();
// The checkpoint predicate
final LongPredicate checkpointPredicate = m -> {
final long checkpointThreshold = TimeUnit.MICROSECONDS.toMillis(m) + maxUncheckpointedMiliseconds;
return checkpointThreshold < currentTime;
};
final boolean checkpointNeeded = inMemoryStores.stream().filter(Objects::nonNull).mapToLong(m -> m.getOldestTupleVersionTimestamp()).anyMatch(checkpointPredicate);
logger.debug("Checkpoint for {} needed {}", ssTableManager.getTupleStoreName().getFullname(), checkpointNeeded);
return checkpointNeeded;
}
Aggregations