Search in sources :

Example 6 with NonTXEntry

use of org.apache.geode.internal.cache.LocalRegion.NonTXEntry in project geode by apache.

the class PdxStringQueryJUnitTest method makeREUpdateInProgress.

public void makeREUpdateInProgress() {
    Iterator entryItr = r.entrySet().iterator();
    while (entryItr.hasNext()) {
        Region.Entry nonTxEntry = (Region.Entry) entryItr.next();
        RegionEntry entry = ((NonTXEntry) nonTxEntry).getRegionEntry();
        entry.setUpdateInProgress(true);
        assertTrue(entry.isUpdateInProgress());
    }
}
Also used : RegionEntry(org.apache.geode.internal.cache.RegionEntry) NonTXEntry(org.apache.geode.internal.cache.LocalRegion.NonTXEntry) IndexStoreEntry(org.apache.geode.cache.query.internal.index.IndexStore.IndexStoreEntry) NonTXEntry(org.apache.geode.internal.cache.LocalRegion.NonTXEntry) CloseableIterator(org.apache.geode.internal.cache.persistence.query.CloseableIterator) Region(org.apache.geode.cache.Region) RegionEntry(org.apache.geode.internal.cache.RegionEntry)

Example 7 with NonTXEntry

use of org.apache.geode.internal.cache.LocalRegion.NonTXEntry in project geode by apache.

the class QueryREUpdateInProgressJUnitTest method putREWithUpdateInProgressTrue.

private void putREWithUpdateInProgressTrue(String region) {
    Region reg = CacheUtils.getRegion(region);
    Portfolio[] values = createPortfoliosAndPositions(numOfEntries);
    int i = 0;
    for (Object val : values) {
        reg.put(i, val);
        i++;
    }
    // Set all RegionEntries to be updateInProgress.
    Iterator entryItr = reg.entrySet().iterator();
    while (entryItr.hasNext()) {
        Region.Entry nonTxEntry = (Region.Entry) entryItr.next();
        RegionEntry entry = ((NonTXEntry) nonTxEntry).getRegionEntry();
        entry.setUpdateInProgress(true);
        assertTrue(entry.isUpdateInProgress());
    }
}
Also used : RegionEntry(org.apache.geode.internal.cache.RegionEntry) NonTXEntry(org.apache.geode.internal.cache.LocalRegion.NonTXEntry) NonTXEntry(org.apache.geode.internal.cache.LocalRegion.NonTXEntry) Portfolio(org.apache.geode.cache.query.data.Portfolio) Iterator(java.util.Iterator) Region(org.apache.geode.cache.Region) RegionEntry(org.apache.geode.internal.cache.RegionEntry)

Example 8 with NonTXEntry

use of org.apache.geode.internal.cache.LocalRegion.NonTXEntry in project geode by apache.

the class RegionEntryFlagsJUnitTest method testUpdateInProgressFlag.

@Test
public void testUpdateInProgressFlag() {
    Region region = CacheUtils.createRegion("testRegion", null, Scope.DISTRIBUTED_ACK);
    // Put one entry in the region.
    region.put(1, 1);
    Set entries = region.entrySet();
    assertEquals(1, entries.size());
    Region.Entry nonTxEntry = (Entry) entries.iterator().next();
    RegionEntry entry = ((NonTXEntry) nonTxEntry).getRegionEntry();
    assertFalse(entry.isUpdateInProgress());
    entry.setUpdateInProgress(true);
    assertTrue(entry.isUpdateInProgress());
    entry.setUpdateInProgress(false);
    assertFalse(entry.isUpdateInProgress());
}
Also used : NonTXEntry(org.apache.geode.internal.cache.LocalRegion.NonTXEntry) Entry(org.apache.geode.cache.Region.Entry) NonTXEntry(org.apache.geode.internal.cache.LocalRegion.NonTXEntry) Set(java.util.Set) Entry(org.apache.geode.cache.Region.Entry) Region(org.apache.geode.cache.Region) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 9 with NonTXEntry

use of org.apache.geode.internal.cache.LocalRegion.NonTXEntry in project geode by apache.

the class RegionEntryFlagsJUnitTest method testNetSearchFlag.

