@Override public void visit(Integer bucketId, Region r) { buf.append("bucketId: " + partitionedRegion.bucketStringForLogs(bucketId.intValue()) + " bucketName: " + r.toString() + "\n"); } });
@Override public void visit(Integer bucketId, Region r) { buf.append("bucketId: ").append(partitionedRegion.bucketStringForLogs(bucketId.intValue())).append(" bucketName: ").append(r).append("\n"); } });
static protected void checkBucketMetadataCleanup(final PartitionedRegion pr, final InternalDistributedMember memberId) { Iterator itr = pr.getRegionAdvisor().getBucketSet().iterator(); try { while (itr.hasNext()) { final Integer bucketId = (Integer)itr.next(); assertTrue("CLeanup did not remove member from bucket meta-data, member=" + memberId + " from bucket=" + pr.bucketStringForLogs(bucketId.intValue()), !pr.getRegionAdvisor() .getBucketOwners(bucketId.intValue()).contains(memberId)); } } catch (NoSuchElementException done) { } } }
public void run2() throws CacheException { getCache(); Map prIDmap = PartitionedRegion.prIdToPR; Iterator itr = prIDmap.values().iterator(); while (itr.hasNext()) { Object o = itr.next(); if (o == PartitionedRegion.PRIdMap.DESTROYED) { continue; } PartitionedRegion prRegion = (PartitionedRegion) o; Iterator bukI = prRegion.getRegionAdvisor().getBucketSet().iterator(); while(bukI.hasNext()) { Integer bucketId = (Integer) bukI.next(); Set bucketOwners = prRegion.getRegionAdvisor().getBucketOwners(bucketId.intValue()); if (bucketOwners.contains(dsMember)) { fail("Failed DistributedMember's = " + dsMember + " bucket [" + prRegion.bucketStringForLogs(bucketId.intValue()) + "] meta-data not cleared for partitioned region " + prRegion); } } } } };
/** * 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 (this.logger.fineEnabled()) { this.logger.fine("handleRemoteGetEntries: bucketId: " + this.partitionedRegion.bucketStringForLogs(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; }
/** * Iterates over all buckets and marks them sick if the given member hosts the * bucket. * @param member * @param sick true if the bucket should be marked sick, false if healthy */ public void markBucketsOnMember(DistributedMember member, boolean sick){ //The health profile exchange at cache level should take care of preInitQueue if (buckets==null) { return; } for(int i=0; i<buckets.length; i++){ if (sick && !this.buckets[i].getBucketOwners().contains(member)) { continue; } this.buckets[i].setBucketSick(member, sick); if (logger.isDebugEnabled()) { logger.debug("Marked bucket ({}) {}", getPartitionedRegion().bucketStringForLogs(i), (this.buckets[i].isBucketSick() ? "sick" : "healthy")); } } }
/** * Fetch a BucketRegion, but do not return until it is initialized * @param key optional for error reporting; if none, no key available. * @param bucketId the bucket to fetch * @return the region * @throws ForceReattemptException */ public BucketRegion getInitializedBucketForId(Object key, Integer bucketId) throws ForceReattemptException { final BucketRegion bucketRegion = this.localBucket2RegionMap.get(bucketId); if (null == bucketRegion) { this.partitionedRegion.checkReadiness(); if (this.logger.fineEnabled()) { this.logger.fine("Got null bucket region for bucketId=" + partitionedRegion.bucketStringForLogs(bucketId.intValue()) + " for PartitionedRegion = " + this.partitionedRegion); } ForceReattemptException fre = new BucketNotFoundException(LocalizedStrings.PartitionedRegionDataStore_BUCKET_ID_0_NOT_FOUND_ON_VM_1.toLocalizedString(new Object[] {this.partitionedRegion.bucketStringForLogs(bucketId.intValue()), this.partitionedRegion.getMyId()})); if (key != null) { fre.setHash(key.hashCode()); } throw fre; } bucketRegion.waitForData(); return bucketRegion; }
/** * Fetch a BucketRegion, but do not return until it is initialized * @param key optional for error reporting; if none, no key available. * @param bucketId the bucket to fetch * @return the region * @throws ForceReattemptException */ public BucketRegion getInitializedBucketForId(Object key, Integer bucketId) throws ForceReattemptException { final BucketRegion bucketRegion = this.localBucket2RegionMap.get(bucketId); if (null == bucketRegion) { this.partitionedRegion.checkReadiness(); if (logger.isDebugEnabled()) { logger.debug("Got null bucket region for bucketId={}{}{} for PartitionedRegion = {}", this.partitionedRegion.getPRId(), PartitionedRegion.BUCKET_ID_SEPARATOR, bucketId, this.partitionedRegion); } ForceReattemptException fre = new BucketNotFoundException(LocalizedStrings.PartitionedRegionDataStore_BUCKET_ID_0_NOT_FOUND_ON_VM_1.toLocalizedString(new Object[] {this.partitionedRegion.bucketStringForLogs(bucketId.intValue()), this.partitionedRegion.getMyId()})); if (key != null) { fre.setHash(key.hashCode()); } throw fre; } bucketRegion.waitForData(); return bucketRegion; }
public void updateBucketStatus(int bucketId, DistributedMember member, boolean profileRemoved) { if (profileRemoved) { this.buckets[bucketId].setBucketSick(member, false); //getClientBucketProfiles(bucketId).remove(); } else { ResourceAdvisor advisor = getPartitionedRegion(). getCache().getResourceAdvisor(); boolean sick = advisor.adviseCritialMembers().contains(member); if (logger.isDebugEnabled()) { logger.debug("updateBucketStatus:({}):member:{}:sick:{}", getPartitionedRegion().bucketStringForLogs(bucketId), member, sick); } this.buckets[bucketId].setBucketSick(member, sick); } }
/** * Logs the b2n nodelist for specified bucketId. * * @param bId */ public void dumpB2NForBucket(int bId) { getRegionAdvisor().getBucket(bId).getBucketAdvisor().dumpProfiles( "Dumping advisor bucket meta-data for bId=" + bucketStringForLogs(bId) + " aka " + getBucketName(bId)); }
/** * @throws ForceReattemptException if it detects that the given bucket moved * @throws RegionDestroyedException if the given pr was destroyed */ private static void checkForBucketMoved(Integer bId, BucketRegion br, PartitionedRegion pr) throws ForceReattemptException, RegionDestroyedException { if (br.isBucketDestroyed()) { // see if the pr is destroyed if (pr.isLocallyDestroyed || pr.isClosed) { throw new RegionDestroyedException("PR destroyed during query", pr.getFullPath()); } pr.checkReadiness(); throw new ForceReattemptException("Bucket id " + pr.bucketStringForLogs(bId.intValue()) + " not found on VM " + pr.getMyId()); } }
/** * @throws ForceReattemptException if it detects that the given bucket moved * @throws RegionDestroyedException if the given pr was destroyed */ private static void checkForBucketMoved(Integer bId, BucketRegion br, PartitionedRegion pr) throws ForceReattemptException, RegionDestroyedException { if (br.isBucketDestroyed()) { // see if the pr is destroyed if (pr.isLocallyDestroyed || pr.isClosed) { throw new RegionDestroyedException("PR destroyed during query", pr.getFullPath()); } pr.checkReadiness(); throw new ForceReattemptException("Bucket id " + pr.bucketStringForLogs(bId.intValue()) + " not found on VM " + pr.getMyId()); } }
/** * throws LowMemoryException if the given bucket is hosted on a member * which has crossed the ResourceManager threshold. * @param bucketId * @param key for bucketId used in exception * @throws LowMemoryException */ public void checkIfBucketSick(final int bucketId, final Object key) throws LowMemoryException{ if (MemoryThresholds.isLowMemoryExceptionDisabled()) { return; } assert this.buckets != null; assert this.buckets[bucketId] != null; if (this.buckets[bucketId].isBucketSick()) { Set<DistributedMember> sm = this.buckets[bucketId].getSickMembers(); if (sm.isEmpty()) { // check again as this list is obtained under synchronization // fixes bug 50845 return; } if (logger.isDebugEnabled()) { logger.debug("For bucket {} sick members are ", getPartitionedRegion().bucketStringForLogs(bucketId), sm); } throw new LowMemoryException(LocalizedStrings.ResourceManager_LOW_MEMORY_PR_0_KEY_1_MEMBERS_2.toLocalizedString( new Object[] {getPartitionedRegion().getFullPath(), key, sm}), sm); } }
/** * Logs the b2n nodelist for specified bucketId. * * @param bId */ public void dumpB2NForBucket(int bId) { //StringBuffer b = new StringBuffer(); // DEBUG // b.append("\n").append("Dumping allPR.." + // dumpAllPartitionedRegions()).append("\n"); getRegionAdvisor().getBucket(bId).getBucketAdvisor().dumpProfiles( logger, "Dumping advisor bucket meta-data for bId=" + bucketStringForLogs(bId) + " aka " + getBucketName(bId)); //logger.fine(b.toString()); }
if (this.logger.fineEnabled()) { this.logger.fine("Got null bucket region for bucketId=" + partitionedRegion.bucketStringForLogs(bucketId) + " for PartitionedRegion = " + this.partitionedRegion); LocalizedStrings.PartitionedRegionDataStore_BUCKET_ID_0_NOT_FOUND_ON_VM_1 .toLocalizedString(new Object[] { this.partitionedRegion.bucketStringForLogs(bucketId), this.partitionedRegion.getMyId() })); if (key != null) {
/** * Iterates over all buckets and marks them sick if the given member hosts the * bucket. * @param member * @param sick true if the bucket should be marked sick, false if healthy */ public void markBucketsOnMember(DistributedMember member, boolean sick){ //The health profile exchange at cache level should take care of preInitQueue if (buckets==null) { return; } for(int i=0; i<buckets.length; i++){ if (sick && !this.buckets[i].getBucketOwners().contains(member)) { continue; } this.buckets[i].setBucketSick(member, sick); if(getLogWriter().fineEnabled()){ getLogWriter().fine("Marked bucket ("+getPartitionedRegion() .bucketStringForLogs(i)+") "+(this.buckets[i].isBucketSick() ? "sick":"healthy")); } } }
public void updateEntryVersionLocally(Integer bucketId, EntryEventImpl event) throws ForceReattemptException { if (this.logger.fineEnabled()) { this.logger.fine("updateEntryVersionLocally: bucketId=" + this.partitionedRegion.bucketStringForLogs(bucketId.intValue()) + " for key=" + event.getKey()); } final BucketRegion bucketRegion = getInitializedBucketForId(event.getKey(), bucketId); try { event.setRegion(bucketRegion); bucketRegion.basicUpdateEntryVersion(event); // bug 34361: don't send a reply if bucket was destroyed during the op bucketRegion.checkReadiness(); } catch(RegionDestroyedException rde){ checkRegionDestroyedOnBucket(bucketRegion, event.isOriginRemote(), rde); } } }
public void updateBucketStatus(int bucketId, DistributedMember member, boolean profileRemoved) { if (profileRemoved) { this.buckets[bucketId].setBucketSick(member, false); //getClientBucketProfiles(bucketId).remove(); } else { ResourceAdvisor advisor = getPartitionedRegion(). getCache().getResourceAdvisor(); boolean sick = advisor.adviseCriticalMembers().contains(member); if (getLogWriter().fineEnabled()) { getLogWriter().fine("updateBucketStatus:("+getPartitionedRegion() .bucketStringForLogs(bucketId)+"):member:"+member+":sick:"+sick); } this.buckets[bucketId].setBucketSick(member, sick); } }
/** * throws LowMemoryException if the given bucket is hosted on a member * which has crossed the ResourceManager threshold. * @param bucketId * @param key for bucketId used in exception * @throws LowMemoryException */ public void checkIfBucketSick(final int bucketId, final Object key) throws LowMemoryException{ if (MemoryThresholds.isLowMemoryExceptionDisabled()) { return; } assert this.buckets != null; assert this.buckets[bucketId] != null; if (this.buckets[bucketId].isBucketSick()) { Set<DistributedMember> sm = this.buckets[bucketId].getSickMembers(); if (sm.isEmpty()) { // check again as this list is obtained under synchronization // fixes bug 50845 return; } if (getLogWriter().fineEnabled()) { getLogWriter().fine("For bucket "+getPartitionedRegion().bucketStringForLogs(bucketId)+ " sick members are "+ sm); } throw new LowMemoryException(LocalizedStrings.ResourceManager_LOW_MEMORY_PR_0_KEY_1_MEMBERS_2.toLocalizedString( new Object[] {getPartitionedRegion().getFullPath(), key, sm}), sm); } }
+ partitionedRegion.bucketStringForLogs(bucketId) + " region " + bucketRegion.getName());