sprint-1 - Renamed events.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/2f1c7b39 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/2f1c7b39 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/2f1c7b39 Branch: refs/heads/ignite-188 Commit: 2f1c7b3952a747095a33764fbea3240f5539d635 Parents: 2133af1 Author: Dmitiry Setrakyan <dsetrak...@gridgain.com> Authored: Thu Feb 5 19:29:41 2015 -0800 Committer: Dmitiry Setrakyan <dsetrak...@gridgain.com> Committed: Thu Feb 5 19:29:42 2015 -0800 ---------------------------------------------------------------------- examples/config/example-cache.xml | 2 +- examples/config/example-compute.xml | 2 +- .../examples/datagrid/CacheEventsExample.java | 10 +- .../ignite/examples/events/EventsExample.java | 14 +- .../examples/misc/springbean/spring-bean.xml | 2 +- .../scalar/examples/ScalarCacheExample.scala | 8 +- .../apache/ignite/gridify/AbstractAopTest.java | 6 +- .../optimized/OptimizedMarshallerAopTest.java | 6 +- .../internal/TaskEventSubjectIdSelfTest.java | 32 +- .../src/test/resources/spring-server-node.xml | 6 +- .../java/org/apache/ignite/IgniteEvents.java | 16 +- .../affinity/CacheAffinityFunctionContext.java | 2 +- .../fair/CachePartitionFairAffinity.java | 4 +- .../ignite/cache/query/CacheQueryType.java | 6 +- .../configuration/IgniteConfiguration.java | 10 +- .../ignite/events/AuthenticationEvent.java | 172 +++ .../ignite/events/AuthorizationEvent.java | 146 +++ .../org/apache/ignite/events/CacheEvent.java | 331 +++++ .../ignite/events/CachePreloadingEvent.java | 172 +++ .../ignite/events/CacheQueryExecutedEvent.java | 237 ++++ .../ignite/events/CacheQueryReadEvent.java | 299 +++++ .../apache/ignite/events/CheckpointEvent.java | 122 ++ .../apache/ignite/events/DeploymentEvent.java | 118 ++ .../apache/ignite/events/DiscoveryEvent.java | 165 +++ .../java/org/apache/ignite/events/Event.java | 154 +++ .../org/apache/ignite/events/EventAdapter.java | 168 +++ .../apache/ignite/events/EventLocalOrder.java | 44 + .../org/apache/ignite/events/EventType.java | 1146 ++++++++++++++++++ .../events/IgniteAuthenticationEvent.java | 172 --- .../ignite/events/IgniteAuthorizationEvent.java | 146 --- .../apache/ignite/events/IgniteCacheEvent.java | 331 ----- .../events/IgniteCachePreloadingEvent.java | 172 --- .../events/IgniteCacheQueryExecutedEvent.java | 237 ---- .../events/IgniteCacheQueryReadEvent.java | 299 ----- .../ignite/events/IgniteCheckpointEvent.java | 122 -- .../ignite/events/IgniteDeploymentEvent.java | 118 -- .../ignite/events/IgniteDiscoveryEvent.java | 165 --- .../org/apache/ignite/events/IgniteEvent.java | 154 --- .../ignite/events/IgniteEventAdapter.java | 168 --- .../ignite/events/IgniteEventLocalOrder.java | 44 - .../apache/ignite/events/IgniteEventType.java | 1146 ------------------ .../org/apache/ignite/events/IgniteFsEvent.java | 22 +- .../apache/ignite/events/IgniteJobEvent.java | 236 ---- .../ignite/events/IgniteLicenseEvent.java | 116 -- .../ignite/events/IgniteSecureSessionEvent.java | 154 --- .../ignite/events/IgniteSwapSpaceEvent.java | 104 -- .../apache/ignite/events/IgniteTaskEvent.java | 168 --- .../java/org/apache/ignite/events/JobEvent.java | 236 ++++ .../org/apache/ignite/events/LicenseEvent.java | 116 ++ .../ignite/events/SecureSessionEvent.java | 154 +++ .../apache/ignite/events/SwapSpaceEvent.java | 104 ++ .../org/apache/ignite/events/TaskEvent.java | 168 +++ .../internal/GridEventConsumeHandler.java | 28 +- .../ignite/internal/IgniteEventsImpl.java | 22 +- .../internal/managers/GridManagerAdapter.java | 2 +- .../checkpoint/GridCheckpointManager.java | 4 +- .../managers/communication/GridIoManager.java | 8 +- .../deployment/GridDeploymentCommunication.java | 8 +- .../deployment/GridDeploymentLocalStore.java | 8 +- .../GridDeploymentPerLoaderStore.java | 12 +- .../GridDeploymentPerVersionStore.java | 12 +- .../discovery/GridDiscoveryManager.java | 17 +- .../eventstorage/GridEventStorageManager.java | 58 +- .../eventstorage/GridEventStorageMessage.java | 8 +- .../eventstorage/GridLocalEventListener.java | 2 +- .../swapspace/GridSwapSpaceManager.java | 4 +- .../affinity/GridAffinityAssignmentCache.java | 2 +- .../affinity/GridAffinityProcessor.java | 8 +- .../GridCacheAffinityFunctionContextImpl.java | 6 +- .../processors/cache/GridCacheAdapter.java | 2 +- .../cache/GridCacheAffinityManager.java | 2 +- .../cache/GridCacheDeploymentManager.java | 6 +- .../processors/cache/GridCacheEventManager.java | 8 +- .../cache/GridCacheEvictionManager.java | 18 +- .../processors/cache/GridCacheMapEntry.java | 2 +- .../processors/cache/GridCacheMvccManager.java | 8 +- .../GridCachePartitionExchangeManager.java | 12 +- .../processors/cache/GridCacheSwapManager.java | 2 +- .../distributed/GridDistributedCacheEntry.java | 2 +- .../distributed/dht/GridDhtLocalPartition.java | 2 +- .../distributed/dht/GridDhtLockFuture.java | 2 +- .../distributed/dht/GridDhtTxPrepareFuture.java | 2 +- .../colocated/GridDhtColocatedLockFuture.java | 2 +- .../dht/preloader/GridDhtForceKeysFuture.java | 4 +- .../preloader/GridDhtPartitionDemandPool.java | 6 +- .../preloader/GridDhtPartitionExchangeId.java | 2 +- .../GridDhtPartitionsExchangeFuture.java | 12 +- .../dht/preloader/GridDhtPreloader.java | 8 +- .../distributed/near/GridNearCacheEntry.java | 2 +- .../distributed/near/GridNearLockFuture.java | 2 +- .../cache/local/GridLocalCacheEntry.java | 2 +- .../query/GridCacheDistributedQueryManager.java | 6 +- .../cache/query/GridCacheQueryManager.java | 24 +- .../GridCacheContinuousQueryHandler.java | 6 +- .../GridCacheContinuousQueryManager.java | 2 +- .../cache/transactions/IgniteTxAdapter.java | 2 +- .../transactions/IgniteTxLocalAdapter.java | 2 +- .../cache/transactions/IgniteTxManager.java | 8 +- .../cache/version/GridCacheVersionManager.java | 6 +- .../clock/GridClockSyncProcessor.java | 16 +- .../continuous/GridContinuousProcessor.java | 8 +- .../dataload/IgniteDataLoaderImpl.java | 6 +- .../processors/fs/GridGgfsDataManager.java | 6 +- .../processors/fs/GridGgfsDeleteWorker.java | 2 +- .../fs/GridGgfsFragmentizerManager.java | 14 +- .../internal/processors/fs/GridGgfsImpl.java | 6 +- .../processors/fs/GridGgfsMetaManager.java | 2 +- .../processors/job/GridJobProcessor.java | 20 +- .../internal/processors/job/GridJobWorker.java | 4 +- .../handlers/task/GridTaskCommandHandler.java | 8 +- .../service/GridServiceProcessor.java | 6 +- .../processors/streamer/IgniteStreamerImpl.java | 6 +- .../processors/task/GridTaskProcessor.java | 8 +- .../processors/task/GridTaskWorker.java | 6 +- .../ignite/internal/util/IgniteUtils.java | 8 +- .../GridTcpCommunicationMessageAdapter.java | 2 +- .../ignite/internal/util/lang/GridFunc.java | 40 +- .../apache/ignite/internal/util/typedef/PE.java | 6 +- .../event/VisorGridAuthenticationEvent.java | 2 +- .../event/VisorGridAuthorizationEvent.java | 2 +- .../visor/event/VisorGridDeploymentEvent.java | 2 +- .../visor/event/VisorGridDiscoveryEvent.java | 2 +- .../internal/visor/event/VisorGridEvent.java | 2 +- .../visor/event/VisorGridEventsLost.java | 2 +- .../internal/visor/event/VisorGridJobEvent.java | 2 +- .../visor/event/VisorGridLicenseEvent.java | 2 +- .../visor/event/VisorGridTaskEvent.java | 2 +- .../node/VisorNodeEventsCollectorTask.java | 64 +- .../internal/visor/util/VisorTaskUtils.java | 44 +- .../segmentation/GridSegmentationPolicy.java | 6 +- .../org/apache/ignite/spi/IgniteSpiAdapter.java | 10 +- .../org/apache/ignite/spi/IgniteSpiContext.java | 4 +- .../checkpoint/cache/CacheCheckpointSpi.java | 6 +- .../jobstealing/JobStealingCollisionSpi.java | 8 +- .../communication/tcp/TcpCommunicationSpi.java | 8 +- .../ignite/spi/discovery/DiscoverySpi.java | 2 +- .../spi/discovery/DiscoverySpiListener.java | 2 +- .../spi/discovery/DiscoverySpiOrderSupport.java | 2 +- .../discovery/tcp/TcpClientDiscoverySpi.java | 6 +- .../spi/discovery/tcp/TcpDiscoverySpi.java | 4 +- .../spi/eventstorage/EventStorageSpi.java | 6 +- .../memory/MemoryEventStorageSpi.java | 20 +- .../adaptive/AdaptiveLoadBalancingSpi.java | 10 +- .../RoundRobinGlobalLoadBalancer.java | 8 +- .../roundrobin/RoundRobinLoadBalancingSpi.java | 8 +- .../WeightedRandomLoadBalancingSpi.java | 10 +- .../spi/swapspace/SwapSpaceSpiListener.java | 2 +- .../spi/swapspace/file/FileSwapSpaceSpi.java | 2 +- .../spring-cache-client-benchmark-1.xml | 6 +- modules/core/src/test/config/example-cache.xml | 2 +- modules/core/src/test/config/ggfs-loopback.xml | 6 +- modules/core/src/test/config/ggfs-shmem.xml | 6 +- .../src/test/config/load/cache-benchmark.xml | 6 +- .../test/config/load/cache-client-benchmark.xml | 6 +- .../GridCachePartitionFairAffinitySelfTest.java | 10 +- .../GridGgfsEventsAbstractSelfTest.java | 82 +- .../ignite/internal/ClusterMetricsSelfTest.java | 12 +- .../internal/ClusterNodeMetricsSelfTest.java | 10 +- .../ignite/internal/GridDeploymentSelfTest.java | 6 +- .../internal/GridDiscoveryEventSelfTest.java | 38 +- .../ignite/internal/GridDiscoverySelfTest.java | 6 +- .../GridEventStorageCheckAllEventsSelfTest.java | 40 +- ...ventStorageRuntimeConfigurationSelfTest.java | 14 +- .../internal/GridEventStorageSelfTest.java | 34 +- .../GridFailedInputParametersSelfTest.java | 2 +- .../internal/GridJobSubjectIdSelfTest.java | 8 +- .../GridKernalConcurrentAccessStopSelfTest.java | 6 +- .../GridLocalEventListenerSelfTest.java | 8 +- .../GridMultipleVersionsDeploymentSelfTest.java | 6 +- .../internal/GridNonHistoryMetricsSelfTest.java | 6 +- .../internal/GridProjectionAbstractTest.java | 16 +- .../internal/GridRuntimeExceptionSelfTest.java | 20 +- .../internal/GridSameVmStartupSelfTest.java | 12 +- .../internal/GridSpiExceptionSelfTest.java | 6 +- .../GridTaskCancelSingleNodeSelfTest.java | 6 +- .../internal/GridTaskJobRejectSelfTest.java | 22 +- .../internal/GridTaskTimeoutSelfTest.java | 8 +- .../GridCheckpointManagerAbstractSelfTest.java | 10 +- .../GridDiscoveryManagerAliveCacheSelfTest.java | 10 +- .../events/GridEventStorageManagerSelfTest.java | 12 +- .../swapspace/GridSwapSpaceManagerSelfTest.java | 10 +- .../cache/GridCacheAbstractFullApiSelfTest.java | 10 +- .../cache/GridCacheBasicApiAbstractTest.java | 6 +- .../GridCacheEvictionEventAbstractTest.java | 10 +- .../GridCacheExAbstractFullApiSelfTest.java | 6 +- .../GridCacheGroupLockAbstractSelfTest.java | 8 +- .../cache/GridCacheOffHeapSelfTest.java | 10 +- .../GridCachePreloadingEvictionsSelfTest.java | 6 +- .../cache/GridCacheSwapReloadSelfTest.java | 10 +- .../GridCacheBasicOpAbstractTest.java | 8 +- .../distributed/GridCacheEventAbstractTest.java | 8 +- ...heExpiredEntriesPreloadAbstractSelfTest.java | 4 +- .../GridCacheMultiNodeAbstractTest.java | 6 +- .../GridCacheMultiNodeLockAbstractTest.java | 16 +- .../GridCacheNodeFailureAbstractTest.java | 10 +- .../GridCachePreloadEventsAbstractSelfTest.java | 10 +- .../GridCachePreloadLifecycleAbstractTest.java | 2 +- .../GridCacheTransformEventSelfTest.java | 20 +- ...GridCacheDhtEvictionNearReadersSelfTest.java | 14 +- .../dht/GridCacheDhtEvictionSelfTest.java | 20 +- .../dht/GridCacheDhtPreloadDelayedSelfTest.java | 24 +- .../GridCacheDhtPreloadDisabledSelfTest.java | 6 +- ...ridCacheDhtPreloadMultiThreadedSelfTest.java | 6 +- .../dht/GridCacheDhtPreloadSelfTest.java | 18 +- ...idCachePartitionedPreloadEventsSelfTest.java | 4 +- ...dCachePartitionedTopologyChangeSelfTest.java | 10 +- ...ridCachePartitionedUnloadEventsSelfTest.java | 22 +- ...tomicClientOnlyMultiNodeFullApiSelfTest.java | 6 +- .../near/GridCacheGetStoreErrorSelfTest.java | 2 +- ...idCacheNearOnlyMultiNodeFullApiSelfTest.java | 6 +- .../GridCachePartitionedAffinitySelfTest.java | 8 +- ...titionedExplicitLockNodeFailureSelfTest.java | 6 +- ...achePartitionedMultiNodeFullApiSelfTest.java | 6 +- .../GridCacheReplicatedEvictionSelfTest.java | 12 +- ...idCacheReplicatedUnswapAdvancedSelfTest.java | 6 +- .../GridCacheReplicatedPreloadSelfTest.java | 8 +- ...eplicatedPreloadStartStopEventsSelfTest.java | 6 +- .../eviction/GridCacheEvictionAbstractTest.java | 2 +- .../GridCacheEvictionLockUnlockSelfTest.java | 6 +- ...ridCacheContinuousQueryAbstractSelfTest.java | 18 +- .../continuous/GridEventConsumeSelfTest.java | 128 +- .../dataload/GridDataLoaderPerformanceTest.java | 2 +- .../GridDataLoaderProcessorSelfTest.java | 6 +- .../processors/fs/GridGgfsSizeSelfTest.java | 6 +- .../ipc/shmem/IpcSharedMemoryNodeStartup.java | 2 +- .../apache/ignite/lang/GridFuncSelfTest.java | 46 +- .../loadtests/cache/GridCacheSwapLoadTest.java | 8 +- .../GridContinuousOperationsLoadTest.java | 10 +- .../marshaller/GridMarshallerAbstractTest.java | 6 +- .../GridP2PMissedResourceCacheSizeSelfTest.java | 2 +- .../ignite/p2p/GridP2PTimeoutSelfTest.java | 4 +- ...ridAbstractDiscoveryRandomStartStopTest.java | 2 +- .../GridAbstractDiscoverySelfTest.java | 2 +- .../discovery/GridAbstractDiscoveryTest.java | 2 +- .../tcp/GridTcpClientDiscoverySelfTest.java | 26 +- .../tcp/GridTcpDiscoveryMultiThreadedTest.java | 2 +- .../discovery/tcp/GridTcpDiscoverySelfTest.java | 64 +- ...MemoryEventStorageMultiThreadedSelfTest.java | 4 +- .../GridMemoryEventStorageSpiSelfTest.java | 14 +- ...inLoadBalancingSpiMultipleNodesSelfTest.java | 6 +- ...RobinLoadBalancingSpiNotPerTaskSelfTest.java | 6 +- .../GridSwapSpaceSpiAbstractSelfTest.java | 2 +- .../inmemory/GridTestSwapSpaceSpi.java | 2 +- .../testframework/GridSpiTestContext.java | 26 +- .../testframework/junits/GridAbstractTest.java | 2 +- .../junits/common/GridCommonAbstractTest.java | 2 +- .../core/src/test/webapp/META-INF/gg-config.xml | 2 +- .../tests/p2p/GridEventConsumeFilter.java | 4 +- .../p2p/GridP2PEventFilterExternalPath1.java | 4 +- .../p2p/GridP2PEventFilterExternalPath2.java | 4 +- .../hadoop/jobtracker/GridHadoopJobTracker.java | 8 +- ...dGgfsHadoop20FileSystemAbstractSelfTest.java | 2 +- ...ridGgfsHadoopFileSystemAbstractSelfTest.java | 2 +- ...ridGgfsHadoopFileSystemIpcCacheSelfTest.java | 2 +- .../GridGgfsNearOnlyMultiNodeSelfTest.java | 2 +- .../cache/GridCacheAbstractQuerySelfTest.java | 66 +- .../cache/GridCacheOffHeapAndSwapSelfTest.java | 6 +- .../processors/cache/GridCacheSwapSelfTest.java | 14 +- .../near/GridCacheQueryNodeRestartSelfTest.java | 8 +- .../GridCacheReplicatedFieldsQuerySelfTest.java | 8 +- .../GridCacheReplicatedQuerySelfTest.java | 16 +- .../test/resources/spring-ping-pong-partner.xml | 2 +- .../ignite/scalar/tests/ScalarCacheSpec.scala | 8 +- .../ignite/internal/GridFactorySelfTest.java | 2 +- .../p2p/GridP2PUserVersionChangeSelfTest.java | 24 +- .../GridProjectionStartStopRestartSelfTest.java | 6 +- .../GridTaskUriDeploymentDeadlockSelfTest.java | 6 +- .../commands/alert/VisorAlertCommand.scala | 12 +- .../commands/disco/VisorDiscoveryCommand.scala | 4 +- .../commands/events/VisorEventsCommand.scala | 4 +- .../commands/tasks/VisorTasksCommand.scala | 4 +- .../scala/org/apache/ignite/visor/visor.scala | 30 +- .../config/VisorConfigurationCommandSpec.scala | 2 +- .../commands/tasks/VisorTasksCommandSpec.scala | 4 +- .../yardstick/IgniteAbstractBenchmark.java | 6 +- 275 files changed, 5255 insertions(+), 5256 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/examples/config/example-cache.xml ---------------------------------------------------------------------- diff --git a/examples/config/example-cache.xml b/examples/config/example-cache.xml index 8b37bcb..b3f3c1a 100644 --- a/examples/config/example-cache.xml +++ b/examples/config/example-cache.xml @@ -47,7 +47,7 @@ <!-- Enable cache events for examples. --> <property name="includeEventTypes"> - <util:constant static-field="org.apache.ignite.events.IgniteEventType.EVTS_CACHE"/> + <util:constant static-field="org.apache.ignite.events.EventType.EVTS_CACHE"/> </property> <!-- Cache configurations (all properties are optional). --> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/examples/config/example-compute.xml ---------------------------------------------------------------------- diff --git a/examples/config/example-compute.xml b/examples/config/example-compute.xml index 33400a1..c0c88db 100644 --- a/examples/config/example-compute.xml +++ b/examples/config/example-compute.xml @@ -41,7 +41,7 @@ <!-- Enable task execution events for examples. --> <property name="includeEventTypes"> - <util:constant static-field="org.apache.ignite.events.IgniteEventType.EVTS_TASK_EXECUTION"/> + <util:constant static-field="org.apache.ignite.events.EventType.EVTS_TASK_EXECUTION"/> </property> <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. --> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEventsExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEventsExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEventsExample.java index 5156a1b..1ae194e 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEventsExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEventsExample.java @@ -23,7 +23,7 @@ import org.apache.ignite.lang.*; import java.util.*; -import static org.apache.ignite.events.IgniteEventType.*; +import static org.apache.ignite.events.EventType.*; /** * This examples demonstrates events API. Note that ignite events are disabled by default and @@ -57,8 +57,8 @@ public class CacheEventsExample { // This optional local callback is called for each event notification // that passed remote predicate listener. - IgniteBiPredicate<UUID, IgniteCacheEvent> locLsnr = new IgniteBiPredicate<UUID, IgniteCacheEvent>() { - @Override public boolean apply(UUID uuid, IgniteCacheEvent evt) { + IgniteBiPredicate<UUID, CacheEvent> locLsnr = new IgniteBiPredicate<UUID, CacheEvent>() { + @Override public boolean apply(UUID uuid, CacheEvent evt) { System.out.println("Received event [evt=" + evt.name() + ", key=" + evt.key() + ", oldVal=" + evt.oldValue() + ", newVal=" + evt.newValue()); @@ -68,8 +68,8 @@ public class CacheEventsExample { // Remote listener which only accepts events for keys that are // greater or equal than 10 and if event node is primary for this key. - IgnitePredicate<IgniteCacheEvent> rmtLsnr = new IgnitePredicate<IgniteCacheEvent>() { - @Override public boolean apply(IgniteCacheEvent evt) { + IgnitePredicate<CacheEvent> rmtLsnr = new IgnitePredicate<CacheEvent>() { + @Override public boolean apply(CacheEvent evt) { System.out.println("Cache event [name=" + evt.name() + ", key=" + evt.key() + ']'); int key = evt.key(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/examples/src/main/java/org/apache/ignite/examples/events/EventsExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/events/EventsExample.java b/examples/src/main/java/org/apache/ignite/examples/events/EventsExample.java index 65bb62c..032f98c 100644 --- a/examples/src/main/java/org/apache/ignite/examples/events/EventsExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/events/EventsExample.java @@ -26,7 +26,7 @@ import org.apache.ignite.resources.*; import java.util.*; -import static org.apache.ignite.events.IgniteEventType.*; +import static org.apache.ignite.events.EventType.*; /** * Demonstrates event consume API that allows to register event listeners on remote nodes. @@ -72,8 +72,8 @@ public class EventsExample { Ignite ignite = Ignition.ignite(); - IgnitePredicate<IgniteTaskEvent> lsnr = new IgnitePredicate<IgniteTaskEvent>() { - @Override public boolean apply(IgniteTaskEvent evt) { + IgnitePredicate<TaskEvent> lsnr = new IgnitePredicate<TaskEvent>() { + @Override public boolean apply(TaskEvent evt) { System.out.println("Received task event [evt=" + evt.name() + ", taskName=" + evt.taskName() + ']'); return true; // Return true to continue listening. @@ -105,8 +105,8 @@ public class EventsExample { // This optional local callback is called for each event notification // that passed remote predicate listener. - IgniteBiPredicate<UUID, IgniteTaskEvent> locLsnr = new IgniteBiPredicate<UUID, IgniteTaskEvent>() { - @Override public boolean apply(UUID nodeId, IgniteTaskEvent evt) { + IgniteBiPredicate<UUID, TaskEvent> locLsnr = new IgniteBiPredicate<UUID, TaskEvent>() { + @Override public boolean apply(UUID nodeId, TaskEvent evt) { // Remote filter only accepts tasks whose name being with "good-task" prefix. assert evt.taskName().startsWith("good-task"); @@ -117,8 +117,8 @@ public class EventsExample { }; // Remote filter which only accepts tasks whose name begins with "good-task" prefix. - IgnitePredicate<IgniteTaskEvent> rmtLsnr = new IgnitePredicate<IgniteTaskEvent>() { - @Override public boolean apply(IgniteTaskEvent evt) { + IgnitePredicate<TaskEvent> rmtLsnr = new IgnitePredicate<TaskEvent>() { + @Override public boolean apply(TaskEvent evt) { return evt.taskName().startsWith("good-task"); } }; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/examples/src/main/java/org/apache/ignite/examples/misc/springbean/spring-bean.xml ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/misc/springbean/spring-bean.xml b/examples/src/main/java/org/apache/ignite/examples/misc/springbean/spring-bean.xml index 83099ce..23b4375 100644 --- a/examples/src/main/java/org/apache/ignite/examples/misc/springbean/spring-bean.xml +++ b/examples/src/main/java/org/apache/ignite/examples/misc/springbean/spring-bean.xml @@ -44,7 +44,7 @@ <!-- Enable task execution events for examples. --> <property name="includeEventTypes"> - <util:constant static-field="org.apache.ignite.events.IgniteEventType.EVTS_TASK_EXECUTION"/> + <util:constant static-field="org.apache.ignite.events.EventType.EVTS_TASK_EXECUTION"/> </property> <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. --> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheExample.scala ---------------------------------------------------------------------- diff --git a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheExample.scala b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheExample.scala index 988cc40..a5ed1ae 100644 --- a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheExample.scala +++ b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarCacheExample.scala @@ -18,8 +18,8 @@ package org.apache.ignite.scalar.examples import org.apache.ignite.cache.CacheEntry -import org.apache.ignite.events.IgniteEvent -import org.apache.ignite.events.IgniteEventType._ +import org.apache.ignite.events.Event +import org.apache.ignite.events.EventType._ import org.apache.ignite.lang.IgnitePredicate import org.apache.ignite.scalar.scalar import org.apache.ignite.scalar.scalar._ @@ -129,8 +129,8 @@ object ScalarCacheExample extends App { val g = ignite$ g *< (() => { - val lsnr = new IgnitePredicate[IgniteEvent] { - override def apply(e: IgniteEvent): Boolean = { + val lsnr = new IgnitePredicate[Event] { + override def apply(e: Event): Boolean = { println(e.shortDisplay) true http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/modules/aop/src/test/java/org/apache/ignite/gridify/AbstractAopTest.java ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/apache/ignite/gridify/AbstractAopTest.java b/modules/aop/src/test/java/org/apache/ignite/gridify/AbstractAopTest.java index 520a315..ab481c1 100644 --- a/modules/aop/src/test/java/org/apache/ignite/gridify/AbstractAopTest.java +++ b/modules/aop/src/test/java/org/apache/ignite/gridify/AbstractAopTest.java @@ -32,7 +32,7 @@ import java.lang.reflect.*; import java.util.*; import java.util.concurrent.atomic.*; -import static org.apache.ignite.events.IgniteEventType.*; +import static org.apache.ignite.events.EventType.*; /** * Abstract AOP test. @@ -710,7 +710,7 @@ public abstract class AbstractAopTest extends GridCommonAbstractTest { /** * Event listener. */ - private static final class TestEventListener implements IgnitePredicate<IgniteEvent> { + private static final class TestEventListener implements IgnitePredicate<Event> { /** */ private static final long serialVersionUID = 0L; @@ -723,7 +723,7 @@ public abstract class AbstractAopTest extends GridCommonAbstractTest { private TestEventListener(AtomicInteger cnt) { this.cnt = cnt; } /** {@inheritDoc} */ - @Override public boolean apply(IgniteEvent evt) { + @Override public boolean apply(Event evt) { if ((evt.type() == EVT_TASK_DEPLOYED || evt.type() == EVT_CLASS_DEPLOYED) && evt.message() != null && !evt.message().contains("GridTopic")) cnt.addAndGet(1); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/modules/aop/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerAopTest.java ---------------------------------------------------------------------- diff --git a/modules/aop/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerAopTest.java b/modules/aop/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerAopTest.java index 0e5d5c1..b46adb7 100644 --- a/modules/aop/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerAopTest.java +++ b/modules/aop/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerAopTest.java @@ -26,7 +26,7 @@ import org.apache.ignite.testframework.junits.common.*; import java.util.concurrent.atomic.*; -import static org.apache.ignite.events.IgniteEventType.*; +import static org.apache.ignite.events.EventType.*; /** * Test use GridOptimizedMarshaller and AspectJ AOP. @@ -78,8 +78,8 @@ public class OptimizedMarshallerAopTest extends GridCommonAbstractTest { * @throws Exception If failed. */ public void testUp() throws Exception { - G.ignite().events().localListen(new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { + G.ignite().events().localListen(new IgnitePredicate<Event>() { + @Override public boolean apply(Event evt) { cntr.incrementAndGet(); return true; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/modules/clients/src/test/java/org/apache/ignite/internal/TaskEventSubjectIdSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/TaskEventSubjectIdSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/TaskEventSubjectIdSelfTest.java index baf100b..71b2fd2 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/TaskEventSubjectIdSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/TaskEventSubjectIdSelfTest.java @@ -31,14 +31,14 @@ import java.util.*; import java.util.concurrent.*; import static java.util.concurrent.TimeUnit.*; -import static org.apache.ignite.events.IgniteEventType.*; +import static org.apache.ignite.events.EventType.*; /** * Tests for security subject ID in task events. */ public class TaskEventSubjectIdSelfTest extends GridCommonAbstractTest { /** */ - private static final Collection<IgniteTaskEvent> evts = new ArrayList<>(); + private static final Collection<TaskEvent> evts = new ArrayList<>(); /** */ private static CountDownLatch latch; @@ -62,11 +62,11 @@ public class TaskEventSubjectIdSelfTest extends GridCommonAbstractTest { @Override protected void beforeTestsStarted() throws Exception { Ignite g = startGrid(); - g.events().localListen(new IgnitePredicate<IgniteEvent>() { - @Override public boolean apply(IgniteEvent evt) { - assert evt instanceof IgniteTaskEvent; + g.events().localListen(new IgnitePredicate<Event>() { + @Override public boolean apply(Event evt) { + assert evt instanceof TaskEvent; - evts.add((IgniteTaskEvent)evt); + evts.add((TaskEvent)evt); latch.countDown(); @@ -107,11 +107,11 @@ public class TaskEventSubjectIdSelfTest extends GridCommonAbstractTest { assertEquals(3, evts.size()); - Iterator<IgniteTaskEvent> it = evts.iterator(); + Iterator<TaskEvent> it = evts.iterator(); assert it.hasNext(); - IgniteTaskEvent evt = it.next(); + TaskEvent evt = it.next(); assert evt != null; @@ -162,11 +162,11 @@ public class TaskEventSubjectIdSelfTest extends GridCommonAbstractTest { assertEquals(2, evts.size()); - Iterator<IgniteTaskEvent> it = evts.iterator(); + Iterator<TaskEvent> it = evts.iterator(); assert it.hasNext(); - IgniteTaskEvent evt = it.next(); + TaskEvent evt = it.next(); assert evt != null; @@ -208,11 +208,11 @@ public class TaskEventSubjectIdSelfTest extends GridCommonAbstractTest { assertEquals(3, evts.size()); - Iterator<IgniteTaskEvent> it = evts.iterator(); + Iterator<TaskEvent> it = evts.iterator(); assert it.hasNext(); - IgniteTaskEvent evt = it.next(); + TaskEvent evt = it.next(); assert evt != null; @@ -256,11 +256,11 @@ public class TaskEventSubjectIdSelfTest extends GridCommonAbstractTest { assertEquals(3, evts.size()); - Iterator<IgniteTaskEvent> it = evts.iterator(); + Iterator<TaskEvent> it = evts.iterator(); assert it.hasNext(); - IgniteTaskEvent evt = it.next(); + TaskEvent evt = it.next(); assert evt != null; @@ -300,11 +300,11 @@ public class TaskEventSubjectIdSelfTest extends GridCommonAbstractTest { assertEquals(3, evts.size()); - Iterator<IgniteTaskEvent> it = evts.iterator(); + Iterator<TaskEvent> it = evts.iterator(); assert it.hasNext(); - IgniteTaskEvent evt = it.next(); + TaskEvent evt = it.next(); assert evt != null; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/modules/clients/src/test/resources/spring-server-node.xml ---------------------------------------------------------------------- diff --git a/modules/clients/src/test/resources/spring-server-node.xml b/modules/clients/src/test/resources/spring-server-node.xml index 47a9bf1..3c450b8 100644 --- a/modules/clients/src/test/resources/spring-server-node.xml +++ b/modules/clients/src/test/resources/spring-server-node.xml @@ -69,9 +69,9 @@ <!-- Configure to skip all events for better performance. --> <property name="includeEventTypes"> <list> - <util:constant static-field="org.apache.ignite.events.IgniteEventType.EVT_TASK_FAILED"/> - <util:constant static-field="org.apache.ignite.events.IgniteEventType.EVT_TASK_FINISHED"/> - <util:constant static-field="org.apache.ignite.events.IgniteEventType.EVT_JOB_MAPPED"/> + <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/> + <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/> + <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_MAPPED"/> </list> </property> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/modules/core/src/main/java/org/apache/ignite/IgniteEvents.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteEvents.java b/modules/core/src/main/java/org/apache/ignite/IgniteEvents.java index e3b33ad..90f75c1 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteEvents.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteEvents.java @@ -72,7 +72,7 @@ public interface IgniteEvents extends IgniteAsyncSupport { * @throws IgniteException If query failed. */ @IgniteAsyncSupported - public <T extends IgniteEvent> List<T> remoteQuery(IgnitePredicate<T> p, long timeout, @Nullable int... types) + public <T extends Event> List<T> remoteQuery(IgnitePredicate<T> p, long timeout, @Nullable int... types) throws IgniteException; /** @@ -100,7 +100,7 @@ public interface IgniteEvents extends IgniteAsyncSupport { * @throws IgniteException If failed to add listener. */ @IgniteAsyncSupported - public <T extends IgniteEvent> UUID remoteListen(@Nullable IgniteBiPredicate<UUID, T> locLsnr, + public <T extends Event> UUID remoteListen(@Nullable IgniteBiPredicate<UUID, T> locLsnr, @Nullable IgnitePredicate<T> rmtFilter, @Nullable int... types) throws IgniteException; @@ -141,7 +141,7 @@ public interface IgniteEvents extends IgniteAsyncSupport { * @throws IgniteException If failed to add listener. */ @IgniteAsyncSupported - public <T extends IgniteEvent> UUID remoteListen(int bufSize, + public <T extends Event> UUID remoteListen(int bufSize, long interval, boolean autoUnsubscribe, @Nullable IgniteBiPredicate<UUID, T> locLsnr, @@ -175,7 +175,7 @@ public interface IgniteEvents extends IgniteAsyncSupport { * @throws IgniteException If wait was interrupted. */ @IgniteAsyncSupported - public <T extends IgniteEvent> T waitForLocal(@Nullable IgnitePredicate<T> filter, @Nullable int... types) + public <T extends Event> T waitForLocal(@Nullable IgnitePredicate<T> filter, @Nullable int... types) throws IgniteException; /** @@ -186,7 +186,7 @@ public interface IgniteEvents extends IgniteAsyncSupport { * @param types Event types to be queried. * @return Collection of grid events found on local node. */ - public <T extends IgniteEvent> Collection<T> localQuery(IgnitePredicate<T> p, @Nullable int... types); + public <T extends Event> Collection<T> localQuery(IgnitePredicate<T> p, @Nullable int... types); /** * Records customer user generated event. All registered local listeners will be notified. @@ -200,7 +200,7 @@ public interface IgniteEvents extends IgniteAsyncSupport { * @throws IllegalArgumentException If event type is within GridGain reserved range between {@code 1} and * {@code 1000}. */ - public void recordLocal(IgniteEvent evt); + public void recordLocal(Event evt); /** * Adds an event listener for local events. Note that listener will be added regardless of whether @@ -211,7 +211,7 @@ public interface IgniteEvents extends IgniteAsyncSupport { * @param types Event types for which this listener will be notified. * @throws IllegalArgumentException Thrown in case when passed in array of event types is empty. */ - public void localListen(IgnitePredicate<? extends IgniteEvent> lsnr, int... types); + public void localListen(IgnitePredicate<? extends Event> lsnr, int... types); /** * Removes local event listener. @@ -221,7 +221,7 @@ public interface IgniteEvents extends IgniteAsyncSupport { * then listener will be removed for all types it was registered for. * @return {@code true} if listener was removed, {@code false} otherwise. */ - public boolean stopLocalListen(IgnitePredicate<? extends IgniteEvent> lsnr, @Nullable int... types); + public boolean stopLocalListen(IgnitePredicate<? extends Event> lsnr, @Nullable int... types); /** * Enables provided events. Allows to start recording events that http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/modules/core/src/main/java/org/apache/ignite/cache/affinity/CacheAffinityFunctionContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/affinity/CacheAffinityFunctionContext.java b/modules/core/src/main/java/org/apache/ignite/cache/affinity/CacheAffinityFunctionContext.java index 70a0c2d..ea5a0ec 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/affinity/CacheAffinityFunctionContext.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/affinity/CacheAffinityFunctionContext.java @@ -67,5 +67,5 @@ public interface CacheAffinityFunctionContext { * @return Discovery event caused latest topology change or {@code null} if this information is * not available. */ - @Nullable public IgniteDiscoveryEvent discoveryEvent(); + @Nullable public DiscoveryEvent discoveryEvent(); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/modules/core/src/main/java/org/apache/ignite/cache/affinity/fair/CachePartitionFairAffinity.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/affinity/fair/CachePartitionFairAffinity.java b/modules/core/src/main/java/org/apache/ignite/cache/affinity/fair/CachePartitionFairAffinity.java index f79ec7f..7757b16 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/affinity/fair/CachePartitionFairAffinity.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/affinity/fair/CachePartitionFairAffinity.java @@ -390,9 +390,9 @@ public class CachePartitionFairAffinity implements CacheAffinityFunction { */ private IgniteBiTuple<List<List<ClusterNode>>, Map<UUID, PartitionSet>> createCopy( CacheAffinityFunctionContext ctx, Iterable<ClusterNode> topSnapshot) { - IgniteDiscoveryEvent discoEvt = ctx.discoveryEvent(); + DiscoveryEvent discoEvt = ctx.discoveryEvent(); - UUID leftNodeId = discoEvt.type() == IgniteEventType.EVT_NODE_JOINED ? null : discoEvt.eventNode().id(); + UUID leftNodeId = discoEvt.type() == EventType.EVT_NODE_JOINED ? null : discoEvt.eventNode().id(); List<List<ClusterNode>> cp = new ArrayList<>(parts); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryType.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryType.java b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryType.java index a418cfd..7347892 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryType.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/query/CacheQueryType.java @@ -20,11 +20,11 @@ package org.apache.ignite.cache.query; /** * Cache query type. * <p> - * Used in {@link org.apache.ignite.events.IgniteCacheQueryExecutedEvent} and {@link org.apache.ignite.events.IgniteCacheQueryReadEvent} + * Used in {@link org.apache.ignite.events.CacheQueryExecutedEvent} and {@link org.apache.ignite.events.CacheQueryReadEvent} * to identify the type of query for which an event was fired. * - * @see org.apache.ignite.events.IgniteCacheQueryExecutedEvent#queryType() - * @see org.apache.ignite.events.IgniteCacheQueryReadEvent#queryType() + * @see org.apache.ignite.events.CacheQueryExecutedEvent#queryType() + * @see org.apache.ignite.events.CacheQueryReadEvent#queryType() */ public enum CacheQueryType { /** SQL query. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java index 253d4f5..8818a81 100644 --- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java @@ -447,7 +447,7 @@ public class IgniteConfiguration { private long metricsLogFreq = DFLT_METRICS_LOG_FREQ; /** Local event listeners. */ - private Map<IgnitePredicate<? extends IgniteEvent>, int[]> lsnrs; + private Map<IgnitePredicate<? extends Event>, int[]> lsnrs; /** TCP host. */ private String restTcpHost; @@ -2301,7 +2301,7 @@ public class IgniteConfiguration { } /** - * Sets array of event types, which will be recorded by {@link GridEventStorageManager#record(org.apache.ignite.events.IgniteEvent)}. + * Sets array of event types, which will be recorded by {@link GridEventStorageManager#record(org.apache.ignite.events.Event)}. * Note, that either the include event types or the exclude event types can be established. * * @param inclEvtTypes Include event types. @@ -3076,9 +3076,9 @@ public class IgniteConfiguration { * Each listener is mapped to array of event types. * * @return Pre-configured event listeners map. - * @see org.apache.ignite.events.IgniteEventType + * @see org.apache.ignite.events.EventType */ - public Map<IgnitePredicate<? extends IgniteEvent>, int[]> getLocalEventListeners() { + public Map<IgnitePredicate<? extends Event>, int[]> getLocalEventListeners() { return lsnrs; } @@ -3088,7 +3088,7 @@ public class IgniteConfiguration { * * @param lsnrs Pre-configured event listeners map. */ - public void setLocalEventListeners(Map<IgnitePredicate<? extends IgniteEvent>, int[]> lsnrs) { + public void setLocalEventListeners(Map<IgnitePredicate<? extends Event>, int[]> lsnrs) { this.lsnrs = lsnrs; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/modules/core/src/main/java/org/apache/ignite/events/AuthenticationEvent.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/events/AuthenticationEvent.java b/modules/core/src/main/java/org/apache/ignite/events/AuthenticationEvent.java new file mode 100644 index 0000000..ed6c204 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/events/AuthenticationEvent.java @@ -0,0 +1,172 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.events; + +import org.apache.ignite.cluster.*; +import org.apache.ignite.internal.util.tostring.*; +import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.security.*; + +import java.util.*; + +/** + * Grid authentication event. + * <p> + * Grid events are used for notification about what happens within the grid. Note that by + * design GridGain keeps all events generated on the local node locally and it provides + * APIs for performing a distributed queries across multiple nodes: + * <ul> + * <li> + * {@link org.apache.ignite.IgniteEvents#remoteQuery(org.apache.ignite.lang.IgnitePredicate, long, int...)} - + * asynchronously querying events occurred on the nodes specified, including remote nodes. + * </li> + * <li> + * {@link org.apache.ignite.IgniteEvents#localQuery(org.apache.ignite.lang.IgnitePredicate, int...)} - + * querying only local events stored on this local node. + * </li> + * <li> + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} - + * listening to local grid events (events from remote nodes not included). + * </li> + * </ul> + * User can also wait for events using method {@link org.apache.ignite.IgniteEvents#waitForLocal(org.apache.ignite.lang.IgnitePredicate, int...)}. + * <h1 class="header">Events and Performance</h1> + * It is <b>highly recommended</b> to enable only those events that your application logic requires + * by using {@link org.apache.ignite.configuration.IgniteConfiguration#getIncludeEventTypes()} method in GridGain configuration. Note that certain + * events are required for GridGain's internal operations and such events will still be generated but not stored by + * event storage SPI if they are disabled in GridGain configuration. + * @see EventType#EVT_AUTHENTICATION_FAILED + * @see EventType#EVT_AUTHENTICATION_SUCCEEDED + */ +public class AuthenticationEvent extends EventAdapter { + /** */ + private static final long serialVersionUID = 0L; + + /** Subject type. */ + private GridSecuritySubjectType subjType; + + /** Subject ID. */ + private UUID subjId; + + /** Login. */ + @GridToStringInclude + private Object login; + + /** {@inheritDoc} */ + @Override public String shortDisplay() { + return name() + ": subjType=" + subjType; + } + + /** + * No-arg constructor. + */ + public AuthenticationEvent() { + // No-op. + } + + /** + * Creates authentication event with given parameters. + * + * @param msg Optional message. + * @param type Event type. + */ + public AuthenticationEvent(ClusterNode node, String msg, int type) { + super(node, msg, type); + } + + /** + * Creates authentication event with given parameters. + * + * @param node Node. + * @param msg Optional message. + * @param type Event type. + * @param subjType Subject type. + * @param subjId Subject ID. + */ + public AuthenticationEvent(ClusterNode node, String msg, int type, GridSecuritySubjectType subjType, + UUID subjId, Object login) { + super(node, msg, type); + + this.subjType = subjType; + this.subjId = subjId; + this.login = login; + } + + /** + * Gets subject type that triggered the event. + * + * @return Subject type that triggered the event. + */ + public GridSecuritySubjectType subjectType() { + return subjType; + } + + /** + * Gets subject ID that triggered the event. + * + * @return Subject ID that triggered the event. + */ + public UUID subjectId() { + return subjId; + } + + /** + * Sets subject type that triggered the event. + * + * @param subjType Subject type to set. + */ + public void subjectType(GridSecuritySubjectType subjType) { + this.subjType = subjType; + } + + /** + * Gets login that triggered event. + * + * @return Login object. + */ + public Object login() { + return login; + } + + /** + * Sets login that triggered event. + * + * @param login Login object. + */ + public void login(Object login) { + this.login = login; + } + + /** + * Sets subject ID that triggered the event. + * + * @param subjId Subject ID to set. + */ + public void subjectId(UUID subjId) { + this.subjId = subjId; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(AuthenticationEvent.class, this, + "nodeId8", U.id8(node().id()), + "msg", message(), + "type", name(), + "tstamp", timestamp()); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/modules/core/src/main/java/org/apache/ignite/events/AuthorizationEvent.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/events/AuthorizationEvent.java b/modules/core/src/main/java/org/apache/ignite/events/AuthorizationEvent.java new file mode 100644 index 0000000..4685f3e --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/events/AuthorizationEvent.java @@ -0,0 +1,146 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.events; + +import org.apache.ignite.cluster.*; +import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.security.*; + +/** + * Grid authorization event. + * <p> + * Grid events are used for notification about what happens within the grid. Note that by + * design GridGain keeps all events generated on the local node locally and it provides + * APIs for performing a distributed queries across multiple nodes: + * <ul> + * <li> + * {@link org.apache.ignite.IgniteEvents#remoteQuery(org.apache.ignite.lang.IgnitePredicate, long, int...)} - + * asynchronously querying events occurred on the nodes specified, including remote nodes. + * </li> + * <li> + * {@link org.apache.ignite.IgniteEvents#localQuery(org.apache.ignite.lang.IgnitePredicate, int...)} - + * querying only local events stored on this local node. + * </li> + * <li> + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} - + * listening to local grid events (events from remote nodes not included). + * </li> + * </ul> + * User can also wait for events using method {@link org.apache.ignite.IgniteEvents#waitForLocal(org.apache.ignite.lang.IgnitePredicate, int...)}. + * <h1 class="header">Events and Performance</h1> + * It is <b>highly recommended</b> to enable only those events that your application logic requires + * by using {@link org.apache.ignite.configuration.IgniteConfiguration#getIncludeEventTypes()} method in GridGain configuration. Note that certain + * events are required for GridGain's internal operations and such events will still be generated but not stored by + * event storage SPI if they are disabled in GridGain configuration. + * @see EventType#EVT_AUTHORIZATION_FAILED + * @see EventType#EVT_AUTHORIZATION_SUCCEEDED + */ +public class AuthorizationEvent extends EventAdapter { + /** */ + private static final long serialVersionUID = 0L; + + /** Requested operation. */ + private GridSecurityPermission op; + + /** Authenticated subject authorized to perform operation. */ + private GridSecuritySubject subj; + + /** {@inheritDoc} */ + @Override public String shortDisplay() { + return name() + ": op=" + op; + } + + /** + * No-arg constructor. + */ + public AuthorizationEvent() { + // No-op. + } + + /** + * Creates authorization event with given parameters. + * + * @param msg Optional message. + * @param type Event type. + */ + public AuthorizationEvent(ClusterNode node, String msg, int type) { + super(node, msg, type); + } + + /** + * Creates authorization event with given parameters. + * + * @param node Node. + * @param msg Optional message. + * @param type Event type. + * @param op Requested operation. + * @param subj Authenticated subject. + */ + public AuthorizationEvent(ClusterNode node, String msg, int type, GridSecurityPermission op, + GridSecuritySubject subj) { + super(node, msg, type); + + this.op = op; + this.subj = subj; + } + + /** + * Gets requested operation. + * + * @return Requested operation. + */ + public GridSecurityPermission operation() { + return op; + } + + /** + * Sets requested operation. + * + * @param op Requested operation. + */ + public void operation(GridSecurityPermission op) { + this.op = op; + } + + /** + * Gets authenticated subject. + * + * @return Authenticated subject. + */ + public GridSecuritySubject subject() { + return subj; + } + + /** + * Sets authenticated subject. + * + * @param subj Authenticated subject. + */ + public void subject(GridSecuritySubject subj) { + this.subj = subj; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(AuthorizationEvent.class, this, + "nodeId8", U.id8(node().id()), + "msg", message(), + "type", name(), + "tstamp", timestamp()); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/modules/core/src/main/java/org/apache/ignite/events/CacheEvent.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/events/CacheEvent.java b/modules/core/src/main/java/org/apache/ignite/events/CacheEvent.java new file mode 100644 index 0000000..33e934a --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/events/CacheEvent.java @@ -0,0 +1,331 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.events; + +import org.apache.ignite.cluster.*; +import org.apache.ignite.internal.util.tostring.*; +import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.lang.*; +import org.jetbrains.annotations.*; + +import java.util.*; + +/** + * In-memory database (cache) event. + * <p> + * Grid events are used for notification about what happens within the grid. Note that by + * design GridGain keeps all events generated on the local node locally and it provides + * APIs for performing a distributed queries across multiple nodes: + * <ul> + * <li> + * {@link org.apache.ignite.IgniteEvents#remoteQuery(org.apache.ignite.lang.IgnitePredicate, long, int...)} - + * asynchronously querying events occurred on the nodes specified, including remote nodes. + * </li> + * <li> + * {@link org.apache.ignite.IgniteEvents#localQuery(org.apache.ignite.lang.IgnitePredicate, int...)} - + * querying only local events stored on this local node. + * </li> + * <li> + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} - + * listening to local grid events (events from remote nodes not included). + * </li> + * </ul> + * User can also wait for events using method {@link org.apache.ignite.IgniteEvents#waitForLocal(org.apache.ignite.lang.IgnitePredicate, int...)}. + * <h1 class="header">Events and Performance</h1> + * Note that by default all events in GridGain are enabled and therefore generated and stored + * by whatever event storage SPI is configured. GridGain 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. + * <p> + * It is <b>highly recommended</b> to enable only those events that your application logic requires + * by using {@link org.apache.ignite.configuration.IgniteConfiguration#getIncludeEventTypes()} method in GridGain configuration. Note that certain + * events are required for GridGain's internal operations and such events will still be generated but not stored by + * event storage SPI if they are disabled in GridGain configuration. + * @see EventType#EVT_CACHE_ENTRY_CREATED + * @see EventType#EVT_CACHE_ENTRY_DESTROYED + * @see EventType#EVT_CACHE_ENTRY_EVICTED + * @see EventType#EVT_CACHE_OBJECT_PUT + * @see EventType#EVT_CACHE_OBJECT_READ + * @see EventType#EVT_CACHE_OBJECT_REMOVED + * @see EventType#EVT_CACHE_OBJECT_LOCKED + * @see EventType#EVT_CACHE_OBJECT_UNLOCKED + * @see EventType#EVT_CACHE_OBJECT_SWAPPED + * @see EventType#EVT_CACHE_OBJECT_UNSWAPPED + * @see EventType#EVT_CACHE_OBJECT_EXPIRED + */ +public class CacheEvent extends EventAdapter { + /** */ + private static final long serialVersionUID = 0L; + + /** Cache name. */ + private String cacheName; + + /** Partition for the event. */ + private int part; + + /** Cache entry. */ + @GridToStringInclude + private Object key; + + /** Event ID. */ + @GridToStringInclude + private final IgniteUuid xid; + + /** Lock ID. */ + @GridToStringInclude + private final Object lockId; + + /** New value. */ + @GridToStringInclude + private final Object newVal; + + /** Old value. */ + @GridToStringInclude + private final Object oldVal; + + /** + * Flag indicating whether old value is present in case if we + * don't have it in deserialized form. + */ + @GridToStringInclude + private final boolean hasOldVal; + + /** + * Flag indicating whether new value is present in case if we + * don't have it in deserialized form. + */ + @GridToStringInclude + private final boolean hasNewVal; + + /** Event node. */ + @GridToStringExclude + @Nullable private final ClusterNode evtNode; + + /** Flag indicating whether event happened on {@code near} or {@code partitioned} cache. */ + @GridToStringInclude + private boolean near; + + /** Subject ID. */ + @GridToStringInclude + private UUID subjId; + + /** Closure class name. */ + @GridToStringInclude + private String cloClsName; + + /** Task name if update was initiated within task execution. */ + @GridToStringInclude + private String taskName; + + /** + * Constructs cache event. + * + * @param cacheName Cache name. + * @param node Local node. + * @param evtNode Event node ID. + * @param msg Event message. + * @param type Event type. + * @param part Partition for the event (usually the partition the key belongs to). + * @param near Flag indicating whether event happened on {@code near} or {@code partitioned} cache. + * @param key Cache key. + * @param xid Transaction ID. + * @param lockId Lock ID. + * @param newVal New value. + * @param hasNewVal Flag indicating whether new value is present in case if we + * don't have it in deserialized form. + * @param oldVal Old value. + * @param hasOldVal Flag indicating whether old value is present in case if we + * don't have it in deserialized form. + * @param subjId Subject ID. + * @param cloClsName Closure class name. + */ + public CacheEvent(String cacheName, ClusterNode node, @Nullable ClusterNode evtNode, String msg, int type, int part, + boolean near, Object key, IgniteUuid xid, Object lockId, Object newVal, boolean hasNewVal, + Object oldVal, boolean hasOldVal, UUID subjId, String cloClsName, String taskName) { + super(node, msg, type); + this.cacheName = cacheName; + this.evtNode = evtNode; + this.part = part; + this.near = near; + this.key = key; + this.xid = xid; + this.lockId = lockId; + this.newVal = newVal; + this.hasNewVal = hasNewVal; + this.oldVal = oldVal; + this.hasOldVal = hasOldVal; + this.subjId = subjId; + this.cloClsName = cloClsName; + this.taskName = taskName; + } + + /** + * Gets cache name. + * + * @return Cache name. + */ + @Nullable public String cacheName() { + return cacheName; + } + + /** + * Gets partition for the event which is the partition the key belongs to. + * + * @return Partition for the event. + */ + public int partition() { + return part; + } + + /** + * Gets flag indicating whether event happened on {@code near} or {@code partitioned} cache. + * + * @return Flag indicating whether event happened on {@code near} or {@code partitioned} cache. + */ + public boolean isNear() { + return near; + } + + /** + * Gets node which initiated cache operation or {@code null} if that node is not available. + * + * @return Node which initiated cache operation or {@code null} if that node is not available. + */ + @Nullable public ClusterNode eventNode() { + return evtNode; + } + + /** + * Gets cache entry associated with event. + * + * @return Cache entry associated with event. + */ + @SuppressWarnings({"unchecked"}) + @Nullable public <K> K key() { + return (K)key; + } + + /** + * ID of surrounding cache cache transaction or <tt>null</tt> if there is + * no surrounding transaction. + * + * @return ID of surrounding cache transaction. + */ + @Nullable public IgniteUuid xid() { + return xid; + } + + /** + * ID of the lock if held or <tt>null</tt> if no lock held. + * + * @return ID of the lock if held. + */ + @Nullable public Object lockId() { + return lockId; + } + + /** + * Gets new value for this event. + * + * @return New value associated with event (<tt>null</tt> if event is + * {@link EventType#EVT_CACHE_OBJECT_REMOVED}. + */ + @Nullable public Object newValue() { + return newVal; + } + + /** + * Gets old value associated with this event. + * + * @return Old value associated with event. + */ + @Nullable public Object oldValue() { + return oldVal; + } + + /** + * Gets flag indicating whether cache entry has old value in case if + * we only have old value in serialized form in which case {@link #oldValue()} + * will return {@code null}. + * + * @return Flag indicating whether there is old value associated with this event. + */ + public boolean hasOldValue() { + return hasOldVal; + } + + /** + * Gets flag indicating whether cache entry has new value in case if + * we only have new value in serialized form in which case {@link #newValue()} + * will return {@code null}. + * + * @return Flag indicating whether there is new value associated with this event. + */ + public boolean hasNewValue() { + return hasNewVal; + } + + /** + * Gets security subject ID initiated this cache event, if available. This property is available only for + * {@link EventType#EVT_CACHE_OBJECT_PUT}, {@link EventType#EVT_CACHE_OBJECT_REMOVED} and + * {@link EventType#EVT_CACHE_OBJECT_READ} cache events. + * <p> + * Subject ID will be set either to nodeId initiated cache update or read or client ID initiated + * cache update or read. + * + * @return Subject ID. + */ + @Nullable public UUID subjectId() { + return subjId; + } + + /** + * Gets closure class name (applicable only for TRANSFORM operations). + * + * @return Closure class name. + */ + @Nullable public String closureClassName() { + return cloClsName; + } + + /** + * Gets task name if cache event was caused by an operation initiated within task execution. + * + * @return Task name. + */ + @Nullable public String taskName() { + return taskName; + } + + /** {@inheritDoc} */ + @Override public String shortDisplay() { + return name() + ": near=" + near + ", key=" + key + ", hasNewVal=" + hasNewVal + ", hasOldVal=" + hasOldVal + + ", nodeId8=" + U.id8(node().id()); + } + + /** {@inheritDoc} */ + @SuppressWarnings("ConstantConditions") + @Override public String toString() { + return S.toString(CacheEvent.class, this, + "nodeId8", U.id8(node().id()), + "evtNodeId8", U.id8(evtNode.id()), + "msg", message(), + "type", name(), + "tstamp", timestamp()); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/modules/core/src/main/java/org/apache/ignite/events/CachePreloadingEvent.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/events/CachePreloadingEvent.java b/modules/core/src/main/java/org/apache/ignite/events/CachePreloadingEvent.java new file mode 100644 index 0000000..3261dca --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/events/CachePreloadingEvent.java @@ -0,0 +1,172 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.events; + +import org.apache.ignite.cluster.*; +import org.apache.ignite.internal.util.typedef.internal.*; + +/** + * In-memory database (cache) preloading event. Preload event happens every time there is a change + * in grid topology, which means that a node has either joined or left the grid. + * <p> + * Grid events are used for notification about what happens within the grid. Note that by + * design GridGain keeps all events generated on the local node locally and it provides + * APIs for performing a distributed queries across multiple nodes: + * <ul> + * <li> + * {@link org.apache.ignite.IgniteEvents#remoteQuery(org.apache.ignite.lang.IgnitePredicate, long, int...)} - + * asynchronously querying events occurred on the nodes specified, including remote nodes. + * </li> + * <li> + * {@link org.apache.ignite.IgniteEvents#localQuery(org.apache.ignite.lang.IgnitePredicate, int...)} - + * querying only local events stored on this local node. + * </li> + * <li> + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} - + * listening to local grid events (events from remote nodes not included). + * </li> + * </ul> + * User can also wait for events using method {@link org.apache.ignite.IgniteEvents#waitForLocal(org.apache.ignite.lang.IgnitePredicate, int...)}. + * <h1 class="header">Events and Performance</h1> + * Note that by default all events in GridGain are enabled and therefore generated and stored + * by whatever event storage SPI is configured. GridGain 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. + * <p> + * It is <b>highly recommended</b> to enable only those events that your application logic requires + * by using {@link org.apache.ignite.configuration.IgniteConfiguration#getIncludeEventTypes()} method in GridGain configuration. Note that certain + * events are required for GridGain's internal operations and such events will still be generated but not stored by + * event storage SPI if they are disabled in GridGain configuration. + * @see EventType#EVT_CACHE_PRELOAD_PART_LOADED + * @see EventType#EVT_CACHE_PRELOAD_PART_UNLOADED + * @see EventType#EVT_CACHE_PRELOAD_STARTED + * @see EventType#EVT_CACHE_PRELOAD_STOPPED + */ +public class CachePreloadingEvent extends EventAdapter { + /** */ + private static final long serialVersionUID = 0L; + + /** Cache name. */ + private String cacheName; + + /** Partition for the event. */ + private int part; + + /** Discovery node. */ + private ClusterNode discoNode; + + /** Discovery event type. */ + private int discoEvtType; + + /** Discovery event time. */ + private long discoTs; + + /** + * Constructs cache event. + * + * @param cacheName Cache name. + * @param node Event node. + * @param msg Event message. + * @param type Event type. + * @param part Partition for the event (usually the partition the key belongs to). + * @param discoNode Node that triggered this preloading event. + * @param discoEvtType Discovery event type that triggered this preloading event. + * @param discoTs Timestamp of discovery event that triggered this preloading event. + */ + public CachePreloadingEvent(String cacheName, ClusterNode node, String msg, int type, int part, + ClusterNode discoNode, int discoEvtType, long discoTs) { + super(node, msg, type); + this.cacheName = cacheName; + this.part = part; + this.discoNode = discoNode; + this.discoEvtType = discoEvtType; + this.discoTs = discoTs; + } + + /** + * Gets cache name. + * + * @return Cache name. + */ + public String cacheName() { + return cacheName; + } + + /** + * Gets partition for the event. + * + * @return Partition for the event. + */ + public int partition() { + return part; + } + + /** + * Gets shadow of the node that triggered this preloading event. + * + * @return Shadow of the node that triggered this preloading event. + */ + public ClusterNode discoveryNode() { + return discoNode; + } + + /** + * Gets type of discovery event that triggered this preloading event. + * + * @return Type of discovery event that triggered this preloading event. + * @see DiscoveryEvent#type() + */ + public int discoveryEventType() { + return discoEvtType; + } + + /** + * Gets name of discovery event that triggered this preloading event. + * + * @return Name of discovery event that triggered this preloading event. + * @see DiscoveryEvent#name() + */ + public String discoveryEventName() { + return U.gridEventName(discoEvtType); + } + + /** + * Gets timestamp of discovery event that caused this preloading event. + * + * @return Timestamp of discovery event that caused this preloading event. + */ + public long discoveryTimestamp() { + return discoTs; + } + + /** {@inheritDoc} */ + @Override public String shortDisplay() { + return name() + ": cache=" + CU.mask(cacheName) + ", cause=" + + discoveryEventName(); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(CachePreloadingEvent.class, this, + "discoEvtName", discoveryEventName(), + "nodeId8", U.id8(node().id()), + "msg", message(), + "type", name(), + "tstamp", timestamp()); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/modules/core/src/main/java/org/apache/ignite/events/CacheQueryExecutedEvent.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/events/CacheQueryExecutedEvent.java b/modules/core/src/main/java/org/apache/ignite/events/CacheQueryExecutedEvent.java new file mode 100644 index 0000000..0ff4633 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/events/CacheQueryExecutedEvent.java @@ -0,0 +1,237 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.events; + +import org.apache.ignite.cache.query.*; +import org.apache.ignite.cluster.*; +import org.apache.ignite.internal.util.tostring.*; +import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.lang.*; +import org.jetbrains.annotations.*; + +import java.util.*; + +/** + * Cache query execution event. + * <p> + * Grid events are used for notification about what happens within the grid. Note that by + * design GridGain keeps all events generated on the local node locally and it provides + * APIs for performing a distributed queries across multiple nodes: + * <ul> + * <li> + * {@link org.apache.ignite.IgniteEvents#remoteQuery(org.apache.ignite.lang.IgnitePredicate, long, int...)} - + * asynchronously querying events occurred on the nodes specified, including remote nodes. + * </li> + * <li> + * {@link org.apache.ignite.IgniteEvents#localQuery(org.apache.ignite.lang.IgnitePredicate, int...)} - + * querying only local events stored on this local node. + * </li> + * <li> + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} - + * listening to local grid events (events from remote nodes not included). + * </li> + * </ul> + * User can also wait for events using method {@link org.apache.ignite.IgniteEvents#waitForLocal(org.apache.ignite.lang.IgnitePredicate, int...)}. + * <h1 class="header">Events and Performance</h1> + * Note that by default all events in GridGain are enabled and therefore generated and stored + * by whatever event storage SPI is configured. GridGain 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. + * <p> + * It is <b>highly recommended</b> to enable only those events that your application logic requires + * by using {@link org.apache.ignite.configuration.IgniteConfiguration#getIncludeEventTypes()} method in GridGain configuration. Note that certain + * events are required for GridGain's internal operations and such events will still be generated but not stored by + * event storage SPI if they are disabled in GridGain configuration. + * + * @see EventType#EVT_CACHE_QUERY_EXECUTED + * @see EventType#EVTS_CACHE_QUERY + */ +public class CacheQueryExecutedEvent<K, V> extends EventAdapter { + /** */ + private static final long serialVersionUID = 3738753361235304496L; + + /** Query type. */ + private final CacheQueryType qryType; + + /** Cache name. */ + private final String cacheName; + + /** Class name. */ + private final String clsName; + + /** Clause. */ + private final String clause; + + /** Scan query filter. */ + @GridToStringInclude + private final IgniteBiPredicate<K, V> scanQryFilter; + + /** Continuous query filter. */ + @GridToStringInclude + private final IgnitePredicate<CacheContinuousQueryEntry<K, V>> contQryFilter; + + /** Query arguments. */ + @GridToStringInclude + private final Object[] args; + + /** Security subject ID. */ + private final UUID subjId; + + /** Task name. */ + private final String taskName; + + /** + * @param node Node where event was fired. + * @param msg Event message. + * @param type Event type. + * @param qryType Query type. + * @param cacheName Cache name. + * @param clsName Class name. + * @param clause Clause. + * @param scanQryFilter Scan query filter. + * @param args Query arguments. + * @param subjId Security subject ID. + */ + public CacheQueryExecutedEvent( + ClusterNode node, + String msg, + int type, + CacheQueryType qryType, + @Nullable String cacheName, + @Nullable String clsName, + @Nullable String clause, + @Nullable IgniteBiPredicate<K, V> scanQryFilter, + @Nullable IgnitePredicate<CacheContinuousQueryEntry<K, V>> contQryFilter, + @Nullable Object[] args, + @Nullable UUID subjId, + @Nullable String taskName) { + super(node, msg, type); + + assert qryType != null; + + this.qryType = qryType; + this.cacheName = cacheName; + this.clsName = clsName; + this.clause = clause; + this.scanQryFilter = scanQryFilter; + this.contQryFilter = contQryFilter; + this.args = args; + this.subjId = subjId; + this.taskName = taskName; + } + + /** + * Gets query type. + * + * @return Query type. + */ + public CacheQueryType queryType() { + return qryType; + } + + /** + * Gets cache name on which query was executed. + * + * @return Cache name. + */ + @Nullable public String cacheName() { + return cacheName; + } + + /** + * Gets queried class name. + * <p> + * Applicable for {@code SQL} and @{code full text} queries. + * + * @return Queried class name. + */ + @Nullable public String className() { + return clsName; + } + + /** + * Gets query clause. + * <p> + * Applicable for {@code SQL}, {@code SQL fields} and @{code full text} queries. + * + * @return Query clause. + */ + @Nullable public String clause() { + return clause; + } + + /** + * Gets scan query filter. + * <p> + * Applicable for {@code scan} queries. + * + * @return Scan query filter. + */ + @Nullable public IgniteBiPredicate<K, V> scanQueryFilter() { + return scanQryFilter; + } + + /** + * Gets continuous query filter. + * <p> + * Applicable for {@code continuous} queries. + * + * @return Continuous query filter. + */ + @Nullable public IgnitePredicate<CacheContinuousQueryEntry<K, V>> continuousQueryFilter() { + return contQryFilter; + } + + /** + * Gets query arguments. + * <p> + * Applicable for {@code SQL} and {@code SQL fields} queries. + * + * @return Query arguments. + */ + @Nullable public Object[] arguments() { + return args; + } + + /** + * Gets security subject ID. + * + * @return Security subject ID. + */ + @Nullable public UUID subjectId() { + return subjId; + } + + /** + * Gets the name of the task that executed the query (if any). + * + * @return Task name. + */ + @Nullable public String taskName() { + return taskName; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(CacheQueryExecutedEvent.class, this, + "nodeId8", U.id8(node().id()), + "msg", message(), + "type", name(), + "tstamp", timestamp()); + } +}