http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/modules/core/src/main/java/org/apache/ignite/events/CacheQueryReadEvent.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/events/CacheQueryReadEvent.java b/modules/core/src/main/java/org/apache/ignite/events/CacheQueryReadEvent.java new file mode 100644 index 0000000..aaca9b3 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/events/CacheQueryReadEvent.java @@ -0,0 +1,299 @@ +/* + * 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 read 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_OBJECT_READ + * @see EventType#EVTS_CACHE_QUERY + */ +public class CacheQueryReadEvent<K, V> extends EventAdapter { + /** */ + private static final long serialVersionUID = -1984731272984397445L; + + /** 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; + + /** Key. */ + @GridToStringInclude + private final K key; + + /** Value. */ + @GridToStringInclude + private final V val; + + /** Old value. */ + @GridToStringInclude + private final V oldVal; + + /** Result row. */ + @GridToStringInclude + private final Object row; + + /** + * @param node Node where event was fired. + * @param msg Event message. + * @param type Event 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. + * @param key Key. + * @param val Value. + * @param oldVal Old value. + */ + public CacheQueryReadEvent( + 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, + @Nullable K key, + @Nullable V val, + @Nullable V oldVal, + @Nullable Object row) { + 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; + this.key = key; + this.val = val; + this.oldVal = oldVal; + this.row = row; + } + + /** + * 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; + } + + /** + * Gets read entry key. + * + * @return Key. + */ + @Nullable public K key() { + return key; + } + + /** + * Gets read entry value. + * + * @return Value. + */ + @Nullable public V value() { + return val; + } + + /** + * Gets read entry old value (applicable for continuous queries). + * + * @return Old value. + */ + @Nullable public V oldValue() { + return oldVal; + } + + /** + * Gets read results set row. + * + * @return Result row. + */ + @Nullable public Object row() { + return row; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(CacheQueryReadEvent.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/CheckpointEvent.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/events/CheckpointEvent.java b/modules/core/src/main/java/org/apache/ignite/events/CheckpointEvent.java new file mode 100644 index 0000000..b4dbddf --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/events/CheckpointEvent.java @@ -0,0 +1,122 @@ +/* + * 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.*; + +/** + * Grid checkpoint 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_CHECKPOINT_LOADED + * @see EventType#EVT_CHECKPOINT_REMOVED + * @see EventType#EVT_CHECKPOINT_SAVED + * @see EventType#EVTS_CHECKPOINT + */ +public class CheckpointEvent extends EventAdapter { + /** */ + private static final long serialVersionUID = 0L; + + /** */ + private String cpKey; + + /** + * No-arg constructor. + */ + public CheckpointEvent() { + // No-op. + } + + /** + * Creates new checkpoint event with given parameters. + * + * @param node Local node. + * @param msg Optional event message. + * @param type Event type. + * @param cpKey Checkpoint key associated with this event. + */ + public CheckpointEvent(ClusterNode node, String msg, int type, String cpKey) { + super(node, msg, type); + + this.cpKey = cpKey; + } + + /** {@inheritDoc} */ + @Override public String shortDisplay() { + return name() + ": cpKey=" + cpKey; + } + + /** + * Gets checkpoint key associated with this event. + * + * @return Checkpoint key associated with this event. + */ + public String key() { + assert cpKey != null; + + return cpKey; + } + + /** + * Sets checkpoint key. + * + * @param cpKey Checkpoint key to set. + */ + public void key(String cpKey) { + assert cpKey != null; + + this.cpKey = cpKey; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(CheckpointEvent.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/DeploymentEvent.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/events/DeploymentEvent.java b/modules/core/src/main/java/org/apache/ignite/events/DeploymentEvent.java new file mode 100644 index 0000000..9664855 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/events/DeploymentEvent.java @@ -0,0 +1,118 @@ +/* + * 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.*; + +/** + * Grid deployment 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_CLASS_DEPLOY_FAILED + * @see EventType#EVT_CLASS_DEPLOYED + * @see EventType#EVT_CLASS_UNDEPLOYED + * @see EventType#EVT_TASK_DEPLOY_FAILED + * @see EventType#EVT_TASK_DEPLOYED + * @see EventType#EVT_TASK_UNDEPLOYED + * @see EventType#EVTS_DEPLOYMENT + */ +public class DeploymentEvent extends EventAdapter { + /** */ + private static final long serialVersionUID = 0L; + + /** */ + private String alias; + + /** {@inheritDoc} */ + @Override public String shortDisplay() { + return name() + (alias != null ? ": " + alias : ""); + } + + /** + * No-arg constructor. + */ + public DeploymentEvent() { + // No-op. + } + + /** + * Creates deployment event with given parameters. + * + * @param node Node. + * @param msg Optional event message. + * @param type Event type. + */ + public DeploymentEvent(ClusterNode node, String msg, int type) { + super(node, msg, type); + } + + /** + * Gets deployment alias for this event. + * + * @return Deployment alias. + */ + public String alias() { + return alias; + } + + /** + * Sets deployment alias for this event. + * + * @param alias Deployment alias. + */ + public void alias(String alias) { + this.alias = alias; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(DeploymentEvent.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/DiscoveryEvent.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/events/DiscoveryEvent.java b/modules/core/src/main/java/org/apache/ignite/events/DiscoveryEvent.java new file mode 100644 index 0000000..e0145cf --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/events/DiscoveryEvent.java @@ -0,0 +1,165 @@ +/* + * 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.*; +import org.apache.ignite.internal.util.typedef.internal.*; + +import java.util.*; + +/** + * Grid discovery 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_NODE_METRICS_UPDATED + * @see EventType#EVT_NODE_FAILED + * @see EventType#EVT_NODE_JOINED + * @see EventType#EVT_NODE_LEFT + * @see EventType#EVT_NODE_SEGMENTED + * @see EventType#EVTS_DISCOVERY_ALL + * @see EventType#EVTS_DISCOVERY + */ +public class DiscoveryEvent extends EventAdapter { + /** */ + private static final long serialVersionUID = 0L; + + /** */ + private ClusterNode evtNode; + + /** Topology version. */ + private long topVer; + + /** Collection of nodes corresponding to topology version. */ + private Collection<ClusterNode> topSnapshot; + + /** {@inheritDoc} */ + @Override public String shortDisplay() { + return name() + ": id8=" + U.id8(evtNode.id()) + ", ip=" + F.first(evtNode.addresses()); + } + + /** + * No-arg constructor. + */ + public DiscoveryEvent() { + // No-op. + } + + /** + * Creates new discovery event with given parameters. + * + * @param node Local node. + * @param msg Optional event message. + * @param type Event type. + * @param evtNode Node that caused this event to be generated. + */ + public DiscoveryEvent(ClusterNode node, String msg, int type, ClusterNode evtNode) { + super(node, msg, type); + + this.evtNode = evtNode; + } + + /** + * Sets node this event is referring to. + * + * @param evtNode Event node. + */ + public void eventNode(ClusterNode evtNode) { + this.evtNode = evtNode; + } + + /** + * Gets node that caused this event to be generated. It is potentially different from the node + * on which this event was recorded. For example, node {@code A} locally recorded the event that a remote node + * {@code B} joined the topology. In this case this method will return ID of {@code B}. + * + * @return Event node ID. + */ + public ClusterNode eventNode() { + return evtNode; + } + + /** + * Gets topology version if this event is raised on + * topology change and configured discovery SPI implementation + * supports topology versioning. + * + * @return Topology version or {@code 0} if configured discovery SPI implementation + * does not support versioning. + */ + public long topologyVersion() { + return topVer; + } + + /** + * Gets topology nodes from topology snapshot. If SPI implementation does not support + * versioning, the best effort snapshot will be captured. + * + * @return Topology snapshot. + */ + public Collection<ClusterNode> topologyNodes() { + return topSnapshot; + } + + /** + * Sets the topology snapshot. + * + * @param topVer Topology version. + * @param topSnapshot Topology snapshot. + */ + public void topologySnapshot(long topVer, Collection<ClusterNode> topSnapshot) { + this.topVer = topVer; + this.topSnapshot = topSnapshot; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(DiscoveryEvent.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/Event.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/events/Event.java b/modules/core/src/main/java/org/apache/ignite/events/Event.java new file mode 100644 index 0000000..6330326 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/events/Event.java @@ -0,0 +1,154 @@ +/* + * 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.lang.*; +import org.jetbrains.annotations.*; + +import java.io.*; + +/** + * 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...)} - 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> + * <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 either {@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. + * <h1 class="header">Internal and Hidden Events</h1> + * Also note that some events are considered to be internally used or hidden. + * <p> + * Internally used events are always "recordable" for notification purposes (regardless of whether they were + * enabled or disabled). But won't be sent down to SPI level if user specifically excluded them. + * <p> + * All discovery events are internal: + * <ul> + * <li>{@link EventType#EVT_NODE_FAILED}</li> + * <li>{@link EventType#EVT_NODE_LEFT}</li> + * <li>{@link EventType#EVT_NODE_JOINED}</li> + * <li>{@link EventType#EVT_NODE_METRICS_UPDATED}</li> + * <li>{@link EventType#EVT_NODE_SEGMENTED}</li> + * </ul> + * <p> + * Hidden events are NEVER sent to SPI level. They serve purpose of local + * notification for the local node. + * <p> + * Hidden events: + * <ul> + * <li>{@link EventType#EVT_NODE_METRICS_UPDATED}</li> + * </ul> + * @see JobEvent + * @see CacheEvent + * @see CachePreloadingEvent + * @see SwapSpaceEvent + * @see CheckpointEvent + * @see DeploymentEvent + * @see DiscoveryEvent + * @see TaskEvent + * @see org.apache.ignite.IgniteEvents#waitForLocal(org.apache.ignite.lang.IgnitePredicate, int...) + */ +public interface Event extends Comparable<Event>, Serializable { + /** + * Gets globally unique ID of this event. + * + * @return Globally unique ID of this event. + * @see #localOrder() + */ + public IgniteUuid id(); + + /** + * Gets locally unique ID that is atomically incremented for each event. Unlike + * global {@link #id} this local ID can be used for ordering events on this node. + * <p> + * Note that for performance considerations GridGain doesn't order events globally. + * + * @return Locally unique ID that is atomically incremented for each new event. + * @see #id() + */ + public long localOrder(); + + /** + * Node where event occurred and was recorded + * + * @return node where event occurred and was recorded. + */ + public ClusterNode node(); + + /** + * Gets optional message for this event. + * + * @return Optional (can be {@code null}) message for this event. + */ + @Nullable public String message(); + + /** + * Gets type of this event. All system event types are defined in + * {@link EventType}. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @return Event's type. + * @see EventType + */ + public int type(); + + /** + * Gets name of this event. All events are defined in {@link EventType} class. + * + * @return Name of this event. + */ + public String name(); + + /** + * Gets event timestamp. Timestamp is local to the node on which this + * event was produced. Note that more than one event can be generated + * with the same timestamp. For ordering purposes use {@link #localOrder()} instead. + * + * @return Event timestamp. + */ + public long timestamp(); + + /** + * Gets a shortened version of {@code toString()} result. Suitable for humans to read. + * + * @return Shortened version of {@code toString()} result. + */ + public String shortDisplay(); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/modules/core/src/main/java/org/apache/ignite/events/EventAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/events/EventAdapter.java b/modules/core/src/main/java/org/apache/ignite/events/EventAdapter.java new file mode 100644 index 0000000..3b8fa86 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/events/EventAdapter.java @@ -0,0 +1,168 @@ +/* + * 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.lang.*; +import org.jetbrains.annotations.*; + +/** + * Base adapter for the events. All events (including user-defined ones) should + * extend this adapter as it provides necessary plumbing implementation details. + */ +public class EventAdapter implements Event { + /** */ + private static final long serialVersionUID = 0L; + + /** */ + private final IgniteUuid id = IgniteUuid.randomUuid(); + + /** */ + private final long tstamp = U.currentTimeMillis(); + + /** */ + private ClusterNode node; + + /** */ + private String msg; + + /** */ + private int type; + + /** */ + private long locId = EventLocalOrder.nextOrder(); + + /** + * No-arg constructor. + */ + public EventAdapter() { + // No-op. + } + + /** + * Creates event based with given parameters. + * + * @param msg Optional message. + * @param type Event type. + */ + public EventAdapter(ClusterNode node, String msg, int type) { + assert tstamp > 0; + + A.ensure(type > 0, "Event type ID must be greater than zero."); + + this.node = node; + this.msg = msg; + this.type = type; + } + + /** {@inheritDoc} */ + @Override public int compareTo(Event o) { + return o == null ? 1 : id.compareTo(o.id()); + } + + /** {@inheritDoc} */ + @Override public IgniteUuid id() { + return id; + } + + /** {@inheritDoc} */ + @Override public long localOrder() { + return locId; + } + + /** {@inheritDoc} */ + @Override public boolean equals(Object o) { + assert id != null; + + return this == o || o instanceof EventAdapter && id.equals(((Event)o).id()); + } + + /** {@inheritDoc} */ + @Override public int hashCode() { + assert id != null; + + return id.hashCode(); + } + + /** + * Sets node where even is occurred (i.e. node local to the event). + * + * @param node Node. + */ + public void node(ClusterNode node) { + this.node = node; + } + + /** + * Sets optional event message. + * + * @param msg Optional event message. + */ + public void message(@Nullable String msg) { + this.msg = msg; + } + + /** + * Sets event type. + * + * @param type Event type. + */ + public void type(int type) { + this.type = type; + } + + /** {@inheritDoc} */ + @Override public ClusterNode node() { + return node; + } + + /** {@inheritDoc} */ + @Nullable @Override public String message() { + return msg; + } + + /** {@inheritDoc} */ + @Override public int type() { + return type; + } + + /** {@inheritDoc} */ + @Override public long timestamp() { + return tstamp; + } + + /** + * Gets event type name. + * + * @return Event type name. + */ + @Override public String name() { + return U.gridEventName(type()); + } + + /** {@inheritDoc} */ + @Override public String shortDisplay() { + return toString(); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(EventAdapter.class, this, "name", name()); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/modules/core/src/main/java/org/apache/ignite/events/EventLocalOrder.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/events/EventLocalOrder.java b/modules/core/src/main/java/org/apache/ignite/events/EventLocalOrder.java new file mode 100644 index 0000000..8efe8a7 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/events/EventLocalOrder.java @@ -0,0 +1,44 @@ +/* + * 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 java.util.concurrent.atomic.*; + +/** + * Generator for local atomically incremented IDs for grid events. + */ +final class EventLocalOrder { + /** Generator implementation. */ + private static final AtomicLong gen = new AtomicLong(0); + + /** + * No-arg constructor enforces the singleton. + */ + private EventLocalOrder() { + // No-op. + } + + /** + * Gets next atomically incremented local event order. + * + * @return Next atomically incremented local event order. + */ + public static long nextOrder() { + return gen.getAndIncrement(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/modules/core/src/main/java/org/apache/ignite/events/EventType.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/events/EventType.java b/modules/core/src/main/java/org/apache/ignite/events/EventType.java new file mode 100644 index 0000000..72cf4fd0 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/events/EventType.java @@ -0,0 +1,1146 @@ +/* + * 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.internal.util.typedef.internal.*; + +import java.util.*; + +/** + * Contains event type constants. The decision to use class and not enumeration + * dictated by allowing users to create their own events and/or event types which + * would be impossible with enumerations. + * <p> + * Note that this interface defines not only + * individual type constants but arrays of types as well to be conveniently used with + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} method: + * <ul> + * <li>{@link #EVTS_CHECKPOINT}</li> + * <li>{@link #EVTS_DEPLOYMENT}</li> + * <li>{@link #EVTS_DISCOVERY}</li> + * <li>{@link #EVTS_DISCOVERY_ALL}</li> + * <li>{@link #EVTS_JOB_EXECUTION}</li> + * <li>{@link #EVTS_TASK_EXECUTION}</li> + * <li>{@link #EVTS_LICENSE}</li> + * <li>{@link #EVTS_CACHE}</li> + * <li>{@link #EVTS_CACHE_PRELOAD}</li> + * <li>{@link #EVTS_CACHE_QUERY}</li> + * <li>{@link #EVTS_SWAPSPACE}</li> + * <li>{@link #EVTS_AUTHENTICATION}</li> + * <li>{@link #EVTS_SECURE_SESSION}</li> + * </ul> + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * <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 either {@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. + */ +public interface EventType { + /** + * Built-in event type: checkpoint was saved. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see CheckpointEvent + */ + public static final int EVT_CHECKPOINT_SAVED = 1; + + /** + * Built-in event type: checkpoint was loaded. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see CheckpointEvent + */ + public static final int EVT_CHECKPOINT_LOADED = 2; + + /** + * Built-in event type: checkpoint was removed. Reasons are: + * <ul> + * <li>timeout expired, or + * <li>or it was manually removed, or + * <li>it was automatically removed by the task session + * </ul> + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see CheckpointEvent + */ + public static final int EVT_CHECKPOINT_REMOVED = 3; + + /** + * Built-in event type: node joined topology. + * <br> + * New node has been discovered and joined grid topology. + * Note that even though a node has been discovered there could be + * a number of warnings in the log. In certain situations GridGain + * doesn't prevent a node from joining but prints warning messages into the log. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see DiscoveryEvent + */ + public static final int EVT_NODE_JOINED = 10; + + /** + * Built-in event type: node has normally left topology. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see DiscoveryEvent + */ + public static final int EVT_NODE_LEFT = 11; + + /** + * Built-in event type: node failed. + * <br> + * GridGain detected that node has presumably crashed and is considered failed. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see DiscoveryEvent + */ + public static final int EVT_NODE_FAILED = 12; + + /** + * Built-in event type: node metrics updated. + * <br> + * Generated when node's metrics are updated. In most cases this callback + * is invoked with every heartbeat received from a node (including local node). + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see DiscoveryEvent + */ + public static final int EVT_NODE_METRICS_UPDATED = 13; + + /** + * Built-in event type: local node segmented. + * <br> + * Generated when node determines that it runs in invalid network segment. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see DiscoveryEvent + */ + public static final int EVT_NODE_SEGMENTED = 14; + + public static final int EVT_CLIENT_NODE_DISCONNECTED = 16; + + public static final int EVT_CLIENT_NODE_RECONNECTED = 17; + + /** + * Built-in event type: task started. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see TaskEvent + */ + public static final int EVT_TASK_STARTED = 20; + + /** + * Built-in event type: task finished. + * <br> + * Task got finished. This event is triggered every time + * a task finished without exception. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see TaskEvent + */ + public static final int EVT_TASK_FINISHED = 21; + + /** + * Built-in event type: task failed. + * <br> + * Task failed. This event is triggered every time a task finished with an exception. + * Note that prior to this event, there could be other events recorded specific + * to the failure. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see TaskEvent + */ + public static final int EVT_TASK_FAILED = 22; + + /** + * Built-in event type: task timed out. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see TaskEvent + */ + public static final int EVT_TASK_TIMEDOUT = 23; + + /** + * Built-in event type: task session attribute set. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see TaskEvent + */ + public static final int EVT_TASK_SESSION_ATTR_SET = 24; + + /** + * Built-in event type: task reduced. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + */ + public static final int EVT_TASK_REDUCED = 25; + + /** + * Built-in event type: non-task class deployed. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see DeploymentEvent + */ + public static final int EVT_CLASS_DEPLOYED = 30; + + /** + * Built-in event type: non-task class undeployed. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see DeploymentEvent + */ + public static final int EVT_CLASS_UNDEPLOYED = 31; + + /** + * Built-in event type: non-task class deployment failed. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see DeploymentEvent + */ + public static final int EVT_CLASS_DEPLOY_FAILED = 32; + + /** + * Built-in event type: task deployed. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see DeploymentEvent + */ + public static final int EVT_TASK_DEPLOYED = 33; + + /** + * Built-in event type: task undeployed. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see DeploymentEvent + */ + public static final int EVT_TASK_UNDEPLOYED = 34; + + /** + * Built-in event type: task deployment failed. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see DeploymentEvent + */ + public static final int EVT_TASK_DEPLOY_FAILED = 35; + + /** + * Built-in event type: grid job was mapped in + * {@link org.apache.ignite.compute.ComputeTask#map(List, Object)} method. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see JobEvent + */ + public static final int EVT_JOB_MAPPED = 40; + + /** + * Built-in event type: grid job result was received by + * {@link org.apache.ignite.compute.ComputeTask#result(org.apache.ignite.compute.ComputeJobResult, List)} method. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see JobEvent + */ + public static final int EVT_JOB_RESULTED = 41; + + /** + * Built-in event type: grid job failed over. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see JobEvent + */ + public static final int EVT_JOB_FAILED_OVER = 43; + + /** + * Built-in event type: grid job started. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see JobEvent + */ + public static final int EVT_JOB_STARTED = 44; + + /** + * Built-in event type: grid job finished. + * <br> + * Job has successfully completed and produced a result which from the user perspective + * can still be either negative or positive. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see JobEvent + */ + public static final int EVT_JOB_FINISHED = 45; + + /** + * Built-in event type: grid job timed out. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see JobEvent + */ + public static final int EVT_JOB_TIMEDOUT = 46; + + /** + * Built-in event type: grid job rejected during collision resolution. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see JobEvent + */ + public static final int EVT_JOB_REJECTED = 47; + + /** + * Built-in event type: grid job failed. + * <br> + * Job has failed. This means that there was some error event during job execution + * and job did not produce a result. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see JobEvent + */ + public static final int EVT_JOB_FAILED = 48; + + /** + * Built-in event type: grid job queued. + * <br> + * Job arrived for execution and has been queued (added to passive queue during + * collision resolution). + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see JobEvent + */ + public static final int EVT_JOB_QUEUED = 49; + + /** + * Built-in event type: grid job cancelled. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see JobEvent + */ + public static final int EVT_JOB_CANCELLED = 50; + + /** + * Built-in event type: entry created. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + */ + public static final int EVT_CACHE_ENTRY_CREATED = 60; + + /** + * Built-in event type: entry destroyed. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + */ + public static final int EVT_CACHE_ENTRY_DESTROYED = 61; + + /** + * Built-in event type: entry evicted. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + */ + public static final int EVT_CACHE_ENTRY_EVICTED = 62; + + /** + * Built-in event type: object put. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + */ + public static final int EVT_CACHE_OBJECT_PUT = 63; + + /** + * Built-in event type: object read. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + */ + public static final int EVT_CACHE_OBJECT_READ = 64; + + /** + * Built-in event type: object removed. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + */ + public static final int EVT_CACHE_OBJECT_REMOVED = 65; + + /** + * Built-in event type: object locked. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + */ + public static final int EVT_CACHE_OBJECT_LOCKED = 66; + + /** + * Built-in event type: object unlocked. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + */ + public static final int EVT_CACHE_OBJECT_UNLOCKED = 67; + + /** + * Built-in event type: cache object swapped from swap storage. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + */ + public static final int EVT_CACHE_OBJECT_SWAPPED = 68; + + /** + * Built-in event type: cache object unswapped from swap storage. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + */ + public static final int EVT_CACHE_OBJECT_UNSWAPPED = 69; + + /** + * Built-in event type: cache object was expired when reading it. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + */ + public static final int EVT_CACHE_OBJECT_EXPIRED = 70; + + /** + * Built-in event type: swap space data read. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see SwapSpaceEvent + */ + public static final int EVT_SWAP_SPACE_DATA_READ = 71; + + /** + * Built-in event type: swap space data stored. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see SwapSpaceEvent + */ + public static final int EVT_SWAP_SPACE_DATA_STORED = 72; + + /** + * Built-in event type: swap space data removed. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see SwapSpaceEvent + */ + public static final int EVT_SWAP_SPACE_DATA_REMOVED = 73; + + /** + * Built-in event type: swap space cleared. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see SwapSpaceEvent + */ + public static final int EVT_SWAP_SPACE_CLEARED = 74; + + /** + * Built-in event type: swap space data evicted. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see SwapSpaceEvent + */ + public static final int EVT_SWAP_SPACE_DATA_EVICTED = 75; + + /** + * Built-in event type: cache object stored in off-heap storage. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + */ + public static final int EVT_CACHE_OBJECT_TO_OFFHEAP = 76; + + /** + * Built-in event type: cache object moved from off-heap storage back into memory. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + */ + public static final int EVT_CACHE_OBJECT_FROM_OFFHEAP = 77; + + /** + * Built-in event type: cache preload started. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see SwapSpaceEvent + */ + public static final int EVT_CACHE_PRELOAD_STARTED = 80; + + /** + * Built-in event type: cache preload stopped. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see SwapSpaceEvent + */ + public static final int EVT_CACHE_PRELOAD_STOPPED = 81; + + /** + * Built-in event type: cache partition loaded. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see SwapSpaceEvent + */ + public static final int EVT_CACHE_PRELOAD_PART_LOADED = 82; + + /** + * Built-in event type: cache partition unloaded. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + */ + public static final int EVT_CACHE_PRELOAD_PART_UNLOADED = 83; + + /** + * Built-in event type: cache entry preloaded. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + */ + public static final int EVT_CACHE_PRELOAD_OBJECT_LOADED = 84; + + /** + * Built-in event type: cache entry unloaded. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + */ + public static final int EVT_CACHE_PRELOAD_OBJECT_UNLOADED = 85; + + /** + * Built-in event type: query executed. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + */ + public static final int EVT_CACHE_QUERY_EXECUTED = 96; + + /** + * Built-in event type: query entry read. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + */ + public static final int EVT_CACHE_QUERY_OBJECT_READ = 97; + + /** + * Built-in event type: license violation detected. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see LicenseEvent + */ + public static final int EVT_LIC_VIOLATION = 108; + + /** + * Built-in event type: license violation cleared. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see LicenseEvent + */ + public static final int EVT_LIC_CLEARED = 109; + + /** + * Built-in event type: license violation grace period is expired. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see LicenseEvent + */ + public static final int EVT_LIC_GRACE_EXPIRED = 110; + + /** + * Built-in event type: authentication succeed. + * <p> + * Authentication procedure succeed. This event is triggered every time + * an authentication procedure finished without exception. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see AuthenticationEvent + */ + public static final int EVT_AUTHENTICATION_SUCCEEDED = 111; + + /** + * Built-in event type: authentication failed. + * <p> + * Authentication procedure failed. This means that there was some error event + * during authentication procedure and authentication procedure was not successful. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see AuthenticationEvent + */ + public static final int EVT_AUTHENTICATION_FAILED = 112; + + /** + * Built-in event type: secure session validation succeed. + * <p> + * Secure session validation succeed. This event is triggered every time + * a validation of secure session procedure finished without exception. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see SecureSessionEvent + */ + public static final int EVT_SECURE_SESSION_VALIDATION_SUCCEEDED = 113; + + /** + * Built-in event type: secure session validation failed. + * <br> + * Secure session validation failed. This means that there was some error event + * during secure session validation procedure and validation was not succeed. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see SecureSessionEvent + */ + public static final int EVT_SECURE_SESSION_VALIDATION_FAILED = 114; + + /** + * Built-in event type: Visor detects that some events were evicted from events buffer since last poll. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + */ + public static final int EVT_VISOR_EVENTS_LOST = 115; + + /** + * Built-in event type: GGFS file created. + * <p> + * Fired when GGFS component creates new file. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see IgniteFsEvent + */ + public static final int EVT_GGFS_FILE_CREATED = 116; + + /** + * Built-in event type: GGFS file renamed. + * <p> + * Fired when GGFS component renames an existing file. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see IgniteFsEvent + */ + public static final int EVT_GGFS_FILE_RENAMED = 117; + + /** + * Built-in event type: GGFS file deleted. + * <p> + * Fired when GGFS component deletes a file. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see IgniteFsEvent + */ + public static final int EVT_GGFS_FILE_DELETED = 118; + + /** + * Built-in event type: GGFS file opened for reading. + * <p> + * Fired when GGFS file is opened for reading. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see IgniteFsEvent + */ + public static final int EVT_GGFS_FILE_OPENED_READ = 119; + + /** + * Built-in event type: GGFS file opened for writing. + * <p> + * Fired when GGFS file is opened for writing. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see IgniteFsEvent + */ + public static final int EVT_GGFS_FILE_OPENED_WRITE = 120; + + /** + * Built-in event type: GGFS file or directory metadata updated. + * <p> + * Fired when GGFS file or directory metadata is updated. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see IgniteFsEvent + */ + public static final int EVT_GGFS_META_UPDATED = 121; + + /** + * Built-in event type: GGFS file closed. + * <p> + * Fired when GGFS file is closed. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see IgniteFsEvent + */ + public static final int EVT_GGFS_FILE_CLOSED_WRITE = 122; + + /** + * Built-in event type: GGFS file closed. + * <p> + * Fired when GGFS file is closed. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see IgniteFsEvent + */ + public static final int EVT_GGFS_FILE_CLOSED_READ = 123; + + /** + * Built-in event type: GGFS directory created. + * <p> + * Fired when GGFS component creates new directory. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see IgniteFsEvent + */ + public static final int EVT_GGFS_DIR_CREATED = 124; + + /** + * Built-in event type: GGFS directory renamed. + * <p> + * Fired when GGFS component renames an existing directory. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see IgniteFsEvent + */ + public static final int EVT_GGFS_DIR_RENAMED = 125; + + /** + * Built-in event type: GGFS directory deleted. + * <p> + * Fired when GGFS component deletes a directory. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see IgniteFsEvent + */ + public static final int EVT_GGFS_DIR_DELETED = 126; + + /** + * Built-in event type: GGFS file purged. + * <p> + * Fired when GGFS file data was actually removed from cache. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see IgniteFsEvent + */ + public static final int EVT_GGFS_FILE_PURGED = 127; + + /** + * Built-in event type: authorization succeed. + * <p> + * Authorization procedure succeed. This event is triggered every time + * an authorization procedure finished without exception. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see AuthorizationEvent + */ + public static final int EVT_AUTHORIZATION_SUCCEEDED = 128; + + /** + * Built-in event type: authorization failed. + * <p> + * Authorization procedure failed. This means that there was some error event + * during authorization procedure and authorization procedure was not successful. + * <p> + * NOTE: all types in range <b>from 1 to 1000 are reserved</b> for + * internal GridGain events and should not be used by user-defined events. + * + * @see AuthorizationEvent + */ + public static final int EVT_AUTHORIZATION_FAILED = 129; + + /** + * All license events. This array can be directly passed into + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} method to + * subscribe to all license events. + * + * @see LicenseEvent + */ + public static final int[] EVTS_LICENSE = { + EVT_LIC_CLEARED, + EVT_LIC_VIOLATION, + EVT_LIC_GRACE_EXPIRED + }; + + /** + * All checkpoint events. This array can be directly passed into + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} method to + * subscribe to all checkpoint events. + * + * @see CheckpointEvent + */ + public static final int[] EVTS_CHECKPOINT = { + EVT_CHECKPOINT_SAVED, + EVT_CHECKPOINT_LOADED, + EVT_CHECKPOINT_REMOVED + }; + + /** + * All deployment events. This array can be directly passed into + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} method to + * subscribe to all deployment events. + * + * @see DeploymentEvent + */ + public static final int[] EVTS_DEPLOYMENT = { + EVT_CLASS_DEPLOYED, + EVT_CLASS_UNDEPLOYED, + EVT_CLASS_DEPLOY_FAILED, + EVT_TASK_DEPLOYED, + EVT_TASK_UNDEPLOYED, + EVT_TASK_DEPLOY_FAILED + }; + + /** + * All events indicating an error or failure condition. It is convenient to use + * when fetching all events indicating error or failure. + */ + public static final int[] EVTS_ERROR = { + EVT_JOB_TIMEDOUT, + EVT_JOB_FAILED, + EVT_JOB_FAILED_OVER, + EVT_JOB_REJECTED, + EVT_JOB_CANCELLED, + EVT_TASK_TIMEDOUT, + EVT_TASK_FAILED, + EVT_CLASS_DEPLOY_FAILED, + EVT_TASK_DEPLOY_FAILED, + EVT_TASK_DEPLOYED, + EVT_TASK_UNDEPLOYED, + EVT_LIC_CLEARED, + EVT_LIC_VIOLATION, + EVT_LIC_GRACE_EXPIRED, + EVT_CACHE_PRELOAD_STARTED, + EVT_CACHE_PRELOAD_STOPPED + }; + + /** + * All discovery events <b>except</b> for {@link #EVT_NODE_METRICS_UPDATED}. Subscription to + * {@link #EVT_NODE_METRICS_UPDATED} can generate massive amount of event processing in most cases + * is not necessary. If this event is indeed required you can subscribe to it individually or use + * {@link #EVTS_DISCOVERY_ALL} array. + * <p> + * This array can be directly passed into + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} method to + * subscribe to all discovery events <b>except</b> for {@link #EVT_NODE_METRICS_UPDATED}. + * + * @see DiscoveryEvent + */ + public static final int[] EVTS_DISCOVERY = { + EVT_NODE_JOINED, + EVT_NODE_LEFT, + EVT_NODE_FAILED, + EVT_NODE_SEGMENTED, + EVT_CLIENT_NODE_DISCONNECTED, + EVT_CLIENT_NODE_RECONNECTED + }; + + /** + * All discovery events. This array can be directly passed into + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} method to + * subscribe to all discovery events. + * + * @see DiscoveryEvent + */ + public static final int[] EVTS_DISCOVERY_ALL = { + EVT_NODE_JOINED, + EVT_NODE_LEFT, + EVT_NODE_FAILED, + EVT_NODE_SEGMENTED, + EVT_NODE_METRICS_UPDATED, + EVT_CLIENT_NODE_DISCONNECTED, + EVT_CLIENT_NODE_RECONNECTED + }; + + /** + * All grid job execution events. This array can be directly passed into + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} method to + * subscribe to all grid job execution events. + * + * @see JobEvent + */ + public static final int[] EVTS_JOB_EXECUTION = { + EVT_JOB_MAPPED, + EVT_JOB_RESULTED,+ + EVT_JOB_FAILED_OVER, + EVT_JOB_STARTED, + EVT_JOB_FINISHED, + EVT_JOB_TIMEDOUT, + EVT_JOB_REJECTED, + EVT_JOB_FAILED, + EVT_JOB_QUEUED, + EVT_JOB_CANCELLED + }; + + /** + * All grid task execution events. This array can be directly passed into + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} method to + * subscribe to all grid task execution events. + * + * @see TaskEvent + */ + public static final int[] EVTS_TASK_EXECUTION = { + EVT_TASK_STARTED, + EVT_TASK_FINISHED, + EVT_TASK_FAILED, + EVT_TASK_TIMEDOUT, + EVT_TASK_SESSION_ATTR_SET, + EVT_TASK_REDUCED + }; + + /** + * All cache events. This array can be directly passed into + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} method to + * subscribe to all cache events. + */ + public static final int[] EVTS_CACHE = { + EVT_CACHE_ENTRY_CREATED, + EVT_CACHE_ENTRY_DESTROYED, + EVT_CACHE_OBJECT_PUT, + EVT_CACHE_OBJECT_READ, + EVT_CACHE_OBJECT_REMOVED, + EVT_CACHE_OBJECT_LOCKED, + EVT_CACHE_OBJECT_UNLOCKED, + EVT_CACHE_OBJECT_SWAPPED, + EVT_CACHE_OBJECT_UNSWAPPED, + EVT_CACHE_OBJECT_EXPIRED + }; + + /** + * All cache preload events. This array can be directly passed into + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} method to + * subscribe to all cache preload events. + */ + public static final int[] EVTS_CACHE_PRELOAD = { + EVT_CACHE_PRELOAD_STARTED, + EVT_CACHE_PRELOAD_STOPPED, + EVT_CACHE_PRELOAD_PART_LOADED, + EVT_CACHE_PRELOAD_PART_UNLOADED, + EVT_CACHE_PRELOAD_OBJECT_LOADED, + EVT_CACHE_PRELOAD_OBJECT_UNLOADED + }; + + /** + * All cache query events. This array can be directly passed into + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} method to + * subscribe to all cache query events. + */ + public static final int[] EVTS_CACHE_QUERY = { + EVT_CACHE_QUERY_EXECUTED, + EVT_CACHE_QUERY_OBJECT_READ + }; + + /** + * All swap space events. This array can be directly passed into + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} method to + * subscribe to all cloud events. + * + * @see SwapSpaceEvent + */ + public static final int[] EVTS_SWAPSPACE = { + EVT_SWAP_SPACE_CLEARED, + EVT_SWAP_SPACE_DATA_REMOVED, + EVT_SWAP_SPACE_DATA_READ, + EVT_SWAP_SPACE_DATA_STORED, + EVT_SWAP_SPACE_DATA_EVICTED + }; + + /** + * All authentication events. This array can be directly passed into + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} method to + * subscribe to all cloud events. + * + * @see AuthenticationEvent + */ + public static final int[] EVTS_AUTHENTICATION = { + EVT_AUTHENTICATION_SUCCEEDED, + EVT_AUTHENTICATION_FAILED + }; + + /** + * All authorization events. This array can be directly passed into + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} method to + * subscribe to all cloud events. + * + * @see AuthenticationEvent + */ + public static final int[] EVTS_AUTHORIZATION = { + EVT_AUTHORIZATION_SUCCEEDED, + EVT_AUTHORIZATION_FAILED + }; + + /** + * All secure session events. This array can be directly passed into + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} method to + * subscribe to all GGFS events. + * + * @see IgniteFsEvent + */ + public static final int[] EVTS_SECURE_SESSION = { + EVT_SECURE_SESSION_VALIDATION_SUCCEEDED, + EVT_SECURE_SESSION_VALIDATION_FAILED + }; + + /** + * All GGFS events. This array can be directly passed into + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} method to + * subscribe to all cloud events. + * + * @see SecureSessionEvent + */ + public static final int[] EVTS_GGFS = { + EVT_GGFS_FILE_CREATED, + EVT_GGFS_FILE_RENAMED, + EVT_GGFS_FILE_DELETED, + EVT_GGFS_FILE_OPENED_READ, + EVT_GGFS_FILE_OPENED_WRITE, + EVT_GGFS_FILE_CLOSED_WRITE, + EVT_GGFS_FILE_CLOSED_READ, + EVT_GGFS_FILE_PURGED, + EVT_GGFS_META_UPDATED, + EVT_GGFS_DIR_CREATED, + EVT_GGFS_DIR_RENAMED, + EVT_GGFS_DIR_DELETED, + }; + + /** + * All GridGain events (<b>including</b> metric update event). + */ + public static final int[] EVTS_ALL = U.gridEvents(); + + /** + * All GridGain events (<b>excluding</b> metric update event). + */ + public static final int[] EVTS_ALL_MINUS_METRIC_UPDATE = U.gridEvents(EVT_NODE_METRICS_UPDATED); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f1c7b39/modules/core/src/main/java/org/apache/ignite/events/IgniteAuthenticationEvent.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/events/IgniteAuthenticationEvent.java b/modules/core/src/main/java/org/apache/ignite/events/IgniteAuthenticationEvent.java deleted file mode 100644 index 71a424e..0000000 --- a/modules/core/src/main/java/org/apache/ignite/events/IgniteAuthenticationEvent.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * 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 IgniteEventType#EVT_AUTHENTICATION_FAILED - * @see IgniteEventType#EVT_AUTHENTICATION_SUCCEEDED - */ -public class IgniteAuthenticationEvent extends IgniteEventAdapter { - /** */ - 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 IgniteAuthenticationEvent() { - // No-op. - } - - /** - * Creates authentication event with given parameters. - * - * @param msg Optional message. - * @param type Event type. - */ - public IgniteAuthenticationEvent(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 IgniteAuthenticationEvent(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(IgniteAuthenticationEvent.class, this, - "nodeId8", U.id8(node().id()), - "msg", message(), - "type", name(), - "tstamp", timestamp()); - } -}