Package org.apache.ignite.events
Class CacheEvent
- java.lang.Object
- 
- org.apache.ignite.events.EventAdapter
- 
- org.apache.ignite.events.CacheEvent
 
 
- 
- All Implemented Interfaces:
- Serializable,- Comparable<Event>,- Event
 
 public class CacheEvent extends EventAdapter In-memory database (cache) event.Grid events are used for notification about what happens within the grid. Note that by design Ignite keeps all events generated on the local node locally and it provides APIs for performing a distributed queries across multiple nodes: - 
          IgniteEvents.remoteQuery(IgnitePredicate, long, int...)- asynchronously querying events occurred on the nodes specified, including remote nodes.
- 
          IgniteEvents.localQuery(IgnitePredicate, int...)- querying only local events stored on this local node.
- 
          IgniteEvents.localListen(IgnitePredicate, int...)- listening to local grid events (events from remote nodes not included).
 IgniteEvents.waitForLocal(IgnitePredicate, int...).Events and PerformanceNote that by default all events in Ignite are enabled and therefore generated and stored by whatever event storage SPI is configured. Ignite can and often does generate thousands events per seconds under the load and therefore it creates a significant additional load on the system. If these events are not needed by the application this load is unnecessary and leads to significant performance degradation.It is highly recommended to enable only those events that your application logic requires by using IgniteConfiguration.getIncludeEventTypes()method in Ignite configuration. Note that certain events are required for Ignite's internal operations and such events will still be generated but not stored by event storage SPI if they are disabled in Ignite configuration.- See Also:
- EventType.EVT_CACHE_STARTED,- EventType.EVT_CACHE_STOPPED,- EventType.EVT_CACHE_NODES_LEFT,- EventType.EVTS_CACHE_LIFECYCLE,- EventType.EVT_CACHE_ENTRY_CREATED,- EventType.EVT_CACHE_ENTRY_DESTROYED,- EventType.EVT_CACHE_ENTRY_EVICTED,- EventType.EVT_CACHE_OBJECT_EXPIRED,- EventType.EVT_CACHE_OBJECT_LOCKED,- EventType.EVT_CACHE_OBJECT_PUT,- EventType.EVT_CACHE_OBJECT_READ,- EventType.EVT_CACHE_OBJECT_REMOVED,- EventType.EVT_CACHE_OBJECT_UNLOCKED,- EventType.EVTS_CACHE, Serialized Form
 
- 
- 
Constructor SummaryConstructors Constructor Description CacheEvent(String cacheName, ClusterNode node, @Nullable ClusterNode evtNode, String msg, int type, int part, boolean near, Object key, IgniteUuid xid, String txLbl, Object lockId, Object newVal, boolean hasNewVal, Object oldVal, boolean hasOldVal, UUID subjId, String cloClsName, String taskName)Constructs cache event.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description StringcacheName()Gets cache name.StringclosureClassName()Gets closure class name (applicable only for TRANSFORM operations).ClusterNodeeventNode()Gets node which initiated cache operation ornullif that node is not available.booleanhasNewValue()Gets flag indicating whether cache entry has new value in case if we only have new value in serialized form in which casenewValue()will returnnull.booleanhasOldValue()Gets flag indicating whether cache entry has old value in case if we only have old value in serialized form in which caseoldValue()will returnnull.booleanisNear()Gets flag indicating whether event happened onnearorpartitionedcache.<K> Kkey()Gets cache entry associated with event.ObjectlockId()ID of the lock if held or null if no lock held.ObjectnewValue()Gets new value for this event.ObjectoldValue()Gets old value associated with this event.intpartition()Gets partition for the event which is the partition the key belongs to.StringshortDisplay()Gets a shortened version oftoString()result.UUIDsubjectId()Gets security subject ID initiated this cache event, if security is enabled.StringtaskName()Gets task name if cache event was caused by an operation initiated within task execution.StringtoString()StringtxLabel()Label of surrounding cache transaction or null if there either is no surrounding transaction or label was not set.IgniteUuidxid()ID of surrounding cache transaction or null if there is no surrounding transaction.
 
