use of org.apache.geode.cache.AttributesFactory in project geode by apache.
the class ClientCacheCreation method createClientDefaults.
private static RegionAttributes createClientDefaults() {
AttributesFactory af = new AttributesFactory();
af.setScope(Scope.LOCAL);
// af.setIgnoreJTA(true); In 6.6 and later releases client regions support JTA
af.setSubscriptionAttributes(new SubscriptionAttributes(InterestPolicy.ALL));
return af.create();
}
use of org.apache.geode.cache.AttributesFactory in project geode by apache.
the class RegionCreation method createRoot.
/**
* Creates a root {@link Region} in a given <code>Cache</code> based on the description provided
* by this <code>RegionCreation</code>.
*
* @throws TimeoutException
* @throws CacheWriterException
* @throws RegionExistsException
*/
void createRoot(Cache cache) throws TimeoutException, CacheWriterException, RegionExistsException {
Region root = null;
// Validate the attributes before creating the root region
this.attrs.inheritAttributes(cache);
this.attrs.setIndexes(this.indexes);
this.attrs.prepareForValidation();
extensionPoint.beforeCreate(cache);
try {
root = ((InternalCache) cache).basicCreateRegion(this.name, new AttributesFactory(this.attrs).create());
} catch (RegionExistsException ex) {
root = ex.getRegion();
setMutableAttributes(root);
} catch (RegionDestroyedException ex) {
// Region was concurrently destroyed.
cache.getLoggerI18n().warning(LocalizedStrings.RegionCreation_REGION_DESTROYED_DURING_INITIALIZATION, this.name);
// do nothing
}
if (root != null) {
fillIn(root);
}
}
use of org.apache.geode.cache.AttributesFactory in project geode by apache.
the class GeodeRedisServer method initializeRedis.
private void initializeRedis() {
synchronized (this.cache) {
Region<ByteArrayWrapper, ByteArrayWrapper> stringsRegion;
Region<ByteArrayWrapper, HyperLogLogPlus> hLLRegion;
Region<String, RedisDataType> redisMetaData;
InternalCache gemFireCache = (InternalCache) cache;
try {
if ((stringsRegion = cache.getRegion(STRING_REGION)) == null) {
RegionFactory<ByteArrayWrapper, ByteArrayWrapper> regionFactory = gemFireCache.createRegionFactory(this.DEFAULT_REGION_TYPE);
stringsRegion = regionFactory.create(STRING_REGION);
}
if ((hLLRegion = cache.getRegion(HLL_REGION)) == null) {
RegionFactory<ByteArrayWrapper, HyperLogLogPlus> regionFactory = gemFireCache.createRegionFactory(this.DEFAULT_REGION_TYPE);
hLLRegion = regionFactory.create(HLL_REGION);
}
if ((redisMetaData = cache.getRegion(REDIS_META_DATA_REGION)) == null) {
AttributesFactory af = new AttributesFactory();
af.addCacheListener(metaListener);
af.setDataPolicy(DataPolicy.REPLICATE);
InternalRegionArguments ira = new InternalRegionArguments().setInternalRegion(true).setIsUsedForMetaRegion(true);
redisMetaData = gemFireCache.createVMRegion(REDIS_META_DATA_REGION, af.create(), ira);
}
} catch (IOException | ClassNotFoundException e) {
// only if loading snapshot, not here
InternalGemFireError assErr = new InternalGemFireError(LocalizedStrings.GemFireCache_UNEXPECTED_EXCEPTION.toLocalizedString());
assErr.initCause(e);
throw assErr;
}
this.regionCache = new RegionProvider(stringsRegion, hLLRegion, redisMetaData, expirationFutures, expirationExecutor, this.DEFAULT_REGION_TYPE);
redisMetaData.put(REDIS_META_DATA_REGION, RedisDataType.REDIS_PROTECTED);
redisMetaData.put(HLL_REGION, RedisDataType.REDIS_PROTECTED);
redisMetaData.put(STRING_REGION, RedisDataType.REDIS_PROTECTED);
}
checkForRegions();
}
use of org.apache.geode.cache.AttributesFactory in project geode by apache.
the class CompiledInDUnitTest method createReplicateRegion.
private void createReplicateRegion() {
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(DataPolicy.REPLICATE);
createRegion(this.regionName, this.rootRegionName, factory.create());
}
use of org.apache.geode.cache.AttributesFactory in project geode by apache.
the class LikePredicateJUnitTest method testUndefined.
@Test
public void testUndefined() throws Exception {
String[] queries = { "select * from /pos where status.toUpperCase() like '%ACT%'", "select * from /pos where status.toUpperCase() like 'ACT%'", "select * from /pos where status.toUpperCase() like '%IVE'", "select * from /pos where status.toUpperCase() like 'ACT_VE'", "select * from /pos where status like '%CT%'", "select * from /pos where status like 'ACT%'", "select * from /pos where status like 'ACT_VE'", "select * from /pos where position1.secId like '%B%'", "select * from /pos where position1.secId like 'IB%'", "select * from /pos where position1.secId like 'I_M'", "select * from /pos p, p.positions.values pos where pos.secId like '%B%'", "select * from /pos p, p.positions.values pos where pos.secId like 'IB%'", "select * from /pos p, p.positions.values pos where pos.secId like 'I_M'" };
Cache cache = CacheUtils.getCache();
AttributesFactory attributesFactory = new AttributesFactory();
RegionAttributes regionAttributes = attributesFactory.create();
Region region = cache.createRegion("pos", regionAttributes);
for (int i = 0; i < 10; i++) {
Portfolio p = new Portfolio(i);
if (i % 2 == 0) {
p.status = null;
p.position1 = null;
p.positions = null;
} else {
p.position1 = new Position("IBM", 0);
p.status = "ACTIVE";
}
region.put("key-" + i, p);
}
SelectResults[][] res = new SelectResults[queries.length][2];
QueryService qs = CacheUtils.getCache().getQueryService();
SelectResults results = null;
for (int i = 0; i < queries.length; i++) {
Query q = qs.newQuery(queries[i]);
try {
results = (SelectResults) q.execute();
res[i][0] = results;
} catch (Exception e) {
fail("Query execution failed for query " + queries[i] + " with exception: " + e);
}
if (i < 10) {
assertEquals("Query " + queries[i] + " should return 5 results and not " + results.size(), 5, results.size());
} else {
assertEquals("Query " + queries[i] + " should return 1 results and not " + results.size(), 1, results.size());
}
}
try {
qs.createIndex("status", "status", region.getFullPath());
qs.createIndex("position1secId", "pos1.secId", region.getFullPath());
qs.createIndex("secId", "pos.secId", region.getFullPath() + " pos, pos.secId");
} catch (Exception e) {
fail("Index creation failed");
}
for (int i = 0; i < queries.length; i++) {
Query q = qs.newQuery(queries[i]);
try {
results = (SelectResults) q.execute();
res[i][1] = results;
} catch (Exception e) {
fail("Query execution failed for query " + queries[i] + " with exception: " + e);
}
if (i < 10) {
assertEquals("Query " + queries[i] + " should return 5 results and not " + results.size(), 5, results.size());
} else {
assertEquals("Query " + queries[i] + " should return 1 results and not " + results.size(), 1, results.size());
}
}
CacheUtils.compareResultsOfWithAndWithoutIndex(res);
}
Aggregations