Search in sources :

Example 36 with Conflatable

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());
}
Also used : EventID(org.apache.geode.internal.cache.EventID) Conflatable(org.apache.geode.internal.cache.Conflatable) ClientSubscriptionTest(org.apache.geode.test.junit.categories.ClientSubscriptionTest) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 37 with Conflatable

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());
}
Also used : EventID(org.apache.geode.internal.cache.EventID) Conflatable(org.apache.geode.internal.cache.Conflatable) ClientSubscriptionTest(org.apache.geode.test.junit.categories.ClientSubscriptionTest) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 38 with Conflatable

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());
}
Also used : EventID(org.apache.geode.internal.cache.EventID) Conflatable(org.apache.geode.internal.cache.Conflatable) ClientSubscriptionTest(org.apache.geode.test.junit.categories.ClientSubscriptionTest) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 39 with Conflatable

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());
}
Also used : EventID(org.apache.geode.internal.cache.EventID) Conflatable(org.apache.geode.internal.cache.Conflatable) ClientSubscriptionTest(org.apache.geode.test.junit.categories.ClientSubscriptionTest) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

Conflatable (org.apache.geode.internal.cache.Conflatable)39 EventID (org.apache.geode.internal.cache.EventID)29 ClientSubscriptionTest (org.apache.geode.test.junit.categories.ClientSubscriptionTest)22 Test (org.junit.Test)22 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)21 AtomicLong (java.util.concurrent.atomic.AtomicLong)9 Map (java.util.Map)8 CacheException (org.apache.geode.cache.CacheException)8 HashMap (java.util.HashMap)7 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)7 ConcurrentMap (java.util.concurrent.ConcurrentMap)7 IOException (java.io.IOException)5 List (java.util.List)5 ArrayList (java.util.ArrayList)4 Iterator (java.util.Iterator)4 HashSet (java.util.HashSet)3 Set (java.util.Set)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 EntryEvent (org.apache.geode.cache.EntryEvent)3 CacheListenerAdapter (org.apache.geode.cache.util.CacheListenerAdapter)3