Package com.volantis.mcs.runtime.configuration

Examples of com.volantis.mcs.runtime.configuration.RemotePolicyCacheConfiguration


        PolicyCachePartitionConfiguration partition =
                configuration.getPolicyCachePartition();
        assertNotNull(partition);
        assertEquals(box(100), partition.getSize());

        RemotePolicyCacheConfiguration constraints =
                partition.getConstraintsConfiguration();
        assertNotNull(constraints);
        assertEquals(box(true), constraints.getDefaultCacheThisPolicy());
        assertEquals(box(false), constraints.getDefaultRetainDuringRetry());
        assertEquals(box(true), constraints.getDefaultRetryFailedRetrieval());
        assertEquals(box(50), constraints.getDefaultRetryInterval());
        assertEquals(box(5), constraints.getDefaultRetryMaxCount());
        assertEquals(box(Integer.MAX_VALUE), constraints.getDefaultTimeToLive());

        assertEquals(box(true), constraints.getAllowCacheThisPolicy());
        assertEquals(box(true), constraints.getAllowRetainDuringRetry());
        assertEquals(box(true), constraints.getAllowRetryFailedRetrieval());
        assertEquals(box(Integer.MAX_VALUE), constraints.getMaxRetryMaxCount());
        assertEquals(box(Integer.MAX_VALUE), constraints.getMaxTimeToLive());
        assertEquals(box(10), constraints.getMinRetryInterval());

        assertEquals(1, partition.getTypeSpecificPartitionCount());

        PolicyTypePartitionConfiguration typePartition =
                partition.getTypePartition(PolicyType.AUDIO);
        assertNotNull(typePartition);
        PolicyTypePartitionConfiguration imagePartition =
                partition.getTypePartition(PolicyType.IMAGE);
        assertSame(typePartition, imagePartition);
        assertEquals(Arrays.asList(new PolicyType[] {
            PolicyType.AUDIO, PolicyType.IMAGE
        }), typePartition.getPolicyTypes());
        assertEquals(50, typePartition.getSize());

        constraints = typePartition.getConstraints();
        assertNotNull(constraints);

        assertEquals(null, constraints.getDefaultCacheThisPolicy());
        assertEquals(null, constraints.getDefaultRetainDuringRetry());
        assertEquals(null, constraints.getDefaultRetryFailedRetrieval());
        assertEquals(null, constraints.getDefaultRetryInterval());
        assertEquals(null, constraints.getDefaultRetryMaxCount());
        assertEquals(null, constraints.getDefaultTimeToLive());

        assertEquals(box(false), constraints.getAllowCacheThisPolicy());
        assertEquals(null, constraints.getAllowRetainDuringRetry());
        assertEquals(null, constraints.getAllowRetryFailedRetrieval());
        assertEquals(null, constraints.getMaxRetryMaxCount());
        assertEquals(null, constraints.getMaxTimeToLive());
        assertEquals(null, constraints.getMinRetryInterval());
    }
