boolean putIfAbsentResultHasSameValue(boolean isClient, Object valueToBePut, Object result) { if (Token.isInvalid(result) || result == null) { return valueToBePut == null; } boolean isCompressedOffHeap = isClient ? false : getAttributes().getOffHeap() && getAttributes().getCompressor() != null; return ValueComparisonHelper.checkEquals(valueToBePut, result, isCompressedOffHeap, getCache()); }
/** * @since GemFire 5.0 */ @Override public Object setValue(Object value) { return put(getKey(), value); } }
private TombstoneSweeper getSweeper(LocalRegion r) { if (r.getScope().isDistributed() && r.getServerProxy() == null && r.getDataPolicy().withReplication()) { return this.replicatedTombstoneSweeper; } else { return this.nonReplicatedTombstoneSweeper; } }
private boolean isPeerAccessor(LocalRegion region) { if (region.hasServerProxy()) { return false; } return !region.canStoreDataLocally(); }
protected RegionVersionVector createRegionVersionVector() { if (getConcurrencyChecksEnabled()) { return createVersionVector(); } return null; }
/** @return true if this was a client region; false if not */ @Override public boolean bridgeWriteBeforeDestroy(EntryEventImpl event, Object expectedOldValue) throws CacheWriterException, EntryNotFoundException, TimeoutException { if (hasServerProxy()) { serverDestroy(event, expectedOldValue); return true; } else { return false; } }
boolean retainResult) throws TimeoutException, CacheLoaderException { assert !retainResult || preferCD; validateKey(key); checkReadiness(); checkForNoAccess(); discoverJTA(); CachePerfStats stats = getCachePerfStats(); long start = stats.startGet(); boolean isMiss = true; try { KeyInfo keyInfo = getKeyInfo(key, aCallbackArgument); Object value = getDataView().getDeserializedValue(keyInfo, this, true, disableCopyOnRead, preferCD, clientEvent, returnTombstones, retainResult, true); final boolean isCreate = value == null; && ((getScope().isDistributed()) || hasServerProxy() || basicGetLoader() != null)) { value = getDataView().findObject(keyInfo, this, isCreate, generateCallbacks, value, disableCopyOnRead, preferCD, requestingClient, clientEvent, returnTombstones); if (!returnTombstones && value == Token.TOMBSTONE) { recordMiss(null, key);
/** * Handles both RR and PR cases */ @SuppressWarnings(value = "NP_NULL_PARAM_DEREF", justification = "Null value handled in sendNewRegisterInterestResponseChunk()") private static void handleKVSingleton(LocalRegion region, Object entryKey, boolean serializeValues, ServerConnection servConn) throws IOException { VersionedObjectList values = new VersionedObjectList(MAXIMUM_CHUNK_SIZE, true, region == null || region.getAttributes().getConcurrencyChecksEnabled(), serializeValues); if (region != null) { if (region.containsKey(entryKey) || region.containsTombstone(entryKey)) { VersionTagHolder versionHolder = createVersionTagHolder(); ClientProxyMembershipID id = servConn == null ? null : servConn.getProxyID(); // From Get70.getValueAndIsObject() Object data = region.get(entryKey, null, true, true, true, id, versionHolder, true); VersionTag vt = versionHolder.getVersionTag(); updateValues(values, entryKey, data, vt); } } // Send the last chunk (the only chunk for individual and list keys) // always send it back, even if the list is of zero size. sendNewRegisterInterestResponseChunk(region, entryKey, values, true, servConn); }
@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); }
private static LocalRegion createOwner(boolean withConcurrencyChecks) { LocalRegion owner = mock(LocalRegion.class); CachePerfStats cachePerfStats = mock(CachePerfStats.class); when(owner.getCachePerfStats()).thenReturn(cachePerfStats); when(owner.getEvictionAttributes()).thenReturn(evictionAttributes); when(owner.getConcurrencyChecksEnabled()).thenReturn(withConcurrencyChecks); when(owner.getDataPolicy()).thenReturn(DataPolicy.REPLICATE); doThrow(EntryNotFoundException.class).when(owner).checkEntryNotFound(any()); return owner; }
if (hasServerProxy()) { String queryString = constructRegionQueryString(predicate.trim()); results = getServerProxy().query(queryString, null); } catch (Exception e) { Throwable cause = e.getCause(); QueryService qs = getGemFireCache().getLocalQueryService(); String queryStr = constructRegionQueryString(predicate.trim()); DefaultQuery query = (DefaultQuery) qs.newQuery(queryStr); if (query.getRegionsInQuery(params).size() != 1) {
protected boolean withPersistence() { RegionAttributes ra = dataRegion.getAttributes(); DataPolicy dp = ra.getDataPolicy(); final boolean withPersistence = dp.withPersistence(); return withPersistence; }
/** obtain a lock to prevent concurrent clear() from happening */ public void lockForCacheModification(LocalRegion owner) { if (owner.getServerProxy() == null) { this.versionLock.readLock().lock(); } }
region = (LocalRegion) createRegion(name, attrs); region.create(key, value); Region.Entry entry = region.getEntry(key); assertEquals(value, entry.getValue()); region.getAttributesMutator().setRegionIdleTimeout( new ExpirationAttributes(12000/* ms */, ExpirationAction.INVALIDATE)); region.put(key, value); long tilt = System.currentTimeMillis(); ExpiryTask expiryTask = region.getRegionIdleExpiryTask(); long mediumExpiryTime = expiryTask.getExpirationTime(); region.getAttributesMutator().setRegionIdleTimeout( new ExpirationAttributes(999000/* ms */, ExpirationAction.INVALIDATE)); expiryTask = region.getRegionIdleExpiryTask(); long hugeExpiryTime = expiryTask.getExpirationTime(); ExpiryTask.suspendExpiration(); long shortExpiryTime; try { region.getAttributesMutator().setRegionIdleTimeout( new ExpirationAttributes(20/* ms */, ExpirationAction.INVALIDATE)); expiryTask = region.getRegionIdleExpiryTask(); shortExpiryTime = expiryTask.getExpirationTime(); } finally {
private void setupLocalRegion() { when(owner.getCachePerfStats()).thenReturn(cachePerfStats); when(owner.getCache()).thenReturn(mock(InternalCache.class)); when(owner.getMyId()).thenReturn(myId); when(owner.getKeyInfo(any(), any(), any())).thenReturn(keyInfo); }
@Test public void putIfAbsentResultHasSameValueReturnFalseIfResultDoesNotHaveSameValue() { Object result = "differentValue"; when(region.putIfAbsentResultHasSameValue(true, value, result)).thenCallRealMethod(); assertThat(region.putIfAbsentResultHasSameValue(true, value, result)).isFalse(); verify(region, never()).getAttributes(); }
if (!region.hasServerProxy()) { return; region.getServerProxy().removeListInterest((List) key, isDurable, receiveUpdatesAsInvalidates); } else { region.getServerProxy().removeSingleInterest(key, interestType, isDurable, receiveUpdatesAsInvalidates);
region == null || region.getAttributes().getConcurrencyChecksEnabled(), serializeValues); for (Object key : region.keySet(true)) { VersionTagHolder versionHolder = createVersionTagHolder(); if (keyPattern != null) { Object data = region.get(key, null, true, true, true, id, versionHolder, true); VersionTag versionTag = versionHolder.getVersionTag(); updateValues(values, key, data, versionTag);
/** * Determines whether the receiver is unexpired with regard to the given timeToLive and idleTime * attributes, which may different from this entry's actual attributes. Used for validation of * objects during netSearch(), which must validate remote entries against local timeout * attributes. */ boolean isExpiredWithRegardTo(Object key, int ttl, int idleTime) { if (!getAttributes().getStatisticsEnabled()) { return false; } long expTime; try { expTime = new NetSearchExpirationCalculator(this, key, ttl, idleTime).getExpirationTime(); } catch (EntryNotFoundException ignore) { return true; } return expTime != 0 && expTime <= cacheTimeMillis(); }
/** * Returns true if this region's config indicates that it will use a disk store. Added for bug * 42055. */ protected boolean usesDiskStore(RegionAttributes regionAttributes) { return !isProxy() && (getAttributes().getDataPolicy().withPersistence() || isOverflowEnabled()); }