Search in sources :

Example 1 with StateRecord

use of io.pravega.controller.store.stream.records.StateRecord in project pravega by pravega.

the class InMemoryStream method checkStreamExists.

@Override
CompletableFuture<CreateStreamResponse> checkStreamExists(StreamConfiguration configuration, long timestamp, final int startingSegmentNumber, OperationContext context) {
    CompletableFuture<CreateStreamResponse> result = new CompletableFuture<>();
    final long time;
    final StreamConfigurationRecord config;
    final VersionedMetadata<StateRecord> currentState;
    synchronized (lock) {
        time = creationTime.get();
        config = this.configuration == null ? null : this.configuration.getObject();
        currentState = this.state;
    }
    if (time != Long.MIN_VALUE) {
        if (config != null) {
            handleStreamMetadataExists(timestamp, result, time, startingSegmentNumber, config.getStreamConfiguration(), currentState, context);
        } else {
            result.complete(new CreateStreamResponse(CreateStreamResponse.CreateStatus.NEW, configuration, time, startingSegmentNumber));
        }
    } else {
        result.complete(new CreateStreamResponse(CreateStreamResponse.CreateStatus.NEW, configuration, timestamp, startingSegmentNumber));
    }
    return result;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) StateRecord(io.pravega.controller.store.stream.records.StateRecord) StreamConfigurationRecord(io.pravega.controller.store.stream.records.StreamConfigurationRecord)

Example 2 with StateRecord

use of io.pravega.controller.store.stream.records.StateRecord in project pravega by pravega.

the class ControllerMetadataSerializerTest method testControllerMetadataSerializer.

@Test
public void testControllerMetadataSerializer() {
    StateRecord record = new StateRecord(State.ACTIVE);
    ControllerMetadataSerializer serializer = new ControllerMetadataSerializer(getQualifiedTableName(INTERNAL_SCOPE_NAME, TEST_SCOPE, TEST_STREAM, String.format(METADATA_TABLE, AttributeId.UUID.randomUUID())), STATE_KEY);
    ByteBuffer buf = serializer.serialize(record);
    assertEquals("StateRecord", serializer.getMetadataType());
    assertEquals(record.getState(), ((StateRecord) serializer.deserialize(buf)).getState());
}
Also used : StateRecord(io.pravega.controller.store.stream.records.StateRecord) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 3 with StateRecord

use of io.pravega.controller.store.stream.records.StateRecord in project pravega by pravega.

the class ControllerMetadataJsonSerializerTest method testStateRecord.

@Test
public void testStateRecord() {
    StateRecord record = new StateRecord(State.ACTIVE);
    testRecordSerialization(record, StateRecord.class);
}
Also used : StateRecord(io.pravega.controller.store.stream.records.StateRecord) Test(org.junit.Test)

Aggregations

StateRecord (io.pravega.controller.store.stream.records.StateRecord)3 Test (org.junit.Test)2 StreamConfigurationRecord (io.pravega.controller.store.stream.records.StreamConfigurationRecord)1 ByteBuffer (java.nio.ByteBuffer)1 CompletableFuture (java.util.concurrent.CompletableFuture)1