View Full Code Here


        MarinerConfiguration config = configBuilder.buildConfiguration();
        assertNotNull(config);
        RemotePoliciesConfiguration policies = config.getRemotePolicies();
        assertNotNull(policies);
        assertEquals(connectionTimeout, policies.getConnectionTimeout());
        RemotePolicyCacheConfiguration cache = policies.getPolicyCache();
        Iterator quotas = policies.getQuotaIterator();

        if (cacheValue != null) {
            assertNotNull("RemotePolicyCacheConfiguration", cache);
            assertEquals(cacheValue.cachePolicies,
                    cache.getDefaultCacheThisPolicy());
            assertEquals(cacheValue.defaultTimeToLive,
                    cache.getDefaultTimeToLive());
            assertEquals(cacheValue.defaultRetryFailedRetrieval,
                    cache.getDefaultRetryFailedRetrieval());
            assertEquals(cacheValue.defaultRetryInterval,
                    cache.getDefaultRetryInterval());
            assertEquals(cacheValue.defaultRetryMaxCount,
                    cache.getDefaultRetryMaxCount());
            assertEquals(cacheValue.defaultRetainDuringRetry,
                    cache.getDefaultRetainDuringRetry());
            assertEquals(cacheValue.maxCacheSize,
                    cache.getMaxCacheSize());
            assertEquals(cacheValue.maxTimeToLive,
                    cache.getMaxTimeToLive());
            assertEquals(cacheValue.allowRetryFailedRetrieval,
                    cache.getAllowRetryFailedRetrieval());
            assertEquals(cacheValue.minRetryInterval,
                    cache.getMinRetryInterval());
            assertEquals(cacheValue.maxRetryMaxCount,
                    cache.getMaxRetryMaxCount());
            assertEquals(cacheValue.allowRetainDuringRetry,
                    cache.getAllowRetainDuringRetry());
        } else {
            assertNull("RemotePolicyCacheConfiguration", cache);
        }

        if (quotaValues != null) {
View Full Code Here

        VolantisInternals internals = new VolantisInternals(volantis);

        MarinerConfiguration marinerConfig = internals.getMarinerConfig();
        RemotePoliciesConfiguration configuration =
                marinerConfig.getRemotePolicies();
        RemotePolicyCacheConfiguration cacheConfiguration =
                configuration.getPolicyCache();

        // @todo this nicely demonstrates the bug re remote cache nesting
        // docs says the global and individual are at different nesting levels
        // and yet the tests pass with the same temporary for both, and with an
        // xml file that has them at the same level.

        Assert.assertNotNull("policy props for ", cacheConfiguration);

        // You can see how inconsistent the names of the attributes are. Yuck.
        Assert.assertEquals(cache.cachePolicies,
                cacheConfiguration.getDefaultCacheThisPolicy());
        Assert.assertEquals(cache.defaultTimeToLive,
                cacheConfiguration.getDefaultTimeToLive());
        Assert.assertEquals(cache.defaultRetryFailedRetrieval,
                cacheConfiguration.getDefaultRetryFailedRetrieval());
        Assert.assertEquals(cache.defaultRetryInterval,
                cacheConfiguration.getDefaultRetryInterval());
        Assert.assertEquals(cache.defaultRetryMaxCount,
                cacheConfiguration.getDefaultRetryMaxCount());
        Assert.assertEquals(cache.defaultRetainDuringRetry,
                cacheConfiguration.getDefaultRetainDuringRetry());

        Assert.assertEquals(cache.maxCacheSize,
                cacheConfiguration.getMaxCacheSize());
        Assert.assertEquals(cache.maxTimeToLive,
                cacheConfiguration.getMaxTimeToLive());
        Assert.assertEquals(cache.allowRetryFailedRetrieval,
                cacheConfiguration.getAllowRetryFailedRetrieval());
        Assert.assertEquals(cache.minRetryInterval,
                cacheConfiguration.getMinRetryInterval());
        Assert.assertEquals(cache.maxRetryMaxCount,
                cacheConfiguration.getMaxRetryMaxCount());
        Assert.assertEquals(cache.allowRetainDuringRetry,
                cacheConfiguration.getAllowRetainDuringRetry());

        // Not checking for extra, unused stuff here, probably should...
    }
