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 createCacheClientFromXml( URL url, String poolName, String durableClientId, int timeout, Boolean addControlListener) { ClientCacheFactory ccf = new ClientCacheFactory(); try { File cacheXmlFile = new File(url.toURI().getPath()); ccf.set("cache-xml-file", cacheXmlFile.toURI().getPath()); } catch (URISyntaxException e) { throw new ExceptionInInitializerError(e); } ccf.set("mcast-port", "0"); ccf.set(DistributionConfig.DURABLE_CLIENT_ID_NAME, durableClientId); ccf.set(DistributionConfig.DURABLE_CLIENT_TIMEOUT_NAME, String.valueOf(timeout)); cache = (Cache) ccf.create(); pool = (PoolImpl) PoolManager.find(poolName); }
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()); }
static <K, V> Exporter<K, V> createExporter(Region<?, ?> region, SnapshotOptions<K, V> options) { String pool = region.getAttributes().getPoolName(); if (pool != null) { return new ClientExporter<K, V>(PoolManager.find(pool)); } else if (InternalDistributedSystem.getAnyInstance().isLoner() || region.getAttributes().getDataPolicy().equals(DataPolicy.NORMAL) || region.getAttributes().getDataPolicy().equals(DataPolicy.PRELOADED) || region instanceof LocalDataSet || (((SnapshotOptionsImpl<K, V>) options).isParallelMode() && region.getAttributes().getDataPolicy().withPartitioning())) { // Avoid function execution: // for loner systems to avoid inlining fn execution // for NORMAL/PRELOAD since they don't support fn execution // for LocalDataSet since we're already running a fn // for parallel ops since we're already running a fn return new LocalExporter<K, V>(); } return new WindowedExporter<K, V>(); }
public static void acquireConnectionsAndDestroyEntriesK1andK2() { try { Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME); assertNotNull(r1); String poolName = r1.getAttributes().getPoolName(); assertNotNull(poolName); PoolImpl pool = (PoolImpl) PoolManager.find(poolName); assertNotNull(pool); Connection conn = pool.acquireConnection(); final Connection conn1; if (conn.getServer().getPort() != PORT2) { conn1 = pool.acquireConnection(); // Ensure we have a server with the proper port } else { conn1 = conn; } assertNotNull(conn1); assertEquals(PORT2, conn1.getServer().getPort()); ServerRegionProxy srp = new ServerRegionProxy(Region.SEPARATOR + REGION_NAME, pool); srp.destroyOnForTestsOnly( conn1, "key1", null, Operation.DESTROY, new EntryEventImpl(new EventID(new byte[] {1}, 100000, 1)), null); srp.destroyOnForTestsOnly( conn1, "key2", null, Operation.DESTROY, new EntryEventImpl(new EventID(new byte[] {1}, 100000, 2)), null); } catch (Exception ex) { throw new TestException("Failed while setting acquireConnectionsAndDestroyEntry ", ex); } }