Search in sources :

Example 16 with InvalidMetadataException

use of voldemort.store.InvalidMetadataException in project voldemort by voldemort.

the class DefaultStoreClient method getAll.

public Map<K, Versioned<V>> getAll(Iterable<K> keys) {
    Map<K, List<Versioned<V>>> items = null;
    for (int attempts = 0; ; attempts++) {
        if (attempts >= this.metadataRefreshAttempts)
            throw new VoldemortException(this.metadataRefreshAttempts + " metadata refresh attempts failed.");
        try {
            items = store.getAll(keys, null);
            break;
        } catch (InvalidMetadataException e) {
            logger.info("Received invalid metadata exception during getAll [  " + e.getMessage() + " ] on store '" + storeName + "'. Rebootstrapping");
            bootStrap();
        }
    }
    Map<K, Versioned<V>> result = Maps.newHashMapWithExpectedSize(items.size());
    for (Entry<K, List<Versioned<V>>> mapEntry : items.entrySet()) {
        Versioned<V> value = getItemOrThrow(mapEntry.getKey(), null, mapEntry.getValue());
        result.put(mapEntry.getKey(), value);
    }
    return result;
}
Also used : Versioned(voldemort.versioning.Versioned) InvalidMetadataException(voldemort.store.InvalidMetadataException) List(java.util.List) VoldemortException(voldemort.VoldemortException)

Example 17 with InvalidMetadataException

use of voldemort.store.InvalidMetadataException in project voldemort by voldemort.

the class AsyncMetadataVersionManager method run.

public void run() {
    logger.debug("************* AsyncMetadataVersionManger running. Checking for " + SystemStoreConstants.CLUSTER_VERSION_KEY + " and  " + storesVersionKey + " *************");
    try {
        /*
             * Get the properties object from the system store (containing
             * versions)
             */
        Properties versionProps = MetadataVersionStoreUtils.getProperties(this.systemStoreRepository.getMetadataVersionStore());
        Long newClusterVersion = fetchNewVersion(SystemStoreConstants.CLUSTER_VERSION_KEY, this.currentClusterVersion, versionProps);
        Long newStoreVersion = fetchNewVersion(storesVersionKey, this.currentStoreVersion, versionProps);
        // Check if something has been updated
        if ((newClusterVersion != null) || (newStoreVersion != null)) {
            logger.info("Metadata version mismatch detected. Re-bootstrapping!");
            try {
                if (newClusterVersion != null) {
                    logger.info("Updating cluster version");
                    currentClusterVersion = newClusterVersion;
                }
                if (newStoreVersion != null) {
                    logger.info("Updating store : '" + storesVersionKey + "' version");
                    this.currentStoreVersion = newStoreVersion;
                }
                this.storeClientThunk.call();
            } catch (Exception e) {
                logger.error("Exception occurred while invoking the rebootstrap callback.", e);
            }
        }
    } catch (InvalidMetadataException e) {
        try {
            this.storeClientThunk.call();
        } catch (Exception e2) {
            logger.error("Exception occurred while invoking the rebootstrap callback.", e);
        }
    } catch (Exception e) {
        if (logger.isDebugEnabled()) {
            logger.debug("Could not retrieve metadata versions from the server.", e);
        }
    }
}
Also used : InvalidMetadataException(voldemort.store.InvalidMetadataException) Properties(java.util.Properties) InvalidMetadataException(voldemort.store.InvalidMetadataException)

Example 18 with InvalidMetadataException

use of voldemort.store.InvalidMetadataException in project voldemort by voldemort.

the class InvalidMetadataCheckingStoreTest method testValidMetaData.

public void testValidMetaData() {
    Cluster cluster = ServerTestUtils.getLocalCluster(3, new int[][] { { 0, 1, 2, 3 }, { 4, 5, 6, 7 }, { 8, 9, 10, 11 } });
    StoreDefinition storeDef = ServerTestUtils.getStoreDefs(1).get(0);
    MetadataStore metadata = ServerTestUtils.createMetadataStore(cluster, Arrays.asList(storeDef));
    InvalidMetadataCheckingStore store = new InvalidMetadataCheckingStore(0, new DoNothingStore<ByteArray, byte[], byte[]>(storeDef.getName()), metadata);
    try {
        doOperations(0, store, metadata, 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 19 with InvalidMetadataException

use of voldemort.store.InvalidMetadataException in project voldemort by voldemort.

the class RedirectingStoreTest method testProxyGetDuringPut.

@Test
public void testProxyGetDuringPut() {
    final RedirectingStore storeNode2 = getRedirectingStore(2, servers[2].getMetadataStore(), "test");
    final RedirectingStore storeNode0 = getRedirectingStore(0, servers[0].getMetadataStore(), "test");
    // Check primary
    for (final Entry<ByteArray, byte[]> entry : primaryEntriesMoved.entrySet()) {
        try {
            // should see obsoleteVersionException for same vectorClock
            storeNode2.put(entry.getKey(), Versioned.value(entry.getValue(), new VectorClock().incremented(0, System.currentTimeMillis())), null);
            fail("Should see obsoleteVersionException here.");
        } catch (ObsoleteVersionException e) {
        // ignore
        }
        try {
            // should see obsoleteVersionException for same vectorClock
            storeNode0.put(entry.getKey(), Versioned.value(entry.getValue(), new VectorClock().incremented(0, System.currentTimeMillis())), null);
            fail("Should see obsoleteVersionException here.");
        } catch (ObsoleteVersionException e) {
        // ignore
        } catch (InvalidMetadataException e) {
        }
    }
}
Also used : ObsoleteVersionException(voldemort.versioning.ObsoleteVersionException) VectorClock(voldemort.versioning.VectorClock) InvalidMetadataException(voldemort.store.InvalidMetadataException) ByteArray(voldemort.utils.ByteArray) Test(org.junit.Test)

Aggregations

InvalidMetadataException (voldemort.store.InvalidMetadataException)19 ByteArray (voldemort.utils.ByteArray)15 List (java.util.List)9 Versioned (voldemort.versioning.Versioned)7 VoldemortException (voldemort.VoldemortException)6 Cluster (voldemort.cluster.Cluster)6 ObsoleteVersionException (voldemort.versioning.ObsoleteVersionException)6 VectorClock (voldemort.versioning.VectorClock)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)5 Test (org.junit.Test)5 Node (voldemort.cluster.Node)5 IOException (java.io.IOException)4 StoreDefinition (voldemort.store.StoreDefinition)4 Date (java.util.Date)3 Iterator (java.util.Iterator)3 ExecutorService (java.util.concurrent.ExecutorService)3 ClusterTestUtils (voldemort.ClusterTestUtils)3