Search in sources :

Example 1 with HistoryTimeSeries

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);
}
Also used : HistoryTimeSeries(io.pravega.controller.store.stream.records.HistoryTimeSeries) Test(org.junit.Test)

Example 2 with HistoryTimeSeries

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);
}
Also used : StreamSegmentRecord(io.pravega.controller.store.stream.records.StreamSegmentRecord) HistoryTimeSeriesRecord(io.pravega.controller.store.stream.records.HistoryTimeSeriesRecord) HistoryTimeSeries(io.pravega.controller.store.stream.records.HistoryTimeSeries) Test(org.junit.Test)

Example 3 with HistoryTimeSeries

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);
}
Also used : HistoryTimeSeriesRecord(io.pravega.controller.store.stream.records.HistoryTimeSeriesRecord) ImmutableList(com.google.common.collect.ImmutableList) HistoryTimeSeries(io.pravega.controller.store.stream.records.HistoryTimeSeries)

Example 4 with HistoryTimeSeries

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);
            }
        });
    }
}
Also used : VersionedMetadata(io.pravega.controller.store.VersionedMetadata) HistoryTimeSeries(io.pravega.controller.store.stream.records.HistoryTimeSeries)

Aggregations

HistoryTimeSeries (io.pravega.controller.store.stream.records.HistoryTimeSeries)4 HistoryTimeSeriesRecord (io.pravega.controller.store.stream.records.HistoryTimeSeriesRecord)2 Test (org.junit.Test)2 ImmutableList (com.google.common.collect.ImmutableList)1 VersionedMetadata (io.pravega.controller.store.VersionedMetadata)1 StreamSegmentRecord (io.pravega.controller.store.stream.records.StreamSegmentRecord)1