Search in sources :

Example 1 with MetadataStore

use of voldemort.store.metadata.MetadataStore in project voldemort by voldemort.

the class VoldemortServer method createMetadataFromConfig.

private static MetadataStore createMetadataFromConfig(VoldemortConfig voldemortConfig) {
    MetadataStore metadataStore = MetadataStore.readFromDirectory(new File(voldemortConfig.getMetadataDirectory()));
    int nodeId = getNodeId(voldemortConfig, metadataStore.getCluster());
    metadataStore.initNodeId(nodeId);
    return metadataStore;
}
Also used : MetadataStore(voldemort.store.metadata.MetadataStore) File(java.io.File)

Example 2 with MetadataStore

use of voldemort.store.metadata.MetadataStore in project voldemort by voldemort.

the class ServerTestUtils method getStores.

public static StoreRepository getStores(String storeName, String clusterXml, String storesXml) {
    StoreRepository repository = new StoreRepository();
    Store<ByteArray, byte[], byte[]> store = new InMemoryStorageEngine<ByteArray, byte[], byte[]>(storeName);
    repository.addLocalStore(store);
    repository.addRoutedStore(store);
    // create new metadata store.
    MetadataStore metadata = createMetadataStore(new ClusterMapper().readCluster(new StringReader(clusterXml)), new StoreDefinitionsMapper().readStoreList(new StringReader(storesXml)));
    repository.addLocalStore(metadata);
    return repository;
}
Also used : MetadataStore(voldemort.store.metadata.MetadataStore) InMemoryStorageEngine(voldemort.store.memory.InMemoryStorageEngine) StringReader(java.io.StringReader) StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) ByteArray(voldemort.utils.ByteArray) StoreRepository(voldemort.server.StoreRepository) ClusterMapper(voldemort.xml.ClusterMapper)

Example 3 with MetadataStore

use of voldemort.store.metadata.MetadataStore in project voldemort by voldemort.

the class InvalidMetadataCheckingStoreTest method testAddingPartition.

/**
     * NOTE: the total number of partitions should remain same for hash
     * consistency
     */
public void testAddingPartition() {
    StoreDefinition storeDef = ServerTestUtils.getStoreDefs(1).get(0);
    Cluster cluster = ServerTestUtils.getLocalCluster(3, new int[][] { { 0, 1, 2, 3 }, { 4, 5, 6, 7 }, { 8, 9, 10 } });
    MetadataStore metadata = ServerTestUtils.createMetadataStore(cluster, Arrays.asList(storeDef));
    InvalidMetadataCheckingStore store = new InvalidMetadataCheckingStore(0, new DoNothingStore<ByteArray, byte[], byte[]>(storeDef.getName()), metadata);
    try {
        // add partitions to node 0 on client side.
        Cluster updatedCluster = ServerTestUtils.getLocalCluster(3, new int[][] { { 0, 1, 2, 3, 4, 5, 10 }, { 6, 7 }, { 8, 9 } });
        MetadataStore updatedMetadata = ServerTestUtils.createMetadataStore(updatedCluster, Arrays.asList(storeDef));
        doOperations(0, store, updatedMetadata, storeDef);
        fail("Should see InvalidMetadataExceptions");
    } catch (InvalidMetadataException e) {
    // ignore
    }
}
Also used : MetadataStore(voldemort.store.metadata.MetadataStore) StoreDefinition(voldemort.store.StoreDefinition) InvalidMetadataException(voldemort.store.InvalidMetadataException) Cluster(voldemort.cluster.Cluster) ByteArray(voldemort.utils.ByteArray)

Example 4 with MetadataStore

use of voldemort.store.metadata.MetadataStore in project voldemort by voldemort.

the class InvalidMetadataCheckingStoreTest method testRemovingPartition.

