本文整理汇总了Java中com.gemstone.gemfire.cache.client.ClientCache类的典型用法代码示例。如果您正苦于以下问题:Java ClientCache类的具体用法?Java ClientCache怎么用?Java ClientCache使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ClientCache类属于com.gemstone.gemfire.cache.client包,在下文中一共展示了ClientCache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CacheXmlGenerator
import com.gemstone.gemfire.cache.client.ClientCache; //导入依赖的package包/类
/**
* Creates a new <code>CacheXmlGenerator</code> that generates XML
* for a given <code>ClientCache</code>.
*/
private CacheXmlGenerator(ClientCache cache, boolean useSchema,
String version, boolean includeKeysValues) {
this.cache = (Cache)cache;
this.useSchema = useSchema;
this.version = version;
this.includeKeysValues = includeKeysValues;
this.generateDefaults = true;
if (cache instanceof ClientCacheCreation) {
this.creation = (ClientCacheCreation) cache;
this.creation.startingGenerate();
} else {
this.creation = new ClientCacheCreation();
if (generateDefaults() || cache.getCopyOnRead()) {
this.creation.setCopyOnRead(cache.getCopyOnRead());
}
}
}
示例2: getRegionInstance
import com.gemstone.gemfire.cache.client.ClientCache; //导入依赖的package包/类
public Region<Object, Object> getRegionInstance(Configuration conf,
ClientCache cache) {
Region<Object, Object> region;
// create gemfire region in proxy mode
String regionName = conf.get(REGION);
ClientRegionFactory<Object, Object> regionFactory = cache
.createClientRegionFactory(ClientRegionShortcut.PROXY);
try {
region = regionFactory.create(regionName);
} catch (RegionExistsException e) {
region = cache.getRegion(regionName);
}
return region;
}
示例3: main
import com.gemstone.gemfire.cache.client.ClientCache; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
writeToStdout("Connecting to the distributed system and creating the cache.");
// Create the cache which causes the cache-xml-file to be parsed
ClientCache cache = new ClientCacheFactory()
.set("name", "DeltaPropagationClientReceiver")
.set("cache-xml-file", "xml/DeltaClient2.xml")
.create();
Region<Object, Object> reg = cache.getRegion("exampleRegion");
reg.registerInterest("ALL_KEYS");
writeToStdout("Please press Enter to stop the receiver.");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
bufferedReader.readLine();
cache.close();
}
示例4: main
import com.gemstone.gemfire.cache.client.ClientCache; //导入依赖的package包/类
public static void main(String [] args) throws Exception {
System.out.println("Connecting to the distributed system and creating the cache.");
// Create the cache which causes the cache-xml-file to be parsed
ClientCache cache = new ClientCacheFactory()
.set("name", "I18nClient")
.set("cache-xml-file", "xml/I18nClient.xml")
.create();
// Get the exampleRegion
Region<String, String> region = cache.getRegion("家具店");
System.out.println("Example region, " + region.getFullPath() + ", created in cache.");
System.out.println();
System.out.println("Getting values from the server...");
String query = "SELECT DISTINCT * FROM " + region.getFullPath() + ".keys";
SelectResults<String> results = region.query(query);
List<String> keys = results.asList();
for (String key : keys) {
String value = region.get(key);
System.out.println("item: " + key + " price: " + value);
}
System.out.println();
System.out.println("Closing the cache and disconnecting.");
cache.close();
}
示例5: generateDummyPool
import com.gemstone.gemfire.cache.client.ClientCache; //导入依赖的package包/类
/**
* Generates a dummy pool from the given cache and pool description.
*/
private static void generateDummyPool(ClientCache dummyCache,
PoolDescription pd, String fn) {
// create and configure the dummy pool
PoolFactory dummyFactory =
((ClientCacheCreation)dummyCache).createPoolFactory();
pd.configure(dummyFactory);
String poolName = pd.getName();
Pool dummyPool = null;
try {
dummyPool = dummyFactory.create(poolName);
} catch (IllegalStateException e) {
String msg = "A pool named \"" + poolName + "\" already exists.";
throw new HydraRuntimeException(msg, e);
}
log("Added dummy pool: " + PoolHelper.poolToString(dummyPool));
}
示例6: generateDummyDiskStore
import com.gemstone.gemfire.cache.client.ClientCache; //导入依赖的package包/类
/**
* Generates a dummy disk store from the given cache and disk store
* description.
*/
private static void generateDummyDiskStore(ClientCache dummyCache,
String diskStoreName, DiskStoreDescription dsd, String fn) {
// create and configure the dummy disk store
DiskStoreFactory dummyFactory =
((ClientCacheCreation)dummyCache).createDiskStoreFactory();
dsd.configure(dummyFactory);
DiskStore dummyDiskStore = null;
try {
dummyDiskStore = dummyFactory.create(diskStoreName);
} catch (IllegalStateException e) {
String msg = "A disk store named \"" + diskStoreName
+ "\" already exists.";
throw new HydraRuntimeException(msg, e);
}
log("Added dummy disk store: "
+ DiskStoreHelper.diskStoreToString(dummyDiskStore));
}
示例7: generateDummyFunctions
import com.gemstone.gemfire.cache.client.ClientCache; //导入依赖的package包/类
/**
* Generates dummy functions from the given cache and function list.
*/
private static void generateDummyFunctions(ClientCache dummyCache,
List functions, String fn) {
if (functions != null) {
// create and configure the dummy functions
log("Adding dummy functions: " + functions);
FunctionServiceCreation fsc = new FunctionServiceCreation();
for (Iterator i = functions.iterator(); i.hasNext();) {
Function function = (Function)i.next();
fsc.registerFunction(function);
}
//fsc.create(); // not needed, functions are registered during createCacheWithXml
((ClientCacheCreation)dummyCache).setFunctionServiceCreation(fsc);
log("Added dummy functions: " + fsc.getFunctions());
// save the functions for future reference
XmlFunctionConfigs.put(fn, classnamesFor(functions));
}
}
示例8: createClientRegion
import com.gemstone.gemfire.cache.client.ClientCache; //导入依赖的package包/类
private void createClientRegion(final VM vm, final int port1, final int port2,
final boolean threadLocalConnections) {
SerializableCallable createRegion = new SerializableCallable("create client region in " + vm) {
public Object call() throws Exception {
ClientCacheFactory cf = new ClientCacheFactory();
cf.addPoolServer(getServerHostName(vm.getHost()), port1);
cf.addPoolServer(getServerHostName(vm.getHost()), port2);
cf.setPoolPRSingleHopEnabled(false);
cf.setPoolThreadLocalConnections(threadLocalConnections);
cf.setPoolReadTimeout(10 * 60 * 1000);
ClientCache cache = getClientCache(cf);
cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
.create("region");
return null;
}
};
vm.invoke(createRegion);
}
示例9: testTXManagerOnClientCache
import com.gemstone.gemfire.cache.client.ClientCache; //导入依赖的package包/类
public void testTXManagerOnClientCache() {
ClientCacheCreation cc = new ClientCacheCreation();
//CacheCreation cc = new CacheCreation();
CacheTransactionManagerCreation txMgrCreation = new CacheTransactionManagerCreation();
txMgrCreation.addListener(new TestTXListener());
cc.addCacheTransactionManagerCreation(txMgrCreation);
testXml(cc);
Cache c = getCache();
assertTrue(c instanceof ClientCache);
c.loadCacheXml(generate(cc));
ClientCache clientC = (ClientCache) c;
CacheTransactionManager mgr = clientC.getCacheTransactionManager();
assertNotNull(mgr);
assertTrue(mgr.getListeners()[0] instanceof TestTXListener);
}
示例10: createClientRegion
import com.gemstone.gemfire.cache.client.ClientCache; //导入依赖的package包/类
private void createClientRegion(final VM vm, final String regionName, final int port) {
SerializableCallable createRegion = new SerializableCallable() {
public Object call() throws Exception {
ClientCacheFactory cf = new ClientCacheFactory();
cf.addPoolServer(getServerHostName(vm.getHost()), port);
cf.setPoolSubscriptionEnabled(true);
cf.set("log-level", getDUnitLogLevel());
ClientCache cache = getClientCache(cf);
ClientRegionFactory crf = cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY);
crf.setConcurrencyChecksEnabled(true);
TestRegion = (LocalRegion)crf.create(regionName);
TestRegion.registerInterestRegex(".*", InterestResultPolicy.KEYS_VALUES, false, true);
return null;
}
};
vm.invoke(createRegion);
}
示例11: createDurableClientRegion
import com.gemstone.gemfire.cache.client.ClientCache; //导入依赖的package包/类
private void createDurableClientRegion(final VM vm, final String regionName,
final int port1, final int port2, final boolean ccEnabled) {
SerializableCallable createRegion = new SerializableCallable() {
public Object call() throws Exception {
ClientCacheFactory cf = new ClientCacheFactory();
cf.addPoolServer(getServerHostName(vm.getHost()), port1);
cf.addPoolServer(getServerHostName(vm.getHost()), port2);
cf.setPoolSubscriptionEnabled(true);
cf.setPoolSubscriptionRedundancy(1);
// bug #50683 - secondary durable queue retains all GC messages
cf.set("durable-client-id", ""+vm.getPid());
cf.set("durable-client-timeout", "" + 200);
cf.set("log-level", "fine");
ClientCache cache = getClientCache(cf);
ClientRegionFactory crf = cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY);
crf.setConcurrencyChecksEnabled(ccEnabled);
TestRegion = (LocalRegion)crf.create(regionName);
TestRegion.registerInterestRegex(".*", InterestResultPolicy.KEYS_VALUES, true, true);
cache.readyForEvents();
return null;
}
};
vm.invoke(createRegion);
}
示例12: createClientRegion
import com.gemstone.gemfire.cache.client.ClientCache; //导入依赖的package包/类
private void createClientRegion(VM vm, final int port1, final boolean isEmpty, final boolean ri, final int port2) {
vm.invoke(new SerializableCallable() {
public Object call() throws Exception {
ClientCacheFactory ccf = new ClientCacheFactory();
ccf.addPoolServer("localhost"/*getServerHostName(Host.getHost(0))*/, port1);
if (port2 > 0) {
ccf.addPoolServer("localhost", port2);
}
ccf.setPoolSubscriptionEnabled(true);
ccf.set("log-level", getDUnitLogLevel());
ClientCache cCache = getClientCache(ccf);
ClientRegionFactory<Integer, String> crf = cCache
.createClientRegionFactory(isEmpty ? ClientRegionShortcut.PROXY
: ClientRegionShortcut.CACHING_PROXY);
Region<Integer, String> r = crf.create(REP_REG_NAME);
Region<Integer, String> pr = crf.create(PR_REG_NAME);
if (ri) {
r.registerInterestRegex(".*");
pr.registerInterestRegex(".*");
}
return null;
}
});
}
示例13: createClientRegion
import com.gemstone.gemfire.cache.client.ClientCache; //导入依赖的package包/类
private void createClientRegion(VM vm, final int port, final boolean isEmpty, final boolean ri) {
vm.invoke(new SerializableCallable() {
public Object call() throws Exception {
ClientCacheFactory ccf = new ClientCacheFactory();
ccf.addPoolServer("localhost"/*getServerHostName(Host.getHost(0))*/, port);
ccf.setPoolSubscriptionEnabled(false);
ccf.set("log-level", getDUnitLogLevel());
ClientCache cCache = getClientCache(ccf);
ClientRegionFactory<Integer, String> crf = cCache
.createClientRegionFactory(isEmpty ? ClientRegionShortcut.PROXY
: ClientRegionShortcut.CACHING_PROXY);
Region<Integer, String> r = crf.create(D_REFERENCE);
Region<Integer, String> customer = crf.create(CUSTOMER);
Region<Integer, String> order = crf.create(ORDER);
if (ri) {
r.registerInterestRegex(".*");
customer.registerInterestRegex(".*");
order.registerInterestRegex(".*");
}
return null;
}
});
}
示例14: createProxyRegs
import com.gemstone.gemfire.cache.client.ClientCache; //导入依赖的package包/类
private void createProxyRegs() {
ClientCache cache = (ClientCache)CacheFactory.getAnyInstance();
cache.createClientRegionFactory(ClientRegionShortcut.PROXY).create(repRegionName);
cache.createClientRegionFactory(ClientRegionShortcut.PROXY).create(localRegionName);
cache.createClientRegionFactory(ClientRegionShortcut.PROXY)
.create(PartitionedRegionName1);
cache.createClientRegionFactory(ClientRegionShortcut.PROXY)
.create(PartitionedRegionName2);
cache.createClientRegionFactory(ClientRegionShortcut.PROXY)
.create(PartitionedRegionName3);
cache.createClientRegionFactory(ClientRegionShortcut.PROXY)
.create(PartitionedRegionName4);
cache.createClientRegionFactory(ClientRegionShortcut.PROXY)
.create(PartitionedRegionName5);
}
示例15: addTimerForPdxTypeMetrics
import com.gemstone.gemfire.cache.client.ClientCache; //导入依赖的package包/类
public static void addTimerForPdxTypeMetrics(final ClientCache clientCache) {
Region temp = clientCache.getRegion("PdxTypes");
if (temp == null) {
temp = clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY).create("PdxTypes");
}
final Region pdxRegions = temp;
metricRegistry.register(MetricRegistry.name("PdxTypes", "count"),
(Gauge<Integer>) () -> pdxRegions.keySetOnServer().size());
ConsoleReporter reporter = ConsoleReporter.forRegistry(metricRegistry)
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.build();
reporter.start(1, TimeUnit.MINUTES);
}