本文整理汇总了Java中com.gemstone.gemfire.cache.Cache.getRegion方法的典型用法代码示例。如果您正苦于以下问题:Java Cache.getRegion方法的具体用法?Java Cache.getRegion怎么用?Java Cache.getRegion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.gemstone.gemfire.cache.Cache
的用法示例。
在下文中一共展示了Cache.getRegion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDefaultColocate_39857
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public void testDefaultColocate_39857() throws SQLException,
StandardException {
Connection conn = getConnection();
Statement s = conn.createStatement();
Cache cache = CacheFactory.getAnyInstance();
s.execute("create table EMP.TESTTABLE1 (ID1 int primary key,"
+ "DESCRIPTION1 varchar(1024), ADDRESS1 varchar(1024))");
s.execute("create table EMP.TESTTABLE2 (ID2 int primary key, "
+ "DESCRIPTION2 varchar(1024), ADDRESS2 varchar(1024)) "
+ "partition by primary key colocate with (EMP.TESTTABLE1)");
Region regtwo = cache.getRegion("/EMP/TESTTABLE2");
RegionAttributes rattr = regtwo.getAttributes();
PartitionResolver pr = rattr.getPartitionAttributes()
.getPartitionResolver();
assertNotNull(pr);
GfxdPartitionByExpressionResolver cpr = (GfxdPartitionByExpressionResolver)pr;
assertNotNull(cpr);
int numofcolumns = cpr.getColumnNames().length;
assertEquals(1, numofcolumns);
assertEquals("ID2", cpr.getColumnNames()[0]);
String masterTable = cpr.getMasterTable(false /* immediate master*/);
assertEquals("/EMP/TESTTABLE1", masterTable);
}
示例2: getCacheSerializableRunnableForPRPutsKeyValue
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
* This function puts portfolio objects into the created Region (PR or Local) *
*
* @param regionName
* @param portfolio
* @param to
* @param from
* @return cacheSerializable object
*/
public CacheSerializableRunnable getCacheSerializableRunnableForPRPutsKeyValue(
final String regionName, final Object[] portfolio, final int from,
final int to)
{
SerializableRunnable prPuts = new CacheSerializableRunnable("PRPuts") {
public void run2() throws CacheException
{
Cache cache = getCache();
Region region = cache.getRegion(regionName);
for (int j = from; j < to; j++)
region.put(new Portfolio(j), portfolio[j]);
// getLogWriter()
// .info(
// "PRQueryDUnitHelper#getCacheSerializableRunnableForPRPuts: Inserted Portfolio data on Region "
// + regionName);
}
};
return (CacheSerializableRunnable)prPuts;
}
示例3: 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();
}
示例4: doPutForLocalMaxMemory
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private CacheSerializableRunnable doPutForLocalMaxMemory(
final String regionName, final String key) throws Exception
{
CacheSerializableRunnable putForLocalMaxMemory = new CacheSerializableRunnable(
"putForLocalMaxMemory") {
public void run2()
{
final int MAX_SIZE = 1024;
Cache cache = getCache();
byte Obj[] = new byte[MAX_SIZE];
Arrays.fill(Obj, (byte)'A');
PartitionedRegion pr = (PartitionedRegion)cache
.getRegion(Region.SEPARATOR + regionName);
for (int i = 0; i < MAX_SIZE * 2; i++) {
pr.put(key + i, Obj);
getLogWriter().info("MAXSIZE : " + i);
}
getLogWriter().info("Put successfully done for vm" + key);
}
};
return putForLocalMaxMemory;
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:24,代码来源:PartitionedRegionBucketCreationDistributionDUnitTest.java
示例5: getBucketList
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
protected List<Integer> getBucketList(String tableName) {
Cache cache = CacheHelper.getCache();
for (PartitionRegionInfo pri :
PartitionRegionHelper.getPartitionRegionInfo(cache)) {
String regionPath = pri.getRegionPath();
if (regionPath.contains(tableName)) {
Log.getLogWriter().info("Region path is " + regionPath);
PartitionedRegion pr = (PartitionedRegion)cache.getRegion(regionPath);
Log.getLogWriter().info("Region name is " + pr.getName());
PartitionedRegionDataStore dataStore = pr.getDataStore();
List<Integer> bids = (List<Integer>)pr.getLocalBucketsListTestOnly();
for (Integer bid : bids) {
Log.getLogWriter().info(pr.getName() + ": size of bucket[" + bid
+ "]=" + dataStore.getBucketSize(bid));
}
return bids;
}
}
return null;
}
示例6: getCacheSerializableRunnableForPRInvalidQuery
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
* This function <br>
* 1. Creates & executes a query with Logical Operators on the given PR Region
* 2. Executes the same query on the local region <br>
* 3. Compares the appropriate resultSet <br>
*
* @param regionName
*
*
* @return cacheSerializable object
*/
public CacheSerializableRunnable getCacheSerializableRunnableForPRInvalidQuery(
final String regionName, final String invalidQuery)
{
SerializableRunnable PrRegion = new CacheSerializableRunnable("PRQuery") {
@Override
public void run2() throws CacheException
{
Cache cache = getCache();
// Querying the PR region with an Invalid query string
String query = "INVALID QUERY";
Region region = cache.getRegion(regionName);
try {
region.query(query);
fail("PRQueryDUnitHelper#getCacheSerializableRunnableForPRInvalidQuery: InvalidQueryException expected");
}
catch (QueryInvalidException e) {
// pass
}
catch (QueryException qe) {
getLogWriter()
.error(
"PRQueryDUnitHelper#getCacheSerializableRunnableForPRInvalidQuery: Caught another Exception while querying , Exception is "
+ qe, qe);
fail("PRQueryDUnitHelper#getCacheSerializableRunnableForPRInvalidQuery: Caught another Exception while querying , Exception is "
+ qe);
}
}
};
return (CacheSerializableRunnable)PrRegion;
}
示例7: clearAllRegions
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
protected void clearAllRegions() {
// get the list of test regions (written to the BB by Hydratask_initialize/createHierRegions
Set<String> testRegions = (Set<String>)(RecoveryBB.getBB().getSharedMap().get(allRegionNamesKey));
Cache theCache = CacheHelper.getCache();
for (String regionName: testRegions) {
Region aRegion = theCache.getRegion(regionName);
if (aRegion == null) {
throw new TestException("Region " + regionName + " could not be found in cache");
}
aRegion.clear();
Log.getLogWriter().info("Successfully cleared " + regionName);
}
}
示例8: checkBucketEventTracker
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private SerializableRunnable checkBucketEventTracker(VM vm, final int bucketNumber, final int expectedEntryCount) {
SerializableRunnable checkEventTracker = new SerializableRunnable("checkEventTracker") {
public void run() {
Cache cache = getCache();
PartitionedRegion region = (PartitionedRegion) cache.getRegion("partitioned");
BucketRegion br = region.getBucketRegion(bucketNumber);
checkEventTracker(br, expectedEntryCount);
}
};
vm.invoke(checkEventTracker);
return checkEventTracker;
}
示例9: doEntryOps
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
* Do 2 puts, 1 invalidate and 1 destroy for a key "key-1"
*/
public static void doEntryOps()
{
try {
getLogWriter().info("Putting entries...");
Cache cacheClient = GemFireCacheImpl.getInstance();
Region r1 = cacheClient.getRegion(Region.SEPARATOR +REGION_NAME1);
Region r2 = cacheClient.getRegion(Region.SEPARATOR +REGION_NAME2);
Region r3 = cacheClient.getRegion(Region.SEPARATOR +REGION_NAME3);
r1.put("key-1", "11");
r2.put("key-1", "11");
r3.put("key-1", "11");
r1.put("key-1", "22");
r2.put("key-1", "22");
r3.put("key-1", "22");
r1.invalidate("key-1");
r2.invalidate("key-1");
r3.invalidate("key-1");
r1.destroy("key-1");
r2.destroy("key-1");
r3.destroy("key-1");
}
catch (Exception ex) {
ex.printStackTrace();
fail("failed while region doing ops", ex);
}
}
示例10: destroyRegion1
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public static void destroyRegion1()
{
try {
Cache cache = new BridgeWriterMiscDUnitTest("temp").getCache();
Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME1);
assertNotNull(r1);
r1.destroyRegion();
}
catch (Exception e) {
e.printStackTrace();
fail("Test failed due to Exception during closeBothRegions", e);
}
}
示例11: testDefaultConnectionPool
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public void testDefaultConnectionPool() throws CacheException {
getSystem();
CacheCreation cache = new CacheCreation();
PoolFactory f = cache.createPoolFactory();
f.addLocator(ALIAS2, 3777);
f.create("mypool");
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setPoolName("mypool");
cache.createVMRegion("rootNORMAL", attrs);
testXml(cache);
Cache c = getCache();
assertNotNull(c);
Region r = c.getRegion("rootNORMAL");
assertNotNull(r);
assertEquals("mypool", r.getAttributes().getPoolName());
Pool cp = PoolManager.find("mypool");
assertNotNull(cp);
assertEquals(1, cp.getLocators().size());
assertEquals(0, cp.getServers().size());
assertEquals(createINSA(ALIAS2, 3777), cp.getLocators().get(0));
assertEquals(PoolFactory.DEFAULT_FREE_CONNECTION_TIMEOUT, cp.getFreeConnectionTimeout());
assertEquals(PoolFactory.DEFAULT_LOAD_CONDITIONING_INTERVAL, cp.getLoadConditioningInterval());
assertEquals(PoolFactory.DEFAULT_SOCKET_BUFFER_SIZE, cp.getSocketBufferSize());
assertEquals(PoolFactory.DEFAULT_THREAD_LOCAL_CONNECTIONS, cp.getThreadLocalConnections());
assertEquals(PoolFactory.DEFAULT_READ_TIMEOUT, cp.getReadTimeout());
assertEquals(PoolFactory.DEFAULT_MIN_CONNECTIONS, cp.getMinConnections());
assertEquals(PoolFactory.DEFAULT_MAX_CONNECTIONS, cp.getMaxConnections());
assertEquals(PoolFactory.DEFAULT_RETRY_ATTEMPTS, cp.getRetryAttempts());
assertEquals(PoolFactory.DEFAULT_IDLE_TIMEOUT, cp.getIdleTimeout());
assertEquals(PoolFactory.DEFAULT_PING_INTERVAL, cp.getPingInterval());
assertEquals(PoolFactory.DEFAULT_STATISTIC_INTERVAL, cp.getStatisticInterval());
assertEquals(PoolFactory.DEFAULT_SERVER_GROUP, cp.getServerGroup());
assertEquals(PoolFactory.DEFAULT_SUBSCRIPTION_ENABLED, cp.getSubscriptionEnabled());
assertEquals(PoolFactory.DEFAULT_SUBSCRIPTION_REDUNDANCY, cp.getSubscriptionRedundancy());
assertEquals(PoolFactory.DEFAULT_SUBSCRIPTION_MESSAGE_TRACKING_TIMEOUT, cp.getSubscriptionMessageTrackingTimeout());
assertEquals(PoolFactory.DEFAULT_SUBSCRIPTION_ACK_INTERVAL, cp.getSubscriptionAckInterval());
}
示例12: getAllRegionPathList
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
* Returns a sorted list of all region full paths found in the specified
* cache.
* @param cache The cache to search.
* @return Returns a sorted list of all region paths defined in the
* distributed system.
*/
public static List getAllRegionPathList(Cache cache, boolean recursive)
{
ArrayList list = new ArrayList();
if (cache == null) {
return list;
}
// get a list of all root regions
Set regions = cache.rootRegions();
Iterator itor = regions.iterator();
while (itor.hasNext()) {
String regionPath = ((Region)itor.next()).getFullPath();
Region region = cache.getRegion(regionPath);
list.add(regionPath);
Set subregionSet = region.subregions(true);
if (recursive) {
for (Iterator subIter = subregionSet.iterator(); subIter.hasNext(); ){
list.add(((Region)subIter.next()).getFullPath());
}
}
}
Collections.sort(list);
return list;
}
示例13: testCreateTable
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public void testCreateTable() throws SQLException, StandardException {
// Create a schema
Connection conn = getConnection();
Statement s = conn.createStatement();
s.execute("create schema EMP");
// Get the cache;
Cache cache = CacheFactory.getAnyInstance();
// Check for PARTITION BY COLUMN
s.execute("create table EMP.PARTITIONTESTTABLE (ID int not null, "
+ " SECONDID int not null, THIRDID int not null, primary key (ID, SECONDID))"
+ " PARTITION BY COLUMN (ID)");
Region regtwo = cache.getRegion("/EMP/PARTITIONTESTTABLE");
RegionAttributes rattr = regtwo.getAttributes();
PartitionResolver pr = rattr.getPartitionAttributes()
.getPartitionResolver();
assertNotNull(pr);
GfxdPartitionByExpressionResolver scpr = (GfxdPartitionByExpressionResolver)pr;
assertNotNull(scpr);
assertTrue(scpr.columnsSubsetOfPrimary());
assertEquals(1, scpr.getColumnNames().length);
assertEquals("ID", scpr.getColumnNames()[0]);
}
示例14: size_s
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private void size_s(String command) throws Exception
{
LinkedList list = new LinkedList();
gfsh.parseCommand(command, list);
String regionPath;
if (list.size() == 2) {
regionPath = gfsh.getCurrentPath();
} else {
regionPath = (String) list.get(2);
}
regionPath = regionPath.trim();
if (regionPath.equals("/")) {
gfsh.println("Error: Invalid path. Root path not allowed.");
return;
}
regionPath = gfsh.getFullPath(regionPath, gfsh.getCurrentPath());
gfsh.println(" Region: " + regionPath);
// Local region
Cache cache = gfsh.getCache();
Region region = cache.getRegion(regionPath);
if (region == null) {
gfsh.println("Error: region undefine - " + regionPath);
} else {
gfsh.println(" Local region size: " + region.size());
}
// Server region
CommandResults results = gfsh.getCommandClient().execute(new RegionSizeTask(regionPath));
Object obj = results.getDataObject();
if (obj == null) {
gfsh.println("Error: Unable to get size from the server - " + results.getCodeMessage());
} else {
ArrayList sizeList = new ArrayList(2);
sizeList.add(results.getDataObject());
PrintUtil.printMappableList(sizeList);
}
}
示例15: populateRegions
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
static void populateRegions(int regionId, long startRow, long endRow,
String regionName, String csvFilePath) throws IOException {
Cache cache = CacheHelper.getCache();
Region<Object, Object> region = cache.getRegion(regionName);
Region<Object, Object> region_noIndex = cache.getRegion(regionName
+ "_noIndex");
BufferedReader reader = new BufferedReader(new FileReader(csvFilePath));
String line = reader.readLine(); // skip column names
int i = 0;
while (i != startRow && (line = reader.readLine()) != null) {
i++;
}
while ((line = reader.readLine()) != null && i <= endRow) {
i++;
String[] split = line.split("\t");
switch (regionId) {
case COMMUNITY:
UUID id = UUID.fromString(split[0]);
String description = split[1];
String name = split[2];
int ordinal = Integer.parseInt(split[3]);
String ownerId = split[4];
String communityType = split[5];
region.put(id, new CommunityImpl(id, name, ownerId, communityType,
description, ordinal));
region_noIndex.put(id, new CommunityImpl(id, name, ownerId,
communityType, description, ordinal));
break;
case LOGIN_COMMUNITY:
id = UUID.fromString(split[0]);
UUID communityId = UUID.fromString(split[1]);
String loginId = split[2];
region.put(id, new LoginCommunityAssignmentImpl(id, communityId,
loginId));
region_noIndex.put(id, new LoginCommunityAssignmentImpl(id,
communityId, loginId));
break;
case BRANCH_COMMUNITY:
id = UUID.fromString(split[0]);
String branchId = split[1];
communityId = UUID.fromString(split[2]);
region.put(id, new BranchCommunityAssignmentImpl(id, branchId,
communityId));
region_noIndex.put(id, new BranchCommunityAssignmentImpl(id,
branchId, communityId));
break;
default:
break;
}
}
}