@Test
public void testNetSearchFlag() {
    Region region = CacheUtils.createRegion("testRegion", null, Scope.DISTRIBUTED_ACK);
    // Put one entry in the region.
    region.put(1, 1);
    Set entries = region.entrySet();
    assertEquals(1, entries.size());
    Region.Entry nonTxEntry = (Entry) entries.iterator().next();
    RegionEntry entry = ((NonTXEntry) nonTxEntry).getRegionEntry();
    assertFalse(entry.getValueWasResultOfSearch());
    entry.setValueResultOfSearch(true);
    assertTrue(entry.getValueWasResultOfSearch());
    entry.setValueResultOfSearch(false);
    assertFalse(entry.getValueWasResultOfSearch());
}
Also used : NonTXEntry(org.apache.geode.internal.cache.LocalRegion.NonTXEntry) Entry(org.apache.geode.cache.Region.Entry) NonTXEntry(org.apache.geode.internal.cache.LocalRegion.NonTXEntry) Set(java.util.Set) Entry(org.apache.geode.cache.Region.Entry) Region(org.apache.geode.cache.Region) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 10 with NonTXEntry

use of org.apache.geode.internal.cache.LocalRegion.NonTXEntry in project geode by apache.

the class BaseCommand method appendNewRegisterInterestResponseChunk.

public static void appendNewRegisterInterestResponseChunk(LocalRegion region, VersionedObjectList values, Object riKeys, Set<Map.Entry> set, ServerConnection servConn) throws IOException {
    for (Entry entry : set) {
        if (entry instanceof Region.Entry) {
            // local entries
            VersionTag vt;
            Object key;
            Object value;
            if (entry instanceof EntrySnapshot) {
                vt = ((EntrySnapshot) entry).getVersionTag();
                key = ((EntrySnapshot) entry).getRegionEntry().getKey();
                value = ((EntrySnapshot) entry).getRegionEntry().getValue(null);
                updateValues(values, key, value, vt);
            } else {
                VersionStamp vs = ((NonTXEntry) entry).getRegionEntry().getVersionStamp();
                vt = vs == null ? null : vs.asVersionTag();
                key = entry.getKey();
                value = ((NonTXEntry) entry).getRegionEntry()._getValueRetain(region, true);
                try {
                    updateValues(values, key, value, vt);
                } finally {
                    OffHeapHelper.release(value);
                }
            }
        } else {
            // Map.Entry (remote entries)
            List list = (List) entry.getValue();
            Object value = list.get(0);
            VersionTag tag = (VersionTag) list.get(1);
            updateValues(values, entry.getKey(), value, tag);
        }
        if (values.size() == MAXIMUM_CHUNK_SIZE) {
            // Send the chunk and clear the list
            sendNewRegisterInterestResponseChunk(region, riKeys != null ? riKeys : "ALL_KEYS", values, false, servConn);
            values.clear();
        }
    }
// for
}
Also used : Entry(java.util.Map.Entry) NonTXEntry(org.apache.geode.internal.cache.LocalRegion.NonTXEntry) NonTXEntry(org.apache.geode.internal.cache.LocalRegion.NonTXEntry) VersionTag(org.apache.geode.internal.cache.versions.VersionTag) List(java.util.List) ArrayList(java.util.ArrayList) VersionStamp(org.apache.geode.internal.cache.versions.VersionStamp) EntrySnapshot(org.apache.geode.internal.cache.EntrySnapshot)

Aggregations

NonTXEntry (org.apache.geode.internal.cache.LocalRegion.NonTXEntry)14 VersionTag (org.apache.geode.internal.cache.versions.VersionTag)9 Test (org.junit.Test)8 Region (org.apache.geode.cache.Region)7 Entry (org.apache.geode.cache.Region.Entry)6 VersionStamp (org.apache.geode.internal.cache.versions.VersionStamp)5 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)5 RegionEntry (org.apache.geode.internal.cache.RegionEntry)4 VersionSource (org.apache.geode.internal.cache.versions.VersionSource)4 EntrySnapshot (org.apache.geode.internal.cache.EntrySnapshot)3 LocalRegion (org.apache.geode.internal.cache.LocalRegion)3 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)3 Iterator (java.util.Iterator)2 Set (java.util.Set)2 Host (org.apache.geode.test.dunit.Host)2 VM (org.apache.geode.test.dunit.VM)2 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1