use of org.apache.geode.internal.cache.GemFireCacheImpl in project geode by apache.
the class CacheXml66DUnitTest method testTransactionWriter.
/**
* Tests that a region created with a named attributes set programmatically for delta propogation
* has the correct attributes.
*/
@Test
public void testTransactionWriter() throws Exception {
CacheCreation creation = new CacheCreation();
CacheTransactionManagerCreation ctmc = new CacheTransactionManagerCreation();
ctmc.setWriter(new TestTransactionWriter());
creation.addCacheTransactionManagerCreation(ctmc);
testXml(creation);
Cache c = getCache();
assertTrue(c instanceof GemFireCacheImpl);
c.loadCacheXml(generate(creation));
TransactionWriter tw = c.getCacheTransactionManager().getWriter();
assertTrue("tw should be TransactionWriter, but it is:" + tw, tw instanceof TestTransactionWriter);
}
use of org.apache.geode.internal.cache.GemFireCacheImpl in project geode by apache.
the class CacheXml66DUnitTest method testPARTITION_REDUNDANT_PERSISTENT.
@Test
public void testPARTITION_REDUNDANT_PERSISTENT() throws Exception {
CacheCreation cache = new CacheCreation();
RegionCreation root = (RegionCreation) cache.createRegion("prpartition", "PARTITION_REDUNDANT_PERSISTENT");
testXml(cache);
GemFireCacheImpl c = (GemFireCacheImpl) getCache();
Region r = c.getRegion("prpartition");
assertNotNull(r);
RegionAttributes ra = r.getAttributes();
assertEquals(DataPolicy.PERSISTENT_PARTITION, ra.getDataPolicy());
assertNotNull(ra.getPartitionAttributes());
assertEquals(1, ra.getPartitionAttributes().getRedundantCopies());
}
use of org.apache.geode.internal.cache.GemFireCacheImpl in project geode by apache.
the class CacheXml66DUnitTest method testClientLOCAL_PERSISTENT.
@Test
public void testClientLOCAL_PERSISTENT() throws Exception {
ClientCacheCreation cache = new ClientCacheCreation();
RegionCreation root = (RegionCreation) cache.createRegion("cplocal", "LOCAL_PERSISTENT");
testXml(cache);
GemFireCacheImpl c = (GemFireCacheImpl) getCache();
assertEquals(true, c.isClient());
Region r = c.getRegion("cplocal");
assertNotNull(r);
RegionAttributes ra = r.getAttributes();
assertEquals(DataPolicy.PERSISTENT_REPLICATE, ra.getDataPolicy());
assertEquals(Scope.LOCAL, ra.getScope());
assertEquals(null, ra.getPoolName());
}
use of org.apache.geode.internal.cache.GemFireCacheImpl in project geode by apache.
the class CacheXml66DUnitTest method testLOCAL_PERSISTENT.
@Test
public void testLOCAL_PERSISTENT() throws Exception {
CacheCreation cache = new CacheCreation();
RegionCreation root = (RegionCreation) cache.createRegion("plocal", "LOCAL_PERSISTENT");
testXml(cache);
GemFireCacheImpl c = (GemFireCacheImpl) getCache();
Region r = c.getRegion("plocal");
assertNotNull(r);
RegionAttributes ra = r.getAttributes();
assertEquals(DataPolicy.PERSISTENT_REPLICATE, ra.getDataPolicy());
assertEquals(Scope.LOCAL, ra.getScope());
}
use of org.apache.geode.internal.cache.GemFireCacheImpl in project geode by apache.
the class CacheXmlGenerator method parse.
/**
* Called by the transformer to parse the "input source". We ignore the input source and, instead,
* generate SAX events to the {@link #setContentHandler ContentHandler}.
*/
public void parse(InputSource input) throws SAXException {
Assert.assertTrue(this.handler != null);
boolean isClientCache = this.creation instanceof ClientCacheCreation;
handler.startDocument();
AttributesImpl atts = new AttributesImpl();
if (this.useSchema) {
if (null == version.getSchemaLocation()) {
// TODO jbarrett - localize
throw new IllegalStateException("No schema for version " + version.getVersion());
}
// add schema location for cache schema.
handler.startPrefixMapping(W3C_XML_SCHEMA_INSTANCE_PREFIX, W3C_XML_SCHEMA_INSTANCE_NS_URI);
addAttribute(atts, W3C_XML_SCHEMA_INSTANCE_PREFIX, W3C_XML_SCHEMA_INSTANCE_ATTRIBUTE_SCHEMA_LOCATION, version.getNamespace() + " " + version.getSchemaLocation());
// add cache schema to default prefix.
handler.startPrefixMapping(XmlConstants.DEFAULT_PREFIX, version.getNamespace());
addAttribute(atts, VERSION, this.version.getVersion());
}
if (creation.hasLockLease()) {
atts.addAttribute("", "", LOCK_LEASE, "", String.valueOf(creation.getLockLease()));
}
if (creation.hasLockTimeout()) {
atts.addAttribute("", "", LOCK_TIMEOUT, "", String.valueOf(creation.getLockTimeout()));
}
if (creation.hasSearchTimeout()) {
atts.addAttribute("", "", SEARCH_TIMEOUT, "", String.valueOf(creation.getSearchTimeout()));
}
if (this.version.compareTo(CacheXmlVersion.GEMFIRE_5_5) >= 0) {
// TODO
}
if (this.version.compareTo(CacheXmlVersion.GEMFIRE_5_7) >= 0) {
// TODO
}
if (this.version.compareTo(CacheXmlVersion.GEMFIRE_5_8) >= 0) {
// TODO
}
if (this.version.compareTo(CacheXmlVersion.GEMFIRE_6_0) >= 0) {
// TODO
}
if (this.version.compareTo(CacheXmlVersion.GEMFIRE_6_5) >= 0) {
// TODO
}
if (this.version.compareTo(CacheXmlVersion.GEMFIRE_7_0) >= 0) {
// TODO
}
if (this.version.compareTo(CacheXmlVersion.GEMFIRE_7_0) >= 0) {
// TODO
}
if (this.version.compareTo(CacheXmlVersion.GEMFIRE_5_1) >= 0) {
if (creation.hasMessageSyncInterval()) {
atts.addAttribute("", "", MESSAGE_SYNC_INTERVAL, "", String.valueOf(creation.getMessageSyncInterval()));
}
}
if (this.version.compareTo(CacheXmlVersion.GEMFIRE_4_0) >= 0) {
if (creation.hasServer()) {
atts.addAttribute("", "", IS_SERVER, "", String.valueOf(creation.isServer()));
}
if (creation.hasCopyOnRead()) {
atts.addAttribute("", "", COPY_ON_READ, "", String.valueOf(creation.getCopyOnRead()));
}
}
if (isClientCache) {
handler.startElement("", CLIENT_CACHE, CLIENT_CACHE, atts);
} else {
handler.startElement("", CACHE, CACHE, atts);
}
if (this.cache != null) {
if (!isClientCache) {
generate(this.cache.getCacheTransactionManager());
} else if (this.version.compareTo(CacheXmlVersion.GEMFIRE_6_6) >= 0) {
generate(this.cache.getCacheTransactionManager());
}
generateDynamicRegionFactory(this.cache);
if (!isClientCache) {
if (this.version.compareTo(CacheXmlVersion.GEMFIRE_7_0) >= 0) {
Set<GatewaySender> senderSet = cache.getGatewaySenders();
for (GatewaySender sender : senderSet) {
generateGatewaySender(sender);
}
generateGatewayReceiver(this.cache);
generateAsyncEventQueue(this.cache);
}
}
if (!isClientCache && this.version.compareTo(CacheXmlVersion.GEMFIRE_7_0) >= 0) {
if (this.cache.getGatewayConflictResolver() != null) {
generate(GATEWAY_CONFLICT_RESOLVER, this.cache.getGatewayConflictResolver());
}
}
if (!isClientCache) {
for (Iterator iter = this.cache.getCacheServers().iterator(); iter.hasNext(); ) {
CacheServer bridge = (CacheServer) iter.next();
generate(bridge);
}
}
if (this.version.compareTo(CacheXmlVersion.GEMFIRE_5_7) >= 0) {
Iterator pools;
if (this.cache instanceof GemFireCacheImpl) {
pools = PoolManager.getAll().values().iterator();
} else {
pools = this.creation.getPools().values().iterator();
}
while (pools.hasNext()) {
Pool cp = (Pool) pools.next();
generate(cp);
}
}
if (this.version.compareTo(CacheXmlVersion.GEMFIRE_6_5) >= 0) {
if (this.cache instanceof GemFireCacheImpl) {
InternalCache gfc = (InternalCache) this.cache;
for (DiskStore ds : gfc.listDiskStores()) {
generate(ds);
}
} else {
for (DiskStore ds : this.creation.listDiskStores()) {
generate(ds);
}
}
}
if (this.version.compareTo(CacheXmlVersion.GEMFIRE_6_6) >= 0) {
generatePdx();
}
if (this.version.compareTo(CacheXmlVersion.GEMFIRE_4_1) >= 0) {
Map namedAttributes = this.cache.listRegionAttributes();
for (Iterator iter = namedAttributes.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry = (Map.Entry) iter.next();
String id = (String) entry.getKey();
RegionAttributes attrs = (RegionAttributes) entry.getValue();
// Since CacheCreation predefines these even in later versions
// we need to exclude them in all versions.
// It would be better if CacheCreation could only predefine them
// for versions 6.5 and later but that is not easy to do
{
if (this.creation instanceof ClientCacheCreation) {
try {
ClientRegionShortcut.valueOf(id);
// skip this guy since id mapped to one of the enum types
continue;
} catch (IllegalArgumentException ignore) {
// id is not a shortcut so go ahead and call generate
}
} else {
try {
RegionShortcut.valueOf(id);
// skip this guy since id mapped to one of the enum types
continue;
} catch (IllegalArgumentException ignore) {
// id is not a shortcut so go ahead and call generate
}
}
}
generate(id, attrs);
}
}
if (cache instanceof GemFireCacheImpl) {
generateRegions();
} else {
TreeSet rSet = new TreeSet(new RegionComparator());
rSet.addAll(this.cache.rootRegions());
Iterator it = rSet.iterator();
while (it.hasNext()) {
Region root = (Region) it.next();
generateRegion(root);
}
}
if (this.version.compareTo(CacheXmlVersion.GEMFIRE_5_8) >= 0) {
generateFunctionService();
}
if (this.version.compareTo(CacheXmlVersion.GEMFIRE_6_0) >= 0) {
generateResourceManager();
generateSerializerRegistration();
}
if (!isClientCache) {
if (this.version.compareTo(CacheXmlVersion.GEMFIRE_6_5) >= 0) {
if (this.cache instanceof GemFireCacheImpl) {
InternalCache internalCache = (InternalCache) this.cache;
for (File file : internalCache.getBackupFiles()) {
generateBackupFile(file);
}
} else {
for (File file : this.creation.getBackupFiles()) {
generateBackupFile(file);
}
}
}
}
if (this.version.compareTo(CacheXmlVersion.GEMFIRE_6_6) >= 0) {
generateInitializer();
}
}
if (cache instanceof Extensible) {
@SuppressWarnings("unchecked") final Extensible<Cache> extensible = (Extensible<Cache>) cache;
generate(extensible);
}
if (isClientCache) {
handler.endElement("", CLIENT_CACHE, CLIENT_CACHE);
} else {
handler.endElement("", CACHE, CACHE);
}
handler.endDocument();
}
Aggregations