Search in sources :

Example 1 with VersionIncrementingStore

use of voldemort.store.versioned.VersionIncrementingStore in project voldemort by voldemort.

the class InMemoryMultiThreadedTest method main.

public static void main(String[] args) throws Exception {
    Store<byte[], byte[], byte[]> store = new VersionIncrementingStore<byte[], byte[], byte[]>(new InMemoryStorageEngine<byte[], byte[], byte[]>("test"), 0, new SystemTime());
    store = new InconsistencyResolvingStore<byte[], byte[], byte[]>(store, new VectorClockInconsistencyResolver<byte[]>());
    new MultithreadedStressTest(store, 5, 1000000, 10).testGetAndPut();
}
Also used : VersionIncrementingStore(voldemort.store.versioned.VersionIncrementingStore) VectorClockInconsistencyResolver(voldemort.versioning.VectorClockInconsistencyResolver) SystemTime(voldemort.utils.SystemTime)

Example 2 with VersionIncrementingStore

use of voldemort.store.versioned.VersionIncrementingStore in project voldemort by voldemort.

the class MockStoreClientFactory method getRawStore.

private <K1, V1, T1> Store<K1, V1, T1> getRawStore(String storeName) {
    List<StoreDefinition> storeDefs = storeMapper.readStoreList(new StringReader(storesXml));
    StoreDefinition storeDef = null;
    for (StoreDefinition d : storeDefs) if (d.getName().equals(storeName))
        storeDef = d;
    if (storeDef == null)
        throw new BootstrapFailureException("Unknown store '" + storeName + "'.");
    DefaultSerializerFactory serializerFactory = new DefaultSerializerFactory();
    Serializer<K1> keySerializer = (Serializer<K1>) serializerFactory.getSerializer(storeDef.getKeySerializer());
    Serializer<V1> valueSerializer = (Serializer<V1>) serializerFactory.getSerializer(storeDef.getValueSerializer());
    Serializer<T1> transformsSerializer = null;
    if (storeDef.isView())
        transformsSerializer = (Serializer<T1>) serializerFactory.getSerializer(storeDef.getTransformsSerializer());
    // Add inconsistency resolving decorator, using their inconsistency
    // resolver (if they gave us one)
    InconsistencyResolver<Versioned<V1>> secondaryResolver = new TimeBasedInconsistencyResolver();
    StorageEngine engine;
    if (storeDef.isView())
        engine = new InMemoryStorageEngine(storeDef.getViewTargetStoreName());
    else
        engine = new InMemoryStorageEngine(storeDef.getName());
    if (storeDef.isView()) {
        // instantiate view
        String targetName = storeDef.getViewTargetStoreName();
        StoreDefinition targetDef = StoreUtils.getStoreDef(storeDefs, targetName);
        engine = new ViewStorageEngine(storeName, engine, this.viewValueSerializer != null ? this.viewValueSerializer : serializerFactory.getSerializer(storeDef.getValueSerializer()), this.transformsSerializer != null ? this.transformsSerializer : serializerFactory.getSerializer(storeDef.getTransformsSerializer()), this.keySerializer != null ? this.keySerializer : serializerFactory.getSerializer(targetDef.getKeySerializer()), this.valueSerializer != null ? this.valueSerializer : serializerFactory.getSerializer(targetDef.getValueSerializer()), null, ViewStorageConfiguration.loadTransformation(storeDef.getValueTransformation()));
    }
    Store store = new VersionIncrementingStore(engine, nodeId, time);
    store = new SerializingStore(store, this.keySerializer != null ? this.keySerializer : keySerializer, this.valueSerializer != null ? this.valueSerializer : valueSerializer, this.transformsSerializer != null ? this.transformsSerializer : transformsSerializer);
    Store<K1, V1, T1> consistentStore = new InconsistencyResolvingStore<K1, V1, T1>(store, new ChainedResolver<Versioned<V1>>(new VectorClockInconsistencyResolver(), secondaryResolver));
    return consistentStore;
}
Also used : Versioned(voldemort.versioning.Versioned) Store(voldemort.store.Store) SerializingStore(voldemort.store.serialized.SerializingStore) InconsistencyResolvingStore(voldemort.store.versioned.InconsistencyResolvingStore) VersionIncrementingStore(voldemort.store.versioned.VersionIncrementingStore) ViewStorageEngine(voldemort.store.views.ViewStorageEngine) StorageEngine(voldemort.store.StorageEngine) InMemoryStorageEngine(voldemort.store.memory.InMemoryStorageEngine) VersionIncrementingStore(voldemort.store.versioned.VersionIncrementingStore) InconsistencyResolvingStore(voldemort.store.versioned.InconsistencyResolvingStore) InMemoryStorageEngine(voldemort.store.memory.InMemoryStorageEngine) StoreDefinition(voldemort.store.StoreDefinition) StringReader(java.io.StringReader) SerializingStore(voldemort.store.serialized.SerializingStore) Serializer(voldemort.serialization.Serializer) ViewStorageEngine(voldemort.store.views.ViewStorageEngine) DefaultSerializerFactory(voldemort.serialization.DefaultSerializerFactory) TimeBasedInconsistencyResolver(voldemort.versioning.TimeBasedInconsistencyResolver) VectorClockInconsistencyResolver(voldemort.versioning.VectorClockInconsistencyResolver)