View Full Code Here

                // Use the default local partition.
                builder.setCacheControlDefaultsMap(localConstraintsMap);
                builder.setCacheGroup(policyCache.getLocalDefaultGroup());
            }
        } else {
            RemotePolicyCacheConfiguration partitionConfiguration =
                    partition.getConstraintsConfiguration();

            PolicyCachePartitionConstraints partitionConstraints;
            Group baseGroup;
            if (builder.isRemote()) {
                // The project is remote so use the group associated with the
                // remote partition if any, or the remote group.
                String location = configuration.getLocation();
                baseGroup = policyCache.getRemotePartitionGroup(location);
                if (baseGroup == null) {
                    baseGroup = policyCache.getRemoteGroup();
                }
                partitionConstraints =
                        policyCache.getRemotePartitionConstraints();
            } else {
                baseGroup = policyCache.getLocalGroup();
                partitionConstraints =
                        policyCache.getLocalPartitionConstraints();
            }

            int partitionSize = partitionConstraints.constrainPartitionSize(
                    partition.getSize());
            if (partitionSize < 1) {
                throw new IllegalStateException("Partition size must be >= 1");
            }

            CacheFactory cacheFactory = CacheFactory.getDefaultInstance();
            GroupBuilder groupBuilder = cacheFactory.createGroupBuilder();
            groupBuilder.setMaxCount(partitionSize);
            Group partitionGroup = baseGroup.addGroup(
                    configuration.getLocation(), groupBuilder);

            // Create the base constraints for the partition. These will
            // be used to derive the constraints for the type specific
            // partitions.
            CacheControlConstraints base =
                    new CacheControlConstraints(
                            partitionConstraints.getConstraints(),
                            partitionConfiguration);

            builder.setCacheControlDefaults(base.getDefaultCacheControl());

            SeparateCacheControlConstraintsMap constraintsMap =
                    new SeparateCacheControlConstraintsMap();
            for (Iterator i = PolicyType.getPolicyTypes().iterator(); i.hasNext();) {
                PolicyType policyType = (PolicyType) i.next();
                PolicyTypePartitionConfiguration typePartitionConfiguration =
                        partition.getTypePartition(policyType);
                CacheControlConstraints typeConstraints;
                groupBuilder = cacheFactory.createGroupBuilder();
                if (typePartitionConfiguration == null) {
                    typeConstraints = base;
                    groupBuilder.setMaxCount(partitionSize);
                } else {
                    RemotePolicyCacheConfiguration typeConfiguration =
                            typePartitionConfiguration.getConstraints();
                    if (typeConfiguration == null) {
                        typeConstraints = base;
                    } else {
                        typeConstraints = new CacheControlConstraints(base,
View Full Code Here

        return map;
    }

    private CacheControlConstraints createLocalCacheConstraints(
            Boolean allowCacheThisPolicy, Integer timeout) {
        RemotePolicyCacheConfiguration cacheConfiguration =
                new RemotePolicyCacheConfiguration();

        cacheConfiguration.setAllowCacheThisPolicy(allowCacheThisPolicy);

        // Allow retries as previously we did retry when there was an
        // error simply because we did not cache the fact that there was an
        // error. Retain during retry, retry immediately, and allow any
        // number of retries.
        cacheConfiguration.setAllowRetryFailedRetrieval(Boolean.TRUE);
        cacheConfiguration.setMinRetryInterval(INTEGER_ZERO);
        cacheConfiguration.setMaxRetryMaxCount(INTEGER_MAX_VALUE);
        cacheConfiguration.setAllowRetainDuringRetry(Boolean.TRUE);

        cacheConfiguration.setDefaultRetryFailedRetrieval(Boolean.TRUE);
        cacheConfiguration.setDefaultRetryInterval(INTEGER_ZERO);
        cacheConfiguration.setDefaultRetryMaxCount(INTEGER_MAX_VALUE);
        cacheConfiguration.setDefaultRetainDuringRetry(Boolean.TRUE);

        cacheConfiguration.setDefaultTimeToLive(timeout);
        CacheControlConstraints constraints = new CacheControlConstraints(
                cacheConfiguration);
        return constraints;
    }
View Full Code Here

     * @return The constraints.
     */
    private CacheControlConstraints createRemoteCacheControlConstraints() {
        RemotePoliciesConfiguration remotePolicies =
                marinerConfig.getRemotePolicies();
        RemotePolicyCacheConfiguration policyCacheConfiguration =
                remotePolicies.getPolicyCache();

        if (policyCacheConfiguration == null) {
            policyCacheConfiguration = new RemotePolicyCacheConfiguration();
        }

        // Treat a maxTimeToLive of 0 as unlimited.
        Integer maxTimeToLive = policyCacheConfiguration.getMaxTimeToLive();
        if (maxTimeToLive != null && maxTimeToLive.intValue() == 0) {
            policyCacheConfiguration.setMaxTimeToLive(INTEGER_MAX_VALUE);
        }

        CacheControlConstraints constraints = new CacheControlConstraints(
                policyCacheConfiguration);
        return constraints;
View Full Code Here

            localSize = 1;
        }

        RemotePoliciesConfiguration remotePolicies =
                marinerConfig.getRemotePolicies();
        RemotePolicyCacheConfiguration policyCacheConfiguration =
                remotePolicies.getPolicyCache();
        if (policyCacheConfiguration == null) {
            policyCacheConfiguration = new RemotePolicyCacheConfiguration();
        }

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

        PolicyCacheBuilder builder = new PolicyCacheBuilder(
                localSize, remoteSize);
View Full Code Here

            throws Exception {

        // =====================================================================
        //   Test Expectations
        // =====================================================================
        RemotePolicyCacheConfiguration configuration =
                new RemotePolicyCacheConfiguration();
        CacheControlConstraints constraints = new CacheControlConstraints(configuration);
        CacheControl cacheControl = constraints.getDefaultCacheControl();
        checkCacheControl(cacheControl, true, true, true, 600, 5, 3600);
    }
View Full Code Here

            throws Exception {

        // =====================================================================
        //   Test Expectations
        // =====================================================================
        RemotePolicyCacheConfiguration configuration =
                new RemotePolicyCacheConfiguration();
        CacheControlConstraints constraints = new CacheControlConstraints(configuration);
        CacheControlBuilder builder = policyFactory.createCacheControlBuilder();
        builder.setRetainDuringRetry(true);
        builder.setRetryFailedRetrieval(true);
        builder.setRetryInterval(-10);
View Full Code Here

            throws Exception {

        // =====================================================================
        //   Test Expectations
        // =====================================================================
        RemotePolicyCacheConfiguration configuration =
                new RemotePolicyCacheConfiguration();
        configuration.setAllowCacheThisPolicy(Boolean.FALSE);
        configuration.setDefaultCacheThisPolicy(Boolean.TRUE);
        CacheControlConstraints constraints = new CacheControlConstraints(configuration);
        CacheControl cacheControl = constraints.getDefaultCacheControl();

        checkCacheControl(cacheControl, false, false, false, 0, 0, 0);
    }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.runtime.configuration.RemotePolicyCacheConfiguration

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.