use of org.apache.geode.internal.cache.Conflatable in project geode by apache.
the class HARegionQueueStatsJUnitTest method testExpiryStats.
/**
* This test does the following:<br>
* 1)Create HARegionQueue with expiry time as 1 sec<br>
* 2)Add objects with unique eventids and conflation false and sleep for some time.<br>
* 3)Verify that statistics object is not null<br>
* 4)Verify that total events added matches the eventsEnqued stats<br>
* 5)Verify that eventsExpired stats is same as total events added as all events should have
* expired by 1 sec.
*
* @throws Exception - thrown if any problem occurs in test execution
*/
@Test
public void testExpiryStats() throws Exception {
HARegionQueueAttributes haa = new HARegionQueueAttributes();
haa.setExpiryTime(1);
HARegionQueue rq = createHARegionQueue("testExpiryStats", haa);
Conflatable cf = null;
int totalEvents = 100;
for (int i = 0; i < totalEvents; i++) {
cf = new ConflatableObject("key" + i, "value" + i, new EventID(new byte[] { 1 }, 1, i), false, "testing");
rq.put(cf);
}
Thread.sleep(3000);
HARegionQueueStats stats = rq.stats;
assertNotNull("stats for HARegionQueue found null", stats);
assertEquals("eventsEnqued by stats not equal to the actual number of events added to the queue", totalEvents, stats.getEventsEnqued());
assertEquals("expiredEvents not updated", totalEvents, stats.getEventsExpired());
}
use of org.apache.geode.internal.cache.Conflatable in project geode by apache.
the class HARegionQueueStatsJUnitTest method testRemoveByQrmStats.
/**
* This test does the following:<br>
* 1)Create HARegionQueue.<br>
* 2)Add objects with unique eventids and conflation false<br>
* 3)Remove the events through QRM api ( <code>removeDispatchedEvents(EventID id)</code>) with a
* certain lastDispatchedSeqId<br>
* 4)Verify that statistics object is not null<br>
* 5)Verify that total events added matches the eventsEnqued stats<br>
* 6)Verify that eventsRemovedByQrm stats is same as the number of events removed by QRM (upto the
* event having lastDispatchedSeqId, step 3).
*
* @throws Exception - thrown if any problem occurs in test execution
*/
@Test
public void testRemoveByQrmStats() throws Exception {
HARegionQueue rq = createHARegionQueue("testRemoveByQrmStats");
Conflatable cf = null;
int totalEvents = 100;
for (int i = 0; i < totalEvents; i++) {
cf = new ConflatableObject("key" + i, "value" + i, new EventID(new byte[] { 1 }, 1, i), false, "testing");
rq.put(cf);
}
// call for removal thru QRM api
int lastDispatchedSqId = 20;
EventID id = new EventID(new byte[] { 1 }, 1, lastDispatchedSqId);
rq.removeDispatchedEvents(id);
HARegionQueueStats stats = rq.getStatistics();
assertNotNull("stats for HARegionQueue found null", stats);
assertEquals("eventsEnqued by stats not equal to the actual number of events added to the queue", totalEvents, stats.getEventsEnqued());
assertEquals("eventsRemovedByQrm stats not updated properly", (lastDispatchedSqId + 1), stats.getEventsRemovedByQrm());
}
use of org.apache.geode.internal.cache.Conflatable in project geode by apache.
the class HARegionQueueStatsJUnitTest method testRemoveStats.
/**
* This test does the following:<br>
* 1)Create HARegionQueue.<br>
* 2)Add objects with unique eventids and conflation false<br>
* 3)Do some random peek and peek-batch operations and then call remove()<br>
* 4)Verify that statistics object is not null<br>
* 5)Verify that total events added matches the eventsEnqued stats<br>
* 6)Verify that eventsRemoved stats is same as the maximum batch size peeked in above peek
* operations(step 3).
*
* @throws Exception - thrown if any problem occurs in test execution
*/
@Test
public void testRemoveStats() throws Exception {
HARegionQueue rq = createHARegionQueue("testRemoveStats");
Conflatable cf = null;
int totalEvents = 100;
for (int i = 0; i < totalEvents; i++) {
cf = new ConflatableObject("key" + i, "value" + i, new EventID(new byte[] { 1 }, 1, i), false, "testing");
rq.put(cf);
}
// do some random peek operations.
int maxPeekBatchSize = 50;
rq.peek();
rq.peek(8);
rq.peek(maxPeekBatchSize);
rq.peek(35);
rq.peek();
rq.remove();
HARegionQueueStats stats = rq.getStatistics();
assertNotNull("stats for HARegionQueue found null", stats);
assertEquals("eventsEnqued by stats not equal to the actual number of events added to the queue", totalEvents, stats.getEventsEnqued());
assertEquals("All the events peeked were not removed", maxPeekBatchSize, stats.getEventsRemoved());
}
use of org.apache.geode.internal.cache.Conflatable in project geode by apache.
the class HARegionQueueStatsJUnitTest method testVoidRemovalStats.
/**
* This test does the following:<br>
* 1)Create HARegionQueue.<br>
* 2)Add objects with unique eventids and conflation false<br>
* 3)peek a batch to peek all the events added and take() all the events<br>
* 4)Call remove()<br>
* 5)Verify that statistics object is not null<br>
* 6)Verify that total events added matches the eventsEnqued stats<br>
* 7)Verify that numVoidRemovals stats is same as the total events added since all the peeked
* events were removed by take() call and remove() was a void operation.
*
* @throws Exception - thrown if any problem occurs in test execution
*/
@Test
public void testVoidRemovalStats() throws Exception {
HARegionQueue rq = createHARegionQueue("testVoidRemovalStats");
Conflatable cf = null;
int totalEvents = 100;
for (int i = 0; i < totalEvents; i++) {
cf = new ConflatableObject("key" + i, "value" + i, new EventID(new byte[] { 1 }, 1, i), false, "testing");
rq.put(cf);
}
rq.peek(totalEvents);
rq.take(totalEvents);
rq.remove();
HARegionQueueStats stats = rq.getStatistics();
assertNotNull("stats for HARegionQueue found null", stats);
assertEquals("eventsEnqued by stats not equal to the actual number of events added to the queue", totalEvents, stats.getEventsEnqued());
assertEquals("Number of void removals shud be equal to total peeked since all the events were removed by take() before remove()", totalEvents, stats.getNumVoidRemovals());
}
use of org.apache.geode.internal.cache.Conflatable in project geode by apache.
the class HARegionQueueStatsJUnitTest method testPutStatsNoConflation.
/**
* This test does the following:<br>
* 1)Create HARegionQueue<br>
* 2)Add objects with unique eventids and conflation false <br>
* 3)Verify that statistics object is not null<br>
* 4)Verify that total events added matches the eventsEnqued stats<br>
* 5)Verify that eventsConflated stats is zero.
*
* @throws Exception - thrown if any problem occurs in test execution
*/
@Test
public void testPutStatsNoConflation() throws Exception {
HARegionQueue rq = createHARegionQueue("testPutStatsNoConflation");
Conflatable cf = null;
int totalEvents = 100;
for (int i = 0; i < totalEvents; i++) {
cf = new ConflatableObject("key" + i, "value" + i, new EventID(new byte[] { 1 }, 1, i), false, "testing");
rq.put(cf);
}
HARegionQueueStats stats = rq.getStatistics();
assertNotNull("stats for HARegionQueue found null", stats);
assertEquals("eventsEnqued by stats not equal to the actual number of events added to the queue", totalEvents, stats.getEventsEnqued());
assertEquals("eventsConflated by stats not equal zero", 0, stats.getEventsConflated());
}
Aggregations