protected boolean withPersistence() { RegionAttributes ra = dataRegion.getAttributes(); DataPolicy dp = ra.getDataPolicy(); final boolean withPersistence = dp.withPersistence(); return withPersistence; }
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()); }
/** * This implementation only checks readiness and scope */ @Override public Lock getRegionDistributedLock() throws IllegalStateException { checkReadiness(); checkForLimitedOrNoAccess(); Scope theScope = getAttributes().getScope(); Assert.assertTrue(theScope == Scope.LOCAL); throw new IllegalStateException( "Only supported for GLOBAL scope, not LOCAL"); }
@Before public void setup() { when(region.getAttributes()).thenReturn(mock(RegionAttributes.class)); index = new PrimaryKeyIndex(null, null, region, null, null, null, null, null, null, null); }
/************** Public Methods ************************/ Object doNetSearch() throws TimeoutException { resetResults(); RegionAttributes attrs = region.getAttributes(); this.requestInProgress = true; Scope scope = attrs.getScope(); Assert.assertTrue(scope != Scope.LOCAL); netSearchForBlob(); this.requestInProgress = false; return this.result; }
boolean bridgePutIfAbsentResultHasSameValue(byte[] valueToBePut, boolean isValueToBePutObject, Object result) { if (Token.isInvalid(result) || result == null) { return valueToBePut == null; } boolean isCompressedOffHeap = getAttributes().getOffHeap() && getAttributes().getCompressor() != null; if (isValueToBePutObject) { return ValueComparisonHelper.checkEquals(EntryEventImpl.deserialize(valueToBePut), result, isCompressedOffHeap, getCache()); } return ValueComparisonHelper.checkEquals(valueToBePut, result, isCompressedOffHeap, getCache()); }
/** * 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()); }
@Override protected boolean includeLocalRegion(LocalRegion region) { return region.getEvictionAttributes().getAlgorithm().isLRUHeap() && region.getAttributes().getOffHeap(); }
private void handleMessageRetry(LocalRegion region, EntryEventImpl clientEvent) { if (clientEvent.isPossibleDuplicate()) { if (region.getAttributes().getConcurrencyChecksEnabled()) { // recover the version tag from other servers clientEvent.setRegion(region); if (!recoverVersionTagForRetriedOperation(clientEvent)) { // no-one has seen this event clientEvent.setPossibleDuplicate(false); } } } }
protected synchronized void sendValueRequest(final InternalDistributedMember sender) { // send a message to this responder asking for the value // do this on the waiting pool in case the send blocks // Always attempt to send the message to fix bug 37149 RegionAttributes attrs = this.region.getAttributes(); NetSearchRequestMessage.sendMessage(this, this.regionName, this.key, sender, this.remainingTimeout, attrs.getEntryTimeToLive().getTimeout(), attrs.getEntryIdleTimeout().getTimeout()); // if it turns out that we can't send a message to this member then // our membership listener should save the day and schedule a send // to someone else or give up and report a failed search. }
@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(); }
@Test public void putIfAbsentResultHasSameValueReturnTrueIfResultHasSameValue() { Object result = "value"; when(region.putIfAbsentResultHasSameValue(true, value, result)).thenCallRealMethod(); assertThat(region.putIfAbsentResultHasSameValue(true, value, result)).isTrue(); verify(region, never()).getAttributes(); }
@Test public void putIfAbsentResultHasSameValueChecksRegionAttributesIfNotFromClient() { Object result = "value"; when(region.putIfAbsentResultHasSameValue(false, value, result)).thenCallRealMethod(); assertThat(region.putIfAbsentResultHasSameValue(false, value, result)).isTrue(); verify(region).getAttributes(); }
@Override public void createOn(Connection conn, boolean isDurable) { byte regionDataPolicyOrdinal = getCqBaseRegion() == null ? (byte) 0 : getCqBaseRegion().getAttributes().getDataPolicy().ordinal; int state = this.cqState.getState(); this.cqProxy.createOn(getName(), conn, getQueryString(), state, isDurable, regionDataPolicyOrdinal); } }
@Test public void bridgePutIfAbsentResultHasSameValueCanCheckValueForObject() { Object result = "value"; byte[] valueToBePut = EntryEventImpl.serialize(value); when(region.bridgePutIfAbsentResultHasSameValue(valueToBePut, true, result)) .thenCallRealMethod(); assertThat(region.bridgePutIfAbsentResultHasSameValue(valueToBePut, true, result)).isTrue(); verify(region).getAttributes(); }
@Test public void bridgePutIfAbsentResultHasSameValueCanCheckValueForNonObjectByteArray() { byte[] valueToBePut = {0, 1, 2, 3}; Object result = new VMCachedDeserializable(EntryEventImpl.serialize(valueToBePut)); when(region.bridgePutIfAbsentResultHasSameValue(valueToBePut, false, result)) .thenCallRealMethod(); assertThat(region.bridgePutIfAbsentResultHasSameValue(valueToBePut, false, result)).isTrue(); verify(region).getAttributes(); }
@Test public void putIfAbsentResultHasSameValueReturnTrueIfResultHasSameValueAndNotFromClient() { Object result = new VMCachedDeserializable(EntryEventImpl.serialize(value)); when(region.putIfAbsentResultHasSameValue(false, value, result)).thenCallRealMethod(); assertThat(region.putIfAbsentResultHasSameValue(false, value, result)).isTrue(); verify(region).getAttributes(); }
private boolean mustEvict() { LocalRegion owner = _getOwner(); InternalResourceManager resourceManager = owner.getCache().getInternalResourceManager(); boolean offheap = owner.getAttributes().getOffHeap(); return resourceManager.getMemoryMonitor(offheap).getState().isEviction() && this.sizeInVM() > 0; }
/** * Create a continuous query on the given pool * * @param cq the CQ to create on the server */ public Object create(ClientCQ cq) { pool.getRITracker().addCq(cq, cq.isDurable()); byte regionDataPolicyOrdinal = cq.getCqBaseRegion() == null ? (byte) 0 : cq.getCqBaseRegion().getAttributes().getDataPolicy().ordinal; return CreateCQOp.execute(this.pool, cq.getName(), cq.getQueryString(), CqStateImpl.RUNNING, cq.isDurable(), regionDataPolicyOrdinal); }
/** * Create a continuous query on the given server and return the initial query results. * * @param cq the CQ to create on the server */ public SelectResults createWithIR(ClientCQ cq) { pool.getRITracker().addCq(cq, cq.isDurable()); byte regionDataPolicyOrdinal = cq.getCqBaseRegion() == null ? (byte) 0 : cq.getCqBaseRegion().getAttributes().getDataPolicy().ordinal; return CreateCQWithIROp.execute(this.pool, cq.getName(), cq.getQueryString(), CqStateImpl.RUNNING, cq.isDurable(), regionDataPolicyOrdinal); }