Package com.volantis.mcs.runtime.configuration

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


        // We have implemented VolantisInternals as a workaround rather than
        // use the commented code below to get around a bug to do with
        // reflection in the IBM JDK 1.4.1.
        VolantisInternals internals = new VolantisInternals(volantis);
        PolicyCacheConfiguration configuration =
                internals.getPolicyCacheConfiguration(cache.policyType);

        // NOTE: this fails in IBM JDK 1.4.1 with IllegalAccessException
        // the *second* time it is run. It looks like a VM bug to me.
//        ReflectionManager accessMgr = new ReflectionManager(
//                Volantis.class.getDeclaredMethod(
//                "getPolicyCacheAttributes", new Class[] {String.class})
//        );
//        Map props = (Map)accessMgr.useAsAccessible(new ReflectionExecutor() {
//            public Object execute(AccessibleObject object) throws Exception {
//                 return ((Method)object).invoke(volantis,
//                         new Object[] {policy});
//            }
//        });
        Assert.assertEquals(cache.strategy,
                configuration.getStrategy());
        Assert.assertEquals(cache.maxEntries.toString(),
                configuration.getMaxEntries().toString());
        Assert.assertEquals(cache.timeout.toString(),
                configuration.getTimeout().toString());

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


        MarinerConfiguration config = configBuilder.buildConfiguration();
        assertNotNull(config);
        PolicyCaches caches = config.getPolicies();
        assertNotNull(caches);
        PolicyCacheFinder cacheFinder = new PolicyCacheFinder();
        PolicyCacheConfiguration cache = cacheFinder.find(caches, tagId);
        if (cacheValue != null) {
            assertNotNull("policyCacheConfiguration", cache);
            // enabled attribute is tested via the EnabledDigester test case
            assertEquals(cacheValue.strategy, cache.getStrategy());
            assertEquals(cacheValue.maxEntries, cache.getMaxEntries());
            assertEquals(cacheValue.timeout, cache.getTimeout());
        } else {
            assertNull("policyCacheConfiguration", cache);
        }
    }
View Full Code Here

        // Now create the set of defaults for the different policy types.
        Collection policyTypes = PolicyType.getPolicyTypes();
        for (Iterator i = policyTypes.iterator(); i.hasNext();) {
            PolicyType policyType = (PolicyType) i.next();
            PolicyCacheConfiguration configuration =
                    getPolicyCacheConfiguration(policyType);
            Boolean allowCacheThisPolicy;
            Integer timeout;
            if (configuration == null) {
                // Policies are not to be cached so do not create a group
                // for them.
                allowCacheThisPolicy = Boolean.FALSE;
                timeout = INTEGER_MAX_VALUE;
            } else {

                allowCacheThisPolicy = Boolean.TRUE;
                timeout = configuration.getTimeout();
                if (timeout == null || timeout.intValue() == -1) {
                    timeout = INTEGER_MAX_VALUE;
                }
            }
View Full Code Here

        Collection policyTypes = PolicyType.getPolicyTypes();
        for (Iterator i = policyTypes.iterator();
             i.hasNext() && localSize < Integer.MAX_VALUE;) {

            PolicyType policyType = (PolicyType) i.next();
            PolicyCacheConfiguration groupConfiguration =
                    getPolicyCacheConfiguration(policyType);
            if (groupConfiguration != null) {
                Integer integer = groupConfiguration.getMaxEntries();
                if (integer != null) {
                    if (integer.intValue() != -1) {
                        localSize += integer.intValue();
                    } else {
                        localSize = Integer.MAX_VALUE;
                    }
                } else {
                    localSize = Integer.MAX_VALUE;
                }
            }
        }

        // If the local size is still 0 then set it to one so that the cache
        // can be built.
        if (localSize == 0) {
            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);

        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;
                }
            }
View Full Code Here

        return integer == null ? defaultValue : integer.intValue();
    }

    PolicyCacheConfiguration getPolicyCacheConfiguration(PolicyType policyType) {
        PolicyCaches policies = marinerConfig.getPolicies();
        PolicyCacheConfiguration cacheConfiguration =
                policies.getPolicyCache(policyType);
        return cacheConfiguration;
    }
View Full Code Here

TOP

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

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.