use of org.apache.geode.internal.cache.PartitionAttributesImpl in project geode by apache.
the class CacheXmlParser method startPartitionAttributes.
/**
* When a <code>parition-attributes</code> element is encountered, we push a ParitionAttributes??
* for configuring paritioned storage on the stack.
*/
private void startPartitionAttributes(Attributes atts) {
PartitionAttributesImpl paf = new PartitionAttributesImpl();
String redundancy = atts.getValue(PARTITION_REDUNDANT_COPIES);
if (redundancy != null) {
paf.setRedundantCopies(parseInt(redundancy));
}
String localMaxMem = atts.getValue(LOCAL_MAX_MEMORY);
if (localMaxMem != null) {
paf.setLocalMaxMemory(parseInt(localMaxMem));
}
String totalMaxMem = atts.getValue(TOTAL_MAX_MEMORY);
if (totalMaxMem != null) {
paf.setTotalMaxMemory(parseLong(totalMaxMem));
}
String totalNumBuckets = atts.getValue(TOTAL_NUM_BUCKETS);
if (totalNumBuckets != null) {
paf.setTotalNumBuckets(parseInt(totalNumBuckets));
}
String colocatedWith = atts.getValue(PARTITION_COLOCATED_WITH);
if (colocatedWith != null) {
paf.setColocatedWith(colocatedWith);
}
String recoveryDelay = atts.getValue(RECOVERY_DELAY);
if (recoveryDelay != null) {
paf.setRecoveryDelay(parseInt(recoveryDelay));
}
String startupRecoveryDelay = atts.getValue(STARTUP_RECOVERY_DELAY);
if (startupRecoveryDelay != null) {
paf.setStartupRecoveryDelay(parseInt(startupRecoveryDelay));
}
stack.push(paf);
}
use of org.apache.geode.internal.cache.PartitionAttributesImpl in project geode by apache.
the class CacheXmlParser method endPartitionAttributes.
/**
* When a <code>partition-attributes</code> element is finished, the {@link PartitionAttributes}
* are on top of the stack followed by the {@link RegionAttributesCreation} to which the partition
* attributes are assigned.
*/
private void endPartitionAttributes() {
PartitionAttributesImpl paf = (PartitionAttributesImpl) stack.pop();
paf.validateAttributes();
RegionAttributesCreation rattrs = peekRegionAttributesContext(PARTITION_ATTRIBUTES);
// change the 5.0 default data policy (EMPTY) to the current default
if (rattrs.hasDataPolicy() && rattrs.getDataPolicy().isEmpty() && (this.version.compareTo(CacheXmlVersion.GEMFIRE_5_0) == 0)) {
rattrs.setDataPolicy(PartitionedRegionHelper.DEFAULT_DATA_POLICY);
}
rattrs.setPartitionAttributes(paf);
}
use of org.apache.geode.internal.cache.PartitionAttributesImpl in project geode by apache.
the class CacheXmlParser method endPartitionResolver.
/**
* When a <code>partition-resolver</code> element is finished, the {@link Parameter}s and class
* names are popped off the stack. The <code>PartitionResolver</code> is instantiated and
* initialized with the parameters, if appropriate.
*/
private void endPartitionResolver() {
Declarable d = createDeclarable();
if (!(d instanceof PartitionResolver)) {
throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_1.toLocalizedString(new Object[] { d.getClass().getName(), "PartitionResolver" }));
}
PartitionAttributesImpl pai = peekPartitionAttributesImpl(PARTITION_ATTRIBUTES);
pai.setPartitionResolver((PartitionResolver) d);
}
use of org.apache.geode.internal.cache.PartitionAttributesImpl in project geode by apache.
the class CacheXmlParser method endPartitionListener.
/**
* When a <code>partition-listener</code> element is finished, the {@link Parameter}s and class
* names are popped off the stack. The <code>PartitionListener</code> is instantiated and
* initialized with the parameters, if appropriate.
*/
private void endPartitionListener() {
Declarable d = createDeclarable();
if (!(d instanceof PartitionListener)) {
throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_1.toLocalizedString(new Object[] { d.getClass().getName(), "PartitionListener" }));
}
PartitionAttributesImpl pai = peekPartitionAttributesImpl(PARTITION_ATTRIBUTES);
pai.addPartitionListener((PartitionListener) d);
}
use of org.apache.geode.internal.cache.PartitionAttributesImpl in project geode by apache.
the class PRFunctionExecutionDUnitTest method testRemoteSingleKeyExecution_byName_FunctionInvocationTargetException.
/**
* Test remote execution by a pure accessor which doesn't have the function factory
* present.Function throws the FunctionInvocationTargetException. As this is the case of HA then
* system should retry the function execution. After 5th attempt function will send Boolean as
* last result.
*/
@Test
public void testRemoteSingleKeyExecution_byName_FunctionInvocationTargetException() throws Exception {
final String rName = getUniqueName();
Host host = Host.getHost(0);
final VM accessor = host.getVM(2);
final VM datastore = host.getVM(3);
getCache();
accessor.invoke(new SerializableCallable("Create PR") {
public Object call() throws Exception {
RegionAttributes ra = PartitionedRegionTestHelper.createRegionAttrsForPR(0, 0);
getCache().createRegion(rName, ra);
return Boolean.TRUE;
}
});
datastore.invoke(new SerializableCallable("Create PR with Function Factory") {
public Object call() throws Exception {
RegionAttributes ra = PartitionedRegionTestHelper.createRegionAttrsForPR(0, 10);
AttributesFactory raf = new AttributesFactory(ra);
PartitionAttributesImpl pa = new PartitionAttributesImpl();
pa.setAll(ra.getPartitionAttributes());
raf.setPartitionAttributes(pa);
getCache().createRegion(rName, raf.create());
Function function = new TestFunction(true, TestFunction.TEST_FUNCTION_REEXECUTE_EXCEPTION);
FunctionService.registerFunction(function);
return Boolean.TRUE;
}
});
accessor.invoke(new SerializableCallable("Create data, invoke exectuable") {
public Object call() throws Exception {
PartitionedRegion pr = (PartitionedRegion) getCache().getRegion(rName);
final String testKey = "execKey";
final Set testKeysSet = new HashSet();
testKeysSet.add(testKey);
DistributedSystem.setThreadsSocketPolicy(false);
Function function = new TestFunction(true, TestFunction.TEST_FUNCTION_REEXECUTE_EXCEPTION);
FunctionService.registerFunction(function);
Execution dataSet = FunctionService.onRegion(pr);
pr.put(testKey, new Integer(1));
try {
ResultCollector rs1 = dataSet.withFilter(testKeysSet).setArguments(Boolean.TRUE).execute(function.getId());
List list = (ArrayList) rs1.getResult();
assertEquals(list.get(0), 5);
} catch (Throwable e) {
e.printStackTrace();
Assert.fail("This is not expected Exception", e);
}
return Boolean.TRUE;
}
});
}
Aggregations