@Override public void toData(final DataOutput out) throws IOException { super.toData(out); try { // Write EventID DataSerializer.writeObject(this.event.getEventId(), out); ((InternalDistributedMember)event.getDistributedMember()).toData(out); // Write Region name DataSerializer.writeString(this.event.getRegion().getFullPath(), out); } catch (Exception e) { throw new IOException(e); } }
@Override public void toData(final DataOutput out) throws IOException { super.toData(out); try { // Write EventID DataSerializer.writeObject(this.event.getEventId(), out); // Write Member; TODO: SW: why is this required? get rid of it by // having an additional flag and getSender will get the origin ((InternalDistributedMember)event.getDistributedMember()).toData(out); // Write Region name DataSerializer.writeString(this.event.getRegion().getFullPath(), out); } catch (Exception e) { throw new IOException(e); } }
@Override public void toData(final DataOutput out) throws IOException { super.toData(out); try { // Write EventID DataSerializer.writeObject(this.event.getEventId(), out); // Write Member; TODO: SW: why is this required? get rid of it by // having an additional flag and getSender will get the origin ((InternalDistributedMember)event.getDistributedMember()).toData(out); // Write Region name DataSerializer.writeString(this.event.getRegion().getFullPath(), out); } catch (Exception e) { throw new IOException(e); } }
@Override public void invokeTXCallbacks( final EnumListenerEvent eventType, final EntryEventImpl event, final boolean callDispatchListenerEvent) { if (logger.isDebugEnabled()) { logger.debug("BR.invokeTXCallbacks for event {}", event); } // bucket events may make it to this point even though the bucket is still // initializing. We can't block while initializing or a GII state flush // may hang, so we avoid notifying the bucket if (this.isInitialized()) { boolean callThem = callDispatchListenerEvent; if (event.isPossibleDuplicate() && this.eventTracker.isInitialImageProvider(event.getDistributedMember())) { callThem = false; } super.invokeTXCallbacks(eventType, event, callThem); } final EntryEventImpl prevent = createEventForPR(event); try { this.partitionedRegion.invokeTXCallbacks(eventType, prevent, this.partitionedRegion.isInitialized() ? callDispatchListenerEvent : false); } finally { prevent.release(); } }
void basicUpdateEntryVersion(EntryEventImpl event) throws EntryNotFoundException { if (hasSeenEvent(event)) { if(logger.isTraceEnabled(LogMarker.DM)) { logger.trace(LogMarker.DM, "LR.basicDestroy: this cache has already seen this event {}", event); } if (this.concurrencyChecksEnabled && event.getVersionTag() != null && !event.getVersionTag().isRecorded()) { getVersionVector().recordVersion((InternalDistributedMember) event.getDistributedMember(), event.getVersionTag()); } return; } getDataView().updateEntryVersion(event); }
EntryEventImpl createEventForPR(EntryEventImpl sourceEvent) { EntryEventImpl e2 = new EntryEventImpl(sourceEvent); boolean returned = false; try { e2.setRegion(this.partitionedRegion); if (FORCE_LOCAL_LISTENERS_INVOCATION) { e2.setInvokePRCallbacks(true); } else { e2.setInvokePRCallbacks(sourceEvent.getInvokePRCallbacks()); } DistributedMember dm = this.getDistributionManager().getDistributionManagerId(); e2.setOriginRemote(!e2.getDistributedMember().equals(dm)); returned = true; return e2; } finally { if (!returned) { e2.release(); } } }
EntryEventImpl createEventForPR(EntryEventImpl sourceEvent) { EntryEventImpl e2 = new EntryEventImpl(sourceEvent); boolean returned = false; try { e2.setRegion(this.partitionedRegion); if (FORCE_LOCAL_LISTENERS_INVOCATION) { e2.setInvokePRCallbacks(true); } else { e2.setInvokePRCallbacks(sourceEvent.getInvokePRCallbacks()); } DistributedMember dm = this.getDistributionManager().getDistributionManagerId(); e2.setOriginRemote(!e2.getDistributedMember().equals(dm)); returned = true; return e2; } finally { if (!returned) { e2.release(); } } }
public void testDestroyCreatesTombstone() throws Exception { String name = getName(); Properties props = new Properties(); props.put(DistributionConfig.LOCATORS_NAME, ""); props.put(DistributionConfig.MCAST_PORT_NAME, "0"); props.put(DistributionConfig.LOG_LEVEL_NAME, "config"); GemFireCacheImpl cache = (GemFireCacheImpl)CacheFactory.create(DistributedSystem.connect(props)); RegionFactory f = cache.createRegionFactory(RegionShortcut.REPLICATE); DistributedRegion region = (DistributedRegion)f.create(name); EntryEventImpl ev = EntryEventImpl.create(region, Operation.DESTROY, "myDestroyedKey", null, null, true, new InternalDistributedMember(InetAddress.getLocalHost(), 1234)); VersionTag tag = VersionTag.create((InternalDistributedMember)ev.getDistributedMember()); tag.setIsRemoteForTesting(); tag.setEntryVersion(2); tag.setRegionVersion(12345); tag.setVersionTimeStamp(System.currentTimeMillis()); tag.setDistributedSystemId(1); ev.setVersionTag(tag); cache.getLogger().info("destroyThread is trying to destroy the entry: " + region.getRegionEntry("myDestroyedKey")); region.basicDestroy(ev, false, null); // expectedOldValue not supported on RegionEntry entry = region.getRegionEntry("myDestroyedKey"); Assert.assertTrue(entry != null, "expected to find a region entry for myDestroyedKey"); Assert.assertTrue(entry.isTombstone(), "expected entry to be found and be a tombstone but it is " + entry); }
@Override public void invokePutCallbacks( final EnumListenerEvent eventType, final EntryEventImpl event, final boolean callDispatchListenerEvent, boolean notifyGateways) { if (logger.isTraceEnabled()) { logger.trace("invoking put callbacks on bucket for event {}", event); } // bucket events may make it to this point even though the bucket is still // initializing. We can't block while initializing or a GII state flush // may hang, so we avoid notifying the bucket if (this.isInitialized()) { boolean callThem = callDispatchListenerEvent; if (callThem && event.isPossibleDuplicate() && this.eventTracker.isInitialImageProvider(event.getDistributedMember())) { callThem = false; } super.invokePutCallbacks(eventType, event, callThem, notifyGateways); } final EntryEventImpl prevent = createEventForPR(event); try { this.partitionedRegion.invokePutCallbacks(eventType, prevent, this.partitionedRegion.isInitialized() ? callDispatchListenerEvent : false, false); } finally { prevent.release(); } }
@Override public void invokeDestroyCallbacks( final EnumListenerEvent eventType, final EntryEventImpl event, final boolean callDispatchListenerEvent, boolean notifyGateways) { // bucket events may make it to this point even though the bucket is still // initializing. We can't block while initializing or a GII state flush // may hang, so we avoid notifying the bucket if (this.isInitialized()) { boolean callThem = callDispatchListenerEvent; if (event.isPossibleDuplicate() && this.eventTracker.isInitialImageProvider(event.getDistributedMember())) { callThem = false; } super.invokeDestroyCallbacks(eventType, event, callThem, notifyGateways); } final EntryEventImpl prevent = createEventForPR(event); try { this.partitionedRegion.invokeDestroyCallbacks(eventType, prevent, this.partitionedRegion.isInitialized() ? callDispatchListenerEvent : false, false); } finally { prevent.release(); } }
@Override public void invokeInvalidateCallbacks( final EnumListenerEvent eventType, final EntryEventImpl event, final boolean callDispatchListenerEvent) { // bucket events may make it to this point even though the bucket is still // initializing. We can't block while initializing or a GII state flush // may hang, so we avoid notifying the bucket if (this.isInitialized()) { boolean callThem = callDispatchListenerEvent; if (event.isPossibleDuplicate() && this.eventTracker.isInitialImageProvider(event.getDistributedMember())) { callThem = false; } super.invokeInvalidateCallbacks(eventType, event, callThem); } final EntryEventImpl prevent = createEventForPR(event); try { this.partitionedRegion.invokeInvalidateCallbacks(eventType, prevent, this.partitionedRegion.isInitialized() ? callDispatchListenerEvent : false); } finally { prevent.release(); } }
@Override public void invokeInvalidateCallbacks( final EnumListenerEvent eventType, final EntryEventImpl event, final boolean callDispatchListenerEvent) { // bucket events may make it to this point even though the bucket is still // initializing. We can't block while initializing or a GII state flush // may hang, so we avoid notifying the bucket if (this.isInitialized()) { boolean callThem = callDispatchListenerEvent; if (event.isPossibleDuplicate() && this.eventTracker.isInitialImageProvider(event.getDistributedMember())) { callThem = false; } super.invokeInvalidateCallbacks(eventType, event, callThem); } final EntryEventImpl prevent = createEventForPR(event); try { this.partitionedRegion.invokeInvalidateCallbacks(eventType, prevent, this.partitionedRegion.isInitialized() ? callDispatchListenerEvent : false); } finally { prevent.release(); } }
@Override public void invokeDestroyCallbacks( final EnumListenerEvent eventType, final EntryEventImpl event, final boolean callDispatchListenerEvent, boolean notifyGateways) { // bucket events may make it to this point even though the bucket is still // initializing. We can't block while initializing or a GII state flush // may hang, so we avoid notifying the bucket if (this.isInitialized()) { boolean callThem = callDispatchListenerEvent; if (event.isPossibleDuplicate() && this.eventTracker.isInitialImageProvider(event.getDistributedMember())) { callThem = false; } super.invokeDestroyCallbacks(eventType, event, callThem, notifyGateways); } final EntryEventImpl prevent = createEventForPR(event); try { this.partitionedRegion.invokeDestroyCallbacks(eventType, prevent, this.partitionedRegion.isInitialized() ? callDispatchListenerEvent : false, false); } finally { prevent.release(); } }
void basicUpdateEntryVersion(EntryEventImpl event) throws EntryNotFoundException { if (hasSeenEvent(event)) { if (DistributionManager.VERBOSE) { cache.getLoggerI18n().info( LocalizedStrings.DEBUG, "LR.basicDestroy: this cache has already seen this event " + event); } if (this.concurrencyChecksEnabled && event.getVersionTag() != null && !event.getVersionTag().isRecorded()) { getVersionVector().recordVersion((InternalDistributedMember) event.getDistributedMember(), event.getVersionTag(), event); } return; } getDataView().updateEntryVersion(event); }
getVersionVector().recordVersion((InternalDistributedMember) event.getDistributedMember(), event.getVersionTag());
/** * @param cacheWrite * true if cacheWrite should be performed or false if cacheWrite * should not be performed * @see DistributedRegion#basicDestroy(EntryEventImpl, boolean, Object) */ void basicDestroy(final EntryEventImpl event, final boolean cacheWrite, Object expectedOldValue) throws EntryNotFoundException, CacheWriterException, TimeoutException { if (!event.isOriginRemote()) { checkIfReplicatedAndLocalDestroy(event); } if (hasSeenEvent(event)) { assert getJTAEnlistedTX() == null; if(logger.isTraceEnabled(LogMarker.DM)) { logger.trace(LogMarker.DM, "LR.basicDestroy: this cache has already seen this event {}", event); } if (this.concurrencyChecksEnabled && event.getVersionTag() != null && !event.getVersionTag().isRecorded()) { getVersionVector().recordVersion((InternalDistributedMember) event.getDistributedMember(), event.getVersionTag()); } // Bug 49449: When client retried and returned with hasSeenEvent for both LR and DR, the server should still // notifyGatewayHubs even the event could be duplicated in gateway queues1 notifyGatewaySender(EnumListenerEvent.AFTER_DESTROY, event); return; } discoverJTA(); getDataView().destroyExistingEntry(event, cacheWrite, expectedOldValue); }
@Override public void invokeTXCallbacks( final EnumListenerEvent eventType, final EntryEventImpl event, final boolean callDispatchListenerEvent, final boolean notifyGateway) { if (getCache().getLogger().fineEnabled()) { getCache().getLogger().fine("BR.invokeTXCallbacks for event " + event); } // bucket events may make it to this point even though the bucket is still // initializing. We can't block while initializing or a GII state flush // may hang, so we avoid notifying the bucket if (this.isInitialized()) { boolean callThem = callDispatchListenerEvent; if (event.isPossibleDuplicate() && this.eventTracker.isInitialImageProvider(event.getDistributedMember())) { callThem = false; } super.invokeTXCallbacks(eventType, event, callThem, notifyGateway); } final EntryEventImpl prevent = createEventForPR(event); try { this.partitionedRegion.invokeTXCallbacks(eventType, prevent, this.partitionedRegion.isInitialized() ? callDispatchListenerEvent : false, false); } finally { prevent.release(); } }
@Override public void invokePutCallbacks( final EnumListenerEvent eventType, final EntryEventImpl event, final boolean callDispatchListenerEvent, boolean notifyGateways) { if (getCache().getLogger().finerEnabled()) { getCache().getLogger().finer("invoking put callbacks on bucket for event " + event); } // bucket events may make it to this point even though the bucket is still // initializing. We can't block while initializing or a GII state flush // may hang, so we avoid notifying the bucket if (this.isInitialized()) { boolean callThem = callDispatchListenerEvent; if (callThem && event.isPossibleDuplicate() && this.eventTracker.isInitialImageProvider(event.getDistributedMember())) { callThem = false; } super.invokePutCallbacks(eventType, event, callThem, notifyGateways); } final EntryEventImpl prevent = createEventForPR(event); try { this.partitionedRegion.invokePutCallbacks(eventType, prevent, this.partitionedRegion.isInitialized() ? callDispatchListenerEvent : false, false); } finally { prevent.release(); } }
getVersionVector().recordVersion((InternalDistributedMember) event.getDistributedMember(), event.getVersionTag(), event);
updateTimeStampEvent.setKeyInfo(event); updateTimeStampEvent.setGenerateCallbacks(false); updateTimeStampEvent.distributedMember = event.getDistributedMember(); updateTimeStampEvent.setNewEventId(getSystem());