Search in sources :

Example 1 with CacheEvent

use of org.apache.geode.cache.CacheEvent in project geode by apache.

the class TXRmtEvent method getPutEvents.

public List getPutEvents() {
    if (this.events == null) {
        return Collections.EMPTY_LIST;
    } else {
        ArrayList result = new ArrayList(this.events.size());
        Iterator it = this.events.iterator();
        while (it.hasNext()) {
            CacheEvent ce = (CacheEvent) it.next();
            if (ce.getOperation().isUpdate() && isEventUserVisible(ce)) {
                result.add(ce);
            }
        }
        if (result.isEmpty()) {
            return Collections.EMPTY_LIST;
        } else {
            return Collections.unmodifiableList(result);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) CacheEvent(org.apache.geode.cache.CacheEvent)

Example 2 with CacheEvent

use of org.apache.geode.cache.CacheEvent in project geode by apache.

the class TXRmtEvent method getEvents.

public List getEvents() {
    if (this.events == null) {
        return Collections.EMPTY_LIST;
    } else {
        ArrayList result = new ArrayList(this.events.size());
        Iterator it = this.events.iterator();
        while (it.hasNext()) {
            CacheEvent ce = (CacheEvent) it.next();
            if (isEventUserVisible(ce)) {
                result.add(ce);
            }
        }
        if (result.isEmpty()) {
            return Collections.EMPTY_LIST;
        } else {
            return Collections.unmodifiableList(result);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) CacheEvent(org.apache.geode.cache.CacheEvent)

Example 3 with CacheEvent

use of org.apache.geode.cache.CacheEvent in project geode by apache.

the class TXRmtEvent method getInvalidateEvents.

public List getInvalidateEvents() {
    if (this.events == null) {
        return Collections.EMPTY_LIST;
    } else {
        ArrayList result = new ArrayList(this.events.size());
        Iterator it = this.events.iterator();
        while (it.hasNext()) {
            CacheEvent ce = (CacheEvent) it.next();
            if (ce.getOperation().isInvalidate() && isEventUserVisible(ce)) {
                result.add(ce);
            }
        }
        if (result.isEmpty()) {
            return Collections.EMPTY_LIST;
        } else {
            return Collections.unmodifiableList(result);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) CacheEvent(org.apache.geode.cache.CacheEvent)

Example 4 with CacheEvent

use of org.apache.geode.cache.CacheEvent in project geode by apache.

the class TXRmtEvent method getDestroyEvents.

public List getDestroyEvents() {
    if (this.events == null) {
        return Collections.EMPTY_LIST;
    } else {
        ArrayList result = new ArrayList(this.events.size());
        Iterator it = this.events.iterator();
        while (it.hasNext()) {
            CacheEvent ce = (CacheEvent) it.next();
            if (ce.getOperation().isDestroy() && isEventUserVisible(ce)) {
                result.add(ce);
            }
        }
        if (result.isEmpty()) {
            return Collections.EMPTY_LIST;
        } else {
            return Collections.unmodifiableList(result);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) CacheEvent(org.apache.geode.cache.CacheEvent)

Example 5 with CacheEvent

use of org.apache.geode.cache.CacheEvent in project geode by apache.

the class SearchLoadAndWriteProcessor method doNetWrite.

/** return true if a CacheWriter was actually invoked */
boolean doNetWrite(CacheEvent event, Set netWriteRecipients, CacheWriter localWriter, int paction) throws CacheWriterException, TimeoutException {
    int action = paction;
    this.requestInProgress = true;
    Scope scope = this.region.getScope();
    if (localWriter != null) {
        doLocalWrite(localWriter, event, action);
        this.requestInProgress = false;
        return true;
    }
    if (scope == Scope.LOCAL && (region.getPartitionAttributes() == null)) {
        return false;
    }
    @Released CacheEvent listenerEvent = getEventForListener(event);
    try {
        if (action == BEFOREUPDATE && listenerEvent.getOperation().isCreate()) {
            action = BEFORECREATE;
        }
        boolean cacheWrote = netWrite(listenerEvent, action, netWriteRecipients);
        this.requestInProgress = false;
        return cacheWrote;
    } finally {
        if (event != listenerEvent) {
            if (listenerEvent instanceof EntryEventImpl) {
                ((Releasable) listenerEvent).release();
            }
        }
    }
}
Also used : Released(org.apache.geode.internal.offheap.annotations.Released) Scope(org.apache.geode.cache.Scope) CacheEvent(org.apache.geode.cache.CacheEvent) Releasable(org.apache.geode.internal.offheap.Releasable)

Aggregations

CacheEvent (org.apache.geode.cache.CacheEvent)9 ArrayList (java.util.ArrayList)6 Iterator (java.util.Iterator)5 List (java.util.List)2 AttributesFactory (org.apache.geode.cache.AttributesFactory)2 CacheException (org.apache.geode.cache.CacheException)2 EntryEvent (org.apache.geode.cache.EntryEvent)2 Region (org.apache.geode.cache.Region)2 SubscriptionAttributes (org.apache.geode.cache.SubscriptionAttributes)2 Releasable (org.apache.geode.internal.offheap.Releasable)2 Released (org.apache.geode.internal.offheap.annotations.Released)2 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)2 VM (org.apache.geode.test.dunit.VM)2 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 Properties (java.util.Properties)1 TreeMap (java.util.TreeMap)1