Search in sources :

Example 21 with RegionEntry

use of org.apache.geode.internal.cache.RegionEntry 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 22 with RegionEntry

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

the class MemoryIndexStoreJUnitTest method testAddMappingAddsToBackingMap.

@Test
public void testAddMappingAddsToBackingMap() throws Exception {
    RegionEntry mockEntry1 = mockEntries[0];
    RegionEntry mockEntry2 = mockEntries[1];
    store.addMapping("1", mockEntry1);
    store.addMapping("2", mockEntry2);
    assertEquals(2, numObjectsInStore(store));
    assertTrue(objectContainedIn(store, mockEntry1));
    assertTrue(objectContainedIn(store, mockEntry2));
}
Also used : RegionEntry(org.apache.geode.internal.cache.RegionEntry) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 23 with RegionEntry

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

the class ServerResponseMatrix method checkForValidStateAfterNotification.

public static boolean checkForValidStateAfterNotification(LocalRegion region, Object key, int operation) {
    // 4 nonexistent/destroyed , valid , invalid,local-invalid ,
    // 4 create , update , invalidate, destroy
    boolean[][] matrix = { { true, true, true, true }, { true, true, true, true }, { true, true, true, true }, { true, true, true, true } };
    int cacheEntryState = -1;
    RegionEntry re = region.entries.getEntry(key);
    if (re == null) {
        // nonexistent or destroyed
        cacheEntryState = 0;
    } else {
        Token token = re.getValueAsToken();
        if (token == Token.DESTROYED || token == Token.REMOVED_PHASE1 || token == Token.REMOVED_PHASE2 || token == Token.TOMBSTONE) {
            // destroyed
            cacheEntryState = 0;
        } else if (token == Token.LOCAL_INVALID) {
            // local-invalid
            cacheEntryState = 3;
        } else if (token == Token.INVALID) {
            // invalid
            cacheEntryState = 2;
        } else {
            // valid
            cacheEntryState = 1;
        }
    }
    int notificationState = -1;
    switch(operation) {
        case MessageType.LOCAL_CREATE:
            notificationState = 0;
            break;
        case MessageType.LOCAL_UPDATE:
            notificationState = 1;
            break;
        case MessageType.LOCAL_INVALIDATE:
            notificationState = 2;
            break;
        case MessageType.LOCAL_DESTROY:
            notificationState = 3;
            break;
    }
    return matrix[cacheEntryState][notificationState];
}
Also used : RegionEntry(org.apache.geode.internal.cache.RegionEntry) Token(org.apache.geode.internal.cache.Token)

Example 24 with RegionEntry

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

the class ServerResponseMatrix method checkForValidStateAfterRegisterInterest.

public static boolean checkForValidStateAfterRegisterInterest(LocalRegion region, Object key, Object serverValue) {
    int cacheEntryState = -1;
    RegionEntry re = region.entries.getEntry(key);
    if (re == null) {
        // nonexistent
        cacheEntryState = 0;
    } else {
        Token token = re.getValueAsToken();
        if (token == Token.DESTROYED) {
            // destroyed
            cacheEntryState = 3;
        } else if (token == Token.INVALID) {
            // invalid
            cacheEntryState = 2;
        } else {
            // valid
            cacheEntryState = 1;
        }
    }
    // A matrix During register interest response processing
    // 4 nonexistent, valid , invalid,destroyed
    // 2 invalid, valid
    boolean[][] matrix = { { true, true }, { false, false }, { true, true }, { true, true } };
    // invalid
    int registerInterstResState = 0;
    if (serverValue != null) {
        // valid
        registerInterstResState = 1;
    }
    return matrix[cacheEntryState][registerInterstResState];
}
Also used : RegionEntry(org.apache.geode.internal.cache.RegionEntry) Token(org.apache.geode.internal.cache.Token)

Example 25 with RegionEntry

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

the class RangeIndex method dump.

