Search in sources :

Example 91 with LocalRegion

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

the class GetEntryCommand method getValueAndIsObject.

@Override
public void getValueAndIsObject(Region p_region, Object key, Object callbackArg, ServerConnection servConn, Object[] result) {
    Object data = null;
    LocalRegion region = (LocalRegion) p_region;
    Entry entry = region.getEntry(key);
    if (logger.isDebugEnabled()) {
        logger.debug("GetEntryCommand: for key: {} returning entry: {}", key, entry);
    }
    if (entry != null) {
        EntrySnapshot snap = new EntrySnapshot();
        NonLocalRegionEntry re = new NonLocalRegionEntry(entry, region);
        snap.setRegionEntry(re);
        snap.setRegion(region);
        data = snap;
    }
    result[0] = data;
    // isObject is true
    result[1] = true;
}
Also used : Entry(org.apache.geode.cache.Region.Entry) NonLocalRegionEntry(org.apache.geode.internal.cache.NonLocalRegionEntry) LocalRegion(org.apache.geode.internal.cache.LocalRegion) NonLocalRegionEntry(org.apache.geode.internal.cache.NonLocalRegionEntry) EntrySnapshot(org.apache.geode.internal.cache.EntrySnapshot)

Example 92 with LocalRegion

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

the class QueueStateImpl method handleMarker.

public void handleMarker() {
    ArrayList regions = new ArrayList();
    Cache cache = GemFireCacheImpl.getInstance();
    if (cache == null) {
        return;
    }
    Set rootRegions = cache.rootRegions();
    for (Iterator iter1 = rootRegions.iterator(); iter1.hasNext(); ) {
        Region rootRegion = (Region) iter1.next();
        regions.add(rootRegion);
        try {
            // throws RDE
            Set subRegions = rootRegion.subregions(true);
            for (Iterator iter2 = subRegions.iterator(); iter2.hasNext(); ) {
                regions.add(iter2.next());
            }
        } catch (RegionDestroyedException e) {
            // region is gone go to the next one bug 38705
            continue;
        }
    }
    for (Iterator iter = regions.iterator(); iter.hasNext(); ) {
        LocalRegion region = (LocalRegion) iter.next();
        try {
            if (region.getAttributes().getPoolName() != null && region.getAttributes().getPoolName().equals(qManager.getPool().getName())) {
                // can this throw RDE??
                region.handleMarker();
            }
        } catch (RegionDestroyedException e) {
            // region is gone go to the next one bug 38705
            continue;
        }
    }
}
Also used : Set(java.util.Set) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) LocalRegion(org.apache.geode.internal.cache.LocalRegion) Region(org.apache.geode.cache.Region) LocalRegion(org.apache.geode.internal.cache.LocalRegion) Cache(org.apache.geode.cache.Cache)

Example 93 with LocalRegion

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

the class GemFireMemberStatus method initializeRegionSizes.

protected void initializeRegionSizes() {
    Iterator rootRegions = cache.rootRegions().iterator();
    while (rootRegions.hasNext()) {
        LocalRegion rootRegion = (LocalRegion) rootRegions.next();
        if (!(rootRegion instanceof HARegion)) {
            RegionStatus rootRegionStatus = rootRegion instanceof PartitionedRegion ? new PartitionedRegionStatus((PartitionedRegion) rootRegion) : new RegionStatus(rootRegion);
            putRegionStatus(rootRegion.getFullPath(), rootRegionStatus);
            Iterator subRegions = rootRegion.subregions(true).iterator();
            while (subRegions.hasNext()) {
                LocalRegion subRegion = (LocalRegion) subRegions.next();
                RegionStatus subRegionStatus = subRegion instanceof PartitionedRegion ? new PartitionedRegionStatus((PartitionedRegion) subRegion) : new RegionStatus(subRegion);
                putRegionStatus(subRegion.getFullPath(), subRegionStatus);
            }
        }
    }
}
Also used : PartitionedRegionStatus(org.apache.geode.internal.cache.PartitionedRegionStatus) RegionStatus(org.apache.geode.internal.cache.RegionStatus) PartitionedRegionStatus(org.apache.geode.internal.cache.PartitionedRegionStatus) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Iterator(java.util.Iterator) LocalRegion(org.apache.geode.internal.cache.LocalRegion) HARegion(org.apache.geode.internal.cache.HARegion)

Example 94 with LocalRegion

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

the class IndexUtils method getIndexManager.

public static IndexManager getIndexManager(Region region, boolean createIfNotAvailable) {
    if (region == null || region.isDestroyed()) {
        return null;
    }
    LocalRegion lRegion = (LocalRegion) region;
    IndexManager idxMgr = lRegion.getIndexManager();
    if (idxMgr == null && createIfNotAvailable) {
        // JUst before creating new IndexManager.
        if (testHook != null && region instanceof PartitionedRegion) {
            testHook.hook(0);
        }
        Object imSync = lRegion.getIMSync();
        synchronized (imSync) {
            // Double checked locking
            if (lRegion.getIndexManager() == null) {
                idxMgr = new IndexManager(region);
                lRegion.setIndexManager(idxMgr);
            } else {
                idxMgr = lRegion.getIndexManager();
            }
        }
    }
    return idxMgr;
}
Also used : PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) LocalRegion(org.apache.geode.internal.cache.LocalRegion)

Example 95 with LocalRegion

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

the class MemberMBeanBridge method getListOfRegions.

/**
   * @return list of regions
   */
public String[] getListOfRegions() {
    Set<LocalRegion> listOfAppRegions = cache.getApplicationRegions();
    if (listOfAppRegions != null && listOfAppRegions.size() > 0) {
        String[] regionStr = new String[listOfAppRegions.size()];
        int j = 0;
        for (LocalRegion rg : listOfAppRegions) {
            regionStr[j] = rg.getFullPath();
            j++;
        }
        return regionStr;
    }
    return ManagementConstants.NO_DATA_STRING;
}
Also used : LocalRegion(org.apache.geode.internal.cache.LocalRegion)

Aggregations

LocalRegion (org.apache.geode.internal.cache.LocalRegion)243 Test (org.junit.Test)103 Region (org.apache.geode.cache.Region)70 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)54 IOException (java.io.IOException)50 AttributesFactory (org.apache.geode.cache.AttributesFactory)42 VM (org.apache.geode.test.dunit.VM)39 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)38 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)37 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)34 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)34 Cache (org.apache.geode.cache.Cache)31 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)31 Host (org.apache.geode.test.dunit.Host)31 Iterator (java.util.Iterator)29 QueryService (org.apache.geode.cache.query.QueryService)29 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)27 CancelException (org.apache.geode.CancelException)26 CacheException (org.apache.geode.cache.CacheException)26 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)25