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;
}
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());
}
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);
}
Aggregations