use of oap.storage.Metadata in project oap by oaplatform.
the class MongoStorage method fsync.
@Override
public void fsync() {
super.fsync();
val count = new MutableInt();
Stream.of(data.values().stream().filter(m -> m.modified >= lastFsync)).grouped(bulkSize).forEach(list -> {
count.add(list.size());
final List<? extends WriteModel<Metadata<T>>> bulk = Lists.map(list, metadata -> {
val id = getIdentifier().get(metadata.object);
return new ReplaceOneModel<>(eq("_id", new ObjectId(id)), metadata, UPDATE_OPTIONS_UPSERT);
});
collection.bulkWrite(bulk);
});
log.info("[{}] fsync total: {}, modified: {}", collection.getNamespace(), size(), count.intValue());
lastFsync = System.currentTimeMillis();
}
Aggregations