-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GG-37994 Session attributes propagated to task event.
- Loading branch information
Showing
10 changed files
with
383 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
modules/core/src/main/java/org/apache/ignite/events/TaskEventV2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
* Copyright 2023 GridGain Systems, Inc. and Contributors. | ||
* | ||
* Licensed under the GridGain Community Edition License (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.gridgain.com/products/software/community-edition/gridgain-community-edition-license | ||
* | ||
* 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.ClusterNode; | ||
import org.apache.ignite.internal.util.typedef.internal.S; | ||
import org.apache.ignite.internal.util.typedef.internal.U; | ||
import org.apache.ignite.lang.IgniteUuid; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Map; | ||
import java.util.UUID; | ||
|
||
/** | ||
* Grid task event. | ||
* <p> | ||
* Grid events are used for notification about what happens within the grid. Note that by | ||
* design Ignite keeps all events generated on the local node locally and it provides | ||
* APIs for performing a distributed queries across multiple nodes: | ||
* <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 Ignite are enabled and therefore generated and stored | ||
* by whatever event storage SPI is configured. Ignite can and often does generate thousands events per seconds | ||
* under the load and therefore it creates a significant additional load on the system. If these events are | ||
* not needed by the application this load is unnecessary and leads to significant performance degradation. | ||
* <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 Ignite configuration. Note that certain | ||
* events are required for Ignite's internal operations and such events will still be generated but not stored by | ||
* event storage SPI if they are disabled in Ignite configuration. | ||
* @see EventType#EVT_TASK_FAILED | ||
* @see EventType#EVT_TASK_FINISHED | ||
* @see EventType#EVT_TASK_REDUCED | ||
* @see EventType#EVT_TASK_STARTED | ||
* @see EventType#EVT_TASK_SESSION_ATTR_SET | ||
* @see EventType#EVT_TASK_TIMEDOUT | ||
* @see EventType#EVTS_TASK_EXECUTION | ||
*/ | ||
public class TaskEventV2 extends TaskEvent { | ||
/** */ | ||
private static final long serialVersionUID = 0L; | ||
|
||
/** */ | ||
private Map<Object, Object> attributes; | ||
|
||
/** | ||
* | ||
* @param node Node. | ||
* @param msg Optional message. | ||
* @param type Event type. | ||
* @param sesId Task session ID. | ||
* @param taskName Task name. | ||
* @param taskClsName Task class name. | ||
* @param internal Task is internal. | ||
* @param subjId Subject ID. | ||
* @param attributes Task session attributes. | ||
*/ | ||
public TaskEventV2(ClusterNode node, String msg, int type, IgniteUuid sesId, String taskName, String taskClsName, | ||
boolean internal, @Nullable UUID subjId, Map<Object, Object> attributes) { | ||
super(node, msg, type, sesId, taskName, taskClsName, internal, subjId); | ||
this.attributes = attributes; | ||
} | ||
|
||
/** | ||
* Gets map of attributes from attached task session. | ||
* | ||
* @return Attributes from task session. | ||
*/ | ||
public Map<Object, Object> attributes() { | ||
return attributes; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override public String toString() { | ||
return S.toString(TaskEventV2.class, this, | ||
"nodeId8", U.id8(node().id()), | ||
"msg", message(), | ||
"type", name(), | ||
"attributes", attributes(), | ||
"tstamp", timestamp()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.