本文整理汇总了Java中com.gemstone.gemfire.cache.Cache.close方法的典型用法代码示例。如果您正苦于以下问题:Java Cache.close方法的具体用法?Java Cache.close怎么用?Java Cache.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.gemstone.gemfire.cache.Cache
的用法示例。
在下文中一共展示了Cache.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public void run() throws Exception {
writeToStdout("Peer to which other peer sends request for function Execution");
writeToStdout("Connecting to the distributed system and creating the cache... ");
// Create the cache which causes the cache-xml-file to be parsed
Cache cache = new CacheFactory()
.set("name", "FunctionExecutionPeer1")
.set("cache-xml-file", "xml/FunctionExecutionPeer.xml")
.create();
// Get the exampleRegion
Region<String, String> exampleRegion = cache.getRegion(EXAMPLE_REGION_NAME);
writeToStdout("Example region \"" + exampleRegion.getFullPath() + "\" created in cache.");
writeToStdout("Registering the function MultiGetFunction on Peer");
MultiGetFunction function = new MultiGetFunction();
FunctionService.registerFunction(function);
writeToStdout("Please start Other Peer And Then Press Enter to continue.");
stdinReader.readLine();
System.out.println("Closing the cache and disconnecting.");
cache.close();
}
示例2: main
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
writeToStdout("This example demonstrates delta propagation. This program is a server,");
writeToStdout("listening on a port for client requests. The client program connects and");
writeToStdout("requests data. The client in this example is also configured to produce/consume");
writeToStdout("information on data destroys and updates.");
writeToStdout("To stop the program, press Ctrl c in console.");
writeToStdout("Connecting to the distributed system and creating the cache...");
// Create the cache which causes the cache-xml-file to be parsed
Cache cache = new CacheFactory()
.set("name", "DeltaPropagationServer")
.set("cache-xml-file", "xml/DeltaServer.xml")
.set("mcast-port", "38485")
.create();
writeToStdout("Connected to the distributed system.");
writeToStdout("Created the cache.");
writeToStdout("Please press Enter to stop the server.");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
bufferedReader.readLine();
cache.close();
}
示例3: testNestedPDXObject
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public void testNestedPDXObject() {
final Properties props = new Properties();
props.setProperty(DistributionConfig.MCAST_ADDRESS_NAME, "239.192.81.10");
DistributedSystem.connect(props);
Cache cache = new CacheFactory().create();
PdxInstanceFactory pf = PdxInstanceFactoryImpl.newCreator("Portfolio", false);
pf.writeInt("ID", 111);
pf.writeString("status", "active");
pf.writeString("secId", "IBM");
PdxInstance pi = pf.create();
PDXContainer cont = new PDXContainer(1);
cont.setPi(pi);
TypedJson tJsonObj = new TypedJson(RESULT,cont);
System.out.println(tJsonObj);
cache.close();
}
示例4: main
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
System.out.println("\nConnecting to the distributed system and creating the cache.");
// Create the cache which causes the cache-xml-file to be parsed
Cache cache = new CacheFactory()
.set("cache-xml-file", "xml/HelloWorld.xml")
.create();
// Get the exampleRegion
Region<String,String> exampleRegion = cache.getRegion("exampleRegion");
System.out.println("Example region, " + exampleRegion.getFullPath() + ", created in cache. ");
System.out.println("Putting entry: Hello, World");
exampleRegion.put("Hello", "World");
System.out.println("Putting entry: Hello, Moon!");
exampleRegion.put("Hello", "Moon!");
// Close the cache and disconnect from GemFire distributed system
System.out.println("\nClosing the cache and disconnecting.");
cache.close();
System.out.println("\nPlease press Enter in the HelloWorldConsumer.");
}
示例5: killClientWithCacheClose
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
* Kill the clients by closing the cache with keep-alive option as true
*/
public static void killClientWithCacheClose() {
if (DistributedSystemHelper.getDistributedSystem() != null) {
// close the cache and disconnect from the distributed system
Cache cache = CacheHelper.getCache();
// closing the cache with the keep-alive option true for the durable
// clients
cache.close(true);
//DistributedSystemHelper.getDistributedSystem().disconnect();
}
testInstance.initInstance();
}
示例6: testGatewayConflictResolver
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/** make sure we can create regions with concurrencyChecksEnabled=true */
public void testGatewayConflictResolver() throws CacheException {
CacheCreation cache = new CacheCreation();
cache.setGatewayConflictResolver(new ConflictResolver());
testXml(cache);
Cache c = getCache();
assertNotNull(c);
GatewayConflictResolver resolver = c.getGatewayConflictResolver();
assertNotNull(resolver);
assertTrue(resolver instanceof ConflictResolver);
assertTrue(((ConflictResolver)resolver).initialized);
c.close();
}
示例7: closeCache
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
* close the client cache
*
*/
public static void closeCache()
{
Cache cacheClient = GemFireCacheImpl.getInstance();
if (cacheClient != null && !cacheClient.isClosed()) {
cacheClient.close();
cacheClient.getDistributedSystem().disconnect();
}
}
示例8: closeCacheAsync
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
protected AsyncInvocation closeCacheAsync(VM vm0) {
SerializableRunnable close = new SerializableRunnable() {
public void run() {
Cache cache = getCache();
cache.close();
}
};
return vm0.invokeAsync(close);
}
示例9: testAsyncIndexUpdaterThreadShutdownForRR
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public void testAsyncIndexUpdaterThreadShutdownForRR() {
Cache cache = new CacheFactory().create();
RegionFactory rf = cache.createRegionFactory(RegionShortcut.REPLICATE);
rf.setIndexMaintenanceSynchronous(false);
Region localRegion = rf.create(name);
assertNotNull("Region ref null", localRegion);
try {
cache.getQueryService().createIndex("idIndex", "ID", "/"+name);
} catch (Exception e) {
cache.close();
e.printStackTrace();
fail("Index creation failed");
}
for (int i=0; i<500; i++) {
localRegion.put(i, new Portfolio(i));
}
GemFireCacheImpl internalCache = (GemFireCacheImpl)cache;
// Don't disconnect distributed system yet to keep system thread groups alive.
internalCache.close("Normal disconnect", null, false, false);
// Get Asynchronous index updater thread group from Distributed System.
ThreadGroup indexUpdaterThreadGroup = LogWriterImpl.getThreadGroup("QueryMonitor Thread Group");
assertEquals(0, indexUpdaterThreadGroup.activeCount());
internalCache.getSystem().disconnect();
}
示例10: closeCache
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
protected void closeCache(VM vm0) {
SerializableRunnable close = new SerializableRunnable("Close Cache") {
public void run() {
Cache cache = getCache();
cache.close();
}
};
vm0.invoke(close);
}
示例11: main
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
System.out.println("This example keeps the region size below 10 entries by destroying the ");
System.out.println("least recently used entry when an entry addition would take the count");
System.out.println("over 10.");
System.out.println();
System.out.println("You can set capacity limits based on entry count, absolute region size,");
System.out.println("or region size as a percentage of available heap.");
System.out.println("Connecting to the distributed system and creating the cache.");
// Create the cache which causes the cache-xml-file to be parsed
Cache cache = new CacheFactory()
.set("name", "DataEviction")
.set("cache-xml-file", "xml/DataEviction.xml")
.create();
// Get the exampleRegion
Region<String, String> exampleRegion = cache.getRegion("exampleRegion");
System.out.println("Example region, " + exampleRegion.getFullPath() + ", created in cache. ");
System.out.println("Putting 12 cache entries into the cache. The listener will report on");
System.out.println("the puts and on any destroys done by the eviction controller.");
for (long i = 1; i < 13; i++) {
exampleRegion.put("key" + i, "value" + i);
Thread.sleep(10);
}
// Close the cache and disconnect from GemFire distributed system
System.out.println("Closing the cache and disconnecting.");
cache.close();
}
示例12: closeCacheAsync
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
protected void closeCacheAsync(VM vm0) {
SerializableRunnable close = new SerializableRunnable() {
public void run() {
Cache cache = getCache();
cache.close();
}
};
vm0.invokeAsync(close);
}
示例13: recycleClientWithCacheClose
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
* Kill the clients by closing the cache with keep-alive option as true
* re-start and register interest with same interest policy as earlier
*/
public static void recycleClientWithCacheClose() {
if (DistributedSystemHelper.getDistributedSystem() != null) {
// close the cache and disconnect from the distributed system
Cache cache = CacheHelper.getCache();
// closing the cache with the keep-alive option true for the durable
// clients
cache.close(true);
//DistributedSystemHelper.getDistributedSystem().disconnect();
}
testInstance.initInstance();
((InterestPolicyTest)testInstance).renewSubscription();
}
示例14: closeCache
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
* Closes the cache if it exists and is open.
*/
public static synchronized void closeCache() {
Cache cache = getCache();
if (cache != null) {
log("Closing cache: " + cacheToString(cache));
cache.close();
log("Closed cache");
TheCacheConfig = null; // so the next create can have a different config
}
}
示例15: testUpdateVersionAfterCreate
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
* Tests for LocalRegion.
*/
public void testUpdateVersionAfterCreate() {
Cache cache = new CacheFactory().create();
Region region = cache.createRegionFactory(RegionShortcut.REPLICATE).create(regionName);
try {
region.create("key-1", "value-1");
Entry entry = region.getEntry("key-1");
assertTrue(entry instanceof NonTXEntry);
RegionEntry regionEntry = ((NonTXEntry)entry).getRegionEntry();
VersionStamp stamp = regionEntry.getVersionStamp();
// Create a duplicate entry version tag from stamp with newer time-stamp.
VersionTag tag = VersionTag.create(stamp.getMemberID());
int entryVersion = stamp.getEntryVersion();
VersionSource member = stamp.getMemberID();
int dsid = stamp.getDistributedSystemId();
long time = System.currentTimeMillis() + 1;
tag.setEntryVersion(entryVersion);
tag.setDistributedSystemId(dsid);
tag.setVersionTimeStamp(time);
tag.setIsGatewayTag(true);
assertTrue(region instanceof LocalRegion);
EntryEventImpl event = createNewEvent((LocalRegion)region, tag, entry.getKey());
((LocalRegion)region).basicUpdateEntryVersion(event);
// Verify the new stamp
entry = region.getEntry("key-1");
assertTrue(entry instanceof NonTXEntry);
regionEntry = ((NonTXEntry)entry).getRegionEntry();
stamp = regionEntry.getVersionStamp();
assertEquals(
"Time stamp did NOT get updated by UPDATE_VERSION operation on LocalRegion",
time, stamp.getVersionTimeStamp());
assertEquals(++entryVersion, stamp.getEntryVersion());
assertEquals(member, stamp.getMemberID());
assertEquals(dsid, stamp.getDistributedSystemId());
} finally {
region.destroyRegion();
cache.close();
}
}