/** * 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 RegionMap#size */ public int entryCount() { return getDataView().entryCount(this); }
public void performPutAllEntry(EntryEventImpl event) { getDataView().putEntry(event, false, false, null, false, 0L, false); }
/** * Allows null as new value to accomodate create with a null value. Assumes all key, value, and * callback validations have been performed. * * @param event the event object for this operation, with the exception that the oldValue * parameter is not yet filled in. The oldValue will be filled in by this operation. * * @param ifNew true if this operation must not overwrite an existing key * @param ifOld true if this operation must not create a new key * @param expectedOldValue only succeed if old value is equal to this value. If null, then doesn't * matter what old value is. If INVALID token, must be INVALID. * @param requireOldValue true if the oldValue should be set in event even if ifNew and entry * exists * @return false if ifNew is true and there is an existing key or if ifOld is true and * expectedOldValue does not match the current value in the cache. Otherwise return true. */ @Override public boolean basicPut(EntryEventImpl event, boolean ifNew, boolean ifOld, Object expectedOldValue, boolean requireOldValue) throws TimeoutException, CacheWriterException { return getDataView().putEntry(event, ifNew, ifOld, expectedOldValue, requireOldValue, 0L, false); }
/** * @param rememberRead true if read should be remembered in a transaction * @since GemFire 5.5 */ private Object basicGetValueInVM(Object key, boolean rememberRead) throws EntryNotFoundException { return getDataView().getValueInVM(getKeyInfo(key), this, rememberRead); }
@Override void basicClear(RegionEventImpl regionEvent) { getDataView().checkSupportsRegionClear(); basicClear(regionEvent, true); }
@Override void basicLocalClear(RegionEventImpl rEvent) { getDataView().checkSupportsRegionClear(); cmnClearRegion(rEvent, false/* cacheWrite */, false/* useRVV */); }
protected int entryCount(Set<Integer> buckets, boolean estimate) { assert buckets == null : "unexpected buckets " + buckets + " for region " + toString(); return getDataView().entryCount(this); }
/** internally we often need to get an entry whether it is a tombstone or not */ public Region.Entry getEntry(Object key, boolean allowTombstones) { return getDataView().getEntry(getKeyInfo(key), this, allowTombstones); }
@Override public boolean containsValueForKey(Object key) { discoverJTA(); return getDataView().containsValueForKey(getKeyInfo(key), this); }
@Override public boolean containsKey(Object key) { checkReadiness(); checkForNoAccess(); return getDataView().containsKey(getKeyInfo(key), this); }
@Override public void localDestroyRegion(Object aCallbackArgument) { getDataView().checkSupportsRegionDestroy(); RegionEventImpl event = new RegionEventImpl(this, Operation.REGION_LOCAL_DESTROY, aCallbackArgument, false, getMyId(), generateEventID()/* generate EventID */); try { basicDestroyRegion(event, false); } catch (CacheWriterException e) { // not possible with local operation, CacheWriter not called throw new Error( "CacheWriterException should not be thrown in localDestroyRegion", e); } catch (TimeoutException e) { // not possible with local operation, no distributed locks possible throw new Error( "TimeoutException should not be thrown in localDestroyRegion", e); } }
/** * Just like getEntry but also updates the stats that get would have depending on a flag. See bug * 42410. Also skips discovering JTA * * @return the entry if it exists; otherwise null. */ public Entry accessEntry(Object key, boolean updateStats) { validateKey(key); checkReadiness(); checkForNoAccess(); if (updateStats) { return getDataView().accessEntry(getKeyInfo(key), this); } else { return getDataView().getEntry(getKeyInfo(key), this, false); } }
@Before public void setup() { region = mock(LocalRegion.class); event = mock(EntryEventImpl.class); eventID = mock(EventID.class); serverRegionProxy = mock(ServerRegionProxy.class); cancelCriterion = mock(CancelCriterion.class); exception = mock(PutAllPartialResultException.class); when(event.getEventId()).thenReturn(eventID); when(event.getCallbackArgument()).thenReturn(callbacks); when(region.hasServerProxy()).thenReturn(true); when(region.getServerProxy()).thenReturn(serverRegionProxy); when(region.getRegionMap()).thenReturn(mock(RegionMap.class)); when(region.getDataView()).thenReturn(mock(InternalDataView.class)); when(region.getCancelCriterion()).thenReturn(cancelCriterion); when(exception.getFailure()).thenReturn(cacheClosedException); when(cancelCriterion.generateCancelledException(cacheClosedException)) .thenReturn(cacheClosedException); }
@Override public Region.Entry getEntry(Object key) { validateKey(key); checkReadiness(); checkForNoAccess(); discoverJTA(); return getDataView().getEntry(getKeyInfo(key), this, false); }
@Override public void localInvalidateRegion(Object aCallbackArgument) { getDataView().checkSupportsRegionInvalidate(); checkReadiness(); checkForNoAccess(); RegionEventImpl event = new RegionEventImpl(this, Operation.REGION_LOCAL_INVALIDATE, aCallbackArgument, false, getMyId()); basicInvalidateRegion(event); }
@Override public boolean containsTombstone(Object key) { checkReadiness(); checkForNoAccess(); if (!this.getConcurrencyChecksEnabled()) { return false; } else { try { Entry entry = getDataView().getEntry(getKeyInfo(key), this, true); return entry != null && entry.getValue() == Token.TOMBSTONE; } catch (EntryDestroyedException ignore) { return true; } } }
@Override public void invalidateRegion(Object aCallbackArgument) throws TimeoutException { getDataView().checkSupportsRegionInvalidate(); checkReadiness(); checkForLimitedOrNoAccess(); RegionEventImpl event = new RegionEventImpl(this, Operation.REGION_INVALIDATE, aCallbackArgument, false, getMyId(), generateEventID()); basicInvalidateRegion(event); }
@Override public void destroyRegion(Object aCallbackArgument) throws CacheWriterException, TimeoutException { this.cache.invokeBeforeDestroyed(this); getDataView().checkSupportsRegionDestroy(); checkForLimitedOrNoAccess(); RegionEventImpl event = new RegionEventImpl(this, Operation.REGION_DESTROY, aCallbackArgument, false, getMyId(), generateEventID()); basicDestroyRegion(event, true); }
void basicUpdateEntryVersion(EntryEventImpl event) throws EntryNotFoundException { if (hasSeenEvent(event)) { if (logger.isTraceEnabled(LogMarker.DM_VERBOSE)) { logger.trace(LogMarker.DM_VERBOSE, "LR.basicDestroy: this cache has already seen this event {}", event); } if (this.getConcurrencyChecksEnabled() && event.getVersionTag() != null && !event.getVersionTag().isRecorded()) { getVersionVector().recordVersion((InternalDistributedMember) event.getDistributedMember(), event.getVersionTag()); } return; } getDataView().updateEntryVersion(event); }
Object validatedPut(EntryEventImpl event, long startPut) throws TimeoutException, CacheWriterException { if (event.getEventId() == null && generateEventID()) { event.setNewEventId(this.cache.getDistributedSystem()); } Object oldValue = null; if (basicPut(event, false, // ifNew false, // ifOld null, // expectedOldValue false // requireOldValue )) { if (!event.isOldValueOffHeap()) { // don't copy it to heap just to return from put. // TODO: come up with a better way to do this. oldValue = event.getOldValue(); } if (!getDataView().isDeferredStats()) { getCachePerfStats().endPut(startPut, false); } } return handleNotAvailable(oldValue); }