@Test public void testConcurrencyFalseTagNull() { // case 1: concurrencyCheckEanbled = false, version tag is null: distribute DistributedRegion region = prepare(false); EntryEventImpl event = createDummyEvent(region); assertNull(event.getVersionTag()); doTest(region, event, 1); }
@Test public void testConcurrencyTrueTagNull() { // case 2: concurrencyCheckEanbled = true, version tag is null: not to distribute DistributedRegion region = prepare(true); EntryEventImpl event = createDummyEvent(region); assertNull(event.getVersionTag()); doTest(region, event, 0); }
@Test public void testConcurrencyTrueTagValid() { // case 4: concurrencyCheckEanbled = true, version tag is valid: distribute DistributedRegion region = prepare(true); EntryEventImpl event = createDummyEvent(region); VersionTag tag = createVersionTag(true); event.setVersionTag(tag); assertTrue(tag.hasValidVersion()); doTest(region, event, 1); }
private EntryEventImpl createDummyEvent(DistributedRegion region) { // create a dummy event id EventID eventId = createDummyEventID(); String key = "key1"; String value = "Value1"; // create an event EntryEventImpl event = EntryEventImpl.create( region, Operation.CREATE, key, value, null, false /* origin remote */, null, false /* generateCallbacks */, eventId); // avoid calling invokeCallbacks event.callbacksInvoked(true); return event; }
public void process(LocalRegion lr, DistributedMember src, long lastMod) { if (this.op.isRegion()) { // it is a region operation RegionEventImpl re = new RegionEventImpl(lr, this.op, this.cbArg, true, src); // re.setQueued(true); if (this.op.isRegionInvalidate()) { lr.basicInvalidateRegion(re); } else if (this.op == Operation.REGION_CLEAR) { lr.cmnClearRegion(re, false /* cacheWrite */, false /*useRVV*/); } else { throw new IllegalStateException( LocalizedStrings.QueuedOperation_THE_0_SHOULD_NOT_HAVE_BEEN_QUEUED.toLocalizedString( this.op)); } } else { // it is an entry operation // TODO :EventID should be passed from the sender & should be reused here EntryEventImpl ee = EntryEventImpl.create(lr, this.op, this.key, null, this.cbArg, true, src); try { // ee.setQueued(true); if (this.op.isCreate() || this.op.isUpdate()) { UpdateOperation.UpdateMessage.setNewValueInEvent( this.value, this.valueObj, ee, this.deserializationPolicy); try { long time = lastMod; if (ee.getVersionTag() != null) { time = ee.getVersionTag().getVersionTimeStamp(); } if (AbstractUpdateOperation.doPutOrCreate(lr, ee, time, true, true)) { // am I done? } } catch (ConcurrentCacheModificationException e) { // operation was rejected by the cache's concurrency control // mechanism as being old } } else if (this.op.isDestroy()) { ee.setOldValueFromRegion(); try { lr.basicDestroy(ee, false, null); // expectedOldValue // ???:ezoerner:20080815 // can a remove(key, value) operation be // queued? } catch (ConcurrentCacheModificationException e) { // operation was rejected by the cache's concurrency control mechanism as being old } catch (EntryNotFoundException ignore) { } catch (CacheWriterException e) { throw new Error( LocalizedStrings.QueuedOperation_CACHEWRITER_SHOULD_NOT_BE_CALLED .toLocalizedString(), e); } catch (TimeoutException e) { throw new Error( LocalizedStrings.QueuedOperation_DISTRIBUTEDLOCK_SHOULD_NOT_BE_ACQUIRED .toLocalizedString(), e); } } else if (this.op.isInvalidate()) { ee.setOldValueFromRegion(); boolean forceNewEntry = lr.dataPolicy.withReplication() && !lr.isInitialized(); boolean invokeCallbacks = lr.isInitialized(); try { lr.basicInvalidate(ee, invokeCallbacks, forceNewEntry); } catch (ConcurrentCacheModificationException e) { // operation was rejected by the cache's concurrency control mechanism as being old } catch (EntryNotFoundException ignore) { } } else { throw new IllegalStateException( LocalizedStrings.QueuedOperation_THE_0_SHOULD_NOT_HAVE_BEEN_QUEUED.toLocalizedString( this.op)); } } finally { ee.release(); } } }