/** * Returns a random region from the cache. * * @param cache * @return Region */ public static Region getRandomRegion(Cache cache) { return (Region) cache.rootRegions().iterator().next(); }
public static void performGet() throws Exception { Set roots = cache.rootRegions(); if ( roots.isEmpty() || roots.size() != 1 ) { throw new Exception( "expected one root." ); } Object[] rootsArray = roots.toArray(); reg = (Region) rootsArray[0]; }
public static void performGet() throws Exception { Set roots = cache.rootRegions(); if ( roots.isEmpty() || roots.size() != 1 ) { throw new Exception( "expected one root." ); } Object[] rootsArray = roots.toArray(); reg = (Region) rootsArray[0]; for( int i = 0; i < 50; i++ ) { reg.get( "key" + i ); } }
/** Return a Set of all regions (and any subregions) existing in this member * * @return Set of all regions (and any subregions) existing in this member */ private static Set<Region<?, ?>> getAllRegions() { Set<Region<?, ?>> regionSet = new HashSet(CacheHelper.getCache().rootRegions()); Set<Region<?, ?>> rootRegions = new HashSet(regionSet); for (Region aRegion: rootRegions) { regionSet.addAll(aRegion.subregions(true)); } return regionSet; }
public List<ApplicationStat> getStats() { List<ApplicationStat> res = new ArrayList(); Set<Region<?, ?>> regions = cache.rootRegions(); for (Region<?, ?> region : regions) { res.add(getStat(region)); for (Region<?, ?> subRegion : region.subregions(true)) { res.add(getStat(subRegion)); } } return res; }
/** * Create a region hierarchy -- we need dozens of regions */ public synchronized static void createRegionHierarchyTask() { Cache c = CacheUtil.createCache(); if (c.rootRegions().size() <= 0) { testInstance.createRegionHierarchy(); } }
public static void putDataMultiTask() { Set regions = CacheHelper.getCache().rootRegions(); Log.getLogWriter().info("Putting data in regions: " + regions); for (int i = 0; i < 10000; i++) { for (Iterator it = regions.iterator(); it.hasNext();) { Region region = (Region)it.next(); region.put(new Integer(i), new Integer(i)); } } }
protected void populateRegions() { Cache myCache = CacheHelper.getCache(); Set regions = myCache.rootRegions(); for (Iterator iter = regions.iterator(); iter.hasNext();) { Region aRegion = (Region)iter.next(); Log.getLogWriter().info("Putting " + ENTRIES_TO_PUT + " entries into " + aRegion.getFullPath()); for (int i = 1; i <= ENTRIES_TO_PUT; i++) { aRegion.put("" + System.currentTimeMillis(), new Integer(i)); } } }
protected void dumpLocalKeys() { StringBuffer aStr = new StringBuffer(); DistributedMember dm = DistributedSystemHelper.getDistributedSystem().getDistributedMember(); aStr.append("Keys local to " + dm.toString() + " by region\n"); Set rootRegions = CacheHelper.getCache().rootRegions(); for (Iterator it = rootRegions.iterator(); it.hasNext(); ) { Region aRegion = (Region)it.next(); Region localRegion = PartitionRegionHelper.getLocalData(aRegion); aStr.append(" " + aRegion.getName() + ": " + localRegion.keySet() + "\n"); } Log.getLogWriter().info(aStr.toString()); }
public void checkCQ() { CQUtil.displaySelectResults(); Set regions = CacheHelper.getCache().rootRegions(); StringBuffer aStr = new StringBuffer("rootRegions = \n"); for (Iterator iter = regions.iterator(); iter.hasNext();) { Region aRegion = (Region)iter.next(); aStr.append(" " + aRegion.getFullPath() + " named " + aRegion.getName() + "\n"); } Log.getLogWriter().info(aStr.toString()); }
public static void invokeCacheMiss() { 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)) { int keysize = reg.keySet().size(); for (int j = 0; j < keysize; j++) reg.get("notexist" + j); } } }
private void logRegions() { Cache theCache = CacheHelper.getCache(); Set<Region<?, ?>> rootRegions = theCache.rootRegions(); StringBuffer aStr = new StringBuffer(); for (Region aRegion : rootRegions) { aStr.append(aRegion.getFullPath() + ":\n"); for (Object key : aRegion.keySet()) { aStr.append(" " + key + " " + aRegion.get(key) + "\n"); } } Log.getLogWriter().info(aStr.toString()); }
@Override public void run2() throws CacheException { Set<Region<?, ?>> rootRegions = getCache().rootRegions(); if (rootRegions != null) { for (Region<?, ?> region : rootRegions) { region.clear(); } } disconnectFromDS(); } });
/** * Selects and returns a random rootRegion */ protected Region getRandomRootRegion() { Set rootRegions = CacheHelper.getCache().rootRegions(); Log.getLogWriter().fine("getRandomRootRegion found " + rootRegions); int randInt = TestConfig.tab().getRandGen().nextInt(0, rootRegions.size() - 1); Object[] regionList = rootRegions.toArray(); Region rootRegion = (Region)regionList[randInt]; return (rootRegion); }
private void verifyPRs() { Set<Region<?, ?>> rootRegions = CacheHelper.getCache().rootRegions(); Set<Region> regionSet = new HashSet(rootRegions); for (Region aRegion: rootRegions) { regionSet.addAll(aRegion.subregions(true)); } for (Region aRegion: regionSet) { if (aRegion.getAttributes().getDataPolicy().withPartitioning()) { verifyPR(aRegion); } } }
public static void HydraTask_doOperations() { Operations ops = new Operations(); ops.initializeOperationsClient(); Cache theCache = CacheHelper.getCache(); if (theCache == null) { // can happen during HA return; } Set<Region<?, ?>> rootRegions = theCache.rootRegions(); for (Region aRegion: rootRegions) { ops.doEntryOperations(aRegion); } }
/** Log the local size of the PR data store */ public synchronized static void HydraTask_logLocalSize() { Cache myCache = CacheHelper.getCache(); Set<Region<?,?>> rootRegions = myCache.rootRegions(); for (Region aRegion : rootRegions) { if (aRegion instanceof PartitionedRegion) { Log.getLogWriter().info("Number of entries in this dataStore for region" + aRegion.getName() + " : " + ParRegUtil.getLocalSize(aRegion)); } } }
/** Log the size of each root region * */ private static void logRegionSizes() { for (Region aRegion: CacheHelper.getCache().rootRegions()) { Log.getLogWriter().info("Region " + aRegion.getFullPath() + " is size " + aRegion.size()); } }
/** Add new entries to all root regions until the region has a size of at * least REGION_SIZE. */ public static void HydraTask_populateRegions() { for (Region aRegion: CacheHelper.getCache().rootRegions()) { while (aRegion.size() < REGION_SIZE) { Object key = NameFactory.getNextPositiveObjectName(); Object value = NameFactory.getCounterForName(key); aRegion.put(key, value); } } logRegionSizes(); }
protected void assignBuckets() throws InterruptedException { Cache c = CacheHelper.getCache(); if (c != null) { for (Region r : c.rootRegions()) { Log.getLogWriter().info("Creating buckets for region " + r.getName()); CachePerfClientVersion.assignBucketsToPartitions(r); Log.getLogWriter().info("Created buckets for region " + r.getName()); } } }