Search in sources :

Example 11 with DeltaSessionAttributeEvent

use of org.apache.geode.modules.session.catalina.internal.DeltaSessionAttributeEvent in project geode by apache.

the class DeltaSession method removeAttribute.

public void removeAttribute(String name, boolean notify) {
    checkBackingCacheAvailable();
    if (expired) {
        return;
    }
    synchronized (this.changeLock) {
        // Remove the attribute locally
        super.removeAttribute(name, true);
        // Create the destroy attribute message
        DeltaSessionAttributeEvent event = new DeltaSessionDestroyAttributeEvent(name);
        queueAttributeEvent(event, true);
        // Distribute the update
        if (!isCommitEnabled()) {
            putInRegion(getOperatingRegion(), true, null);
        }
    }
}
Also used : DeltaSessionAttributeEvent(org.apache.geode.modules.session.catalina.internal.DeltaSessionAttributeEvent) DeltaSessionDestroyAttributeEvent(org.apache.geode.modules.session.catalina.internal.DeltaSessionDestroyAttributeEvent)

Example 12 with DeltaSessionAttributeEvent

use of org.apache.geode.modules.session.catalina.internal.DeltaSessionAttributeEvent in project geode by apache.

the class DeltaSession7 method applyAttributeEvents.

public void applyAttributeEvents(Region<String, DeltaSessionInterface> region, List<DeltaSessionAttributeEvent> events) {
    for (DeltaSessionAttributeEvent event : events) {
        event.apply(this);
        queueAttributeEvent(event, false);
    }
    putInRegion(region, false, true);
}
Also used : DeltaSessionAttributeEvent(org.apache.geode.modules.session.catalina.internal.DeltaSessionAttributeEvent)

Example 13 with DeltaSessionAttributeEvent

use of org.apache.geode.modules.session.catalina.internal.DeltaSessionAttributeEvent in project geode by apache.

the class DeltaSession7 method setAttribute.

public void setAttribute(String name, Object value, boolean notify) {
    checkBackingCacheAvailable();
    synchronized (this.changeLock) {
        // Serialize the value
        byte[] serializedValue = serialize(value);
        // Store the attribute locally
        if (this.preferDeserializedForm) {
            super.setAttribute(name, value, true);
        } else {
            super.setAttribute(name, serializedValue, true);
        }
        if (serializedValue == null) {
            return;
        }
        // Create the update attribute message
        DeltaSessionAttributeEvent event = new DeltaSessionUpdateAttributeEvent(name, serializedValue);
        queueAttributeEvent(event, true);
        // Distribute the update
        if (!isCommitEnabled()) {
            putInRegion(getOperatingRegion(), true, null);
        }
    }
}
Also used : DeltaSessionAttributeEvent(org.apache.geode.modules.session.catalina.internal.DeltaSessionAttributeEvent) DeltaSessionUpdateAttributeEvent(org.apache.geode.modules.session.catalina.internal.DeltaSessionUpdateAttributeEvent)

Example 14 with DeltaSessionAttributeEvent

use of org.apache.geode.modules.session.catalina.internal.DeltaSessionAttributeEvent in project geode by apache.

the class DeltaSession7 method queueAttributeEvent.

private void queueAttributeEvent(DeltaSessionAttributeEvent event, boolean checkAddToCurrentGatewayDelta) {
    // Add to current gateway delta if necessary
    if (checkAddToCurrentGatewayDelta) {
        // If the manager has enabled gateway delta replication and is a P2P
        // manager, the GatewayDeltaForwardCacheListener will be invoked in this
        // VM. Add the event to the currentDelta.
        DeltaSessionManager mgr = (DeltaSessionManager) this.manager;
        if (this.enableGatewayDeltaReplication && mgr.isPeerToPeer()) {
            // be added at commit time.
            if (!isCommitEnabled()) {
                List<DeltaSessionAttributeEvent> events = new ArrayList<DeltaSessionAttributeEvent>();
                events.add(event);
                this.currentGatewayDeltaEvent = new DeltaSessionAttributeEventBatch(this.sessionRegionName, this.id, events);
            }
        }
    }
    this.eventQueue.add(event);
}
Also used : DeltaSessionAttributeEvent(org.apache.geode.modules.session.catalina.internal.DeltaSessionAttributeEvent) ArrayList(java.util.ArrayList) DeltaSessionAttributeEventBatch(org.apache.geode.modules.session.catalina.internal.DeltaSessionAttributeEventBatch)

Example 15 with DeltaSessionAttributeEvent

use of org.apache.geode.modules.session.catalina.internal.DeltaSessionAttributeEvent in project geode by apache.

the class DeltaSession8 method fromDelta.

public void fromDelta(DataInput in) throws IOException, InvalidDeltaException {
    // Read whether to apply the changes to another DS if necessary
    this.applyRemotely = in.readBoolean();
    // Read the events
    List<DeltaSessionAttributeEvent> events = null;
    try {
        events = DataSerializer.readArrayList(in);
    } catch (ClassNotFoundException e) {
        throw new InvalidDeltaException(e);
    }
    // This allows for backwards compatibility with 2.1 clients
    if (((InputStream) in).available() > 0) {
        this.lastAccessedTime = in.readLong();
        this.maxInactiveInterval = in.readInt();
    }
    // Iterate and apply the events
    for (DeltaSessionAttributeEvent event : events) {
        event.apply(this);
    }
    // Add the events to the gateway delta region if necessary
    if (this.enableGatewayDeltaReplication && this.applyRemotely) {
        setCurrentGatewayDeltaEvent(new DeltaSessionAttributeEventBatch(this.sessionRegionName, this.id, events));
    }
    // Access it to set the last accessed time. End access it to set not new.
    access();
    endAccess();
}
Also used : InvalidDeltaException(org.apache.geode.InvalidDeltaException) DeltaSessionAttributeEvent(org.apache.geode.modules.session.catalina.internal.DeltaSessionAttributeEvent) DeltaSessionAttributeEventBatch(org.apache.geode.modules.session.catalina.internal.DeltaSessionAttributeEventBatch)

Aggregations

DeltaSessionAttributeEvent (org.apache.geode.modules.session.catalina.internal.DeltaSessionAttributeEvent)15 DeltaSessionAttributeEventBatch (org.apache.geode.modules.session.catalina.internal.DeltaSessionAttributeEventBatch)6 ArrayList (java.util.ArrayList)3 InvalidDeltaException (org.apache.geode.InvalidDeltaException)3 DeltaSessionDestroyAttributeEvent (org.apache.geode.modules.session.catalina.internal.DeltaSessionDestroyAttributeEvent)3 DeltaSessionUpdateAttributeEvent (org.apache.geode.modules.session.catalina.internal.DeltaSessionUpdateAttributeEvent)3