Search in sources :

Example 1 with ClientRegionEventImpl

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;
}
Also used : EntryEventImpl(org.apache.geode.internal.cache.EntryEventImpl) ClientRegionEventImpl(org.apache.geode.internal.cache.ClientRegionEventImpl) RegionEventImpl(org.apache.geode.internal.cache.RegionEventImpl) VersionTag(org.apache.geode.internal.cache.versions.VersionTag) EventID(org.apache.geode.internal.cache.EventID) ClientRegionEventImpl(org.apache.geode.internal.cache.ClientRegionEventImpl) CqException(org.apache.geode.cache.query.CqException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) AuthenticationFailedException(org.apache.geode.security.AuthenticationFailedException) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException) UnsupportedVersionException(org.apache.geode.cache.UnsupportedVersionException) RegionExistsException(org.apache.geode.cache.RegionExistsException) CancelException(org.apache.geode.CancelException) AuthenticationRequiredException(org.apache.geode.security.AuthenticationRequiredException)

Aggregations

IOException (java.io.IOException)1 CancelException (org.apache.geode.CancelException)1 CacheException (org.apache.geode.cache.CacheException)1 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)1 RegionExistsException (org.apache.geode.cache.RegionExistsException)1 UnsupportedVersionException (org.apache.geode.cache.UnsupportedVersionException)1 CqException (org.apache.geode.cache.query.CqException)1 ClientRegionEventImpl (org.apache.geode.internal.cache.ClientRegionEventImpl)1 EntryEventImpl (org.apache.geode.internal.cache.EntryEventImpl)1 EventID (org.apache.geode.internal.cache.EventID)1 RegionEventImpl (org.apache.geode.internal.cache.RegionEventImpl)1 VersionTag (org.apache.geode.internal.cache.versions.VersionTag)1 AuthenticationFailedException (org.apache.geode.security.AuthenticationFailedException)1 AuthenticationRequiredException (org.apache.geode.security.AuthenticationRequiredException)1