public String dump() {
    StringBuilder sb = new StringBuilder(toString()).append(" {\n");
    sb.append("Null Values\n");
    Iterator nI = nullMappedEntries.entrySet().iterator();
    while (nI.hasNext()) {
        Map.Entry mapEntry = (Map.Entry) nI.next();
        RegionEntry e = (RegionEntry) mapEntry.getKey();
        Object value = mapEntry.getValue();
        sb.append("  RegionEntry.key = ").append(e.getKey());
        sb.append("  Value.type = ").append(value.getClass().getName());
        if (value instanceof Collection) {
            sb.append("  Value.size = ").append(((Collection) value).size());
        }
        sb.append("\n");
    }
    sb.append(" -----------------------------------------------\n");
    sb.append("Undefined Values\n");
    Iterator uI = undefinedMappedEntries.entrySet().iterator();
    while (uI.hasNext()) {
        Map.Entry mapEntry = (Map.Entry) uI.next();
        RegionEntry e = (RegionEntry) mapEntry.getKey();
        Object value = mapEntry.getValue();
        sb.append("  RegionEntry.key = ").append(e.getKey());
        sb.append("  Value.type = ").append(value.getClass().getName());
        if (value instanceof Collection) {
            sb.append("  Value.size = ").append(((Collection) value).size());
        }
        sb.append("\n");
    }
    sb.append(" -----------------------------------------------\n");
    Iterator i1 = this.valueToEntriesMap.entrySet().iterator();
    while (i1.hasNext()) {
        Map.Entry indexEntry = (Map.Entry) i1.next();
        sb.append(" Key = ").append(indexEntry.getKey()).append("\n");
        sb.append(" Value Type = ").append(" ").append(indexEntry.getValue().getClass().getName()).append("\n");
        if (indexEntry.getValue() instanceof Map) {
            sb.append(" Value Size = ").append(" ").append(((Map) indexEntry.getValue()).size()).append("\n");
        }
        Iterator i2 = ((RegionEntryToValuesMap) indexEntry.getValue()).entrySet().iterator();
        while (i2.hasNext()) {
            Map.Entry mapEntry = (Map.Entry) i2.next();
            RegionEntry e = (RegionEntry) mapEntry.getKey();
            Object value = mapEntry.getValue();
            sb.append("  RegionEntry.key = ").append(e.getKey());
            sb.append("  Value.type = ").append(value.getClass().getName());
            if (value instanceof Collection) {
                sb.append("  Value.size = ").append(((Collection) value).size());
            }
            sb.append("\n");
        // sb.append(" Value.type = ").append(value).append("\n");
        }
        sb.append(" -----------------------------------------------\n");
    }
    sb.append("}// Index ").append(getName()).append(" end");
    return sb.toString();
}
Also used : RegionEntry(org.apache.geode.internal.cache.RegionEntry) IndexStoreEntry(org.apache.geode.cache.query.internal.index.IndexStore.IndexStoreEntry) CloseableIterator(org.apache.geode.internal.cache.persistence.query.CloseableIterator) RuntimeIterator(org.apache.geode.cache.query.internal.RuntimeIterator) Iterator(java.util.Iterator) RegionEntry(org.apache.geode.internal.cache.RegionEntry) Collection(java.util.Collection) Object2ObjectOpenHashMap(it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap) Map(java.util.Map) ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) NavigableMap(java.util.NavigableMap) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) SortedMap(java.util.SortedMap)

Aggregations

RegionEntry (org.apache.geode.internal.cache.RegionEntry)56 Test (org.junit.Test)32 LocalRegion (org.apache.geode.internal.cache.LocalRegion)20 UnitTest (org.apache.geode.test.junit.categories.UnitTest)15 Iterator (java.util.Iterator)13 Region (org.apache.geode.cache.Region)13 VM (org.apache.geode.test.dunit.VM)13 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)11 VersionTag (org.apache.geode.internal.cache.versions.VersionTag)10 Host (org.apache.geode.test.dunit.Host)9 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)9 Map (java.util.Map)8 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)8 CacheException (org.apache.geode.cache.CacheException)7 EntrySnapshot (org.apache.geode.internal.cache.EntrySnapshot)7 CloseableIterator (org.apache.geode.internal.cache.persistence.query.CloseableIterator)7 HashMap (java.util.HashMap)6 HashSet (java.util.HashSet)5 Entry (java.util.Map.Entry)5 Cache (org.apache.geode.cache.Cache)5