RegionAttributesCreation attrs = new RegionAttributesCreation(this.cache); String scope = atts.getValue(SCOPE); if (scope == null) { attrs.setScope(Scope.LOCAL); attrs.setScope(Scope.DISTRIBUTED_NO_ACK); attrs.setScope(Scope.DISTRIBUTED_ACK); attrs.setScope(Scope.GLOBAL); attrs.setMirrorType(MirrorType.NONE); attrs.setMirrorType(MirrorType.KEYS); attrs.setMirrorType(MirrorType.KEYS_VALUES); attrs.setDataPolicy(DataPolicy.NORMAL); attrs.setDataPolicy(DataPolicy.PRELOADED); attrs.setDataPolicy(DataPolicy.EMPTY); attrs.setDataPolicy(DataPolicy.REPLICATE); attrs.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE); attrs.setDataPolicy(DataPolicy.PARTITION);
/** * When a <code>cache-listener</code> element is finished, the {@link * Parameter}s and class names are popped off the stack. The cache listener is * instantiated and initialized with the parameters, if appropriate. */ private void endCacheListener() { Declarable d = createDeclarable(); if (!(d instanceof CacheListener)) { throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_CACHELISTENER.toLocalizedString(d.getClass().getName())); } RegionAttributesCreation attrs = peekRegionAttributesContext(CACHE_LISTENER); attrs.addCacheListener((CacheListener) d); }
attrs.initCacheListeners(this.getCacheListenerInstances(instantiate)); attrs.setCloningEnable(this.cloningEnabled.booleanValue()); attrs.setConcurrencyLevel(this.concurrencyLevel.intValue()); attrs.setCustomEntryIdleTimeout(getCustomEntryIdleTimeoutInstance()); attrs.setCustomEntryTimeToLive(getCustomEntryTimeToLiveInstance()); attrs.setDiskStoreName(this.diskStoreDescription.getName()); attrs.setDiskSynchronous(this.diskSynchronous.booleanValue()); attrs.setEntryIdleTimeout(this.entryIdleTimeout); attrs.setEntryTimeToLive(this.entryTimeToLive); attrs.setEvictionAttributes(this.evictionAttributes); attrs.setInitialCapacity(this.initialCapacity.intValue()); attrs.setKeyConstraint(this.keyConstraint); attrs.setLoadFactor(this.loadFactor.floatValue()); attrs.setPoolName(this.poolDescription.getName()); attrs.setRegionIdleTimeout(this.regionIdleTimeout);
public CacheLoader setCacheLoader(CacheLoader cacheLoader) { CacheLoader old = this.cacheLoader; this.cacheLoader = cacheLoader; setHasCacheLoader(true); if (cacheLoader instanceof BridgeClient && !hasCacheWriter()) { // fix for bug 36247 setCacheWriter((BridgeClient)cacheLoader); } return old; }
public void setCompressor(Compressor compressor) { this.compressor = compressor; setHasCompressor(true); // Cloning must be enabled when a compressor is set if (compressor != null) { setCloningEnable(true); } }
public CacheWriter setCacheWriter(CacheWriter cacheWriter) { CacheWriter old = this.cacheWriter; this.cacheWriter = cacheWriter; setHasCacheWriter(true); if (cacheWriter instanceof BridgeClient && !hasCacheLoader()) { // fix for bug 36247 setCacheLoader((BridgeClient)cacheWriter); } return old; }
if (setDefaultPool && this.requiresPoolName && !hasPoolName()) { String defaultPoolName = null; if (cache instanceof GemFireCacheImpl) { setPoolName(defaultPoolName); if (setDefaultPool && parentWithHas.requiresPoolName) { this.requiresPoolName = true; if (!hasPoolName()) { String defaultPoolName = null; if (cache instanceof GemFireCacheImpl) { setPoolName(defaultPoolName); if (!hasCacheListeners()) { if (parentIsUserSpecified) { if (parentWithHas.hasCacheListeners()) { initCacheListeners(parent.getCacheListeners()); initCacheListeners(parent.getCacheListeners()); if (!hasGatewaySenderId()) { if (parentIsUserSpecified) { if (parentWithHas.hasGatewaySenderId()) { initGatewaySenders(parent.getGatewaySenderIds()); initGatewaySenders(parent.getGatewaySenderIds()); if (!hasAsyncEventListeners()) {
RegionAttributesCreation attr = new RegionAttributesCreation(cc); if (regDef.getScope() != null) attr.setScope(regDef.getScope()); if (regDef.getMirroring() != null) attr.setMirrorType(regDef.getMirroring()); attr.addCacheListener((CacheListener)(TestHelper.createInstance((String)(listenerList.get(i))))); attr.setEvictionAttributes(regDef.getEvictionAttributes()); if (regDef.getCacheLoader() != null) attr.setCacheLoader((CacheLoader)(TestHelper.createInstance(regDef.getCacheLoader()))); if (regDef.getCacheWriter() != null) attr.setCacheWriter((CacheWriter)(TestHelper.createInstance(regDef.getCacheWriter()))); if (regDef.getConcurrencyLevel() != null) attr.setConcurrencyLevel(regDef.getConcurrencyLevel().intValue()); if (regDef.getEnableOffHeapMemory() != null) { if (regDef.getEnableOffHeapMemory().equalsIgnoreCase("ifOffHeapMemoryConfigured")) { if (offHeapMemorySize != null) { if (offHeapMemorySize.charAt(0) != '0') { attr.setEnableOffHeapMemory(true); attr.setKeyConstraint(regDef.getKeyConstraint()); if (regDef.getValueConstraint() != null) attr.setValueConstraint(regDef.getValueConstraint()); if (regDef.getLoadFactor() != null) attr.setLoadFactor(regDef.getLoadFactor().floatValue()); if (regDef.getStatisticsEnabled() != null) attr.setStatisticsEnabled(regDef.getStatisticsEnabled().booleanValue());
/** * Tests a region with non-default region attributes */ public void testNonDefaultRegionAttributes() throws CacheException { CacheCreation cache = new CacheCreation(); RegionAttributesCreation attrs = new RegionAttributesCreation(cache); attrs.setScope(Scope.DISTRIBUTED_NO_ACK); attrs.setMirrorType(MirrorType.KEYS_VALUES); attrs.setInitialCapacity(142); attrs.setLoadFactor(42.42f); attrs.setStatisticsEnabled(false); cache.createRegion("root", attrs); testXml(cache); }
RegionAttributesCreation attrs = new RegionAttributesCreation(creation); attrs.setScope(Scope.LOCAL); attrs.setEarlyAck(false); attrs.setMulticastEnabled(true); creation.createRegion(r1, attrs); attrs = new RegionAttributesCreation(creation); attrs.setId(attrId); attrs.setScope(Scope.DISTRIBUTED_NO_ACK); attrs.setEarlyAck(false); attrs.setMulticastEnabled(true); creation.setRegionAttributes(attrs.getId(), attrs); attrs = new RegionAttributesCreation(creation); attrs.setRefid(attrId); creation.createRegion(r3, attrs); attrs = new RegionAttributesCreation(creation); attrs.setScope(Scope.DISTRIBUTED_ACK); attrs.setEarlyAck(false); attrs.setMulticastEnabled(true); creation.createRegion(r2, attrs);
RegionAttributesCreation attrs = new RegionAttributesCreation(cache); attrs.setStatisticsEnabled(true); attrs.setRegionTimeToLive(expire); attrs.setRegionIdleTimeout(expire); attrs.setEntryTimeToLive(expire); attrs.setEntryIdleTimeout(expire);
/** * Tests that named region attributes are registered when the cache is * created. */ public void testRegisteringNamedRegionAttributes() { CacheCreation cache = new CacheCreation(); RegionAttributesCreation attrs; String id1 = "id1"; attrs = new RegionAttributesCreation(cache); attrs.setScope(Scope.DISTRIBUTED_ACK); attrs.setMirrorType(MirrorType.KEYS); cache.setRegionAttributes(id1, attrs); String id2 = "id2"; attrs = new RegionAttributesCreation(cache); attrs.setScope(Scope.DISTRIBUTED_NO_ACK); attrs.setMirrorType(MirrorType.KEYS_VALUES); attrs.setConcurrencyLevel(15); cache.setRegionAttributes(id2, attrs); String id3 = "id3"; attrs = new RegionAttributesCreation(cache); attrs.setScope(Scope.LOCAL); attrs.setValueConstraint(Integer.class); cache.setRegionAttributes(id3, attrs); testXml(cache); }
public void testCacheServerDisableTcpNoDelay() throws CacheException { CacheCreation cache = new CacheCreation(); CacheServer cs = cache.addCacheServer(); cs.setTcpNoDelay(false); RegionAttributesCreation attrs = new RegionAttributesCreation(cache); attrs.setDataPolicy(DataPolicy.NORMAL); cache.createVMRegion("rootNORMAL", attrs); testXml(cache); }
RegionAttributesCreation attrs = new RegionAttributesCreation(creation); attrs.setScope(Scope.LOCAL); attrs.setEarlyAck(false); attrs.setCloningEnable(false); attrs.setMulticastEnabled(true); creation.createRegion(r1, attrs); RegionAttributesCreation attrsSub = new RegionAttributesCreation(creation); attrsSub.setScope(Scope.LOCAL); reg1.createSubregion(sub, attrsSub); Region subRegion = reg1.getSubregion(sub);
this.attrs = (RegionAttributesCreation) attrs; } else { this.attrs = new RegionAttributesCreation(this.cache, attrs, false); if ((setRefid && (this.attrs.getRefid() == null))) { this.attrs.setRefid(getRefid()); attrs.getEvictionAttributes().getMaximum(), attrs.getPartitionAttributes().getLocalMaxMemory() }); this.attrs.setEvictionAttributes(attrs.getEvictionAttributes() .createLRUMemoryAttributes( attrs.getPartitionAttributes().getLocalMaxMemory(),
RegionAttributesCreation creation = (RegionAttributesCreation) getRegionAttributes(id); creation.inheritAttributes(cache, false); if (creation.getHDFSStoreName() != null) HDFSStoreImpl store = cache.findHDFSStore(creation.getHDFSStoreName()); if(store == null || store.getHDFSEventQueueAttributes() == null) { HDFSIntegrationUtil.createDefaultAsyncQueueForHDFS((Cache)cache, creation.getHDFSWriteOnly(), id); if (creation.getHDFSStoreName() != null && creation.getPartitionAttributes().getColocatedWith() == null) { creation.addAsyncEventQueueId(HDFSStoreFactoryImpl.getEventQueueName(id));
RegionAttributesCreation attrs = new RegionAttributesCreation(cache); attrs.setDataPolicy(DataPolicy.NORMAL); cache.createRegion("rootNORMAL", attrs); RegionAttributesCreation attrs = new RegionAttributesCreation(cache); attrs.setDataPolicy(DataPolicy.NORMAL); attrs.setSubscriptionAttributes(new SubscriptionAttributes(InterestPolicy.ALL)); cache.createRegion("rootNORMAL_ALL", attrs); RegionAttributesCreation attrs = new RegionAttributesCreation(cache); attrs.setMirrorType(MirrorType.KEYS_VALUES); cache.createRegion("rootREPLICATE", attrs); RegionAttributesCreation attrs = new RegionAttributesCreation(cache); attrs.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE); cache.createRegion("rootPERSISTENT_REPLICATE", attrs); RegionAttributesCreation attrs = new RegionAttributesCreation(cache); attrs.setDataPolicy(DataPolicy.EMPTY); cache.createRegion("rootEMPTY", attrs); RegionAttributesCreation attrs = new RegionAttributesCreation(cache); attrs.setDataPolicy(DataPolicy.EMPTY); attrs.setSubscriptionAttributes(new SubscriptionAttributes(InterestPolicy.ALL)); cache.createRegion("rootEMPTY_ALL", attrs);
/** * Tests the is-lock-grantor attribute in xml. */ public void testIsLockGrantorAttribute() throws CacheException { CacheCreation cache = new CacheCreation(); RegionAttributesCreation attrs = new RegionAttributesCreation(cache); attrs.setLockGrantor(true); attrs.setScope(Scope.GLOBAL); attrs.setMirrorType(MirrorType.KEYS_VALUES); cache.createRegion("root", attrs); testXml(cache); assertEquals(true, cache.getRegion("root").getAttributes().isLockGrantor()); }
/** * Tests that a region created with a named attributes has the correct * attributes. * * This tests currently fails due to (what seem to me as) limitations in the * XML generator and the comparison of the XML. I have run this test by hand * and looked at the generated XML and there were no significant problems, * however because of the limitations, I am disabling this test, but leaving * the functionality for future comparisons (by hand of course). -- Mitch * Thomas 01/18/2006 */ public void testPartitionedRegionInstantiation() throws CacheException { CacheCreation cache = new CacheCreation(); RegionAttributesCreation attrs = new RegionAttributesCreation(cache); PartitionAttributesFactory paf = new PartitionAttributesFactory(); paf.setLocalMaxMemory(4) .setTotalNumBuckets(17) .setTotalMaxMemory(8); attrs.setPartitionAttributes(paf.create()); cache.createRegion("pRoot", attrs); }
/** * Tests a bridge client and special setCacheLoader over-ride behavior on * region attributes */ public void testBridgeClientLoaderOverride() throws CacheException { getSystem(); CacheCreation cache = new CacheCreation(); RegionAttributesCreation attrs = new RegionAttributesCreation(cache); final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(1); BridgeClient bc = new TestBridgeClient(); Properties props = new Properties(); props.setProperty("endpoints", "server=" + DistributedTestCase.getIPLiteral() + ":" + ports[0]); bc.init(props); attrs.setCacheWriter(bc); attrs.setCacheLoader(new CacheLoaderWithDeclarables()); cache.createRegion("root", attrs); testXml(cache); final Region ro = cache.getRegion("root"); assertTrue(ro.getAttributes().getCacheWriter() instanceof BridgeClient); assertTrue(ro.getAttributes().getCacheLoader() instanceof CacheLoaderWithDeclarables); // now that a BridgeLoader creates its own pool make sure it exists assertEquals("pools="+PoolManager.getAll(), 1, PoolManager.getAll().size()); }