/** * 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 Object getLocalValueInVM(final Object key, int bucketId) { try { BucketRegion br = getInitializedBucketForId(key, Integer.valueOf(bucketId)); return br.getValueInVM(key); } catch (ForceReattemptException e) { e.checkKey(key); return null; } }
public Object getLocalValueOnDiskOrBuffer(final Object key, int bucketId) { try { BucketRegion br = getInitializedBucketForId(key, Integer.valueOf(bucketId)); return br.getValueOnDiskOrBuffer(key); } catch (ForceReattemptException e) { e.checkKey(key); return null; } }
public Object getLocalValueOnDiskOrBuffer(final Object key, int bucketId) { try { BucketRegion br = getInitializedBucketForId(key, Integer.valueOf(bucketId)); return br.getValueOnDiskOrBuffer(key); } catch (ForceReattemptException e) { e.checkKey(key); return null; } }
public Object getLocalValueInVM(final Object key, int bucketId) { try { BucketRegion br = getInitializedBucketForId(key, Integer.valueOf(bucketId)); return br.getValueInVM(key); } catch (ForceReattemptException e) { e.checkKey(key); return null; } }
/** * This method is intended for testing purposes only. * DO NOT use in product code. */ public Object getLocalValueOnDisk(final Object key, int bucketId) { try { BucketRegion br = getInitializedBucketForId(key, Integer.valueOf(bucketId)); return br.getValueOnDisk(key); } catch (ForceReattemptException e) { e.checkKey(key); return null; } }
/** * This method is intended for testing purposes only. * DO NOT use in product code. */ public Object getLocalValueOnDisk(final Object key, int bucketId) { try { BucketRegion br = getInitializedBucketForId(key, Integer.valueOf(bucketId)); return br.getValueOnDisk(key); } catch (ForceReattemptException e) { e.checkKey(key); return null; } }
/** * Fetch a BucketRegion, but do not return until it is initialized * and the primary is known. * @see #getInitializedBucketForId(Object, Integer) * @param key * @param bucketId * @return the initialized region * @throws ForceReattemptException */ public BucketRegion getInitializedBucketWithKnownPrimaryForId(Object key, Integer bucketId) throws ForceReattemptException { final BucketRegion br = getInitializedBucketForId(key, bucketId); br.getBucketAdvisor().getPrimary();// waits until the primary is initialized return br; }
/** * Fetch a BucketRegion, but do not return until it is initialized * and the primary is known. * @see #getInitializedBucketForId(Object, Integer) * @param key * @param bucketId * @return the initialized region * @throws ForceReattemptException */ public BucketRegion getInitializedBucketWithKnownPrimaryForId(Object key, Integer bucketId) throws ForceReattemptException { final BucketRegion br = getInitializedBucketForId(key, bucketId); br.getBucketAdvisor().getPrimary();// waits until the primary is initialized return br; }
/** * 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; }
private Map<Integer, SizeEntry> getSizeLocallyForPrimary(Collection<Integer> bucketIds, boolean estimate) { Map<Integer, SizeEntry> mySizeMap; if (this.localBucket2RegionMap.isEmpty()) { return Collections.emptyMap(); } mySizeMap = new HashMap<Integer, SizeEntry>(this.localBucket2RegionMap.size()); BucketRegion r = null; for(Integer bucketId : bucketIds) { try { r = getInitializedBucketForId(null, bucketId); mySizeMap.put(bucketId, new SizeEntry(estimate ? r.sizeEstimate() : r.size(), r.getBucketAdvisor().isPrimary())); // if (getLogWriter().fineEnabled() && r.getBucketAdvisor().isPrimary()) { // r.verifyTombstoneCount(); // } } catch (PrimaryBucketException skip) { // sizeEstimate() will throw this exception as it will not try to read from HDFS on a secondary bucket, // this bucket will be retried in PartitionedRegion.getSizeForHDFS() fixes bug 49033 continue; } catch (ForceReattemptException skip) { continue; } catch(RegionDestroyedException skip) { continue; } } // while return mySizeMap; }
@Override public void run2() throws CacheException { PartitionedRegion pr = (PartitionedRegion)getCache().getRegion(prName); Integer bucketId = new Integer(PartitionedRegionHelper.getHashKey(pr, null, buk0Key1, null, null)); try { BucketRegion buk0 = pr.getDataStore().getInitializedBucketForId(buk0Key1, bucketId); assertNotNull(buk0); assertTrue(buk0.getBucketAdvisor().isPrimary()); } catch (ForceReattemptException e) { getLogWriter().severe(e); fail(); } } });
public void updateEntryVersionLocally(Integer bucketId, EntryEventImpl event) throws ForceReattemptException { if (logger.isDebugEnabled()) { logger.debug("updateEntryVersionLocally: bucketId={}{}{} for key={}", this.partitionedRegion.getPRId(), PartitionedRegion.BUCKET_ID_SEPARATOR, bucketId, 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); } } }
@Override public void run2() throws CacheException { PartitionedRegion pr = (PartitionedRegion)getCache().getRegion(prName); Integer bucketId = new Integer(PartitionedRegionHelper.getHashKey(pr, null, buk0Key1, null, null)); try { BucketRegion buk0 = pr.getDataStore().getInitializedBucketForId(buk0Key1, bucketId); assertNotNull(buk0); assertFalse(buk0.getBucketAdvisor().isPrimary()); } catch (ForceReattemptException e) { getLogWriter().severe(e); fail(); } } };
@Override public void run2() throws CacheException { PartitionedRegion pr = (PartitionedRegion)getCache().getRegion(prName); Integer bucketId = new Integer(PartitionedRegionHelper.getHashKey(pr, null, buk0Key1, null, null)); try { BucketRegion buk0 = pr.getDataStore().getInitializedBucketForId(buk0Key1, bucketId); assertNotNull(buk0); Entry k1e = buk0.getEntry(buk0Key1); assertNotNull(k1e); } catch (ForceReattemptException e) { getLogWriter().severe(e); fail(); } } };
public HDFSBucketRegionQueue getBucketRegionQueue(PartitionedRegion region, int bucketId) throws ForceReattemptException { PartitionedRegion leader = ColocationHelper.getLeaderRegion(region); if (leader == null) return null; String leaderregionPath = leader.getFullPath(); PartitionedRegion prQ = this.userRegionNameToshadowPRMap.get(leaderregionPath); if (prQ == null) return null; HDFSBucketRegionQueue brq; brq = ((HDFSBucketRegionQueue)prQ.getDataStore() .getLocalBucketById(bucketId)); if(brq == null) { prQ.getRegionAdvisor().waitForLocalBucketStorage(bucketId); } brq = ((HDFSBucketRegionQueue)prQ.getDataStore() .getInitializedBucketForId(null, bucketId)); return brq; }
public HDFSBucketRegionQueue getBucketRegionQueue(PartitionedRegion region, int bucketId) throws ForceReattemptException { PartitionedRegion leader = ColocationHelper.getLeaderRegion(region); if (leader == null) return null; String leaderregionPath = leader.getFullPath(); PartitionedRegion prQ = this.userRegionNameToshadowPRMap.get(leaderregionPath); if (prQ == null) return null; HDFSBucketRegionQueue brq; brq = ((HDFSBucketRegionQueue)prQ.getDataStore() .getLocalBucketById(bucketId)); if(brq == null) { prQ.getRegionAdvisor().waitForLocalBucketStorage(bucketId); } brq = ((HDFSBucketRegionQueue)prQ.getDataStore() .getInitializedBucketForId(null, bucketId)); return brq; }
@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.warningEnabled()) { logger.fine("remove: " + "Got ForceReattemptException for " + this + " for bucket = " + bucketId); } } } return object; // OFFHEAP: ok since only callers uses it to check for empty queue }
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); } } }
@SuppressWarnings("unchecked") private boolean hasAdjunctRecipientsNeedingDelta(EntryEventImpl event) { PartitionedRegion pr = ((PartitionedRegion)this); BucketRegion br = null; FilterRoutingInfo filterRouting = null; Set twoMessages = Collections.EMPTY_SET; Set adjunctRecipients = Collections.EMPTY_SET; Set cacheservers = null; int bId = event.getKeyInfo().getBucketId(); try { br = pr.dataStore.getInitializedBucketForId(event.getKey(), bId); } catch (ForceReattemptException fre) { return true; } Set<InternalDistributedMember> recipients = br.getCacheDistributionAdvisor().adviseUpdate(event); twoMessages = br.getBucketAdvisor().adviseRequiresTwoMessages(); CacheDistributionAdvisor cda = pr.getCacheDistributionAdvisor(); filterRouting = cda.adviseFilterRouting(event, recipients); adjunctRecipients = br.getAdjunctReceivers(event, recipients, twoMessages, filterRouting); cacheservers = cda.adviseCacheServers(); return !Collections.disjoint(adjunctRecipients, cacheservers); }