/** GC operation for non-partitioned regions */ public static ClientTombstoneMessage gc(LocalRegion region, Map<VersionSource, Long> regionGCVersions, EventID eventId) { return new ClientTombstoneMessage(TOperation.GC, region, regionGCVersions, eventId); }
@Override public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("ClientTombstoneMessage[op=").append(this.op) .append(";region=").append(getRegionName()) .append(";removalInfo=").append(this.removalInformation) .append(";memberId=").append(getMembershipId()) .append(";eventId=").append(getEventId()).append("]"); return buffer.toString(); } }
private ClientTombstoneMessage(TOperation op, LocalRegion region, Object removalInformation, EventID eventId) { super(EnumListenerEvent.AFTER_TOMBSTONE_EXPIRATION, null, eventId); this.op = op; this.removalInformation = removalInformation; setRegionName(region.getFullPath()); // fix for bug #45962 - tombstone message must have the region name }
@Override protected final boolean operateOnPartitionedRegion( final DistributionManager dm, PartitionedRegion r, long startTime) throws ForceReattemptException { if (logger.isTraceEnabled(LogMarker.DM)) { logger.debug("PRTombstoneMessage operateOnRegion: {}", r.getFullPath()); } FilterProfile fp = r.getFilterProfile(); if (this.keys != null && this.keys.size() > 0) { // sanity check if (fp != null && CacheClientNotifier.getInstance() != null && this.eventID != null) { RegionEventImpl regionEvent = new RegionEventImpl(r, Operation.REGION_DESTROY, null, true, r.getGemFireCache().getMyId()); regionEvent.setLocalFilterInfo(fp.getLocalFilterRouting(regionEvent)); ClientUpdateMessage clientMessage = ClientTombstoneMessage.gc(r, this.keys, this.eventID); CacheClientNotifier.notifyClients(regionEvent, clientMessage); } } return true; }
protected Message getGFE70Message(Version clientVersion) { Message message = null; // The format: // part 0: operation (gc=0) // part 1: region name // part 2: operation ordinal // part 3: regionGCVersions // Last part: event ID int numParts = 4; message = new Message(numParts, clientVersion); // Set message type message.setMessageType(MessageType.TOMBSTONE_OPERATION); message.addStringPart(this.getRegionName()); message.addIntPart(this.op.ordinal()); message.addObjPart(this.removalInformation); message.addObjPart(getEventId()); return message; }
@Override public void toData(DataOutput out) throws IOException { out.writeByte(op.ordinal()); out.writeByte(_operation.getEventCode()); DataSerializer.writeString(getRegionName(), out); DataSerializer.writeObject(this.removalInformation, out); DataSerializer.writeObject(this._membershipId, out); DataSerializer.writeObject(this._eventIdentifier, out); }
@Override protected Message getMessage(CacheClientProxy proxy, byte[] latestValue) throws IOException { if (Version.GFE_70.compareTo(proxy.getVersion()) <= 0) { return getGFE70Message(proxy.getVersion()); } else { return null; } }
@Override protected void notifyClientsOfTombstoneGC(Map<VersionSource, Long> regionGCVersions, Set<Object>removedKeys, EventID eventID, FilterInfo routing) { if (CacheClientNotifier.getInstance() != null) { // Only route the event to clients interested in the partitioned region. // We do this by constructing a region-level event and then use it to // have the filter profile ferret out all of the clients that have interest // in this region FilterProfile fp = getFilterProfile(); if ((removedKeys != null && removedKeys.size() > 0) // bug #51877 - NPE in clients && (routing != null || fp != null)) { // fix for bug #46309 - don't send null/empty key set to clients RegionEventImpl regionEvent = new RegionEventImpl(getPartitionedRegion(), Operation.REGION_DESTROY, null, true, getMyId()); FilterInfo clientRouting = routing; if (clientRouting == null) { clientRouting = fp.getLocalFilterRouting(regionEvent); } regionEvent.setLocalFilterInfo(clientRouting); ClientUpdateMessage clientMessage = ClientTombstoneMessage.gc(getPartitionedRegion(), removedKeys, eventID); CacheClientNotifier.notifyClients(regionEvent, clientMessage); } } }
protected Message getGFE70Message(Version clientVersion) { Message message = null; // The format: // part 0: operation (gc=0) // part 1: region name // part 2: operation ordinal // part 3: regionGCVersions // Last part: event ID int numParts = 4; message = new Message(numParts, clientVersion); // Set message type message.setMessageType(MessageType.TOMBSTONE_OPERATION); message.addStringPart(this.getRegionName()); message.addIntPart(this.op.ordinal()); message.addObjPart(this.removalInformation); message.addObjPart(getEventId()); return message; }
@Override public void toData(DataOutput out) throws IOException { out.writeByte(op.ordinal()); out.writeByte(_operation.getEventCode()); DataSerializer.writeString(getRegionName(), out); DataSerializer.writeObject(this.removalInformation, out); DataSerializer.writeObject(this._membershipId, out); DataSerializer.writeObject(this._eventIdentifier, out); }
@Override protected Message getMessage(CacheClientProxy proxy, byte[] latestValue) throws IOException { if (Version.GFE_70.compareTo(proxy.getVersion()) <= 0) { return getGFE70Message(proxy.getVersion()); } else { return null; } }
@Override public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("ClientTombstoneMessage[op=").append(this.op) .append(";region=").append(getRegionName()) .append(";removalInfo=").append(this.removalInformation) .append(";memberId=").append(getMembershipId()) .append(";eventId=").append(getEventId()).append("]"); return buffer.toString(); } }
/** queue a tombstone GC message for the client. See bug #46832 */ public static void tombstonegc() throws Exception { LocalRegion r = (LocalRegion)cache.getRegion("/"+REGION_NAME); assertNotNull(r); DistributedMember id = r.getCache().getDistributedSystem().getDistributedMember(); RegionEventImpl regionEvent = new RegionEventImpl(r, Operation.REGION_DESTROY, null, true, id); FilterInfo clientRouting = r.getFilterProfile().getLocalFilterRouting(regionEvent); assertTrue(clientRouting.getInterestedClients().size() > 0); regionEvent.setLocalFilterInfo(clientRouting); Map<VersionSource, Long> map = Collections.emptyMap(); ClientTombstoneMessage message = ClientTombstoneMessage.gc( r, map, new EventID(r.getCache().getDistributedSystem())); CacheClientNotifier.notifyClients(regionEvent, message); }
/** GC operation for partitioned regions */ public static ClientTombstoneMessage gc(LocalRegion region, Set<Object> removedKeys, EventID eventId) { return new ClientTombstoneMessage(TOperation.GC_PR, region, removedKeys, eventId); }
private ClientTombstoneMessage(TOperation op, LocalRegion region, Object removalInformation, EventID eventId) { super(EnumListenerEvent.AFTER_TOMBSTONE_EXPIRATION, null, eventId, region.getLogWriterI18n()); this.op = op; this.removalInformation = removalInformation; setRegionName(region.getFullPath()); // fix for bug #45962 - tombstone message must have the region name }
@Override protected void notifyClientsOfTombstoneGC(Map<VersionSource, Long> regionGCVersions, Set<Object>removedKeys, EventID eventID, FilterInfo routing) { if (CacheClientNotifier.getInstance() != null) { // Only route the event to clients interested in the partitioned region. // We do this by constructing a region-level event and then use it to // have the filter profile ferret out all of the clients that have interest // in this region FilterProfile fp = getFilterProfile(); if (routing != null || (removedKeys != null && removedKeys.size() > 0 && fp != null)) { // fix for bug #46309 - don't send null/empty key set to clients RegionEventImpl regionEvent = new RegionEventImpl(getPartitionedRegion(), Operation.REGION_DESTROY, null, true, getMyId()); FilterInfo clientRouting = routing; if (clientRouting == null) { clientRouting = fp.getLocalFilterRouting(regionEvent); } regionEvent.setLocalFilterInfo(clientRouting); ClientUpdateMessage clientMessage = ClientTombstoneMessage.gc(getPartitionedRegion(), removedKeys, eventID); CacheClientNotifier.notifyClients(regionEvent, clientMessage); } } }
/** GC operation for non-partitioned regions */ public static ClientTombstoneMessage gc(LocalRegion region, Map<VersionSource, Long> regionGCVersions, EventID eventId) { return new ClientTombstoneMessage(TOperation.GC, region, regionGCVersions, eventId); }
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { // note: does not call super.fromData() since there are no keys, etc. // The message class hierarchy should be revised to have a more abstract // top-level class. this.op = TOperation.values()[in.readByte()]; this._operation = EnumListenerEvent.getEnumListenerEvent(in.readByte()); this.setRegionName(DataSerializer.readString(in)); this.removalInformation = DataSerializer.readObject(in); this._membershipId = ClientProxyMembershipID.readCanonicalized(in); this._eventIdentifier = (EventID)DataSerializer.readObject(in); }
/** pass tombstone garbage-collection info to clients * @param eventID the ID of the event (see bug #50683) * @param routing routing info (routing is computed if this is null) */ protected void notifyClientsOfTombstoneGC(Map<VersionSource, Long> regionGCVersions, Set<Object>keysRemoved, EventID eventID, FilterInfo routing) { if (CacheClientNotifier.getInstance() != null) { // Only route the event to clients interested in the partitioned region. // We do this by constructing a region-level event and then use it to // have the filter profile ferret out all of the clients that have interest // in this region FilterProfile fp = getFilterProfile(); if (fp != null || routing != null) { // null check - fix for bug #45614 RegionEventImpl regionEvent = new RegionEventImpl(this, Operation.REGION_DESTROY, null, true, getMyId()); regionEvent.setEventID(eventID); FilterInfo clientRouting = routing; if (clientRouting == null) { clientRouting = fp.getLocalFilterRouting(regionEvent); } regionEvent.setLocalFilterInfo(clientRouting); ClientUpdateMessage clientMessage = ClientTombstoneMessage.gc(this, regionGCVersions, eventID); CacheClientNotifier.notifyClients(regionEvent, clientMessage); } } }
/** GC operation for partitioned regions */ public static ClientTombstoneMessage gc(LocalRegion region, Set<Object> removedKeys, EventID eventId) { return new ClientTombstoneMessage(TOperation.GC_PR, region, removedKeys, eventId); }