use of org.apache.geode.internal.cache.Conflatable in project geode by apache.
the class HARegionQueueStatsJUnitTest method testTakeStats.
/**
* This test does the following:<br>
* 1)Create HARegionQueue.<br>
* 2)Add objects with unique eventids and conflation false<br>
* 3)Do some take and take-batch operations.<br>
* 4)Verify that statistics object is not null<br>
* 5)Verify that total events added matches the eventsEnqued stats<br>
* 6)Verify that eventsTaken stats is same as the sum of events taken in batch and individually
* (Step 3)
*
* @throws Exception - thrown if any problem occurs in test execution
*/
@Test
public void testTakeStats() throws Exception {
HARegionQueue rq = createHARegionQueue("testTakeStats");
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);
}
int takeInBatch = 50;
int takeOneByOne = 25;
rq.take(takeInBatch);
for (int i = 0; i < takeOneByOne; i++) {
rq.take();
}
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("eventsTaken stats not matching with actual events taken", (takeInBatch + takeOneByOne), stats.getEventsTaken());
}
use of org.apache.geode.internal.cache.Conflatable in project geode by apache.
the class HARegionQueueStatsJUnitTest method testPutStatsConflationEnabled.
/**
* This test does the following:<br>
* 1)Create HARegionQueue<br>
* 2)Add objects with unique eventids and conflation true with same Key. <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 total events added minus 1.
*
* @throws Exception - thrown if any problem occurs in test execution
*/
@Test
public void testPutStatsConflationEnabled() throws Exception {
HARegionQueue rq = createHARegionQueue("testPutStatsConflationEnabled");
Conflatable cf = null;
int totalEvents = 100;
for (int i = 0; i < totalEvents; i++) {
cf = new ConflatableObject("key", "value" + i, new EventID(new byte[] { 1 }, 1, i), true, "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("stats for eventsConflated mismatched", totalEvents - 1, stats.getEventsConflated());
}
use of org.apache.geode.internal.cache.Conflatable in project geode by apache.
the class HARegionQueueStatsJUnitTest method testThreadIdentifierStats.
/**
* This test does the following:<br>
* 1)Create HARegionQueue.<br>
* 2)Add objects with unique eventids as well as ThreadIDs 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 threadIdentifiers stats is same as the number of events added as all the events
* had different ThreadIdentifier objects.
*
* @throws Exception - thrown if any problem occurs in test execution
*/
@Test
public void testThreadIdentifierStats() 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 }, i, 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("threadIdentifiers stats not updated properly", totalEvents, stats.getThreadIdentiferCount());
}
use of org.apache.geode.internal.cache.Conflatable in project geode by apache.
the class HARegionQueueStatsJUnitTest method testSequenceViolationStats.
/**
* This test does the follwing: <br>
* 1)Create HARegionQueue.<br>
* 2)Add objects with unique eventids and conflation false.<br>
* 3)Add some objects with same eventids(sequence ids)- duplicate events.<br>
* 4)Verify that numSequenceViolated stats is same as number of duplicate events.<br>
* 5)Verify that eventsEnqued stats is same as the queue size ( i.e. eventsEnqued stats is not
* updated for duplicate events.)
*
* @throws Exception
*/
@Test
public void testSequenceViolationStats() throws Exception {
HARegionQueue rq = createHARegionQueue("testSequenceViolationStats");
Conflatable cf = null;
int totalEvents = 10;
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);
}
int seqViolated = 3;
for (int i = 0; i < seqViolated; 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("Number of sequence violated by stats not equal to the actual number", seqViolated, stats.getNumSequenceViolated());
assertEquals("Events corresponding to sequence violation not added to the queue but eventsEnqued stats updated for them.", rq.size(), stats.getEventsEnqued());
}
Aggregations