Package com.volantis.cache.provider

Examples of com.volantis.cache.provider.ProviderResult


        // create the content retriever that will actually get the content
        // (eihter just validating the existing value or retrieving the content)
        final CacheAwareHttpContentRetriever contentRetriever =
            new CacheAwareHttpContentRetriever(cache, manager, entry, clock);

        ProviderResult result;
        try {
            // get the content
            final URLContent content =
                contentRetriever.retrieve(url, timeout, httpConfig);
            // store the cache entry state in the result
            final CachedHttpContentState state =
                contentRetriever.getCacheState();
            result =
                new ProviderResult(content, group, state.isCacheable(), state);
        } catch (IOException e) {
            result = new ProviderResult(e, group, false, null);
        }
        return result;
    }
View Full Code Here


        // 4) Entries may have new values.

        if (async.isReady()) {
            value = async.getValue();
        } else {
            ProviderResult result = null;
            Throwable throwable = null;
            boolean failed = true;
            try {
                // Get the entry, this will return null if the entry is marked
                // as being uncacheable.
                CacheEntry entry = async.getEntry();

                // Get the provider to retrieve the object. It is given the
                // whole entry so that it can perform revalidation of an
                // existing entry if it has expired.
                result = provider.retrieve(clock, key, entry);
                if (result == null) {
                    throw new IllegalStateException("Result from provider is null");
                }

                // Request to the provider did not fail.
                failed = false;

            } catch (RuntimeException e) {

                // Remember the exception so that it can be stored in the
                // entry to indicate the original cause.
                throwable = e;

                // Rethrow the exceptions.
                throw e;

            } catch (Error e) {

                // Remember the exception so that it can be stored in the
                // entry to indicate the original cause.
                throwable = e;

                // Rethrow the exceptions.
                throw e;

            } finally {
                if (failed) {
                    async.failed(throwable);
                } else {
                    // the cache must be updated even if the result has a
                    // non-null throwable
                                       
                    value = async.update(result);

                    // if the result has a throwable, thow it wrapped inside a
                    // runtime exception
                    Throwable cause = result.getThrowable();
                    if (cause != null) {
                        // The entry has a throwable so throw a runtime
                        // exception, encapsulating the original throwable.
                        throw new ExtendedRuntimeException(
                            "Attempt to access " + key +
View Full Code Here

                // The first key is always uncacheable.
                boolean cacheable = k.getIndex() != 0;

                String value = "value for (" + k + ")";
                return new ProviderResult(value, k.getGroup(), cacheable, "extensions");
            }
        });
        final InternalCache cache = (InternalCache) builder.buildCache();

        // Create 7 groups, of size 4,8,12,16,20,24,28 with two subgroups
View Full Code Here

        implements CacheableObjectProvider {
   
    public ProviderResult retrieve(
            SystemClock clock, Object key, CacheEntry entry) {
        String value = "value for (" + entry.getKey() + ")";
        return new ProviderResult(value, selectGroup(entry), true, null);
    }
View Full Code Here

                        value = "updated " + oldValue;
                    }
                    cacheable = true;
                }

                ProviderResult result = new ProviderResult(value,
                        cache.getRootGroup(), cacheable, null);
                async.update(result);
                failed = false;
            } catch (RuntimeException e) {
                throwable = e;
View Full Code Here

                                    dependency.getTimeToLive()));
                            dependencyContext.addDependency(dependency);

                            // update the cache with the old value so other
                            // threads don't need to wait the timeout period
                            ProviderResult result = new ProviderResult(
                                value, group, true, pcs);
                            async.update(result);
                        } else {
                            // This thread _is_ responsible for updating the
                            // cached result, so record it along with forwarding
View Full Code Here

            // Set the result to cachable based on the inErrorRecoveryMode
            // state.
            final PipelineCacheState pcs = new PipelineCacheState(
                clock.getCurrentTime().addPeriod(dependency.getTimeToLive()));
            final ProviderResult result = new ProviderResult(
                new RecordingWithDependency(recording, dependency),
                getCacheGroup(), !inErrorRecoveryMode, pcs);
            async.update(result);

            if (inErrorRecoveryMode) {
View Full Code Here

        // If there is a policy then never return the throwable as we are
        // retaining during retry and the caller wants to see the retained
        // policy not an exception. Otherwise if a throwable is set then throw
        // that.
        ProviderResult result;
        if (policy != null || throwable == null) {
            result = new ProviderResult(policy, group, cacheable, state);
        } else if (throwable instanceof RuntimeException) {
            throw (RuntimeException) throwable;
        } else if (throwable instanceof Error) {
            throw (Error) throwable;
        } else {
View Full Code Here

TOP

Related Classes of com.volantis.cache.provider.ProviderResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.