Search in sources :

Example 6 with VersionTagHolder

use of org.apache.geode.internal.cache.VersionTagHolder in project geode by apache.

the class BaseCommand method createVersionTagHolder.

private static VersionTagHolder createVersionTagHolder() {
    VersionTagHolder versionHolder = new VersionTagHolder();
    versionHolder.setOperation(Operation.GET_FOR_REGISTER_INTEREST);
    return versionHolder;
}
Also used : VersionTagHolder(org.apache.geode.internal.cache.VersionTagHolder)

Example 7 with VersionTagHolder

use of org.apache.geode.internal.cache.VersionTagHolder in project geode by apache.

the class DistributedAckRegionCCEDUnitTest method testEntryVersionRollover.

@Test
public void testEntryVersionRollover() throws Exception {
    assumeTrue(getClass() == DistributedAckRegionCCEDUnitTest.class);
    final String name = this.getUniqueName() + "-CC";
    final int numEntries = 1;
    SerializableRunnable createRegion = new SerializableRunnable("Create Region") {

        public void run() {
            try {
                RegionFactory f = getCache().createRegionFactory(getRegionAttributes());
                CCRegion = (LocalRegion) f.create(name);
                for (int i = 0; i < numEntries; i++) {
                    CCRegion.put("cckey" + i, "ccvalue");
                }
                assertEquals("expected no conflated events", 0, CCRegion.getCachePerfStats().getConflatedEventsCount());
            } catch (CacheException ex) {
                org.apache.geode.test.dunit.Assert.fail("While creating region", ex);
            }
        }
    };
    VM vm0 = Host.getHost(0).getVM(0);
    vm0.invoke(createRegion);
    try {
        createRegion.run();
        VersionTag tag = new VMVersionTag();
        // set the version to the max - it should make the system think there's a rollover and reject
        // the change. Then apply it to the cache as if it is a replayed client operation. That should
        // cause the cache to apply the op locally
        tag.setEntryVersion(0xFFFFFF);
        tag.setDistributedSystemId(1);
        tag.setRegionVersion(CCRegion.getVersionVector().getNextVersion());
        VersionTagHolder holder = new VersionTagHolder(tag);
        ClientProxyMembershipID id = ClientProxyMembershipID.getNewProxyMembership(CCRegion.getDistributionManager().getSystem());
        CCRegion.basicBridgePut("cckey0", "newvalue", null, true, null, id, true, holder);
        vm0.invoke(new SerializableRunnable("check conflation count") {

            public void run() {
                assertEquals("expected one conflated event", 1, CCRegion.getCachePerfStats().getConflatedEventsCount());
            }
        });
    } finally {
        disconnectAllFromDS();
    }
}
Also used : ClientProxyMembershipID(org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID) RegionFactory(org.apache.geode.cache.RegionFactory) VersionTagHolder(org.apache.geode.internal.cache.VersionTagHolder) CacheException(org.apache.geode.cache.CacheException) VM(org.apache.geode.test.dunit.VM) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) VMVersionTag(org.apache.geode.internal.cache.versions.VMVersionTag) VersionTag(org.apache.geode.internal.cache.versions.VersionTag) VMVersionTag(org.apache.geode.internal.cache.versions.VMVersionTag) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 8 with VersionTagHolder

use of org.apache.geode.internal.cache.VersionTagHolder in project geode by apache.

the class BaseCommand method appendNewRegisterInterestResponseChunkFromLocal.

public static void appendNewRegisterInterestResponseChunkFromLocal(LocalRegion region, VersionedObjectList values, Object riKeys, Set keySet, ServerConnection servConn) throws IOException {
    ClientProxyMembershipID requestingClient = servConn == null ? null : servConn.getProxyID();
    for (Object key : keySet) {
        VersionTagHolder versionHolder = createVersionTagHolder();
        Object value = region.get(key, null, true, true, true, requestingClient, versionHolder, true);
        updateValues(values, key, value, versionHolder.getVersionTag());
        if (values.size() == MAXIMUM_CHUNK_SIZE) {
            // Send the chunk and clear the list
            // values.setKeys(null); // Now we need to send keys too.
            sendNewRegisterInterestResponseChunk(region, riKeys != null ? riKeys : "ALL_KEYS", values, false, servConn);
            values.clear();
        }
    }
// for
}
Also used : VersionTagHolder(org.apache.geode.internal.cache.VersionTagHolder)

Example 9 with VersionTagHolder

use of org.apache.geode.internal.cache.VersionTagHolder in project geode by apache.

the class Get70 method getValueAndIsObject.

