Search in sources :

Example 21 with VersionSource

use of org.apache.geode.internal.cache.versions.VersionSource in project geode by apache.

the class OrderedTombstoneMap method put.

/**
   * Add a new version tag to map
   */
public void put(VersionTag tag, T entry) {
    // Add the version tag to the appropriate map
    VersionSource member = tag.getMemberID();
    TreeMap<VersionTag, T> memberMap = tombstoneMap.get(member);
    if (memberMap == null) {
        memberMap = new TreeMap<VersionTag, T>(new VersionTagComparator());
        tombstoneMap.put(member, memberMap);
    }
    T oldValue = memberMap.put(tag, entry);
    Assert.assertTrue(oldValue == null);
}
Also used : VersionSource(org.apache.geode.internal.cache.versions.VersionSource) VersionTag(org.apache.geode.internal.cache.versions.VersionTag)

Example 22 with VersionSource

use of org.apache.geode.internal.cache.versions.VersionSource in project geode by apache.

the class RRSynchronizationDUnitTest method doRegionsSyncOnPeerLoss.

/**
   * We hit this problem in bug #45669. delta-GII was not being distributed in the 7.0 release.
   */
public void doRegionsSyncOnPeerLoss(TestType typeOfTest) {
    IgnoredException.addIgnoredException("killing member's ds");
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    VM vm2 = host.getVM(2);
    final String name = this.getUniqueName() + "Region";
    disconnectAllFromDS();
    try {
        createRegion(vm0, name, typeOfTest);
        createRegion(vm1, name, typeOfTest);
        createRegion(vm2, name, typeOfTest);
        createEntry1(vm0);
        // cause one of the VMs to throw away the next operation
        InternalDistributedMember crashedID = getID(vm0);
        VersionSource crashedVersionID = getVersionID(vm0);
        createEntry2(vm1, crashedID, crashedVersionID);
        // Now we crash the member who "modified" vm1's cache.
        // The other replicates should perform a delta-GII for the lost member and
        // get back in sync
        DistributedTestUtils.crashDistributedSystem(vm0);
        verifySynchronized(vm2, crashedID);
    } finally {
        disconnectAllFromDS();
    }
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) VersionSource(org.apache.geode.internal.cache.versions.VersionSource)

Example 23 with VersionSource

use of org.apache.geode.internal.cache.versions.VersionSource in project geode by apache.

the class DistributedPutAllOperation method getEventForPosition.

@Unretained
public EntryEventImpl getEventForPosition(int position) {
    PutAllEntryData entry = this.putAllData[position];
    if (entry == null) {
        return null;
    }
    if (entry.event != null) {
        return entry.event;
    }
    LocalRegion region = (LocalRegion) this.event.getRegion();
    @Retained EntryEventImpl ev = EntryEventImpl.create(region, entry.getOp(), entry.getKey(), null, /* value */
    this.event.getCallbackArgument(), false, /* originRemote */
    this.event.getDistributedMember(), this.event.isGenerateCallbacks(), entry.getEventID());
    boolean returnedEv = false;
    try {
        ev.setPossibleDuplicate(entry.isPossibleDuplicate());
        if (entry.versionTag != null && region.concurrencyChecksEnabled) {
            VersionSource id = entry.versionTag.getMemberID();
            if (id != null) {
                entry.versionTag.setMemberID(ev.getRegion().getVersionVector().getCanonicalId(id));
            }
            ev.setVersionTag(entry.versionTag);
        }
        entry.event = ev;
        returnedEv = true;
        if (entry.getValue() == null && ev.getRegion().getAttributes().getDataPolicy() == DataPolicy.NORMAL) {
            ev.setLocalInvalid(true);
        }
        ev.setNewValue(entry.getValue());
        ev.setOldValue(entry.getOldValue());
        CqService cqService = region.getCache().getCqService();
        if (cqService.isRunning() && !entry.getOp().isCreate() && !ev.hasOldValue()) {
            ev.setOldValueForQueryProcessing();
        }
        ev.setInvokePRCallbacks(!entry.isNotifyOnly());
        if (getBaseEvent().getContext() != null) {
            ev.setContext(getBaseEvent().getContext());
        }
        ev.callbacksInvoked(entry.isCallbacksInvoked());
        ev.setTailKey(entry.getTailKey());
        return ev;
    } finally {
        if (!returnedEv) {
            ev.release();
        }
    }
}
Also used : Retained(org.apache.geode.internal.offheap.annotations.Retained) VersionSource(org.apache.geode.internal.cache.versions.VersionSource) CqService(org.apache.geode.cache.query.internal.cq.CqService) Unretained(org.apache.geode.internal.offheap.annotations.Unretained)

Example 24 with VersionSource

use of org.apache.geode.internal.cache.versions.VersionSource in project geode by apache.

the class DistributedRemoveAllOperation method getEventForPosition.

