private boolean areLocalBucketQueueRegionsPresent() { boolean bucketsAvailable = false; for (PartitionedRegion prQ : this.userRegionNameToshadowPRMap.values()) { if (prQ.getDataStore().getAllLocalBucketRegions().size() > 0) return true; } return false; }
public void run() { PartitionedRegion region = (PartitionedRegion) basicGetCache().getRegion(OrderPartitionedRegionName); MyResourceObserver observer = (MyResourceObserver) InternalResourceManager.getResourceObserver(); try { observer.waitForRegion(region, 60 * 1000); } catch (InterruptedException e) { throw new RuntimeException(e); } assertEquals(2, region.getDataStore().getAllLocalBucketIds().size()); assertEquals(2, region.getDataStore().getAllLocalPrimaryBucketIds().size()); } };
/** * Fetch the entries for the given bucket * @param bucketId the id of the bucket * @return a Map containing all the entries */ public BucketRegion handleRemoteGetEntries(int bucketId) throws ForceReattemptException { if (logger.isDebugEnabled()) { logger.debug("handleRemoteGetEntries: bucketId: {}{}{}", this.partitionedRegion.getPRId(), PartitionedRegion.BUCKET_ID_SEPARATOR, bucketId); } BucketRegion br = getInitializedBucketForId(null, Integer.valueOf(bucketId)); // NOTE: this is a test method that does not take a snapshot so it does not // give a stable set of entries if the bucket is moved during a rebalance return br; }
public Map<Integer, SizeEntry> getSizeForLocalPrimaryBuckets() { return getSizeLocallyForBuckets(getAllLocalPrimaryBucketIds()); }
public void run() throws CacheException { Cache cache = getCache(); PartitionedRegion partitionedregion = (PartitionedRegion) cache.getRegion(PR_PREFIX); PartitionedRegionDataStore dataStore = partitionedregion.getDataStore(); //there should only be 2 items in memory assertEquals(2 * oneItemSize, dataStore.currentAllocatedMemory()); //fault something else into memory and check again. partitionedregion.get(Long.valueOf(82 * totalNumBuckets)); assertEquals(2 * oneItemSize, dataStore.currentAllocatedMemory()); assertEquals(50 * oneItemSize, dataStore.getBucketSize(0)); } };
.getAllLocalBucketIds(); Map<Integer, SizeEntry> bucketSizes = null; if (pr.getDataStore() != null) { bucketSizes = pr.getDataStore().getSizeLocallyForBuckets( allBuckets); Map<Integer, SizeEntry> bucketSizes = null; if (pr.getDataStore() != null) { bucketSizes = pr.getDataStore().getSizeLocallyForBuckets( bucketIds); .getAllLocalPrimaryBucketIds());
@Override public Object peek() throws InterruptedException, CacheException { Object object = null; int bucketId = -1; PartitionedRegion prQ = getRandomShadowPR(); if (prQ != null && prQ.getDataStore().getAllLocalBucketRegions() .size() > 0 && ((bucketId = getRandomPrimaryBucket(prQ)) != -1)) { BucketRegionQueue brq; try { brq = ((BucketRegionQueue)prQ.getDataStore() .getInitializedBucketForId(null, bucketId)); object = brq.peek(); } catch (BucketRegionQueueUnavailableException e) { return object;//since this is not set, it would be null } catch (ForceReattemptException e) { if (logger.isDebugEnabled()) { logger.debug("Remove: Got ForceReattemptException for {} for bucke = {}", this, bucketId); } } } return object; // OFFHEAP: ok since only callers uses it to check for empty queue }
public Object call() throws Exception { Cache cache = getCache(); PartitionedRegion region = (PartitionedRegion) cache.getRegion(regionName); return new TreeSet<Integer>(region.getDataStore().getAllLocalBucketIds()); } };
public int getSizeOfLocalPrimaryBuckets() { int sizeOfLocalPrimaries = 0; Set<BucketRegion> primaryBuckets = getAllLocalPrimaryBucketRegions(); for (BucketRegion br : primaryBuckets) { sizeOfLocalPrimaries += br.size(); } return sizeOfLocalPrimaries; }
if (this.bucketIds != null) { if (estimate) { sizes = ds.getSizeEstimateLocallyForBuckets(this.bucketIds); } else { sizes = ds.getSizeLocallyForBuckets(this.bucketIds); sizes = ds.getSizeEstimateForLocalPrimaryBuckets(); } else { sizes = ds.getSizeForLocalBuckets();
public static void checkStartingBucketIDs_Nodeup() { assertEquals( region_FPR.getDataStore().getAllLocalPrimaryBucketIds().size() % 3, 0); }
public BucketRegion getLocalBucketByKey(Object key) { Integer bucketId = Integer.valueOf(PartitionedRegionHelper.getHashKey(this.partitionedRegion, null, key, null, null)); return getLocalBucketById(bucketId); }
ServerConnection servConn, int transactionID){ if (!areAllBucketsHosted(bucketSet)) { throw new BucketMovedException( LocalizedStrings.FunctionService_BUCKET_MIGRATED_TO_ANOTHER_NODE
public Object call() { PartitionedRegion pr = (PartitionedRegion) getCache().getRegion(regionPath[0]); PartitionedRegionDataStore ds = pr.getDataStore(); if (ds == null) { return new Integer(0); } else { return new Integer(ds.getBucketsManaged()); } } })).intValue();
List<Integer> list = new ArrayList<Integer>(); list.addAll(buckets); bucketSizes = this.dataStore.getSizeLocallyForBuckets(list); bucketSizes = this.dataStore.getSizeForLocalBuckets();
PartitionedRegionDataStore dataStore = partitionedregion.getDataStore(); partitionedregion.put(Integer.valueOf(0), new byte[100]); long oneItemSize = dataStore.getBucketSize(0); for(int i = 1; i < 100; i++) { partitionedregion.put(Integer.valueOf(i * totalNumBuckets), new byte[100]); assertEquals(1, dataStore.getBucketsManaged()); assertEquals(100 * oneItemSize, dataStore.getBucketSize(0)); assertEquals(50 * oneItemSize, dataStore.getBucketSize(0)); assertEquals(50 * oneItemSize, dataStore.getBucketSize(0));
public void run() { Cache cache = getCache(); PartitionedRegion partitionedregion = (PartitionedRegion) cache.getRegion(PR_PREFIX); long bytes = partitionedregion.getDataStore().currentAllocatedMemory(); assertEquals(0, bytes); } });
private void initialize(PartitionedRegion region) { setNumberOfEntries(region.size()); // If there is a data store (meaning that the PR has storage // in this VM), get the number of entries and heap size. Else, // set these to 0. PartitionedRegionDataStore ds = region.getDataStore(); int numLocalEntries = 0; long heapSize = 0; if (ds != null) { CachePerfStats cpStats = ds.getCachePerfStats(); numLocalEntries = (int) cpStats.getEntries(); heapSize = ds.currentAllocatedMemory(); } setNumberOfLocalEntries(numLocalEntries); setHeapSize(heapSize); }
final int localBSize = pr.getDataStore().getBucketsManaged(); getLogWriter().info( "validateBucketsDistribution() - Number of bukctes for " localBSize >= noBucketsExpectedOnEachNode); pr.getDataStore().visitBuckets(new BucketVisitor() { public void visit(Integer bucketId, Region r)
/** * This method iterates over localBucket2RegionMap and returns collective size * of the primary bucket regions. * * @return the map of bucketIds and their associated sizes, or * {@link Collections#EMPTY_MAP}when the size is zero */ public Map<Integer, SizeEntry> getSizeForLocalBuckets() { return getSizeLocallyForBuckets(this.localBucket2RegionMap.keySet()); }