use of org.apache.geode.cache.AttributesFactory in project geode by apache.
the class SlowRecDUnitTest method testSizeDisconnect.
/**
* Make sure that exceeding the queue size limit causes a disconnect.
*/
@Test
public void testSizeDisconnect() throws Exception {
final String expected = "org.apache.geode.internal.tcp.ConnectionException: Forced disconnect sent to" + "||java.io.IOException: Broken pipe";
final String addExpected = "<ExpectedException action=add>" + expected + "</ExpectedException>";
final String removeExpected = "<ExpectedException action=remove>" + expected + "</ExpectedException>";
final AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_NO_ACK);
final Region r = createRootRegion("slowrec", factory.create());
final DM dm = getSystem().getDistributionManager();
final DMStats stats = dm.getStats();
// set others before vm0 connects
final Set others = dm.getOtherDistributionManagerIds();
// create receiver in vm0 with queuing enabled
Properties p = new Properties();
p.setProperty(ASYNC_DISTRIBUTION_TIMEOUT, "5");
// 1 meg
p.setProperty(ASYNC_MAX_QUEUE_SIZE, "1");
doCreateOtherVm(p, false);
final Object key = "key";
// .1M async-max-queue-size should give us 10 of these 100K
final int VALUE_SIZE = 1024 * 100;
// msgs before queue full
final byte[] value = new byte[VALUE_SIZE];
int count = 0;
forceQueuing(r);
long queuedMsgs = stats.getAsyncQueuedMsgs();
long queueSize = stats.getAsyncQueueSize();
getCache().getLogger().info(addExpected);
try {
while (stats.getAsyncQueueSizeExceeded() == 0 && stats.getAsyncQueueTimeouts() == 0) {
r.put(key, value);
count++;
if (stats.getAsyncQueueSize() > 0) {
queuedMsgs = stats.getAsyncQueuedMsgs();
queueSize = stats.getAsyncQueueSize();
}
if (count > 100) {
fail("should have exceeded max-queue-size by now");
}
}
LogWriterUtils.getLogWriter().info("After " + count + " " + VALUE_SIZE + " byte puts slowrec mode kicked in but the queue filled when its size reached " + queueSize + " with " + queuedMsgs + " msgs");
// make sure we lost a connection to vm0
WaitCriterion ev = new WaitCriterion() {
public boolean done() {
return dm.getOtherDistributionManagerIds().size() <= others.size() && stats.getAsyncQueueSize() == 0;
}
public String description() {
return "waiting for connection loss";
}
};
Wait.waitForCriterion(ev, 30 * 1000, 200, true);
} finally {
forceQueueFlush();
getCache().getLogger().info(removeExpected);
}
assertEquals(others, dm.getOtherDistributionManagerIds());
assertEquals(0, stats.getAsyncQueueSize());
}
use of org.apache.geode.cache.AttributesFactory in project geode by apache.
the class RemoveAllMultiVmDUnitTest method createMirroredRegion.
// end of createCache
public static void createMirroredRegion() {
try {
AttributesFactory factory = new AttributesFactory();
factory.setDataPolicy(DataPolicy.REPLICATE);
factory.setScope(Scope.DISTRIBUTED_ACK);
RegionAttributes attr = factory.create();
mirroredRegion = cache.createRegion("mirrored", attr);
} catch (Exception ex) {
ex.printStackTrace();
}
}
use of org.apache.geode.cache.AttributesFactory in project geode by apache.
the class DistributedSystemDUnitTest method testIsolatedDistributedSystem.
@Test
public void testIsolatedDistributedSystem() throws Exception {
Properties config = createLonerConfig();
InternalDistributedSystem system = getSystem(config);
// make sure isolated distributed system can still create a cache and region
Cache cache = CacheFactory.create(system);
Region region = cache.createRegion(getUniqueName(), new AttributesFactory().create());
region.put("test", "value");
assertThat(region.get("test")).isEqualTo("value");
}
use of org.apache.geode.cache.AttributesFactory in project geode by apache.
the class DistTXDebugDUnitTest method createPR.
public static void createPR(String partitionedRegionName, Integer redundancy, Integer localMaxMemory, Integer totalNumBuckets, Object colocatedWith, Boolean isPartitionResolver, Boolean concurrencyChecks) {
PartitionAttributesFactory<String, String> paf = new PartitionAttributesFactory();
paf.setRedundantCopies(redundancy);
if (localMaxMemory != null) {
paf.setLocalMaxMemory(localMaxMemory);
}
if (totalNumBuckets != null) {
paf.setTotalNumBuckets(totalNumBuckets);
}
if (colocatedWith != null) {
paf.setColocatedWith((String) colocatedWith);
}
if (isPartitionResolver) {
paf.setPartitionResolver(new CustomerIDPartitionResolver("CustomerIDPartitionResolver"));
}
PartitionAttributes<String, String> prAttr = paf.create();
AttributesFactory<String, String> attr = new AttributesFactory();
attr.setPartitionAttributes(prAttr);
attr.setConcurrencyChecksEnabled(concurrencyChecks);
assertNotNull(basicGetCache());
Region<String, String> pr = basicGetCache().createRegion(partitionedRegionName, attr.create());
assertNotNull(pr);
LogWriterUtils.getLogWriter().info("Partitioned Region " + partitionedRegionName + " created Successfully :" + pr.toString());
}
use of org.apache.geode.cache.AttributesFactory in project geode by apache.
the class DistTXDebugDUnitTest method createRR.
public static void createRR(String replicatedRegionName, boolean empty) {
AttributesFactory af = new AttributesFactory();
af.setScope(Scope.DISTRIBUTED_ACK);
if (empty) {
af.setDataPolicy(DataPolicy.EMPTY);
} else {
af.setDataPolicy(DataPolicy.REPLICATE);
}
// Region rr = basicGetCache().createRegion(replicatedRegionName,
// af.create());
Region rr = basicGetCache().createRegion(replicatedRegionName, af.create());
assertNotNull(rr);
LogWriterUtils.getLogWriter().info("Replicated Region " + replicatedRegionName + " created Successfully :" + rr.toString());
}
Aggregations