// take the result 3 element "result" as argument instead of
// returning as the result to avoid creating the array repeatedly
// for large number of entries like in getAll. Third element added in
// 7.0 for retrieving version information
public Entry getValueAndIsObject(Region region, Object key, Object callbackArg, ServerConnection servConn) {
    // Region.Entry entry;
    String regionName = region.getFullPath();
    if (servConn != null) {
        servConn.setModificationInfo(true, regionName, key);
    }
    VersionTag versionTag = null;
    // LocalRegion lregion = (LocalRegion)region;
    // entry = lregion.getEntry(key, true);
    boolean isObject = true;
    Object data = null;
    // if (entry != null && region.getAttributes().getConcurrencyChecksEnabled()) {
    // RegionEntry re;
    // if (entry instanceof NonTXEntry) {
    // re = ((NonTXEntry)entry).getRegionEntry();
    // } else if (entry instanceof EntrySnapshot) {
    // re = ((EntrySnapshot)entry).getRegionEntry();
    // } else if (entry instanceof TXEntry) {
    // re = null; // versioning not supported in tx yet
    // data = entry.getValue(); // can I get a serialized form??
    // } else {
    // re = (RegionEntry)entry;
    // }
    // if (re != null) {
    // data = re.getValueInVM();
    // VersionStamp stamp = re.getVersionStamp();
    // if (stamp != null) {
    // versionHolder.setVersionTag(stamp.asVersionTag());
    // }
    // }
    // } else {
    ClientProxyMembershipID id = servConn == null ? null : servConn.getProxyID();
    VersionTagHolder versionHolder = new VersionTagHolder();
    data = ((LocalRegion) region).get(key, callbackArg, true, true, true, id, versionHolder, true);
    // }
    versionTag = versionHolder.getVersionTag();
    // If the value in the VM is a CachedDeserializable,
    // get its value. If it is Token.REMOVED, Token.DESTROYED,
    // Token.INVALID, or Token.LOCAL_INVALID
    // set it to null. If it is NOT_AVAILABLE, get the value from
    // disk. If it is already a byte[], set isObject to false.
    boolean wasInvalid = false;
    if (data instanceof CachedDeserializable) {
        CachedDeserializable cd = (CachedDeserializable) data;
        if (!cd.isSerialized()) {
            // it is a byte[]
            isObject = false;
            data = cd.getDeserializedForReading();
        } else {
            data = cd.getValue();
        }
    } else if (data == Token.REMOVED_PHASE1 || data == Token.REMOVED_PHASE2 || data == Token.DESTROYED) {
        data = null;
    } else if (data == Token.INVALID || data == Token.LOCAL_INVALID) {
        // fix for bug 35884
        data = null;
        wasInvalid = true;
    } else if (data instanceof byte[]) {
        isObject = false;
    }
    Entry result = new Entry();
    result.value = data;
    result.isObject = isObject;
    result.keyNotPresent = !wasInvalid && (data == null || data == Token.TOMBSTONE);
    result.versionTag = versionTag;
    return result;
}
Also used : ClientProxyMembershipID(org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID) VersionTagHolder(org.apache.geode.internal.cache.VersionTagHolder) CachedDeserializable(org.apache.geode.internal.cache.CachedDeserializable) VersionTag(org.apache.geode.internal.cache.versions.VersionTag)

Aggregations

VersionTagHolder (org.apache.geode.internal.cache.VersionTagHolder)9 VersionTag (org.apache.geode.internal.cache.versions.VersionTag)6 ClientProxyMembershipID (org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID)3 CachedDeserializable (org.apache.geode.internal.cache.CachedDeserializable)2 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)2 SuppressWarnings (edu.umd.cs.findbugs.annotations.SuppressWarnings)1 Pattern (java.util.regex.Pattern)1 InternalGemFireError (org.apache.geode.InternalGemFireError)1 CacheException (org.apache.geode.cache.CacheException)1 RegionFactory (org.apache.geode.cache.RegionFactory)1 DistributedSystemDisconnectedException (org.apache.geode.distributed.DistributedSystemDisconnectedException)1 RawValue (org.apache.geode.internal.cache.BucketRegion.RawValue)1 DataLocationException (org.apache.geode.internal.cache.DataLocationException)1 ForceReattemptException (org.apache.geode.internal.cache.ForceReattemptException)1 KeyInfo (org.apache.geode.internal.cache.KeyInfo)1 PartitionedRegionDataStore (org.apache.geode.internal.cache.PartitionedRegionDataStore)1 PrimaryBucketException (org.apache.geode.internal.cache.PrimaryBucketException)1 TXStateProxy (org.apache.geode.internal.cache.TXStateProxy)1 VMVersionTag (org.apache.geode.internal.cache.versions.VMVersionTag)1 Retained (org.apache.geode.internal.offheap.annotations.Retained)1