Search in sources :

Example 11 with GatewaySenderEventCallbackArgument

use of org.apache.geode.internal.cache.wan.GatewaySenderEventCallbackArgument in project geode by apache.

the class LocalRegion method basicBridgePutAll.

/**
   * Called on a bridge server when it has a received a putAll command from a client.
   * 
   * @param map a map of key->value for the entries we are putting
   * @param retryVersions a map of key->version tag. If any of the entries are the result of a
   *        retried client event, we need to make sure we send the original version tag along with
   *        the event.
   * @param callbackArg callback argument from client
   */
public VersionedObjectList basicBridgePutAll(Map map, Map<Object, VersionTag> retryVersions, ClientProxyMembershipID memberId, EventID eventId, boolean skipCallbacks, Object callbackArg) throws TimeoutException, CacheWriterException {
    long startPut = CachePerfStats.getStatTime();
    if (isGatewaySenderEnabled()) {
        callbackArg = new GatewaySenderEventCallbackArgument(callbackArg);
    }
    @Released final EntryEventImpl event = EntryEventImpl.create(this, Operation.PUTALL_CREATE, null, null, /* new value */
    callbackArg, false, /* origin remote */
    memberId.getDistributedMember(), !skipCallbacks, /* generateCallbacks */
    eventId);
    try {
        event.setContext(memberId);
        DistributedPutAllOperation putAllOp = new DistributedPutAllOperation(event, map.size(), true);
        try {
            VersionedObjectList result = basicPutAll(map, putAllOp, retryVersions);
            getCachePerfStats().endPutAll(startPut);
            return result;
        } finally {
            putAllOp.freeOffHeapResources();
        }
    } finally {
        event.release();
    }
}
Also used : Released(org.apache.geode.internal.offheap.annotations.Released) VersionedObjectList(org.apache.geode.internal.cache.tier.sockets.VersionedObjectList) GatewaySenderEventCallbackArgument(org.apache.geode.internal.cache.wan.GatewaySenderEventCallbackArgument)

Example 12 with GatewaySenderEventCallbackArgument

use of org.apache.geode.internal.cache.wan.GatewaySenderEventCallbackArgument in project geode by apache.

the class LocalRegion method basicBridgeRemove.

// TODO: fromClient is always true
public void basicBridgeRemove(Object key, Object expectedOldValue, Object callbackArg, ClientProxyMembershipID memberId, boolean fromClient, EntryEventImpl clientEvent) throws TimeoutException, EntryNotFoundException, CacheWriterException {
    if (fromClient) {
        // GatewayEventCallbackArgument to store the event id.
        if (isGatewaySenderEnabled()) {
            callbackArg = new GatewaySenderEventCallbackArgument(callbackArg);
        }
    }
    // Create an event and put the entry
    @Released final EntryEventImpl event = EntryEventImpl.create(this, Operation.REMOVE, key, null, callbackArg, false, memberId.getDistributedMember(), true, clientEvent.getEventId());
    try {
        event.setContext(memberId);
        // place. AbstractRegionMap performs the checks and throws the exception
        try {
            basicDestroy(event, true, expectedOldValue);
        } finally {
            clientEvent.setVersionTag(event.getVersionTag());
            clientEvent.setIsRedestroyedEntry(event.getIsRedestroyedEntry());
        }
    } finally {
        event.release();
    }
}
Also used : Released(org.apache.geode.internal.offheap.annotations.Released) GatewaySenderEventCallbackArgument(org.apache.geode.internal.cache.wan.GatewaySenderEventCallbackArgument)

Example 13 with GatewaySenderEventCallbackArgument

use of org.apache.geode.internal.cache.wan.GatewaySenderEventCallbackArgument in project geode by apache.

the class LocalRegion method basicBridgeInvalidate.

// TODO: fromClient is always true
public void basicBridgeInvalidate(Object key, Object callbackArg, ClientProxyMembershipID memberId, boolean fromClient, EntryEventImpl clientEvent) throws TimeoutException, EntryNotFoundException, CacheWriterException {
    Object theCallbackArg = callbackArg;
    if (fromClient) {
        // GatewayEventCallbackArgument to store the event id.
        if (isGatewaySenderEnabled()) {
            theCallbackArg = new GatewaySenderEventCallbackArgument(theCallbackArg);
        }
    }
    // Create an event and put the entry
    @Released final EntryEventImpl event = EntryEventImpl.create(this, Operation.INVALIDATE, key, null, theCallbackArg, false, memberId.getDistributedMember(), true, clientEvent.getEventId());
    try {
        event.setContext(memberId);
        // if this is a replayed operation we may already have a version tag
        event.setVersionTag(clientEvent.getVersionTag());
        try {
            basicInvalidate(event);
        } finally {
            clientEvent.setVersionTag(event.getVersionTag());
            clientEvent.isConcurrencyConflict(event.isConcurrencyConflict());
        }
    } finally {
        event.release();
    }
}
Also used : Released(org.apache.geode.internal.offheap.annotations.Released) StoredObject(org.apache.geode.internal.offheap.StoredObject) GatewaySenderEventCallbackArgument(org.apache.geode.internal.cache.wan.GatewaySenderEventCallbackArgument)

Aggregations

GatewaySenderEventCallbackArgument (org.apache.geode.internal.cache.wan.GatewaySenderEventCallbackArgument)13 Released (org.apache.geode.internal.offheap.annotations.Released)9 StoredObject (org.apache.geode.internal.offheap.StoredObject)6 VersionedObjectList (org.apache.geode.internal.cache.tier.sockets.VersionedObjectList)2 ConcurrentCacheModificationException (org.apache.geode.internal.cache.versions.ConcurrentCacheModificationException)2 IOException (java.io.IOException)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 CacheException (org.apache.geode.cache.CacheException)1 EntryExistsException (org.apache.geode.cache.EntryExistsException)1 EntryEventImpl (org.apache.geode.internal.cache.EntryEventImpl)1 EventID (org.apache.geode.internal.cache.EventID)1 EventWrapper (org.apache.geode.internal.cache.wan.AbstractGatewaySender.EventWrapper)1 GatewaySenderEventImpl (org.apache.geode.internal.cache.wan.GatewaySenderEventImpl)1 GatewaySenderStats (org.apache.geode.internal.cache.wan.GatewaySenderStats)1