public static void createClientCache(String host, Integer port1, Integer port2) throws Exception { PORT1 = port1.intValue(); PORT2 = port2.intValue(); Properties props = new Properties(); props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0"); props.setProperty(DistributionConfig.LOCATORS_NAME, ""); new DestroyEntryPropagationDUnitTest("temp").createCache(props); CacheServerTestUtil.disableShufflingOfEndpoints(); Pool p; try { p = PoolManager.createFactory() .addServer(host, PORT1) .addServer(host, PORT2) .setSubscriptionEnabled(true) .setSubscriptionRedundancy(-1) .setReadTimeout(2000) .setSocketBufferSize(1000) .setMinConnections(4) // .setRetryAttempts(2) // .setRetryInterval(250) .create("EntryPropagationDUnitTestPool"); } finally { CacheServerTestUtil.enableShufflingOfEndpoints(); } AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.DISTRIBUTED_ACK); factory.setPoolName(p.getName()); factory.setCacheListener(new CertifiableTestCacheListener(getLogWriter())); RegionAttributes attrs = factory.create(); cache.createRegion(REGION_NAME, attrs); }
public static void createCacheClient(Pool poolAttr, String regionName1, String regionName2) throws Exception { new CacheServerTestUtil("temp").createCache(getClientProperties()); PoolFactoryImpl pf = (PoolFactoryImpl) PoolManager.createFactory(); pf.init(poolAttr); PoolImpl p = (PoolImpl) pf.create("CacheServerTestUtil"); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.LOCAL); factory.setPoolName(p.getName()); RegionAttributes attrs = factory.create(); cache.createRegion(regionName1, attrs); cache.createRegion(regionName2, attrs); pool = p; }
public static void createCacheClient( Pool poolAttr, String regionName, Properties dsProperties, Boolean addControlListener) throws Exception { new CacheServerTestUtil("temp").createCache(dsProperties); PoolFactoryImpl pf = (PoolFactoryImpl) PoolManager.createFactory(); pf.init(poolAttr); PoolImpl p = (PoolImpl) pf.create("CacheServerTestUtil"); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.LOCAL); factory.setPoolName(p.getName()); if (addControlListener.booleanValue()) { factory.addCacheListener(new ControlListener()); } RegionAttributes attrs = factory.create(); cache.createRegion(regionName, attrs); pool = p; }
public static void createPool(PoolAttributes poolAttr) throws Exception { Properties props = new Properties(); props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0"); props.setProperty(DistributionConfig.LOCATORS_NAME, ""); DistributedSystem ds = new CacheServerTestUtil("tmp").getSystem(props); ; PoolFactoryImpl pf = (PoolFactoryImpl) PoolManager.createFactory(); pf.init(poolAttr); PoolImpl p = (PoolImpl) pf.create("CacheServerTestUtil"); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.LOCAL); factory.setPoolName(p.getName()); RegionAttributes attrs = factory.create(); pool = p; }
/** Initializes proxy object and creates region for client */ private void createProxyAndRegionForClient() { try { // props.setProperty("retryAttempts", "5"); PoolFactory pf = PoolManager.createFactory(); proxy = (PoolImpl) pf.addServer("localhost", PORT) .setThreadLocalConnections(true) .setReadTimeout(10000) .setPingInterval(10000) .setMinConnections(0) .create("junitPool"); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.DISTRIBUTED_ACK); cache.createVMRegion(regionName, factory.createRegionAttributes()); } catch (Exception ex) { ex.printStackTrace(); fail("Failed to initialize client"); } }
/** * Create client regions each with their own BridgeWriter instance. * * @param props * @param regionName1 * @param regionName2 * @throws Exception */ public static void createCacheClients( Pool poolAttr, String regionName1, String regionName2, Properties dsProperties) throws Exception { new CacheServerTestUtil("temp").createCache(dsProperties); // Initialize region1 PoolFactoryImpl pf = (PoolFactoryImpl) PoolManager.createFactory(); pf.init(poolAttr); Pool p = pf.create("CacheServerTestUtil1"); AttributesFactory factory1 = new AttributesFactory(); factory1.setScope(Scope.LOCAL); factory1.setPoolName(p.getName()); cache.createRegion(regionName1, factory1.create()); // Initialize region2 p = pf.create("CacheServerTestUtil2"); AttributesFactory factory2 = new AttributesFactory(); factory2.setScope(Scope.LOCAL); factory2.setPoolName(p.getName()); cache.createRegion(regionName2, factory2.create()); }