Skip to content

IGNITE-28731 Create cluster auto activation plugin - #355

Open
DenisPolo wants to merge 4 commits into
apache:masterfrom
DenisPolo:ignite-28731
Open

IGNITE-28731 Create cluster auto activation plugin#355
DenisPolo wants to merge 4 commits into
apache:masterfrom
DenisPolo:ignite-28731

Conversation

@DenisPolo

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread .gigaide/gigaide.properties Outdated
@DenisPolo
DenisPolo force-pushed the ignite-28731 branch 2 times, most recently from e1ba8c9 to 426bd4b Compare June 24, 2026 08:09
Comment thread modules/auto-activation-ext/README.md
Comment on lines +114 to +137
if (cluster.state() == ClusterState.ACTIVE) {
if (logger.isInfoEnabled())
logger.info("Auto activation skipped - cluster already activated");

return;
}

if (cluster.currentBaselineTopology() != null) {
if (logger.isInfoEnabled())
logger.info("Auto activation skipped - baseline is not empty");

return;
}

if (condition.apply(cluster.nodes())) {
if (logger.isInfoEnabled())
logger.info("Auto activation plugin set cluster state ACTIVE - activation condition meet");

cluster.state(ClusterState.ACTIVE);
}
else {
if (logger.isInfoEnabled())
logger.info("Auto activation skipped - activation condition not meet");
}

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.

Should ACTIVE_READ_ONLY be treated as already activated here? With the current check the plugin skips only ACTIVE and later calls cluster.state(ACTIVE), so a read-only cluster can be promoted to read-write mode by auto-activation. I think auto-activation should only activate INACTIVE clusters and leave ACTIVE_READ_ONLY unchanged.

Also add test for ACTIVE_READ_ONLY nodes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Absolutely agree. Added a check for ClusterState.ACTIVE_READ_ONLY and corresponding tests

return;
}

if (condition.apply(cluster.nodes())) {

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.

Should this condition be evaluated only against server nodes? cluster.nodes() includes client nodes, so a client node with a matching consistentId or attribute can satisfy the activation condition and trigger cluster activation before the required server topology is actually present

WDYT?

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.

Also add test for scenario with client nodes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a fair point. I added throwing an 'IgniteException' when a client node is included in the 'conditions' for auto-activation and tests

@@ -0,0 +1,113 @@
<beans xmlns="http://www.springframework.org/schema/beans"

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.

These XML test configs duplicate most of the Ignite configuration. Can we move the common storage/cache/discovery/connector settings to a shared parent bean or common XML file, and keep only node-specific values here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Great idea. Done


/** {@inheritDoc} */
@Override public boolean apply(Collection<ClusterNode> nodes) {
Set<String> missingNodes = new LinkedHashSet<>(requiredNodes);

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.

Suggested change
Set<String> missingNodes = new LinkedHashSet<>(requiredNodes);
Set<String> missingNodes = new HashSet<>(requiredNodes);

Comment on lines +128 to +138
if (condition.apply(cluster.nodes())) {
if (logger.isInfoEnabled())
logger.info("Auto activation plugin set cluster state ACTIVE - activation condition meet");

cluster.state(ClusterState.ACTIVE);
}
else {
if (logger.isInfoEnabled())
logger.info("Auto activation skipped - activation condition not meet");
}
}

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.

Suggested change
if (condition.apply(cluster.nodes())) {
if (logger.isInfoEnabled())
logger.info("Auto activation plugin set cluster state ACTIVE - activation condition meet");
cluster.state(ClusterState.ACTIVE);
}
else {
if (logger.isInfoEnabled())
logger.info("Auto activation skipped - activation condition not meet");
}
}
if (condition.apply(cluster.nodes())) {
if (logger.isInfoEnabled())
logger.info("Auto activation plugin set cluster state ACTIVE - activation condition meet");
cluster.state(ClusterState.ACTIVE);
return;
}
if (logger.isInfoEnabled())
logger.info("Auto activation skipped - activation condition not meet");
}

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.

Usually it's better to use extra return instead of else


/** {@inheritDoc} */
@Override public String copyright() {
return "";

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.

Suggested change
return "";
return "Apache Software Foundation";

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.

Same as in org.apache.ignite.cdc.conflictresolve.CacheVersionConflictResolverPluginProvider#copyright


/** {@inheritDoc} */
@Override public boolean apply(Collection<ClusterNode> nodes) {
Set<String> missingNodes = new LinkedHashSet<>(requiredValues);

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.

Suggested change
Set<String> missingNodes = new LinkedHashSet<>(requiredValues);
Set<String> missingNodes = new HashSet<>(requiredValues);

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.

Better to use HashSet when we do not need insertion order for iteration

Comment on lines +20 to +22
<!--
POM file.
-->

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.

Suggested change
<!--
POM file.
-->

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.

Delete to fix Ignoring multiple XML header comment! warning for command mvn clean install -pl :ignite-auto-activation-ext -am -Pcheckstyle -DskipTests

return;
}

if (condition.apply(cluster.nodes())) {

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.

Can we use cluster.forServers().nodes() here? Then we do not need client checks in both predicate classes.

Or replace IgniteException("Auto-activation-plugin supports on with return false

import org.apache.ignite.plugin.PluginValidationException;

/**
* Activate cluster when specified condition meet

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.

Suggested change
* Activate cluster when specified condition meet
* Activate cluster when specified condition meet.

import static org.apache.ignite.testframework.GridTestUtils.assertThrows;

/**
* {@link AutoActivationPluginProvider} test

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.

Suggested change
* {@link AutoActivationPluginProvider} test
* Tests {@link AutoActivationPluginProvider}.

- Cluster baseline is not empty
- `condition` contains any client node

Depending on how you use Ignite, you can an extension using one of the following methods:

@chesnokoff chesnokoff Aug 11, 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.

you can an extension using one

looks like a verb is missing

Comment on lines +119 to +133
switch (igniteInstanceName) {
case NODE_0:
igniteConfiguration.setConsistentId(NODE_0);
break;

case NODE_1:
igniteConfiguration.setConsistentId(NODE_1);
break;

case NODE_2:
igniteConfiguration.setConsistentId(NODE_2);
break;

default: throw new IllegalArgumentException("Unknown node: " + igniteInstanceName);
}

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.

Looks like switch is overhead here and we can simplify to smth like:

return super.getConfiguration(igniteInstanceName)
            .setConsistentId(igniteInstanceName)
            .setClusterStateOnStart(INACTIVE)
            .setGridLogger(listeningLog);

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