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));
}
}
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;
}
}
}
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);
}
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;
}
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);
}
Aggregations