use of org.apache.geode.internal.cache.ClientRegionEventImpl in project geode by apache.
the class CacheClientNotifier method initializeMessage.
/**
* Initializes a <code>ClientUpdateMessage</code> from an operation and event
*
* @param operation The operation that occurred (e.g. AFTER_CREATE)
* @param event The event containing the data to be updated
* @return a <code>ClientUpdateMessage</code>
*/
private ClientUpdateMessageImpl initializeMessage(EnumListenerEvent operation, CacheEvent event) throws Exception {
if (!supportsOperation(operation)) {
throw new Exception(LocalizedStrings.CacheClientNotifier_THE_CACHE_CLIENT_NOTIFIER_DOES_NOT_SUPPORT_OPERATIONS_OF_TYPE_0.toLocalizedString(operation));
}
// String regionName = event.getRegion().getFullPath();
Object keyOfInterest = null;
final EventID eventIdentifier;
ClientProxyMembershipID membershipID = null;
boolean isNetLoad = false;
Object callbackArgument = null;
byte[] delta = null;
VersionTag versionTag = null;
if (event.getOperation().isEntry()) {
EntryEventImpl entryEvent = (EntryEventImpl) event;
versionTag = entryEvent.getVersionTag();
delta = entryEvent.getDeltaBytes();
callbackArgument = entryEvent.getRawCallbackArgument();
if (entryEvent.isBridgeEvent()) {
membershipID = entryEvent.getContext();
}
keyOfInterest = entryEvent.getKey();
eventIdentifier = entryEvent.getEventId();
isNetLoad = entryEvent.isNetLoad();
} else {
RegionEventImpl regionEvent = (RegionEventImpl) event;
callbackArgument = regionEvent.getRawCallbackArgument();
eventIdentifier = regionEvent.getEventId();
if (event instanceof ClientRegionEventImpl) {
ClientRegionEventImpl bridgeEvent = (ClientRegionEventImpl) event;
membershipID = bridgeEvent.getContext();
}
}
// NOTE: If delta is non-null, value MUST be in Object form of type Delta.
ClientUpdateMessageImpl clientUpdateMsg = new ClientUpdateMessageImpl(operation, (LocalRegion) event.getRegion(), keyOfInterest, null, delta, (byte) 0x01, callbackArgument, membershipID, eventIdentifier, versionTag);
if (event.getOperation().isEntry()) {
EntryEventImpl entryEvent = (EntryEventImpl) event;
// only need a value if notifyBySubscription is true
entryEvent.exportNewValue(clientUpdateMsg);
}
if (isNetLoad) {
clientUpdateMsg.setIsNetLoad(isNetLoad);
}
return clientUpdateMsg;
}
Aggregations