protected AttributesFactory getServerCacheAttributesFactory(boolean enableStorage) { AttributesFactory factory = new AttributesFactory(); PartitionAttributesFactory paf = new PartitionAttributesFactory(); factory.setDataPolicy(DataPolicy.PARTITION); paf.setRedundantCopies(0).setTotalNumBuckets(1); if (!enableStorage) { paf.setLocalMaxMemory(0); } factory.setPartitionAttributes(paf.create()); return factory; }
protected <K, V> void mergePartitionAttributes( final RegionFactory<K, V> regionFactory, final RegionAttributes<K, V> regionAttributes) { // NOTE PartitionAttributes are created by certain RegionShortcuts; need the null check since // RegionAttributes // can technically return null! // NOTE most likely, the PartitionAttributes will never be null since the // PartitionRegionFactoryBean always // sets a PartitionAttributesFactoryBean BeanBuilder on the RegionAttributesFactoryBean // "partitionAttributes" // property. if (regionAttributes.getPartitionAttributes() != null) { PartitionAttributes partitionAttributes = regionAttributes.getPartitionAttributes(); PartitionAttributesFactory partitionAttributesFactory = new PartitionAttributesFactory(partitionAttributes); RegionShortcutWrapper shortcutWrapper = RegionShortcutWrapper.valueOf(shortcut); // NOTE however, since the default value of redundancy is 0, we need to account for // 'redundant' // RegionShortcut types, which specify a redundancy of 1. if (shortcutWrapper.isRedundant() && partitionAttributes.getRedundantCopies() == 0) { partitionAttributesFactory.setRedundantCopies(1); } // NOTE and, since the default value of localMaxMemory is based on the system memory, we need // to account for // 'proxy' RegionShortcut types, which specify a local max memory of 0. if (shortcutWrapper.isProxy()) { partitionAttributesFactory.setLocalMaxMemory(0); } // NOTE internally, RegionFactory.setPartitionAttributes handles merging the // PartitionAttributes, hooray! regionFactory.setPartitionAttributes(partitionAttributesFactory.create()); } }