Search in sources :

Example 1 with ContentDeserializationException

use of org.apache.pulsar.metadata.api.MetadataStoreException.ContentDeserializationException in project pulsar by apache.

the class MetadataCacheImpl method readValueFromStore.

private CompletableFuture<Optional<CacheGetResult<T>>> readValueFromStore(String path) {
    return store.get(path).thenCompose(optRes -> {
        if (!optRes.isPresent()) {
            return FutureUtils.value(Optional.empty());
        }
        try {
            GetResult res = optRes.get();
            T obj = serde.deserialize(path, res.getValue(), res.getStat());
            return FutureUtils.value(Optional.of(new CacheGetResult<>(obj, res.getStat())));
        } catch (Throwable t) {
            return FutureUtils.exception(new ContentDeserializationException("Failed to deserialize payload for key '" + path + "'", t));
        }
    });
}
Also used : CacheGetResult(org.apache.pulsar.metadata.api.CacheGetResult) GetResult(org.apache.pulsar.metadata.api.GetResult) CacheGetResult(org.apache.pulsar.metadata.api.CacheGetResult) ContentDeserializationException(org.apache.pulsar.metadata.api.MetadataStoreException.ContentDeserializationException)

Example 2 with ContentDeserializationException

use of org.apache.pulsar.metadata.api.MetadataStoreException.ContentDeserializationException in project incubator-pulsar by apache.

the class MetadataCacheImpl method readValueFromStore.

private CompletableFuture<Optional<CacheGetResult<T>>> readValueFromStore(String path) {
    return store.get(path).thenCompose(optRes -> {
        if (!optRes.isPresent()) {
            return FutureUtils.value(Optional.empty());
        }
        try {
            GetResult res = optRes.get();
            T obj = serde.deserialize(path, res.getValue(), res.getStat());
            return FutureUtils.value(Optional.of(new CacheGetResult<>(obj, res.getStat())));
        } catch (Throwable t) {
            return FutureUtils.exception(new ContentDeserializationException("Failed to deserialize payload for key '" + path + "'", t));
        }
    });
}
Also used : CacheGetResult(org.apache.pulsar.metadata.api.CacheGetResult) GetResult(org.apache.pulsar.metadata.api.GetResult) CacheGetResult(org.apache.pulsar.metadata.api.CacheGetResult) ContentDeserializationException(org.apache.pulsar.metadata.api.MetadataStoreException.ContentDeserializationException)

Example 3 with ContentDeserializationException

use of org.apache.pulsar.metadata.api.MetadataStoreException.ContentDeserializationException in project pulsar by yahoo.

the class MetadataCacheImpl method readValueFromStore.

private CompletableFuture<Optional<CacheGetResult<T>>> readValueFromStore(String path) {
    return store.get(path).thenCompose(optRes -> {
        if (!optRes.isPresent()) {
            return FutureUtils.value(Optional.empty());
        }
        try {
            GetResult res = optRes.get();
            T obj = serde.deserialize(path, res.getValue(), res.getStat());
            return FutureUtils.value(Optional.of(new CacheGetResult<>(obj, res.getStat())));
        } catch (Throwable t) {
            return FutureUtils.exception(new ContentDeserializationException("Failed to deserialize payload for key '" + path + "'", t));
        }
    });
}
Also used : CacheGetResult(org.apache.pulsar.metadata.api.CacheGetResult) GetResult(org.apache.pulsar.metadata.api.GetResult) CacheGetResult(org.apache.pulsar.metadata.api.CacheGetResult) ContentDeserializationException(org.apache.pulsar.metadata.api.MetadataStoreException.ContentDeserializationException)

Aggregations

CacheGetResult (org.apache.pulsar.metadata.api.CacheGetResult)3 GetResult (org.apache.pulsar.metadata.api.GetResult)3 ContentDeserializationException (org.apache.pulsar.metadata.api.MetadataStoreException.ContentDeserializationException)3