Example 3 with VersionIncrementingStore

use of voldemort.store.versioned.VersionIncrementingStore in project voldemort by voldemort.

the class MockStoreClientFactory method getRawStore.

public <K1, V1, T1> Store<K1, V1, T1> getRawStore(String storeName, InconsistencyResolver<Versioned<V1>> resolver) {
    if (this.storesXml != null)
        return getRawStore(storeName);
    // Add inconsistency resolving decorator, using their inconsistency
    // resolver (if they gave us one)
    InconsistencyResolver<Versioned<V1>> secondaryResolver = new TimeBasedInconsistencyResolver();
    if (resolver != null)
        secondaryResolver = resolver;
    Store store = new VersionIncrementingStore(new InMemoryStorageEngine(storeName), nodeId, time);
    if (isSerialized())
        store = new SerializingStore(store, keySerializer, valueSerializer, transformsSerializer);
    Store<K1, V1, T1> consistentStore = new InconsistencyResolvingStore<K1, V1, T1>(store, new ChainedResolver<Versioned<V1>>(new VectorClockInconsistencyResolver(), secondaryResolver));
    return consistentStore;
}
Also used : Versioned(voldemort.versioning.Versioned) Store(voldemort.store.Store) SerializingStore(voldemort.store.serialized.SerializingStore) InconsistencyResolvingStore(voldemort.store.versioned.InconsistencyResolvingStore) VersionIncrementingStore(voldemort.store.versioned.VersionIncrementingStore) VersionIncrementingStore(voldemort.store.versioned.VersionIncrementingStore) InconsistencyResolvingStore(voldemort.store.versioned.InconsistencyResolvingStore) InMemoryStorageEngine(voldemort.store.memory.InMemoryStorageEngine) TimeBasedInconsistencyResolver(voldemort.versioning.TimeBasedInconsistencyResolver) SerializingStore(voldemort.store.serialized.SerializingStore) VectorClockInconsistencyResolver(voldemort.versioning.VectorClockInconsistencyResolver)

Aggregations

VersionIncrementingStore (voldemort.store.versioned.VersionIncrementingStore)3 VectorClockInconsistencyResolver (voldemort.versioning.VectorClockInconsistencyResolver)3 Store (voldemort.store.Store)2 InMemoryStorageEngine (voldemort.store.memory.InMemoryStorageEngine)2 SerializingStore (voldemort.store.serialized.SerializingStore)2 InconsistencyResolvingStore (voldemort.store.versioned.InconsistencyResolvingStore)2 TimeBasedInconsistencyResolver (voldemort.versioning.TimeBasedInconsistencyResolver)2 Versioned (voldemort.versioning.Versioned)2 StringReader (java.io.StringReader)1 DefaultSerializerFactory (voldemort.serialization.DefaultSerializerFactory)1 Serializer (voldemort.serialization.Serializer)1 StorageEngine (voldemort.store.StorageEngine)1 StoreDefinition (voldemort.store.StoreDefinition)1 ViewStorageEngine (voldemort.store.views.ViewStorageEngine)1 SystemTime (voldemort.utils.SystemTime)1