Search in sources :

Example 6 with RegionEventImpl

use of org.apache.geode.internal.cache.RegionEventImpl 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

RegionEventImpl (org.apache.geode.internal.cache.RegionEventImpl)6 EventID (org.apache.geode.internal.cache.EventID)3 EntryEventImpl (org.apache.geode.internal.cache.EntryEventImpl)2 InitialImageOperation (org.apache.geode.internal.cache.InitialImageOperation)2 IOException (java.io.IOException)1 Properties (java.util.Properties)1 CancelException (org.apache.geode.CancelException)1 AttributesFactory (org.apache.geode.cache.AttributesFactory)1 CacheException (org.apache.geode.cache.CacheException)1 CacheWriter (org.apache.geode.cache.CacheWriter)1 CacheWriterException (org.apache.geode.cache.CacheWriterException)1 EntryEvent (org.apache.geode.cache.EntryEvent)1 Region (org.apache.geode.cache.Region)1 RegionAttributes (org.apache.geode.cache.RegionAttributes)1 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)1 RegionEvent (org.apache.geode.cache.RegionEvent)1 RegionExistsException (org.apache.geode.cache.RegionExistsException)1 UnsupportedVersionException (org.apache.geode.cache.UnsupportedVersionException)1 CqException (org.apache.geode.cache.query.CqException)1 CacheWriterAdapter (org.apache.geode.cache.util.CacheWriterAdapter)1