Package com.volantis.mcs.runtime.policies.cache

Examples of com.volantis.mcs.runtime.policies.cache.PolicyCacheBuilder


        int remoteSize;
        remoteSize = getInteger(policyCacheConfiguration.getMaxCacheSize(),
                DEFAULT_REMOTE_GROUP_SIZE);

        PolicyCacheBuilder builder = new PolicyCacheBuilder(
                localSize, remoteSize);

        CacheControlConstraints localConstraints = createLocalCacheConstraints(
                Boolean.TRUE, null);

        PolicyCachePartitionConstraints localPartitionConstraints =
                createPartitionConstraints(localSize, localConstraints);

        builder.setLocalPartitionConstraints(localPartitionConstraints);

        PolicyCachePartitionConstraints remotePartitionConstraints =
                createPartitionConstraints(remoteSize, remoteConstraints);

        builder.setRemotePartitionConstraints(remotePartitionConstraints);

        // Now build the policy specific groups to the local group.
        for (Iterator i = policyTypes.iterator(); i.hasNext();) {

            PolicyType policyType = (PolicyType) i.next();
            PolicyCacheConfiguration groupConfiguration =
                    getPolicyCacheConfiguration(policyType);
            int maxCount;
            if (groupConfiguration == null) {
                // Allow some entries in the group to ensure that when a policy
                // is marked as uncacheable that it is preserved.
                maxCount = 10;
            } else {
                maxCount = getInteger(groupConfiguration.getMaxEntries(),
                        Integer.MAX_VALUE);
                if (maxCount == -1) {
                    maxCount = Integer.MAX_VALUE;
                }
            }

            builder.addDefaultLocalPolicySpecificGroup(
                    policyType, maxCount);
        }

        Iterator i = remotePolicies.getQuotaIterator();
        while (i.hasNext()) {
            RemotePolicyQuotaConfiguration quota =
                    (RemotePolicyQuotaConfiguration) i.next();
            int percentage = quota.getPercentage().intValue();
            String url = quota.getUrl();
            int share = (remoteSize * percentage) / 100;

            builder.addDefaultRemotePathSpecificGroup(url, share);
        }

        return builder.getPolicyCache();
    }
View Full Code Here


        clockMock.expects.getCurrentTime().returns(Time.inMilliSeconds(2));
        clockMock.expects.getCurrentTime().returns(Time.inMilliSeconds(3));
        clockMock.expects.getCurrentTime().returns(Time.inMilliSeconds(4));
        clockMock.expects.getCurrentTime().returns(Time.inMilliSeconds(5));

        PolicyCacheBuilder builder = new PolicyCacheBuilder(100, 1000,
                clockMock);

        RemotePolicyCacheConfiguration configuration =
                new RemotePolicyCacheConfiguration();
        configuration.setMaxTimeToLive(new Integer(200));
        configuration.setDefaultRetryInterval(new Integer(2));

        constraints = new CacheControlConstraints(configuration);

        PolicyCachePartitionConstraints partitionConstraints =
                new PolicyCachePartitionConstraintsImpl(50, 60, constraints);

        builder.setLocalPartitionConstraints(partitionConstraints);
        builder.setRemotePartitionConstraints(partitionConstraints);
        builder.addDefaultLocalPolicySpecificGroup(PolicyType.AUDIO, 5);

        policyCache = builder.getPolicyCache();

        retrieverMock = new ActivatedPolicyRetrieverMock("retrieverMock",
                expectations);

        projectMock = new RuntimeProjectMock("projectMock", expectations);
View Full Code Here

TOP

Related Classes of com.volantis.mcs.runtime.policies.cache.PolicyCacheBuilder

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.