/** * returns an estimate of the number of entries in this region. This method * should be prefered over size() for hdfs regions where an accurate size is * not needed. This method is not supported on a client * * @return the estimated size of this region */ public int sizeEstimate() { boolean isClient = this.imageState.isClient(); if (isClient) { throw new UnsupportedOperationException( "Method not supported on a client"); } return entryCount(null, true); }
/** * returns an estimate of the number of entries in this region. This method * should be prefered over size() for hdfs regions where an accurate size is * not needed. This method is not supported on a client * * @return the estimated size of this region */ public int sizeEstimate() { boolean isClient = this.imageState.isClient(); if (isClient) { throw new UnsupportedOperationException( "Method not supported on a client"); } return entryCount(discoverJTA(), null, true); }
private int getRegionSizeNoLock(boolean includeHDFSResults) { int result = getRegionMap().size(); // if this is a client with no tombstones then we subtract the number // of entries being affected by register-interest refresh if (this.imageState.isClient() && !this.concurrencyChecksEnabled) { result -= this.imageState.getDestroyedEntriesCount(); } if (includeHDFSResults) { return result; } else { return result - this.tombstoneCount.get(); } }
private void unlockRIReadLock() { assert getImageState().isClient(); getImageState().readUnlockRI(); }
/** * Callers of this method should always follow the call with: if (lockRIReadLock()) { * try { } finally { unlockRIReadLock(); } } * * @return true if lock obtained and unlock needs to be called */ private boolean lockRIReadLock() { if (getImageState().isClient()) { getImageState().readLockRI(); return true; } else { return false; } }
private void unlockRIReadLock() { assert getImageState().isClient(); getImageState().readUnlockRI(); }
/** * Callers of this method should always follow the call with: if (lockRIReadLock()) { * try { } finally { unlockRIReadLock(); } } * * @return true if lock obtained and unlock needs to be called */ private boolean lockRIReadLock() { if (getImageState().isClient()) { getImageState().readLockRI(); return true; } else { return false; } }
/** * @return size after considering imageState */ protected int getRegionSize() { synchronized(getSizeGuard()) { int result = getRegionMap().size(); // if this is a client with no tombstones then we subtract the number // of entries being affected by register-interest refresh if (this.imageState.isClient() && !this.concurrencyChecksEnabled) { return result - this.imageState.getDestroyedEntriesCount(); } if (includeHDFSResults()) { return result; } return result - this.tombstoneCount.get(); } }
protected boolean nonTXContainsKey(KeyInfo keyInfo) { boolean contains = getRegionMap().containsKey(keyInfo.getKey()); if (contains && this.imageState.isClient()) { // fix for bug #40871 - concurrent RI causes containsKey for destroyed entry // to return true RegionEntry re = this.entries.getEntry(keyInfo.getKey()); // TODO:KIRK:OK if (re == null || Token.isRemoved(re.getValueInVM(this))) { if (re == null || re.isDestroyedOrRemoved()) { contains = false; } } return contains; }
/** * (description copied from entryCount() Returns the number of entries in this * region. Note that because of the concurrency properties of the * {@link RegionMap}, the number of entries is only an approximate. That is, * other threads may change the number of entries in this region while this * method is being invoked. * * @see LocalRegion#entryCount() */ public int size() { checkReadiness(); checkForNoAccess(); final TXStateInterface tx = discoverJTA(); boolean isClient = this.imageState.isClient(); if (isClient) { lockRIReadLock(); // bug #40871 - test sees wrong size for region during RI } try { return entryCount(tx); } finally { if (isClient) { unlockRIReadLock(); } } }
/** * (description copied from entryCount() Returns the number of entries in this * region. Note that because of the concurrency properties of the * {@link RegionMap}, the number of entries is only an approximate. That is, * other threads may change the number of entries in this region while this * method is being invoked. * * @see LocalRegion#entryCount() */ public int size() { checkReadiness(); checkForNoAccess(); discoverJTA(); boolean isClient = this.imageState.isClient(); if (isClient) { lockRIReadLock(); // bug #40871 - test sees wrong size for region during RI } try { return entryCount(); } finally { if (isClient) { unlockRIReadLock(); } } }