public Region createVMRegion(String name, RegionAttributes attrs) throws RegionExistsException, TimeoutException { return createRegion(name, attrs); }
public Region createVMRegion(String name, RegionAttributes attrs) throws RegionExistsException, TimeoutException { return createRegion(name, attrs); }
public Object call() throws Exception { ((GemFireCacheImpl)getCache()).createRegion(regionName, regionAttr); return null; } };
private void createCache() throws CacheException { Properties p = new Properties(); p.setProperty("mcast-port", "0"); // loner this.cache = (GemFireCacheImpl)new CacheFactory(p).create(); AttributesFactory af = new AttributesFactory(); af.setScope(Scope.DISTRIBUTED_NO_ACK); af.setIndexMaintenanceSynchronous(true); this.region = this.cache.createRegion("TXTest", af.create()); this.txMgr = this.cache.getCacheTransactionManager(); this.listenerAfterCommit = 0; this.listenerAfterFailedCommit = 0; this.listenerAfterRollback = 0; this.listenerClose = 0; }
/** * */ protected void createRegion() throws Exception { AttributesFactory af = new AttributesFactory(); af.setScope(Scope.DISTRIBUTED_NO_ACK); af.setConcurrencyChecksEnabled(false); // test validation expects this behavior af.setIndexMaintenanceSynchronous(true); this.region = this.cache.createRegion("TXTest", af.create()); } private void closeCache() {
public void testTxDistributedRegion() throws Exception { AttributesFactory attr = new AttributesFactory(); attr.setScope(Scope.DISTRIBUTED_ACK); Region region = cache.createRegion("DistributedRegion", attr.create()); checkOpRejection(region, true, true); region.close(); assertEquals(0 + SYSTEM_LISTENERS, cache.getResourceManager(false). getResourceListeners(ResourceType.HEAP_MEMORY).size()); }
public void testPutsLocalRegion() throws Exception{ AttributesFactory attr = new AttributesFactory(); attr.setScope(Scope.LOCAL); Region region = cache.createRegion("localRegion", attr.create()); checkOpRejection(region, false, true); region.close(); assertEquals(0 + SYSTEM_LISTENERS, cache.getResourceManager(false). getResourceListeners(ResourceType.HEAP_MEMORY).size()); }
public void testTxLocalRegion() throws Exception { AttributesFactory attr = new AttributesFactory(); attr.setScope(Scope.LOCAL); Region region = cache.createRegion("localRegion", attr.create()); checkOpRejection(region, true, true); region.close(); assertEquals(0 + SYSTEM_LISTENERS, cache.getResourceManager(false). getResourceListeners(ResourceType.HEAP_MEMORY).size()); }
/** * creates a distributed region and invokes criticalThresholdReached * then does a put to verify that the put is rejected */ public void testPutsRejectionDistributedRegion() throws Exception { AttributesFactory attr = new AttributesFactory(); attr.setScope(Scope.DISTRIBUTED_ACK); Region region = cache.createRegion("DistributedRegion", attr.create()); checkOpRejection(region, false, true); region.close(); assertEquals(0 + SYSTEM_LISTENERS, cache.getResourceManager(false). getResourceListeners(ResourceType.HEAP_MEMORY).size()); }
public void testPutsRejectedSubRegion() throws Exception { AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.LOCAL); Region subRegion = cache.createRegion("local1", factory.create()) .createSubregion("sub1", factory.create()); checkOpRejection(subRegion, false, true); subRegion.close(); assertEquals(1 + SYSTEM_LISTENERS, cache.getResourceManager(false). getResourceListeners(ResourceType.HEAP_MEMORY).size()); //root region is still present }
public void testTxSubRegion() throws Exception { AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.LOCAL); Region subRegion = cache.createRegion("local1", factory.create()) .createSubregion("sub1", factory.create()); checkOpRejection(subRegion, true, true); subRegion.close(); assertEquals(1 + SYSTEM_LISTENERS, cache.getResourceManager(false). getResourceListeners(ResourceType.HEAP_MEMORY).size()); //root region is still present }
private static Integer createCache(DataPolicy dataPolicy) throws Exception { new CacheRegionClearStatsDUnitTest("temp").createCache(new Properties()); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.DISTRIBUTED_ACK); factory.setDataPolicy(dataPolicy); RegionAttributes attrs = factory.create(); cache.createRegion(REGION_NAME, attrs); int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); CacheServer server1 = cache.addCacheServer(); server1.setPort(port); server1.setNotifyBySubscription(true); server1.start(); return new Integer(server1.getPort()); }
public static void createClientCache(String host, Integer port1) throws Exception { new CacheRegionClearStatsDUnitTest("temp"); Properties props = new Properties(); props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0"); props.setProperty(DistributionConfig.LOCATORS_NAME, ""); new CacheRegionClearStatsDUnitTest("temp").createCache(props); PoolImpl p = (PoolImpl)PoolManager.createFactory().addServer(host, port1.intValue()).setSubscriptionEnabled(false) .setThreadLocalConnections(true).setMinConnections(1).setReadTimeout( 20000).setPingInterval(10000).setRetryAttempts(1) .create("CacheRegionClearStatsDUnitTest"); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.DISTRIBUTED_ACK); factory.setPoolName(p.getName()); RegionAttributes attrs = factory.create(); Region region = cache.createRegion(REGION_NAME, attrs); //region.registerInterest("ALL_KEYS"); }
public static void createClientCacheDisk(String host, Integer port1) throws Exception { new CacheRegionClearStatsDUnitTest("temp"); Properties props = new Properties(); props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0"); props.setProperty(DistributionConfig.LOCATORS_NAME, ""); new CacheRegionClearStatsDUnitTest("temp").createCache(props); PoolImpl p = (PoolImpl)PoolManager.createFactory().addServer(host, port1.intValue()).setSubscriptionEnabled(false) .setThreadLocalConnections(true).setMinConnections(1).setReadTimeout( 20000).setPingInterval(10000).setRetryAttempts(1).create( "CacheRegionClearStatsDUnitTest"); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.DISTRIBUTED_ACK); factory.setPoolName(p.getName()); factory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE); RegionAttributes attrs = factory.create(); Region region = cache.createRegion(REGION_NAME, attrs); //region.registerInterest("ALL_KEYS"); } /**
/** * Expiration needs some more work in the new TX model. */ public void DISABLED_TILL_NEW_TX_IMPL_COMPLETE_testEntryTTLExpiration() throws CacheException { AttributesFactory af = new AttributesFactory(); af.setScope(Scope.DISTRIBUTED_NO_ACK); af.setStatisticsEnabled(true); af.setEntryTimeToLive(new ExpirationAttributes(2, ExpirationAction.DESTROY)); Region exprReg = this.cache.createRegion("TXEntryTTL", af.create()); generalEntryExpirationTest(exprReg, 2); AttributesMutator mutator = exprReg.getAttributesMutator(); mutator.setEntryTimeToLive(new ExpirationAttributes(1, ExpirationAction.DESTROY)); generalEntryExpirationTest(exprReg, 1); }
public void testTxId() { AttributesFactory<Integer, String> af = new AttributesFactory<Integer, String>(); af.setPartitionAttributes(new PartitionAttributesFactory<String, Integer>() .setTotalNumBuckets(2).create()); Region<String, Integer> r = this.cache.createRegion("testTxId", af.create()); r.put("one", 1); CacheTransactionManager mgr = this.cache.getTxManager(); mgr.begin(); r.put("two", 2); mgr.getTransactionId(); mgr.rollback(); } }
/** * Expiration needs some more work in the new TX model. */ public void DISABLED_TILL_NEW_TX_IMPL_COMPLETE_testEntryIdleExpiration() throws CacheException { AttributesFactory af = new AttributesFactory(); af.setScope(Scope.DISTRIBUTED_NO_ACK); af.setStatisticsEnabled(true); af.setEntryIdleTimeout(new ExpirationAttributes(2, ExpirationAction.DESTROY)); Region exprReg = this.cache.createRegion("TXEntryIdle", af.create()); // exprReg.getCache().getLogger().info("invoking expiration test with 2"); generalEntryExpirationTest(exprReg, 2); AttributesMutator mutator = exprReg.getAttributesMutator(); mutator.setEntryIdleTimeout(new ExpirationAttributes(1, ExpirationAction.DESTROY)); // exprReg.getCache().getLogger().info("invoking expiration test with 1 after setting idle timeout of 1 second"); generalEntryExpirationTest(exprReg, 1); }
public void testRegionIdleExpiration() throws CacheException { AttributesFactory af = new AttributesFactory(); af.setScope(Scope.DISTRIBUTED_NO_ACK); af.setStatisticsEnabled(true); af.setRegionIdleTimeout(new ExpirationAttributes(2, ExpirationAction.INVALIDATE)); Region exprReg = this.cache.createRegion("TXRegionIdle", af.create()); generalRegionExpirationTest(exprReg, 2, null, false); generalRegionExpirationTest(exprReg, 1, new ExpirationAttributes(1, ExpirationAction.INVALIDATE), false); generalRegionExpirationTest(exprReg, 2, new ExpirationAttributes(2, ExpirationAction.INVALIDATE), false); generalRegionExpirationTest(exprReg, 1, new ExpirationAttributes(1, ExpirationAction.DESTROY), false); } public void testRegionTTLExpiration() throws CacheException {
public void testRegionTTLExpiration() throws CacheException { AttributesFactory af = new AttributesFactory(); af.setScope(Scope.DISTRIBUTED_NO_ACK); af.setStatisticsEnabled(true); af.setRegionTimeToLive(new ExpirationAttributes(1, ExpirationAction.INVALIDATE)); Region exprReg = this.cache.createRegion("TXRegionTTL", af.create()); generalRegionExpirationTest(exprReg, 1, null, true); generalRegionExpirationTest(exprReg, 2, new ExpirationAttributes(2, ExpirationAction.INVALIDATE), true); generalRegionExpirationTest(exprReg, 1, new ExpirationAttributes(1, ExpirationAction.INVALIDATE), true); generalRegionExpirationTest(exprReg, 1, new ExpirationAttributes(1, ExpirationAction.DESTROY), true); }
public static <K, V> PartitionedRegion createReservoirRegionForSampleTable(String reservoirRegionName, String resolvedBaseName) { Region<K, V> regionBase = Misc.getRegionForTable(resolvedBaseName, false); GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); Region<K, V> childRegion = cache.getRegion(reservoirRegionName); if (childRegion == null) { RegionAttributes<K, V> attributesBase = regionBase.getAttributes(); PartitionAttributes<K, V> partitionAttributesBase = attributesBase.getPartitionAttributes(); AttributesFactory afact = new AttributesFactory(); afact.setDataPolicy(attributesBase.getDataPolicy()); PartitionAttributesFactory paf = new PartitionAttributesFactory(); paf.setTotalNumBuckets(partitionAttributesBase.getTotalNumBuckets()); paf.setRedundantCopies(partitionAttributesBase.getRedundantCopies()); paf.setLocalMaxMemory(partitionAttributesBase.getLocalMaxMemory()); PartitionResolver partResolver = createPartitionResolverForSampleTable(reservoirRegionName); paf.setPartitionResolver(partResolver); paf.setColocatedWith(regionBase.getFullPath()); afact.setPartitionAttributes(paf.create()); childRegion = cache.createRegion(reservoirRegionName, afact.create()); } reservoirRegionCreated = true; return (PartitionedRegion)childRegion; }