use of io.pravega.controller.store.stream.records.HistoryTimeSeries in project pravega by pravega.
the class StreamMetadataStoreTest method testHistoryTimeSeriesChunk.
@Test(timeout = 30000)
public void testHistoryTimeSeriesChunk() throws Exception {
String scope = "history";
String stream = "history";
createAndScaleStream(store, scope, stream, 2);
HistoryTimeSeries chunk = store.getHistoryTimeSeriesChunk(scope, stream, 0, null, executor).join();
assertEquals(chunk.getLatestRecord().getEpoch(), 2);
}
use of io.pravega.controller.store.stream.records.HistoryTimeSeries in project pravega by pravega.
the class ControllerMetadataJsonSerializerTest method testHistoryTimeSeries.
@Test
public void testHistoryTimeSeries() {
List<StreamSegmentRecord> sealedSegments = Lists.newArrayList(StreamSegmentRecord.newSegmentRecord(0, 0, 0L, 0.0, 1.0));
List<StreamSegmentRecord> newSegments = Lists.newArrayList(StreamSegmentRecord.newSegmentRecord(0, 0, 0L, 0.0, 1.0), StreamSegmentRecord.newSegmentRecord(1, 1, 0L, 0.1, 0.2));
HistoryTimeSeriesRecord node = new HistoryTimeSeriesRecord(0, 0, ImmutableList.copyOf(sealedSegments), ImmutableList.copyOf(newSegments), 0L);
HistoryTimeSeriesRecord node2 = new HistoryTimeSeriesRecord(1, 0, ImmutableList.of(), ImmutableList.of(), 1L);
HistoryTimeSeriesRecord node3 = new HistoryTimeSeriesRecord(4, 4, ImmutableList.copyOf(sealedSegments), ImmutableList.copyOf(newSegments), 1L);
HistoryTimeSeries record = new HistoryTimeSeries(ImmutableList.of(node, node2, node3));
testRecordSerialization(record, HistoryTimeSeries.class);
}
use of io.pravega.controller.store.stream.records.HistoryTimeSeries in project pravega by pravega.
the class PersistentStreamBase method createHistoryTimeSeriesChunk.
private CompletableFuture<Void> createHistoryTimeSeriesChunk(int chunkNumber, HistoryTimeSeriesRecord epoch, OperationContext context) {
ImmutableList.Builder<HistoryTimeSeriesRecord> builder = ImmutableList.builder();
HistoryTimeSeries timeSeries = new HistoryTimeSeries(builder.add(epoch).build());
return createHistoryTimeSeriesChunkDataIfAbsent(chunkNumber, timeSeries, context);
}
use of io.pravega.controller.store.stream.records.HistoryTimeSeries in project pravega by pravega.
the class PersistentStreamBase method updateHistoryTimeSeries.
private CompletableFuture<Void> updateHistoryTimeSeries(HistoryTimeSeriesRecord record, OperationContext context) {
int historyChunk = record.getEpoch() / historyChunkSize.get();
boolean isFirst = record.getEpoch() % historyChunkSize.get() == 0;
if (isFirst) {
return createHistoryTimeSeriesChunk(historyChunk, record, context);
} else {
return getHistoryTimeSeriesChunkData(historyChunk, true, context).thenCompose(x -> {
HistoryTimeSeries historyChunkTimeSeries = x.getObject();
if (historyChunkTimeSeries.getLatestRecord().getEpoch() < record.getEpoch()) {
HistoryTimeSeries update = HistoryTimeSeries.addHistoryRecord(historyChunkTimeSeries, record);
return Futures.toVoid(updateHistoryTimeSeriesChunkData(historyChunk, new VersionedMetadata<>(update, x.getVersion()), context));
} else {
return CompletableFuture.completedFuture(null);
}
});
}
}
Aggregations