use of org.apache.geode.cache.RegionAttributes in project geode by apache.
the class TestObject20 method createServerCacheOne.
/**
* This method creates the server cache
*/
public static Integer createServerCacheOne(Integer maxThreads) throws Exception {
new InstantiatorPropagationDUnitTest().createCache(new Properties());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setMirrorType(MirrorType.KEYS_VALUES);
RegionAttributes attrs = factory.create();
cache.createRegion(REGION_NAME, attrs);
int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
CacheServer server1 = cache.addCacheServer();
server1.setPort(port);
server1.setMaxThreads(maxThreads.intValue());
server1.setNotifyBySubscription(true);
server1.start();
return new Integer(port);
}
use of org.apache.geode.cache.RegionAttributes in project geode by apache.
the class ParallelQueueRemovalMessageJUnitTest method createBucketRegionQueue.
private void createBucketRegionQueue() {
// Create InternalRegionArguments
InternalRegionArguments ira = new InternalRegionArguments();
ira.setPartitionedRegion(this.queueRegion);
ira.setPartitionedRegionBucketRedundancy(1);
BucketAdvisor ba = mock(BucketAdvisor.class);
ira.setBucketAdvisor(ba);
InternalRegionArguments pbrIra = new InternalRegionArguments();
RegionAdvisor ra = mock(RegionAdvisor.class);
when(ra.getPartitionedRegion()).thenReturn(this.queueRegion);
pbrIra.setPartitionedRegionAdvisor(ra);
PartitionAttributes pa = mock(PartitionAttributes.class);
when(this.queueRegion.getPartitionAttributes()).thenReturn(pa);
when(this.queueRegion.getBucketName(eq(BUCKET_ID))).thenAnswer(new Answer<String>() {
@Override
public String answer(final InvocationOnMock invocation) throws Throwable {
return PartitionedRegionHelper.getBucketName(queueRegion.getFullPath(), BUCKET_ID);
}
});
when(this.queueRegion.getDataPolicy()).thenReturn(DataPolicy.PARTITION);
when(pa.getColocatedWith()).thenReturn(null);
// classes cannot be mocked
ProxyBucketRegion pbr = new ProxyBucketRegion(BUCKET_ID, this.queueRegion, pbrIra);
when(ba.getProxyBucketRegion()).thenReturn(pbr);
// Create RegionAttributes
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(DataPolicy.REPLICATE);
factory.setEvictionAttributes(EvictionAttributes.createLRUMemoryAttributes(100, null, EvictionAction.OVERFLOW_TO_DISK));
RegionAttributes attributes = factory.create();
// Create BucketRegionQueue
BucketRegionQueue realBucketRegionQueue = new BucketRegionQueue(this.queueRegion.getBucketName(BUCKET_ID), attributes, this.rootRegion, this.cache, ira);
this.bucketRegionQueue = spy(realBucketRegionQueue);
// (this.queueRegion.getBucketName(BUCKET_ID), attributes, this.rootRegion, this.cache, ira);
EntryEventImpl entryEvent = EntryEventImpl.create(this.bucketRegionQueue, Operation.DESTROY, mock(EventID.class), "value", null, false, mock(DistributedMember.class));
doReturn(entryEvent).when(this.bucketRegionQueue).newDestroyEntryEvent(any(), any());
// when(this.bucketRegionQueue.newDestroyEntryEvent(any(), any())).thenReturn();
this.bucketRegionQueueHelper = new BucketRegionQueueHelper(this.cache, this.queueRegion, this.bucketRegionQueue);
}
use of org.apache.geode.cache.RegionAttributes in project geode by apache.
the class CreateAlterDestroyRegionCommandsDUnitTest method regionAlterGroupTest.
private void regionAlterGroupTest() {
CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, this.alterRegionName);
commandStringBuilder.addOption(CliStrings.ALTER_REGION__GROUP, "Group1");
commandStringBuilder.addOption(CliStrings.ALTER_REGION__EVICTIONMAX, "5764");
CommandResult cmdResult = executeCommand(commandStringBuilder.toString());
assertEquals(Result.Status.OK, cmdResult.getStatus());
String stringResult = commandResultToString(cmdResult);
assertEquals(4, countLinesInString(stringResult, false));
assertEquals(false, stringResult.contains("ERROR"));
assertTrue(stringContainsLine(stringResult, this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
assertTrue(stringContainsLine(stringResult, this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
this.alterVm1.invoke(() -> {
RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
assertEquals(5764, attributes.getEvictionAttributes().getMaximum());
});
this.alterVm2.invoke(() -> {
RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
assertEquals(5764, attributes.getEvictionAttributes().getMaximum());
});
commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_REGION);
commandStringBuilder.addOption(CliStrings.ALTER_REGION__REGION, "/" + this.alterRegionName);
commandStringBuilder.addOption(CliStrings.ALTER_REGION__GROUP, "Group2");
commandStringBuilder.addOption(CliStrings.ALTER_REGION__EVICTIONMAX, "6963");
cmdResult = executeCommand(commandStringBuilder.toString());
assertEquals(Result.Status.OK, cmdResult.getStatus());
stringResult = commandResultToString(cmdResult);
assertEquals(3, countLinesInString(stringResult, false));
assertEquals(false, stringResult.contains("ERROR"));
assertFalse(stringContainsLine(stringResult, this.alterVm1Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
assertTrue(stringContainsLine(stringResult, this.alterVm2Name + ".*Region \"/" + this.alterRegionName + "\" altered.*"));
this.alterVm1.invoke(() -> {
RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
assertEquals(5764, attributes.getEvictionAttributes().getMaximum());
});
this.alterVm2.invoke(() -> {
RegionAttributes attributes = getCache().getRegion(alterRegionName).getAttributes();
assertEquals(6963, attributes.getEvictionAttributes().getMaximum());
});
}
use of org.apache.geode.cache.RegionAttributes in project geode by apache.
the class GlobalRegionCCEOffHeapDUnitTest method getRegionAttributes.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected RegionAttributes getRegionAttributes(String type) {
RegionAttributes ra = super.getRegionAttributes(type);
AttributesFactory factory = new AttributesFactory(ra);
if (!ra.getDataPolicy().isEmpty()) {
factory.setOffHeap(true);
}
return factory.create();
}
use of org.apache.geode.cache.RegionAttributes in project geode by apache.
the class DistributedAckRegionCCEOffHeapDUnitTest method getRegionAttributes.
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
protected RegionAttributes getRegionAttributes(String type) {
RegionAttributes ra = super.getRegionAttributes(type);
AttributesFactory factory = new AttributesFactory(ra);
if (!ra.getDataPolicy().isEmpty()) {
factory.setOffHeap(true);
}
return factory.create();
}
Aggregations