- 
- 
- 
Constructor Detail- 
CacheEventpublic CacheEvent(String cacheName, ClusterNode node, @Nullable @Nullable ClusterNode evtNode, String msg, int type, int part, boolean near, Object key, IgniteUuid xid, String txLbl, Object lockId, Object newVal, boolean hasNewVal, Object oldVal, boolean hasOldVal, UUID subjId, String cloClsName, String taskName) Constructs cache event.- Parameters:
- cacheName- Cache name.
- node- Local node.
- evtNode- Event node ID.
- msg- Event message.
- type- Event type.
- part- Partition for the event (usually the partition the key belongs to).
- near- Flag indicating whether event happened on- nearor- partitionedcache.
- key- Cache key.
- xid- Transaction ID.
- txLbl- Transaction label.
- lockId- Lock ID.
- newVal- New value.
- hasNewVal- Flag indicating whether new value is present in case if we don't have it in deserialized form.
- oldVal- Old value.
- hasOldVal- Flag indicating whether old value is present in case if we don't have it in deserialized form.
- subjId- Subject ID.
- cloClsName- Closure class name.
- taskName- Name of the task if cache event was caused by an operation initiated within task execution.
 
 
- 
 - 
Method Detail- 
cacheNamepublic String cacheName() Gets cache name.- Returns:
- Cache name.
 
 - 
partitionpublic int partition() Gets partition for the event which is the partition the key belongs to.- Returns:
- Partition for the event.
 
 - 
isNearpublic boolean isNear() Gets flag indicating whether event happened onnearorpartitionedcache.- Returns:
- Flag indicating whether event happened on nearorpartitionedcache.
 
 - 
eventNodepublic ClusterNode eventNode() Gets node which initiated cache operation ornullif that node is not available.- Returns:
- Node which initiated cache operation or nullif that node is not available.
 
 - 
keypublic <K> K key() Gets cache entry associated with event.- Type Parameters:
- K- Cache entry type.
- Returns:
- Cache entry associated with event.
 
 - 
xidpublic IgniteUuid xid() ID of surrounding cache transaction or null if there is no surrounding transaction.- Returns:
- ID of surrounding cache transaction.
 
 - 
txLabelpublic String txLabel() Label of surrounding cache transaction or null if there either is no surrounding transaction or label was not set.- Returns:
- Label of surrounding cache transaction.
 
 - 
lockIdpublic Object lockId() ID of the lock if held or null if no lock held.- Returns:
- ID of the lock if held.
 
 - 
newValuepublic Object newValue() Gets new value for this event.- Returns:
- New value associated with event (null if event is
      EventType.EVT_CACHE_OBJECT_REMOVED.
 
 - 
oldValuepublic Object oldValue() Gets old value associated with this event.- Returns:
- Old value associated with event.
 
 - 
hasOldValuepublic boolean hasOldValue() Gets flag indicating whether cache entry has old value in case if we only have old value in serialized form in which caseoldValue()will returnnull.- Returns:
- Flag indicating whether there is old value associated with this event.
 
 - 
hasNewValuepublic boolean hasNewValue() Gets flag indicating whether cache entry has new value in case if we only have new value in serialized form in which casenewValue()will returnnull.- Returns:
- Flag indicating whether there is new value associated with this event.
 
 - 
subjectIdpublic UUID subjectId() Gets security subject ID initiated this cache event, if security is enabled. This property is not available forEventType.EVT_CACHE_NODES_LEFT,EventType.EVT_CACHE_ENTRY_EVICTEDandEventType.EVT_CACHE_OBJECT_EXPIREDcache events.- Returns:
- Subject ID if security is enabled, otherwise null.
- See Also:
- IgniteSecurity.enabled()
 
 - 
closureClassNamepublic String closureClassName() Gets closure class name (applicable only for TRANSFORM operations).- Returns:
- Closure class name.
 
 - 
taskNamepublic String taskName() Gets task name if cache event was caused by an operation initiated within task execution.- Returns:
- Task name.
 
 - 
shortDisplaypublic String shortDisplay() Gets a shortened version oftoString()result. Suitable for humans to read.- Specified by:
- shortDisplayin interface- Event
- Overrides:
- shortDisplayin class- EventAdapter
- Returns:
- Shortened version of toString()result.
 
 - 
toStringpublic String toString() - Overrides:
- toStringin class- EventAdapter
 
 
- 
 
-