Skip to content

IGNITE-28770 : Introduce a operation context attributes registry v2#13243

Open
Vladsz83 wants to merge 21 commits into
apache:masterfrom
Vladsz83:IGNITE-28770-Introduce-a-operation-context-attributes-registry_v2
Open

IGNITE-28770 : Introduce a operation context attributes registry v2#13243
Vladsz83 wants to merge 21 commits into
apache:masterfrom
Vladsz83:IGNITE-28770-Introduce-a-operation-context-attributes-registry_v2

Conversation

@Vladsz83

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java Outdated
@petrov-mg

petrov-mg commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

It's also worth adding meaningful comments describing the purpose of DistributedOperationContextManager and its methods.

What is DistributedOperationContextMessage and why was it decided to use a bitmap.

import org.jetbrains.annotations.Nullable;

/**
* A manager of {@link OperationContextAttribute} which are required to be propagated through a cluster.

@petrov-mg petrov-mg Jun 22, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/**
 * Provides the ability to manage {@link OperationContext} attributes in a distributed manner.
 *
 * <p>This mechanism is primarily used to propagate {@link OperationContext} state across the cluster by
 * capturing it before a message is sent, transferring it together with the message, and restoring it on
 * the receiving node before message processing begins.</p>
 *
 * <p>The implementation relies on a mapping between a distributed identifier and an
 * {@link OperationContextAttribute} instance that is consistent across all cluster nodes.</p>
 *
 * <p>To enable propagation of an {@link OperationContextAttribute} value across cluster nodes, the
 * attribute must be created using the {@link #createDistributedAttribute(byte, Message)} method.
 *
 * <p> Note, that the maximum number of distributed attribute instances that can be created is currently limited to
 * {@link #MAX_DISTRIBUTED_ATTR_CNT} for implementation reasons.</p>
 *
 * @see OperationContext
 * @see DistributedOperationContextMessage
 */

return INSTANCE;
}

/**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/**
     * Creates a new {@link OperationContext} attribute with the specified distributed ID and initial value.
     *
     * <p>The distributed ID is used to consistently identify the attribute across all nodes in the cluster.
     * It must be unique, and its value must be in the range from {@code 0} (inclusive) to {@code Byte.SIZE} (exclusive).</p>
     *
     * <p>The value of the created attribute is automatically captured and propagated between cluster nodes
     * during message transmission.</p>
     *
     * @see OperationContextAttribute#newInstance(Object)
     */

}

/**
* Requests current {@link OperationContext} for its effective attributes and collects ones which are also registered

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 /**
     * Collects the values of all distributed {@link OperationContextAttribute}s registered by this manager
     * in a format suitable for transmission between cluster nodes.
     *
     * @see OperationContext#get(OperationContextAttribute)
     */

return res;
}

/** Sets the received distributed operation context attributes (if any) into current {@link OperationContext}. */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/** Restores distributed {@link OperationContextAttribute} values received from a remote node. */

"join request (consider increasing 'joinTimeout' configuration property) " +
"[joinTimeout=" + spi.joinTimeout + ", sock=" + currSock + ']'));

if (msg instanceof TcpDiscoveryAbstractMessage msg0 && msg0.opCtxMsg != null) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just leave the method as is, but wrap all of its code in a try-with-resource block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants