CqQueryTestListener (Apache Geode 1.7.0)
Date: 2018-09-27

org.apache.geode.cache.query.cq.dunit

## Class CqQueryTestListener

- java.lang.Object
- - org.apache.geode.cache.query.cq.dunit.CqQueryTestListener

- All Implemented Interfaces:
    CacheCallback, Declarable, CqListener, CqStatusListener

      public class CqQueryTestListener
      extends java.lang.Object
      implements CqStatusListener

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `java.util.concurrent.ConcurrentLinkedQueue` | `cqEvents`
    `java.lang.String` | `cqName`
    `protected int` | `cqsConnectedCount`
    `protected int` | `cqsDisconnectedCount`
    `java.util.Set` | `creates`
    `java.util.Set` | `destroys`
    `java.util.Set` | `errors`
    `protected boolean` | `eventClose`
    `protected int` | `eventCreateCount`
    `protected int` | `eventDeleteCount`
    `protected int` | `eventErrorCount`
    `protected int` | `eventInvalidateCount`
    `protected int` | `eventQueryDeleteCount`
    `protected int` | `eventQueryInsertCount`
    `protected int` | `eventQueryInvalidateCount`
    `protected int` | `eventQueryUpdateCount`
    `protected boolean` | `eventRegionClear`
    `protected boolean` | `eventRegionInvalidate`
    `java.util.concurrent.ConcurrentLinkedQueue` | `events`
    `protected int` | `eventUpdateCount`
    `java.util.Set` | `invalidates`
    `protected LogWriter` | `logger`
    `static long` | `MAX_TIME`
    `protected int` | `totalEventCount`
    `java.util.Set` | `updates`
    `static boolean` | `usedForUnitTests`
    `java.lang.String` | `userName`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CqQueryTestListener(LogWriter logger)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Called when the region containing this callback is closed or destroyed, when the cache is closed, or when a callback is removed from a region using an `AttributesMutator`.
    `int` | `getCreateEventCount()`
    `int` | `getDeleteEventCount()`
    `int` | `getErrorEventCount()`
    `void` | `getEventHistory()`
    `java.lang.Object[]` | `getEvents()`
    `int` | `getInvalidateEventCount()`
    `int` | `getQueryDeleteEventCount()`
    `int` | `getQueryInsertEventCount()`
    `int` | `getQueryInvalidateEventCount()`
    `int` | `getQueryUpdateEventCount()`
    `int` | `getTotalEventCount()`
    `int` | `getUpdateEventCount()`
    `void` | `onCqConnected()` Called when the cq establishes a connection with a server
    `void` | `onCqDisconnected()` Called when the cq loses connection with all servers
    `void` | `onError(CqEvent cqEvent)` This method is invoked when there is an error during CQ processing.
    `void` | `onEvent(CqEvent cqEvent)` This method is invoked when an event is occurred on the region that satisfied the query condition of this CQ.
    `void` | `printInfo(boolean printKeys)`
    `boolean` | `waitForClose()`
    `boolean` | `waitForCqsConnectedEvents(int total)`
    `boolean` | `waitForCqsDisconnectedEvents(int total)`
    `boolean` | `waitForCreated(java.lang.Object key)`
    `boolean` | `waitForDestroyed(java.lang.Object key)`
    `boolean` | `waitForError(java.lang.String expectedMessage)`
    `void` | `waitForEvents(int creates, int updates, int deletes, int queryInserts, int queryUpdates, int queryDeletes, int totalEvents)`
    `boolean` | `waitForInvalidated(java.lang.Object key)`
    `boolean` | `waitForRegionClear()`
    `boolean` | `waitForRegionInvalidate()`
    `boolean` | `waitForTotalEvents(int total)`
    `boolean` | `waitForUpdated(java.lang.Object key)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.geode.cache.Declarable

      `init, initialize`

- - ### Field Detail

    - #### logger

          protected final LogWriter logger

    - #### eventCreateCount

          protected volatile int eventCreateCount

    - #### eventUpdateCount

          protected volatile int eventUpdateCount

    - #### eventDeleteCount

          protected volatile int eventDeleteCount

    - #### eventInvalidateCount

          protected volatile int eventInvalidateCount

    - #### eventErrorCount

          protected volatile int eventErrorCount

    - #### totalEventCount

          protected volatile int totalEventCount

    - #### eventQueryInsertCount

          protected volatile int eventQueryInsertCount

    - #### eventQueryUpdateCount

          protected volatile int eventQueryUpdateCount

    - #### eventQueryDeleteCount

          protected volatile int eventQueryDeleteCount

    - #### eventQueryInvalidateCount

          protected volatile int eventQueryInvalidateCount

    - #### cqsConnectedCount

          protected volatile int cqsConnectedCount

    - #### cqsDisconnectedCount

          protected volatile int cqsDisconnectedCount

    - #### eventClose

          protected volatile boolean eventClose

    - #### eventRegionClear

          protected volatile boolean eventRegionClear

    - #### eventRegionInvalidate

          protected volatile boolean eventRegionInvalidate

    - #### destroys

          public final java.util.Set destroys

    - #### creates

          public final java.util.Set creates

    - #### invalidates

          public final java.util.Set invalidates

    - #### updates

          public final java.util.Set updates

    - #### errors

          public final java.util.Set errors

    - #### MAX_TIME

          public static final long MAX_TIME

    - #### cqName

          public java.lang.String cqName

    - #### userName

          public java.lang.String userName

    - #### usedForUnitTests

          public static boolean usedForUnitTests

    - #### events

          public java.util.concurrent.ConcurrentLinkedQueue events

    - #### cqEvents

          public java.util.concurrent.ConcurrentLinkedQueue cqEvents

  - ### Constructor Detail

    - #### CqQueryTestListener

          public CqQueryTestListener(LogWriter logger)

  - ### Method Detail

    - #### onEvent

          public void onEvent(CqEvent cqEvent)

      Description copied from interface: `CqListener`
      This method is invoked when an event is occurred on the region that satisfied the query condition of this CQ. This event does not contain an error. If CQ is executed using ExecuteWithInitialResults the returned result may already include the changes with respect to this event. This could arise when updates are happening on the region while CQ registration is in progress. The CQ does not block any region operation as it could affect the performance of region operation. Its up to the application to synchronize between the region operation and CQ registration to avoid duplicate event being delivered.
      Specified by:
        `onEvent` in interface `CqListener`
      See Also:
        `CqQuery.executeWithInitialResults()`

    - #### onError

          public void onError(CqEvent cqEvent)

      Description copied from interface: `CqListener`
      This method is invoked when there is an error during CQ processing. The error can appear while applying query condition on the event. e.g if the event doesn't has attributes as specified in the CQ query. This event does contain an error. The newValue may or may not be available, and will be null if not available.
      Specified by:
        `onError` in interface `CqListener`

    - #### onCqDisconnected

          public void onCqDisconnected()

      Description copied from interface: `CqStatusListener`
      Called when the cq loses connection with all servers
      Specified by:
        `onCqDisconnected` in interface `CqStatusListener`

    - #### onCqConnected

          public void onCqConnected()

      Description copied from interface: `CqStatusListener`
      Called when the cq establishes a connection with a server
      Specified by:
        `onCqConnected` in interface `CqStatusListener`

    - #### getErrorEventCount

          public int getErrorEventCount()

    - #### getTotalEventCount

          public int getTotalEventCount()

    - #### getCreateEventCount

          public int getCreateEventCount()

    - #### getUpdateEventCount

          public int getUpdateEventCount()

    - #### getDeleteEventCount

          public int getDeleteEventCount()

    - #### getInvalidateEventCount

          public int getInvalidateEventCount()

    - #### getQueryInsertEventCount

          public int getQueryInsertEventCount()

    - #### getQueryUpdateEventCount

          public int getQueryUpdateEventCount()

    - #### getQueryDeleteEventCount

          public int getQueryDeleteEventCount()

    - #### getQueryInvalidateEventCount

          public int getQueryInvalidateEventCount()

    - #### getEvents

          public java.lang.Object[] getEvents()

    - #### close

          public void close()

      Description copied from interface: `CacheCallback`
      Called when the region containing this callback is closed or destroyed, when the cache is closed, or when a callback is removed from a region using an `AttributesMutator`.

      Implementations should cleanup any external resources such as database connections. Any runtime exceptions this method throws will be logged.

      It is possible for this method to be called multiple times on a single callback instance, so implementations must be tolerant of this.

      Specified by:
        `close` in interface `CacheCallback`
      See Also:
        `RegionService.close()`, `Region.close()`, `Region.localDestroyRegion()`, `Region.destroyRegion()`, `AttributesMutator`

    - #### printInfo

          public void printInfo(boolean printKeys)

    - #### waitForCreated

          public boolean waitForCreated(java.lang.Object key)

    - #### waitForTotalEvents

          public boolean waitForTotalEvents(int total)

    - #### waitForDestroyed

          public boolean waitForDestroyed(java.lang.Object key)

    - #### waitForInvalidated

          public boolean waitForInvalidated(java.lang.Object key)

    - #### waitForUpdated

          public boolean waitForUpdated(java.lang.Object key)

    - #### waitForClose

          public boolean waitForClose()

    - #### waitForRegionClear

          public boolean waitForRegionClear()

    - #### waitForRegionInvalidate

          public boolean waitForRegionInvalidate()

    - #### waitForError

          public boolean waitForError(java.lang.String expectedMessage)

    - #### waitForCqsDisconnectedEvents

          public boolean waitForCqsDisconnectedEvents(int total)

    - #### waitForCqsConnectedEvents

          public boolean waitForCqsConnectedEvents(int total)

    - #### waitForEvents

          public void waitForEvents(int creates,
                                    int updates,
                                    int deletes,
                                    int queryInserts,
                                    int queryUpdates,
                                    int queryDeletes,
                                    int totalEvents)

    - #### getEventHistory

          public void getEventHistory()