Search in sources :

Example 1 with Cache

use of org.apache.geode.cache.Cache in project geode by apache.

the class CompiledSelect method getRegionIteratorSize.

/**
   * Returns the size of region iterator for count(*) on a region without whereclause.
   * 
   * @since GemFire 6.6.2
   */
private int getRegionIteratorSize(ExecutionContext context, CompiledValue collExpr) throws RegionNotFoundException {
    Region region;
    String regionPath = ((CompiledRegion) collExpr).getRegionPath();
    if (context.getBucketRegion() == null) {
        region = context.getCache().getRegion(regionPath);
    } else {
        region = context.getBucketRegion();
    }
    if (region != null) {
        return region.size();
    } else {
        // if we couldn't find the region because the cache is closed, throw
        // a CacheClosedException
        Cache cache = context.getCache();
        if (cache.isClosed()) {
            throw new CacheClosedException();
        }
        throw new RegionNotFoundException(LocalizedStrings.CompiledRegion_REGION_NOT_FOUND_0.toLocalizedString(regionPath));
    }
}
Also used : RegionNotFoundException(org.apache.geode.cache.query.RegionNotFoundException) Region(org.apache.geode.cache.Region) PdxString(org.apache.geode.pdx.internal.PdxString) CacheClosedException(org.apache.geode.cache.CacheClosedException) InternalCache(org.apache.geode.internal.cache.InternalCache) Cache(org.apache.geode.cache.Cache)

Example 2 with Cache

use of org.apache.geode.cache.Cache 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 3 with Cache

use of org.apache.geode.cache.Cache in project geode by apache.

the class RestAPIsAndInterOpsDUnitTest method createRegion.

public void createRegion() {
    Cache cache = GemFireCacheImpl.getInstance();
    assertNotNull(cache);
    RegionFactory<String, Object> rf = cache.createRegionFactory(RegionShortcut.REPLICATE);
    Region<String, Object> region = rf.create(PEOPLE_REGION_NAME);
}
Also used : JSONObject(org.json.JSONObject) Cache(org.apache.geode.cache.Cache) ClientCache(org.apache.geode.cache.client.ClientCache) InternalCache(org.apache.geode.internal.cache.InternalCache)

Example 4 with Cache

use of org.apache.geode.cache.Cache in project geode by apache.

the class PoolImpl method createAuthenticatedCacheView.

public RegionService createAuthenticatedCacheView(Properties properties) {
    if (!this.multiuserSecureModeEnabled) {
        throw new UnsupportedOperationException("Operation not supported when multiuser-authentication is false.");
    }
    if (properties == null || properties.isEmpty()) {
        throw new IllegalArgumentException("Security properties cannot be empty.");
    }
    Cache cache = CacheFactory.getInstance(InternalDistributedSystem.getAnyInstance());
    Properties props = new Properties();
    for (Entry<Object, Object> entry : properties.entrySet()) {
        props.setProperty((String) entry.getKey(), (String) entry.getValue());
    }
    ProxyCache proxy = new ProxyCache(props, (InternalCache) cache, this);
    synchronized (this.proxyCacheList) {
        this.proxyCacheList.add(proxy);
    }
    return proxy;
}
Also used : Properties(java.util.Properties) Cache(org.apache.geode.cache.Cache) InternalCache(org.apache.geode.internal.cache.InternalCache)

Example 5 with Cache

use of org.apache.geode.cache.Cache in project geode by apache.

the class BootstrappingFunction method execute.

@Override
public void execute(FunctionContext context) {
    // Verify that the cache exists before continuing.
    // When this function is executed by a remote membership listener, it is
    // being invoked before the cache is started.
    Cache cache = verifyCacheExists();
    // Register as membership listener
    registerAsMembershipListener(cache);
    // Register functions
    registerFunctions();
    // Return status
    context.getResultSender().lastResult(Boolean.TRUE);
}
Also used : Cache(org.apache.geode.cache.Cache)

Aggregations

Cache (org.apache.geode.cache.Cache)1044 Region (org.apache.geode.cache.Region)478 Test (org.junit.Test)476 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)292 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)277 VM (org.apache.geode.test.dunit.VM)264 Host (org.apache.geode.test.dunit.Host)230 AttributesFactory (org.apache.geode.cache.AttributesFactory)229 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)177 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)176 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)164 LocalRegion (org.apache.geode.internal.cache.LocalRegion)153 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)123 ClientCache (org.apache.geode.cache.client.ClientCache)117 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)112 Properties (java.util.Properties)101 CacheException (org.apache.geode.cache.CacheException)101 RegionAttributes (org.apache.geode.cache.RegionAttributes)99 QueryService (org.apache.geode.cache.query.QueryService)95 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)93