@Unretained
public EntryEventImpl getEventForPosition(int position) {
    RemoveAllEntryData entry = this.removeAllData[position];
    if (entry == null) {
        return null;
    }
    if (entry.event != null) {
        return entry.event;
    }
    LocalRegion region = (LocalRegion) this.event.getRegion();
    // owned by this.removeAllData once entry.event = ev is done
    @Retained EntryEventImpl ev = EntryEventImpl.create(region, entry.getOp(), entry.getKey(), null, /* value */
    this.event.getCallbackArgument(), false, /* originRemote */
    this.event.getDistributedMember(), this.event.isGenerateCallbacks(), entry.getEventID());
    boolean returnedEv = false;
    try {
        ev.setPossibleDuplicate(entry.isPossibleDuplicate());
        ev.setIsRedestroyedEntry(entry.getRedestroyedEntry());
        if (entry.versionTag != null && region.concurrencyChecksEnabled) {
            VersionSource id = entry.versionTag.getMemberID();
            if (id != null) {
                entry.versionTag.setMemberID(ev.getRegion().getVersionVector().getCanonicalId(id));
            }
            ev.setVersionTag(entry.versionTag);
        }
        entry.event = ev;
        returnedEv = true;
        ev.setOldValue(entry.getOldValue());
        CqService cqService = region.getCache().getCqService();
        if (cqService.isRunning() && !entry.getOp().isCreate() && !ev.hasOldValue()) {
            ev.setOldValueForQueryProcessing();
        }
        ev.setInvokePRCallbacks(!entry.isNotifyOnly());
        if (getBaseEvent().getContext() != null) {
            ev.setContext(getBaseEvent().getContext());
        }
        ev.callbacksInvoked(entry.isCallbacksInvoked());
        ev.setTailKey(entry.getTailKey());
        return ev;
    } finally {
        if (!returnedEv) {
            ev.release();
        }
    }
}
Also used : Retained(org.apache.geode.internal.offheap.annotations.Retained) VersionSource(org.apache.geode.internal.cache.versions.VersionSource) CqService(org.apache.geode.cache.query.internal.cq.CqService) Unretained(org.apache.geode.internal.offheap.annotations.Unretained)

Example 25 with VersionSource

use of org.apache.geode.internal.cache.versions.VersionSource in project geode by apache.

the class CacheClientUpdater method handleTombstoneOperation.

private void handleTombstoneOperation(Message clientMessage) {
    String regionName = "unknown";
    try {
        // not sure why this isn't done by the caller
        int partIdx = 0;
        // see ClientTombstoneMessage.getGFE70Message
        regionName = clientMessage.getPart(partIdx++).getString();
        int op = clientMessage.getPart(partIdx++).getInt();
        LocalRegion region = (LocalRegion) this.cacheHelper.getRegion(regionName);
        if (region == null) {
            if (!quitting()) {
                if (logger.isDebugEnabled()) {
                    logger.debug("{}: Region named {} does not exist", this, regionName);
                }
            }
            return;
        }
        if (logger.isDebugEnabled()) {
            logger.debug("{}: Received tombstone operation for region {} with operation={}", this, region, op);
        }
        if (!region.getConcurrencyChecksEnabled()) {
            return;
        }
        switch(op) {
            case 0:
                Map<VersionSource, Long> regionGCVersions = (Map<VersionSource, Long>) clientMessage.getPart(partIdx++).getObject();
                EventID eventID = (EventID) clientMessage.getPart(partIdx++).getObject();
                region.expireTombstones(regionGCVersions, eventID, null);
                break;
            case 1:
                Set<Object> removedKeys = (Set<Object>) clientMessage.getPart(partIdx++).getObject();
                region.expireTombstoneKeys(removedKeys);
                break;
            default:
                throw new IllegalArgumentException("unknown operation type " + op);
        }
    } catch (Exception e) {
        handleException(": exception while removing tombstones from " + regionName, e);
    }
}
Also used : Set(java.util.Set) LocalRegion(org.apache.geode.internal.cache.LocalRegion) Endpoint(org.apache.geode.cache.client.internal.Endpoint) ServerRefusedConnectionException(org.apache.geode.cache.client.ServerRefusedConnectionException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) CancelException(org.apache.geode.CancelException) GemFireSecurityException(org.apache.geode.security.GemFireSecurityException) InvalidDeltaException(org.apache.geode.InvalidDeltaException) SSLException(javax.net.ssl.SSLException) AuthenticationFailedException(org.apache.geode.security.AuthenticationFailedException) InterruptedIOException(java.io.InterruptedIOException) SocketException(java.net.SocketException) ConcurrentCacheModificationException(org.apache.geode.internal.cache.versions.ConcurrentCacheModificationException) ConnectException(java.net.ConnectException) IOException(java.io.IOException) AuthenticationRequiredException(org.apache.geode.security.AuthenticationRequiredException) VersionSource(org.apache.geode.internal.cache.versions.VersionSource) EventID(org.apache.geode.internal.cache.EventID) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

VersionSource (org.apache.geode.internal.cache.versions.VersionSource)34 VersionTag (org.apache.geode.internal.cache.versions.VersionTag)16 VersionStamp (org.apache.geode.internal.cache.versions.VersionStamp)13 Entry (org.apache.geode.cache.Region.Entry)10 NonTXEntry (org.apache.geode.internal.cache.LocalRegion.NonTXEntry)10 Test (org.junit.Test)10 RegionVersionVector (org.apache.geode.internal.cache.versions.RegionVersionVector)6 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)6 Host (org.apache.geode.test.dunit.Host)5 VM (org.apache.geode.test.dunit.VM)5 HashMap (java.util.HashMap)4 Cache (org.apache.geode.cache.Cache)4 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)4 Region (org.apache.geode.cache.Region)4 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)4 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)4 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)4 Map (java.util.Map)3 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)3 PRLocallyDestroyedException (org.apache.geode.internal.cache.partitioned.PRLocallyDestroyedException)3