/** * Tests creating a cache whose keys are constrained */ public void testConstrainedKeys() throws CacheException { CacheCreation cache = new CacheCreation(); RegionAttributesCreation attrs = new RegionAttributesCreation(cache); attrs.setKeyConstraint(String.class); cache.createRegion("root", attrs); testXml(cache); }
public void testBackupFiles() throws CacheException { CacheCreation cache = new CacheCreation(); File backup1 = new File("/back/me/up"); File backup2 = new File("/me/too/please"); cache.addBackup(backup1); cache.addBackup(backup2); testXml(cache); GemFireCacheImpl c = (GemFireCacheImpl) getCache(); assertEquals(Arrays.asList(new File[] {backup1, backup2}), c.getBackupFiles()); }
public void testDefaultCacheServerBindAddress() throws CacheException { CacheCreation cache = new CacheCreation(); CacheServer bs = cache.addCacheServer(); bs.setPort(AvailablePortHelper.getRandomAvailableTCPPort()); testXml(cache); Cache c = getCache(); assertNotNull(c); CacheServer server = (CacheServer)cache.getCacheServers().iterator().next(); assertNotNull(server); assertEquals(CacheServer.DEFAULT_BIND_ADDRESS, server.getBindAddress()); } public void testCacheServerBindAddress() throws CacheException {
/** * Tests transaction manager with no listener * * @since 4.0 */ public void testCacheTransactionManager() { CacheCreation cache = new CacheCreation(); CacheTransactionManagerCreation txMgrCreation = new CacheTransactionManagerCreation(); cache.addCacheTransactionManagerCreation(txMgrCreation); 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); }
if (this.hasLockLease()) { cache.setLockLease(this.lockLease); if (this.hasLockTimeout()) { cache.setLockTimeout(this.lockTimeout); if (this.hasSearchTimeout()) { cache.setSearchTimeout(this.searchTimeout); if (this.hasMessageSyncInterval()) { cache.setMessageSyncInterval(this.getMessageSyncInterval()); Map m = getPools(); if (!m.isEmpty()) { Iterator it = m.values().iterator(); if (hasResourceManager()) { getResourceManager().configure(cache.getResourceManager()); DiskStoreAttributesCreation pdxRegDSC = initializePdxDiskStore(cache); DiskStoreAttributesCreation creation = (DiskStoreAttributesCreation) iter.next(); if (creation != pdxRegDSC) { createDiskStore(creation, cache); if (this.hasDynamicRegionFactory()) { DynamicRegionFactory.get().open(this.getDynamicRegionFactoryConfig());
other.getLockLease() == this.getLockLease() && other.getLockTimeout() == this.getLockTimeout() && other.getSearchTimeout() == this.getSearchTimeout() && other.getMessageSyncInterval() == this.getMessageSyncInterval() && other.getCopyOnRead() == this.getCopyOnRead() && other.isServer() == this.isServer(); DynamicRegionFactory.Config drc1 = this.getDynamicRegionFactoryConfig(); if (drc1 != null) { drc2 = ((CacheCreation)other).getDynamicRegionFactoryConfig(); } else { drc2 = DynamicRegionFactory.get().getConfig(); if (((CacheCreation)other).getDynamicRegionFactoryConfig() != null) { return false; Collection myBridges = this.getCacheServers(); Collection otherBridges = other.getCacheServers(); if (myBridges.size() != otherBridges.size()) { Map m1 = getPools(); Map m2 = (other instanceof CacheCreation) ? ((CacheCreation)other).getPools() : PoolManager.getAll(); int m1Size = m1.size(); DiskStore ds = other.findDiskStore(name); if (ds == null) {
public void testClientSubscriptionQueueUsingDefaultDS() throws CacheException { CacheCreation cache = new CacheCreation(); cache.setMessageSyncInterval(3445); CacheServer bs = cache.addCacheServer(); ClientSubscriptionConfig csc = bs.getClientSubscriptionConfig(); csc.setEvictionPolicy("entry"); cache.getLogger().config( "EvictionPolicy : " + csc.getEvictionPolicy()); csc.setCapacity(501); cache.getLogger().config( "EvictionCapacity : " + csc.getCapacity()); cache.getLogger().config( "Eviction disk store : " + csc.getDiskStoreName()); RegionAttributesCreation attrs = new RegionAttributesCreation(cache); attrs.setDataPolicy(DataPolicy.NORMAL); cache.createVMRegion("rootNORMAL", attrs); testXml(cache); Cache c = getCache(); assertNotNull(c); CacheServer server = (CacheServer)cache.getCacheServers().iterator() .next(); assertNotNull(server);
public void testBridgeAttributesRelatedToHAOverFlow65() throws CacheException { CacheCreation cache = new CacheCreation(); cache.setMessageSyncInterval(3445); CacheServer bs = cache.addCacheServer(); ClientSubscriptionConfig csc = bs.getClientSubscriptionConfig(); csc.setEvictionPolicy("entry"); cache.getLogger().config( "EvictionPolicy : " + csc.getEvictionPolicy()); csc.setCapacity(501); cache.getLogger().config( "EvictionCapacity : " + csc.getCapacity()); File overflowDirectory = new File("overFlow"); overflowDirectory.mkdirs(); DiskStoreFactory dsf = cache.createDiskStoreFactory(); File[] dirs1 = new File[] {overflowDirectory}; DiskStore ds1 = dsf.setDiskDirs(dirs1).create(getUniqueName()); cache.getLogger().config( "Eviction disk store : " + csc.getDiskStoreName()); RegionAttributesCreation attrs = new RegionAttributesCreation(cache); attrs.setDataPolicy(DataPolicy.NORMAL); cache.createVMRegion("rootNORMAL", attrs); testXml(cache); Cache c = getCache(); assertNotNull(c); CacheServer server = (CacheServer)cache.getCacheServers().iterator() .next(); assertNotNull(server);
assertTrue(this.workingDirectory.isDirectory() && this.workingDirectory.canWrite()); final CacheCreation creation = new CacheCreation(); final RegionAttributesCreation attrs = new RegionAttributesCreation(creation); attrs.setScope(Scope.DISTRIBUTED_ACK); attrs.setDataPolicy(DataPolicy.REPLICATE); creation.createRegion(getUniqueName(), attrs); creation.addCacheServer();
/** * Test EnableBridgeConflation region attribute * @since 4.2 */ public void testEnableBridgeConflationAttribute() throws CacheException { CacheCreation cache = new CacheCreation(); RegionAttributesCreation attrs = new RegionAttributesCreation(cache); attrs.setEnableBridgeConflation(true); cache.createRegion("root", attrs); testXml(cache); assertEquals(true, cache.getRegion("root").getAttributes().getEnableBridgeConflation()); }
public void testTwoConnectionPools() throws CacheException { getSystem(); CacheCreation cache = new CacheCreation(); PoolFactory f = cache.createPoolFactory(); f.addLocator(ALIAS2, 3777).create("mypool"); f.reset().addLocator(ALIAS1, 3888).create("mypool2"); cache.createVMRegion("rootNORMAL", attrs); testXml(cache); Cache c = getCache();
public void testAsyncEventQueue() { getSystem(); CacheCreation cache = new CacheCreation(); AsyncEventQueueFactory factory = cache.createAsyncEventQueueFactory(); factory.setBatchSize(100); factory.setBatchTimeInterval(500); cache.createRegion("UserRegion", attrs);
CacheCreation cache = new CacheCreation(); cache.createPoolFactory() .addServer(getServerHostName(vm0.getHost()), port) .setSubscriptionEnabled(true) .create("connectionPool"); cache.setDynamicRegionFactoryConfig(new DynamicRegionFactory.Config(null, "connectionPool", false, false)); RegionAttributesCreation attrs = new RegionAttributesCreation(cache); cache.createRegion("root", attrs);
/** * disabled test because it can only be done from a bridge client cache. */ public void _testDynamicRegionFactoryCacheWriter() throws CacheException { CacheCreation cache = new CacheCreation(); CacheWriter writer = new MyTestCacheWriter(); cache.setDynamicRegionFactoryConfig(new DynamicRegionFactory.Config(null, (com.gemstone.gemfire.cache.util.BridgeWriter)writer)); RegionAttributesCreation attrs = new RegionAttributesCreation(cache); cache.createRegion("root", attrs); // note that testXml can't check if they are same because enabling // dynamic regions causes a meta region to be produced. testXml(cache, false); assertEquals(true, DynamicRegionFactory.get().isOpen()); assertEquals(null, DynamicRegionFactory.get().getConfig().getDiskDir()); assertEquals(writer, DynamicRegionFactory.get().getConfig().getBridgeWriter()); }
public void testSerialGatewaySender() throws CacheException{ getSystem(); CacheCreation cache = new CacheCreation(); GatewaySenderFactory gatewaySenderFactory = cache.createGatewaySenderFactory(); gatewaySenderFactory.setParallel(false); gatewaySenderFactory.setManualStart(true); cache.createRegion("UserRegion", attrs);
public void testLoadPollInterval() { CacheCreation cache = new CacheCreation(); CacheServer server = cache.addCacheServer(); server.setPort(AvailablePortHelper.getRandomAvailableTCPPort()); server.setLoadPollInterval(12345); testXml(cache); Cache c = getCache(); server = c.getCacheServers().get(0); Assert.assertEquals(12345, server.getLoadPollInterval()); }
public void run2() throws CacheException { createLonerDS(dsName + "_loner_" + NYC_CLIENT_NAME + "_vm3"); beginCacheXml(); PoolImpl pi = null; if (getTestDynamicRegions()) { CacheCreation cc = (CacheCreation)getCache(); pi = (PoolImpl)BridgeTestCase.configureConnectionPoolWithNameAndFactory(null, getServerHostName(host), bsPorts, true, -1, -1, null,"testPool",cc.createPoolFactory()); File d = new File(dsName + DYNAMIC_REGION_DIR + hydra.ProcessMgr.getProcessId()); d.mkdirs(); cc.setDynamicRegionFactoryConfig(new DynamicRegionFactory.Config(d, pi.getName(),false,true)); } else { pi = (PoolImpl)BridgeTestCase.configureConnectionPool(null, getServerHostName(host), bsPorts, true, -1, -1, null); } createParentRegionOnClient(dsName, false,pi); finishCacheXml(dsName + "_" + NYC_CLIENT_NAME); Region r = getCache().getRegion(dsName); r.registerInterestRegex(".*"); } });
@SuppressWarnings("deprecation") public BridgeServer addBridgeServer() { return (BridgeServer)addCacheServer(); }
public void testAlreadyExistingPool() throws CacheException { getSystem(); PoolFactoryImpl f = (PoolFactoryImpl) PoolManager.createFactory(); f.setStartDisabled(true).addLocator(ALIAS2, 12345).create("mypool"); try { // now make sure declarative cache can't create the same pool CacheCreation cache = new CacheCreation(); cache.createPoolFactory().addLocator(ALIAS2, 12345).create("mypool"); try { testXml(cache); fail("expected IllegalStateException"); } catch (IllegalStateException expected) { } } finally { PoolManager.close(); } }