public ClientCache createCache() throws Exception { cacheFactory = new ClientCacheFactory(properties); cacheSetups.stream().forEach(setup -> setup.accept(cacheFactory)); cache = cacheFactory.create(); return cache; }
public void createClientCache(final Properties config, final Properties systemProperties) { System.getProperties().putAll(systemProperties); clientCache = (InternalClientCache) new ClientCacheFactory(config).create(); }
public void createClientCache() { clientCache = (InternalClientCache) new ClientCacheFactory(config).create(); }
public void createClientCache(final Properties config) { clientCache = (InternalClientCache) new ClientCacheFactory(config).create(); }
@Deprecated public static ClientCache createClientCache(String username, String password, int serverPort, Properties extraProperties) { Properties props = new Properties(); props.setProperty(UserPasswordAuthInit.USER_NAME, username); props.setProperty(UserPasswordAuthInit.PASSWORD, password); props.setProperty(SECURITY_CLIENT_AUTH_INIT, UserPasswordAuthInit.class.getName()); props.setProperty(LOCATORS, ""); props.setProperty(MCAST_PORT, "0"); props.putAll(extraProperties); if (Version.CURRENT.ordinal() >= 75) { props.setProperty(SERIALIZABLE_OBJECT_FILTER, "org.apache.geode.security.query.data.*"); } ClientCache cache = new ClientCacheFactory(props).setPoolSubscriptionEnabled(true) .addPoolServer("localhost", serverPort).create(); return cache; }
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(DURABLE_CLIENT_ID, durableClientId); ccf.set(DURABLE_CLIENT_TIMEOUT, String.valueOf(timeout)); cache = (Cache) ccf.create(); expected = IgnoredException .addIgnoredException("java.net.ConnectionException||java.net.SocketException"); pool = (PoolImpl) PoolManager.find(poolName); }
private final void createCache(final boolean client, final CacheFactory factory) { synchronized (JUnit4CacheTestCase.class) { try { System.setProperty(GEMFIRE_PREFIX + "DISABLE_DISCONNECT_DS_ON_CACHE_CLOSE", "true"); InternalCache newCache; if (client) { System.setProperty(GEMFIRE_PREFIX + "locators", ""); System.setProperty(GEMFIRE_PREFIX + MCAST_PORT, "0"); newCache = (InternalCache) new ClientCacheFactory(getSystem().getProperties()).create(); } else { if (factory == null) { newCache = (InternalCache) CacheFactory.create(getSystem()); } else { Properties config = getSystem().getProperties(); for (Map.Entry entry : config.entrySet()) { factory.set((String) entry.getKey(), (String) entry.getValue()); } newCache = (InternalCache) factory.create(); } } cache = newCache; } finally { System.clearProperty(GEMFIRE_PREFIX + "DISABLE_DISCONNECT_DS_ON_CACHE_CLOSE"); System.clearProperty(GEMFIRE_PREFIX + "locators"); System.clearProperty(GEMFIRE_PREFIX + MCAST_PORT); } } }
ClientCacheFactory ccf = new ClientCacheFactory(); ccf.setPdxReadSerialized(true); if (serverPort != 0) {
public static void createCacheClientFromXmlN(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(DURABLE_CLIENT_ID, durableClientId); ccf.set(DURABLE_CLIENT_TIMEOUT, String.valueOf(timeout)); ccf.set(LOG_FILE, "abs_client_system.log"); ccf.set(LOG_LEVEL, LogWriterUtils.getDUnitLogLevel()); cache = (Cache) ccf.create(); expected = IgnoredException .addIgnoredException("java.net.ConnectionException||java.net.SocketException"); pool = (PoolImpl) PoolManager.find(poolName); }
@Override protected void createOrRetrieveCache() { if (getLogger().isDebugEnabled()) { getLogger().debug(this + ": Creating cache"); } // Get the existing cache if any try { this.cache = ClientCacheFactory.getAnyInstance(); } catch (CacheClosedException e) { } // If no cache exists, create one String message = null; if (this.cache == null || this.cache.isClosed()) { // enable pool subscription so that default cache can be used by hibernate module this.cache = new ClientCacheFactory(createDistributedSystemProperties()).create(); message = "Created "; } else { message = "Retrieved "; } getLogger().info(message + this.cache); }
@Override public void run2() throws CacheException { getSystem(properties); final ClientCacheFactory ccf = new ClientCacheFactory(properties); for (int i = 0; i < servers.length; i++) { ccf.addPoolServer(NetworkUtils.getServerHostName(servers[i].getHost()), ports[i]); } ccf.setPoolSubscriptionEnabled(true); ccf.setPoolSubscriptionRedundancy(redundancyLevel); ClientCache cache = (ClientCache) getClientCache(ccf); } });
@Test(expected = GemFireConfigException.class) public void clientIsPreventedFromConnectingToLocatorAsServer() { IgnoredException.addIgnoredException("Improperly configured client detected"); ClientCacheFactory clientCacheFactory = new ClientCacheFactory(); clientCacheFactory.addPoolServer("localhost", DistributedTestUtils.getDUnitLocatorPort()); clientCacheFactory.setPoolSubscriptionEnabled(true); getClientCache(clientCacheFactory); Region region = ((ClientCache) cache).createClientRegionFactory(ClientRegionShortcut.PROXY) .create(REGION_NAME1); region.registerInterest(k1); }
@Before public void setup() { serverVM = VM.getVM(0); clientVM = VM.getVM(1); final int locatorPort = DistributedTestUtils.getDUnitLocatorPort(); // create a server cache and a client cache serverVM.invoke(() -> { String locatorSpec = "localhost[" + locatorPort + "]"; CacheFactory config = new CacheFactory(); config.set( ConfigurationProperties.LOCATORS, locatorSpec); config.set( ConfigurationProperties.NAME, "server1"); Cache serverCache = config.create(); cache = serverCache; CacheServer cacheServer = serverCache.addCacheServer(); cacheServer.start(); }); clientVM.invoke(() -> { ClientCacheFactory config = new ClientCacheFactory(); config.addPoolLocator("localhost", locatorPort); config.setPoolSubscriptionEnabled(true); cache = config.create(); }); }
public static void createClientCache(Pool poolAttr, String regionName, Properties dsProperties) throws Exception { ClientCacheFactory ccf = new ClientCacheFactory(dsProperties); if (poolAttr != null) { ccf.setPoolFreeConnectionTimeout(poolAttr.getFreeConnectionTimeout())
public static void main(String[] args) { // connect to the locator using default port 10334 ClientCache cache = new ClientCacheFactory().addPoolLocator("127.0.0.1", 10334) .set("log-level", "WARN").create(); // create a local region that matches the server region Region<String, String> region = cache.<String, String>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY) .create("example-region"); printQuotes(region); cache.close(); }
public static void main(String[] args) { // connect to the locator using default port 10334 ClientCache cache = new ClientCacheFactory().addPoolLocator("127.0.0.1", 10334) .set("log-level", "WARN").create(); Example example = new Example(); // create a local region that matches the server region ClientRegionFactory<Integer, String> clientRegionFactory = cache.createClientRegionFactory(ClientRegionShortcut.PROXY); Region<Integer, String> region = clientRegionFactory.create("example-region"); example.putEntries(region); cache.close(); }
public static void main(String[] args) { // connect to the locator using default port 10334 ClientCache cache = new ClientCacheFactory().addPoolLocator("127.0.0.1", 10334) .set("log-level", "WARN").create(); // create a local region that matches the server region Region<String, String> region = cache.<String, String>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY) .create("example-region"); new Example().getValidNames(region); cache.close(); }
public static void main(String[] args) { // connect to the locator using default port 10334 ClientCache cache = new ClientCacheFactory().addPoolLocator("127.0.0.1", 10334) .set("log-level", "WARN").create(); Example example = new Example(); // create a local region that matches the server region ClientRegionFactory<Integer, String> clientRegionFactory = cache.createClientRegionFactory(ClientRegionShortcut.PROXY); Region<Integer, String> region = clientRegionFactory.create("example-region"); example.putEntries(region); cache.close(); }
public static void main(String[] args) { // connect to the locator using default port 10334 ClientCache cache = new ClientCacheFactory().addPoolLocator("127.0.0.1", 10334) .set("log-level", "WARN").create(); // create a local region that matches the server region Region<Integer, String> region = cache.<Integer, String>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY) .create("example-region"); Execution execution = FunctionService.onRegion(region); new Example().getPrimes(region, execution); cache.close(); }
public static void main(String[] args) throws LuceneQueryException { // connect to the locator using default port 10334 ClientCache cache = new ClientCacheFactory().addPoolLocator("127.0.0.1", 10334) .set("log-level", "WARN").create(); // create a local region that matches the server region Region<Integer, EmployeeData> region = cache.<Integer, EmployeeData>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY) .create("example-region"); insertValues(region); query(cache); queryNestedObject(cache); cache.close(); }