public void testRemovingPartition() {
    StoreDefinition storeDef = ServerTestUtils.getStoreDefs(1).get(0);
    Cluster cluster = ServerTestUtils.getLocalCluster(3, new int[][] { { 0, 1, 2, 3 }, { 4, 5, 6, 7 }, { 8, 9, 10 } });
    MetadataStore metadata = ServerTestUtils.createMetadataStore(cluster, Arrays.asList(storeDef));
    InvalidMetadataCheckingStore store = new InvalidMetadataCheckingStore(0, new DoNothingStore<ByteArray, byte[], byte[]>(storeDef.getName()), metadata);
    try {
        // remove partitions to node 0 on client side.
        Cluster updatedCluster = ServerTestUtils.getLocalCluster(3, new int[][] { { 0, 1 }, { 2, 4, 5, 6, 7 }, { 3, 8, 9, 10 } });
        MetadataStore updatedMetadata = ServerTestUtils.createMetadataStore(updatedCluster, Arrays.asList(storeDef));
        doOperations(0, store, updatedMetadata, storeDef);
    } catch (InvalidMetadataException e) {
        throw new RuntimeException("Should not see any InvalidMetaDataException", e);
    }
}
Also used : MetadataStore(voldemort.store.metadata.MetadataStore) StoreDefinition(voldemort.store.StoreDefinition) InvalidMetadataException(voldemort.store.InvalidMetadataException) Cluster(voldemort.cluster.Cluster) ByteArray(voldemort.utils.ByteArray)

Example 5 with MetadataStore

use of voldemort.store.metadata.MetadataStore in project voldemort by voldemort.

the class BlockingSlopPusherTest method setUp.

@Override
protected void setUp() throws Exception {
    Cluster cluster = makeCluster(3);
    repo = new StoreRepository();
    repo.setSlopStore(new SlopStorageEngine(new InMemoryStorageEngine<ByteArray, byte[], byte[]>("slop"), cluster));
    repo.addNodeStore(0, new InMemoryStorageEngine<ByteArray, byte[], byte[]>(STORE_NAME));
    repo.addNodeStore(1, new InMemoryStorageEngine<ByteArray, byte[], byte[]>(STORE_NAME));
    repo.addNodeStore(2, new FailingStore<ByteArray, byte[], byte[]>(STORE_NAME));
    MetadataStore metadataStore = ServerTestUtils.createMetadataStore(cluster, ServerTestUtils.getStoreDefs(1));
    Props props = new Props();
    props.put("node.id", 0);
    props.put("voldemort.home", "/");
    pusher = new BlockingSlopPusherJob(repo, metadataStore, new NoopFailureDetector(), new VoldemortConfig(props), new ScanPermitWrapper(1));
}
Also used : BlockingSlopPusherJob(voldemort.server.scheduler.slop.BlockingSlopPusherJob) NoopFailureDetector(voldemort.cluster.failuredetector.NoopFailureDetector) ScanPermitWrapper(voldemort.server.storage.ScanPermitWrapper) Cluster(voldemort.cluster.Cluster) StoreRepository(voldemort.server.StoreRepository) Props(voldemort.utils.Props) VoldemortConfig(voldemort.server.VoldemortConfig) MetadataStore(voldemort.store.metadata.MetadataStore) InMemoryStorageEngine(voldemort.store.memory.InMemoryStorageEngine) ByteArray(voldemort.utils.ByteArray) SlopStorageEngine(voldemort.store.slop.SlopStorageEngine)

Aggregations

MetadataStore (voldemort.store.metadata.MetadataStore)7 ByteArray (voldemort.utils.ByteArray)5 Cluster (voldemort.cluster.Cluster)4 StoreDefinition (voldemort.store.StoreDefinition)4 InvalidMetadataException (voldemort.store.InvalidMetadataException)3 File (java.io.File)2 StoreRepository (voldemort.server.StoreRepository)2 InMemoryStorageEngine (voldemort.store.memory.InMemoryStorageEngine)2 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 VoldemortException (voldemort.VoldemortException)1 NoopFailureDetector (voldemort.cluster.failuredetector.NoopFailureDetector)1 StoreRoutingPlan (voldemort.routing.StoreRoutingPlan)1 SerializerDefinition (voldemort.serialization.SerializerDefinition)1 VoldemortConfig (voldemort.server.VoldemortConfig)1 VoldemortServer (voldemort.server.VoldemortServer)1 AlreadyRebalancingException (voldemort.server.rebalance.AlreadyRebalancingException)1 RebalancerState (voldemort.server.rebalance.RebalancerState)1