本文整理汇总了Java中com.gemstone.gemfire.cache.Cache类的典型用法代码示例。如果您正苦于以下问题:Java Cache类的具体用法?Java Cache怎么用?Java Cache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Cache类属于com.gemstone.gemfire.cache包,在下文中一共展示了Cache类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testIsServing
import com.gemstone.gemfire.cache.Cache; //导入依赖的package包/类
@Test
public void testIsServing() {
final Cache mockCache = mockContext.mock(Cache.class, "Cache");
final CacheServer mockCacheServer = mockContext.mock(CacheServer.class, "CacheServer");
mockContext.checking(new Expectations() {{
oneOf(mockCache).getCacheServers();
will(returnValue(Collections.singletonList(mockCacheServer)));
}});
final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").build();
assertNotNull(serverLauncher);
assertEquals("serverOne", serverLauncher.getMemberName());
assertTrue(serverLauncher.isServing(mockCache));
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:17,代码来源:ServerLauncherJUnitTest.java
示例2: testPDXObject
import com.gemstone.gemfire.cache.Cache; //导入依赖的package包/类
public void testPDXObject() {
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);
Portfolio p = new Portfolio(2);
pf.writeInt("ID", 111);
pf.writeString("status", "active");
pf.writeString("secId", "IBM");
pf.writeObject("portfolio", p);
PdxInstance pi = pf.create();
TypedJson tJsonObj = new TypedJson(RESULT,pi);
System.out.println(tJsonObj);
cache.close();
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:19,代码来源:TypedJsonJUnitTest.java
示例3: getHARegionQueueInstance
import com.gemstone.gemfire.cache.Cache; //导入依赖的package包/类
/**
* Creates a HARegionQueue object with default attributes.
* used by tests
*
* @param regionName
* @param cache
* @param hrqa
* @param haRgnQType
* @param isDurable
* @return an instance of HARegionQueue
* @throws IOException
* @throws ClassNotFoundException
* @throws CacheException
* @throws InterruptedException
* @since 5.7
*/
public static HARegionQueue getHARegionQueueInstance(String regionName,
Cache cache, HARegionQueueAttributes hrqa, final int haRgnQType,
final boolean isDurable)
throws IOException, ClassNotFoundException, CacheException, InterruptedException
{
Map container = null;
if (haRgnQType == HARegionQueue.BLOCKING_HA_QUEUE) {
container = new HAContainerMap(new HashMap());
}
else {
// Should actually be HAContainerRegion, but ok if only JUnits using this
// method.
container = new HashMap();
}
return getHARegionQueueInstance(regionName, (GemFireCacheImpl)cache, hrqa, haRgnQType,
isDurable, container, null, HandShake.CONFLATION_DEFAULT, false, Boolean.FALSE);
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:35,代码来源:HARegionQueue.java
示例4: invokeRegionEntryPut
import com.gemstone.gemfire.cache.Cache; //导入依赖的package包/类
public static void invokeRegionEntryPut() {
int noOfEntity = conftab.intAt(RecyclePrms.numberOfEntitiesInRegion, 0);
Cache cache = CacheFactory.getInstance(DistributedSystemHelper.getDistributedSystem());
Object[] regionList = cache.rootRegions().toArray();
int numRegs = regionList.length;
for (int i = 0; i < numRegs; i++) {
Region reg = (Region)regionList[i];
if (!(reg instanceof HARegion)) {
Set keys = reg.keySet();
Iterator ite=keys.iterator();
for (int j = 0; ite.hasNext() && j < noOfEntity ; j++ ) {
Object key = ite.next();
reg.put(key,key);
}
}
}
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:21,代码来源:RegionEntryOperations.java
示例5: createPersistentRegionAsync
import com.gemstone.gemfire.cache.Cache; //导入依赖的package包/类
/**
* Creates a persistent region in async manner
*
* @param vm
* reference to VM
* @return reference to AsyncInvocation
*/
@SuppressWarnings("serial")
protected AsyncInvocation createPersistentRegionAsync(final VM vm) {
SerializableRunnable createRegion = new SerializableRunnable(
"Create persistent region") {
public void run() {
Cache cache = getCache();
DiskStoreFactory dsf = cache.createDiskStoreFactory();
File dir = getDiskDirForVM(vm);
dir.mkdirs();
dsf.setDiskDirs(new File[] { dir });
dsf.setMaxOplogSize(1);
dsf.setAllowForceCompaction(true);
dsf.setAutoCompact(false);
DiskStore ds = dsf.create(REGION_NAME);
RegionFactory rf = cache.createRegionFactory();
rf.setDiskStoreName(ds.getName());
rf.setDiskSynchronous(true);
rf.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
rf.setScope(Scope.DISTRIBUTED_ACK);
rf.create(REGION_NAME);
}
};
return vm.invokeAsync(createRegion);
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:32,代码来源:DiskManagementDUnitTest.java
示例6: testPersistenceExplicitDiskStore
import com.gemstone.gemfire.cache.Cache; //导入依赖的package包/类
public void testPersistenceExplicitDiskStore() throws Throwable {
SerializableCallable createRegion = new SerializableCallable() {
public Object call() throws Exception {
//Make sure the type registry is persistent
CacheFactory cf = new CacheFactory();
cf.setPdxPersistent(true);
cf.setPdxDiskStore("store1");
Cache cache = getCache(cf);
cache.createDiskStoreFactory()
.setMaxOplogSize(1)
.setDiskDirs(getDiskDirs())
.create("store1");
AttributesFactory af = new AttributesFactory();
af.setScope(Scope.DISTRIBUTED_ACK);
af.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
af.setDiskStoreName("store1");
createRootRegion("testSimplePdx", af.create());
return null;
}
};
persistenceTest(createRegion);
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:23,代码来源:PdxSerializableDUnitTest.java
示例7: testQueriesOnLocalRegion
import com.gemstone.gemfire.cache.Cache; //导入依赖的package包/类
/**
* Test on Local Region data
*/
public void testQueriesOnLocalRegion() {
Cache cache = CacheUtils.getCache();
createLocalRegion();
assertNotNull(cache.getRegion(regionName));
assertEquals(numElem * 2, cache.getRegion(regionName).size());
QueryService queryService = cache.getQueryService();
Query query1 = null;
try {
for (String queryStr : queries) {
query1 = queryService.newQuery(queryStr);
SelectResults result1 = (SelectResults) query1.execute();
assertEquals(queryStr, numElem * 2, result1.size());
verifyDistinctResults(result1);
}
} catch (Exception e) {
e.printStackTrace();
fail("Query " + query1 + " Execution Failed!");
}
// Destroy current Region for other tests
cache.getRegion(regionName).destroyRegion();
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:29,代码来源:DistinctResultsWithDupValuesInRegionTest.java
示例8: testMembershipPortRangeWithExactThreeValues
import com.gemstone.gemfire.cache.Cache; //导入依赖的package包/类
public void testMembershipPortRangeWithExactThreeValues() throws Exception {
Properties config = new Properties();
int mcastPort = AvailablePort.getRandomAvailablePort(AvailablePort.JGROUPS);
config.setProperty("mcast-port", String.valueOf(mcastPort));
config.setProperty("locators", "");
config.setProperty(DistributionConfig.MEMBERSHIP_PORT_RANGE_NAME, ""
+ (DistributionConfig.DEFAULT_MEMBERSHIP_PORT_RANGE[1] - 2) + "-"
+ (DistributionConfig.DEFAULT_MEMBERSHIP_PORT_RANGE[1]));
system = (InternalDistributedSystem)DistributedSystem.connect(config);
Cache cache = CacheFactory.create(system);
cache.addCacheServer();
DistributionManager dm = (DistributionManager) system.getDistributionManager();
InternalDistributedMember idm = dm.getDistributionManagerId();
system.disconnect();
assertTrue(idm.getPort() <= DistributionConfig.DEFAULT_MEMBERSHIP_PORT_RANGE[1]);
assertTrue(idm.getPort() >= DistributionConfig.DEFAULT_MEMBERSHIP_PORT_RANGE[0]);
assertTrue(idm.getDirectChannelPort() <= DistributionConfig.DEFAULT_MEMBERSHIP_PORT_RANGE[1]);
assertTrue(idm.getDirectChannelPort() >= DistributionConfig.DEFAULT_MEMBERSHIP_PORT_RANGE[0]);
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:20,代码来源:DistributedSystemTest.java
示例9: testIsDefaultServerEnabledWhenCacheServersExist
import com.gemstone.gemfire.cache.Cache; //导入依赖的package包/类
@Test
public void testIsDefaultServerEnabledWhenCacheServersExist() {
final Cache mockCache = mockContext.mock(Cache.class, "Cache");
final CacheServer mockCacheServer = mockContext.mock(CacheServer.class, "CacheServer");
mockContext.checking(new Expectations() {{
oneOf(mockCache).getCacheServers();
will(returnValue(Collections.singletonList(mockCacheServer)));
}});
final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").setDisableDefaultServer(false).build();
assertNotNull(serverLauncher);
assertEquals("serverOne", serverLauncher.getMemberName());
assertFalse(serverLauncher.isDisableDefaultServer());
assertFalse(serverLauncher.isDefaultServerEnabled(mockCache));
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:18,代码来源:ServerLauncherJUnitTest.java
示例10: testDefaultPartitionWhenNoConditionForDefaultExists
import com.gemstone.gemfire.cache.Cache; //导入依赖的package包/类
public void testDefaultPartitionWhenNoConditionForDefaultExists()
throws SQLException, StandardException {
Connection conn = getConnection();
Statement s = conn.createStatement();
s.execute("create schema EMP");
Cache cache = CacheFactory.getAnyInstance();
s
.execute("create table EMP.PARTITIONTESTTABLE (ID int, SECONDID int, THIRDID int)");
Region regtwo = cache.getRegion("/EMP/PARTITIONTESTTABLE");
RegionAttributes rattr = regtwo.getAttributes();
PartitionResolver pr = rattr.getPartitionAttributes()
.getPartitionResolver();
assertNotNull(pr);
GfxdPartitionByExpressionResolver scpr = (GfxdPartitionByExpressionResolver)pr;
assert(scpr.isDefaultPartitioning());
assertEquals(0, scpr.getColumnNames().length);
EntryOperationImpl dEntryOp = new EntryOperationImpl(null, null,
new Integer(10), null, null);
Serializable srobj = scpr.getRoutingObject(dEntryOp);
Integer robj = (Integer)srobj;
assertEquals(10, robj.intValue());
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:23,代码来源:DefaultPartitionTest.java
示例11: run2
import com.gemstone.gemfire.cache.Cache; //导入依赖的package包/类
public void run2() throws CacheException
{
Cache cache = getCache();
Region parentRegion = cache
.getRegion(Region.SEPARATOR + parentRegionName);
Region childRegion = null;
childRegion = parentRegion.createSubregion(childRegionName, parentRegion
.getAttributes());
PartitionedRegion pr = null;
pr = (PartitionedRegion)cache.getRegion(Region.SEPARATOR
+ parentRegionName + Region.SEPARATOR + childRegionName
+ Region.SEPARATOR + PR_PREFIX);
if (pr != null)
fail("PR strill exists");
pr = (PartitionedRegion)childRegion.createSubregion(PR_PREFIX,
createRegionAttributesForPR(1, 200));
// Assert.assertTrue(pr.getBucket2Node().size()==0, "B2N cleanup was not
// done");
assertEquals(0, pr.getRegionAdvisor().getCreatedBucketsCount());
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:23,代码来源:PartitionedRegionAsSubRegionDUnitTest.java
示例12: init
import com.gemstone.gemfire.cache.Cache; //导入依赖的package包/类
public void init(Principal principal,
DistributedMember remoteMember,
Cache cache) throws NotAuthorizedException {
if (principal != null) {
String name = principal.getName().toLowerCase();
if (name != null) {
if (name.equals("root") || name.equals("admin")
|| name.equals("administrator")) {
addReaderOps();
addWriterOps();
this.allowedOps.add(OperationCode.REGION_CREATE);
this.allowedOps.add(OperationCode.REGION_DESTROY);
}
else if (name.startsWith("writer")) {
addWriterOps();
}
else if (name.startsWith("reader")) {
addReaderOps();
}
}
}
this.remoteDistributedMember = remoteMember;
this.logger = cache.getSecurityLogger();
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:26,代码来源:DummyAuthorization.java
示例13: execute
import com.gemstone.gemfire.cache.Cache; //导入依赖的package包/类
public void execute(FunctionContext context) {
final String [] args = (String [])context.getArguments();
final String regionName = args[0];
final String importFileName = args[1];
try {
final Cache cache = CacheFactory.getAnyInstance();
final Region<?,?> region = cache.getRegion(regionName);
final String hostName = cache.getDistributedSystem().getDistributedMember().getHost();
if (region != null) {
RegionSnapshotService<?, ?> snapshotService = region.getSnapshotService();
File importFile = new File(importFileName);
snapshotService.load(new File(importFileName), SnapshotFormat.GEMFIRE);
String successMessage = CliStrings.format(CliStrings.IMPORT_DATA__SUCCESS__MESSAGE, importFile.getCanonicalPath(), hostName, regionName);
context.getResultSender().lastResult(successMessage);
} else {
throw new IllegalArgumentException(CliStrings.format(CliStrings.REGION_NOT_FOUND, regionName));
}
} catch (Exception e) {
context.getResultSender().sendException(e);
}
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:24,代码来源:ImportDataFunction.java
示例14: setupForGC
import com.gemstone.gemfire.cache.Cache; //导入依赖的package包/类
void setupForGC(){
final VM vm1 = Host.getHost(0).getVM(1);
final VM vm2 = Host.getHost(0).getVM(2);
createDefaultSetup(null);
vm1.invoke(new SerializableRunnable() {
public void run() {
// no need to close cache as it will be closed as part of teardown2
Cache cache = getCache();
RegionFactory<Integer, Integer> dataRegionFactory = cache
.createRegionFactory(RegionShortcut.PARTITION);
Region region = dataRegionFactory.create("testRegion");
for (int i = 0; i < 10; i++) {
region.put("key" + (i + 200), "value" + (i + 200));
}
}
});
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:21,代码来源:MiscellaneousCommandsDUnitTest.java
示例15: createRegion
import com.gemstone.gemfire.cache.Cache; //导入依赖的package包/类
private Region<Integer, MyObject> createRegion(final RegionType rt, final SerializationType st) throws Exception {
final String name = "snapshot-" + rt.name() + "-" + st.name();
Region<Integer, MyObject> region = getCache().getRegion(name);
if (region != null) {
region.destroyRegion();
}
SerializableCallable setup = new SerializableCallable() {
@Override
public Object call() throws Exception {
Cache cache = getCache();
new RegionGenerator().createRegion(cache, null, rt, name);
return null;
}
};
SnapshotDUnitTest.forEachVm(setup, true);
return getCache().getRegion(name);
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:20,代码来源:SnapshotPerformanceDUnitTest.java
示例16: execute
import com.gemstone.gemfire.cache.Cache; //导入依赖的package包/类
public Object execute(String command, String regionPath, Object arg) throws Exception
{
String memberId = (String)arg;
if (memberId != null) {
Cache cache = CacheFactory.getAnyInstance();
String thisMemberId = cache.getDistributedSystem().getDistributedMember().getId();
if (memberId.equals(thisMemberId) == false) {
return new GfshData(null);
}
}
try {
Runtime.getRuntime().gc(); //FindBugs - extremely dubious except in benchmarking code
} catch (Exception ex) {
code = AggregateResults.CODE_ERROR;
codeMessage = ex.getMessage();
}
return new GfshData(null);
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:22,代码来源:gc.java
示例17: verifyDeltaSizeFromStats
import com.gemstone.gemfire.cache.Cache; //导入依赖的package包/类
protected void verifyDeltaSizeFromStats(VM vm, final int expectedKeyNum,
final int expectedDeltaGIINum) {
SerializableRunnable verify = new SerializableRunnable() {
public void run() {
Cache cache = getCache();
// verify from CachePerfStats that certain amount of keys in delta
LocalRegion lr = (LocalRegion)getCache().getRegion(REGION_NAME);
CachePerfStats stats = lr.getRegionPerfStats();
// we saved GII completed count in RegionPerfStats only
int size = stats.getGetInitialImageKeysReceived();
cache.getLogger().info("Delta contains: "+ size +" keys");
assertEquals(expectedKeyNum, size);
int num = stats.getDeltaGetInitialImagesCompleted();
cache.getLogger().info("Delta GII completed: "+ num +" times");
assertEquals(expectedDeltaGIINum, num);
}
};
vm.invoke(verify);
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:22,代码来源:GIIDeltaDUnitTest.java
示例18: execute
import com.gemstone.gemfire.cache.Cache; //导入依赖的package包/类
public void execute(final FunctionContext context) {
try {
final Set<IndexDetails> indexDetailsSet = new HashSet<IndexDetails>();
final Cache cache = getCache();
final DistributedMember member = cache.getDistributedSystem().getDistributedMember();
for (final Index index : cache.getQueryService().getIndexes()) {
indexDetailsSet.add(new IndexDetails(member, index));
}
context.getResultSender().lastResult(indexDetailsSet);
}
catch (Exception e) {
context.getResultSender().sendException(e);
}
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:18,代码来源:ListIndexFunction.java
示例19: executeQuery
import com.gemstone.gemfire.cache.Cache; //导入依赖的package包/类
private void executeQuery(VM vm0) {
vm0.invoke(new SerializableRunnable() {
public void run() {
Cache cache = getCache();
Region region = cache.getRegion("region");
Query query = cache.getQueryService().newQuery("select * from /region r where r > 0");
try {
SelectResults results = (SelectResults) query.execute();
assertEquals(new HashSet(Arrays.asList(new Integer[] { 1, 2, 3 ,4, 5, 6, 7, 8, 9 })), results.asSet());
} catch (Exception e) {
fail("Bad query", e);
}
}
});
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:18,代码来源:PartitionedRegionQueryDUnitTest.java
示例20: diskStoreExists
import com.gemstone.gemfire.cache.Cache; //导入依赖的package包/类
private boolean diskStoreExists(Cache cache, String diskStoreName) {
ManagementService managementService = ManagementService.getExistingManagementService(cache);
DistributedSystemMXBean dsMXBean = managementService.getDistributedSystemMXBean();
Map<String, String[]> diskstore = dsMXBean.listMemberDiskstore();
Set<Entry<String, String[]>> entrySet = diskstore.entrySet();
for (Entry<String, String[]> entry : entrySet) {
String[] value = entry.getValue();
if (CliUtil.contains(value, diskStoreName)) {
return true;
}
}
return false;
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:17,代码来源:CreateAlterDestroyRegionCommands.java
注:本文中的com.gemstone.gemfire.cache.Cache类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论