Skip to content

IGNITE-28731 Create cluster auto activation plugin - #355

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

IGNITE-28731 Create cluster auto activation plugin#355
DenisPolo wants to merge 5 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

/** {@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);

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.

Done

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

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.

Done


/** {@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

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.

Done


/** {@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

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.

Done

Comment thread modules/auto-activation-ext/pom.xml Outdated
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

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.

Done

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

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.

Good suggestion! I've applied the cluster.forServers().nodes()

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.

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.

Done

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}.

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.

Done

Comment thread modules/auto-activation-ext/README.md Outdated
- 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

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.

Certainly missed it. Fixed.

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);

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.

Oh, this is much better! Done

@chesnokoff chesnokoff left a comment

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.

Many tests repeat the same node startup sequence and cluster state checks. Can we extract common helper methods for starting configured nodes and checking the expected state? This would make the individual test scenarios shorter and easier to understand

Comment on lines +44 to +57
@Override public boolean apply(Collection<ClusterNode> nodes) {
Set<String> missingNodes = new HashSet<>(requiredNodes);

for (ClusterNode node : nodes) {
String nodeConsistentId = node.consistentId().toString();

missingNodes.remove(nodeConsistentId);

if (missingNodes.isEmpty())
break;
}

return missingNodes.isEmpty();
}

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
@Override public boolean apply(Collection<ClusterNode> nodes) {
Set<String> missingNodes = new HashSet<>(requiredNodes);
for (ClusterNode node : nodes) {
String nodeConsistentId = node.consistentId().toString();
missingNodes.remove(nodeConsistentId);
if (missingNodes.isEmpty())
break;
}
return missingNodes.isEmpty();
}
@Override public boolean apply(Collection<ClusterNode> nodes) {
Set<String> missingNodes = new HashSet<>(requiredNodes);
for (ClusterNode node : nodes) {
String nodeConsistentId = node.consistentId().toString();
missingNodes.remove(nodeConsistentId);
if (missingNodes.isEmpty())
return true;
}
return false;
}

Comment on lines +52 to +65
@Override public boolean apply(Collection<ClusterNode> nodes) {
Set<String> missingNodes = new HashSet<>(requiredValues);

for (ClusterNode node : nodes) {
String attrVal = node.attribute(attrName);

missingNodes.remove(attrVal);

if (missingNodes.isEmpty())
break;
}

return missingNodes.isEmpty();
}

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
@Override public boolean apply(Collection<ClusterNode> nodes) {
Set<String> missingNodes = new HashSet<>(requiredValues);
for (ClusterNode node : nodes) {
String attrVal = node.attribute(attrName);
missingNodes.remove(attrVal);
if (missingNodes.isEmpty())
break;
}
return missingNodes.isEmpty();
}
@Override public boolean apply(Collection<ClusterNode> nodes) {
Set<String> missingNodes = new HashSet<>(requiredValues);
for (ClusterNode node : nodes) {
String attrVal = node.attribute(attrName);
missingNodes.remove(attrVal);
if (missingNodes.isEmpty())
return true;
}
return false;
}


/** {@inheritDoc} */
@Override public void onIgniteStart() {

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 IgniteConfiguration from XML. */
private IgniteConfiguration getConfigurationFromXml(String xmlPath) throws Exception {

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.

From IDEA: Exception 'java.lang.Exception' is never thrown in the method

PluginProvider<?> autoActivationProvider = new AutoActivationPluginProvider(
new ActivateByConsistentID(Set.of(NODE_0, NODE_1))
);

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.

remove nl

PluginProvider<?> autoActivationProvider = new AutoActivationPluginProvider(
new ActivateByConsistentID(Set.of(NODE_2))
);

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.

remove nl

PluginProvider<?> autoActivationProvider = new AutoActivationPluginProvider(
new ActivateByConsistentID(Set.of(NODE_2))
);

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.

remove nl

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 for other methods: remove empty lines as first lines in method bodies

Comment on lines +139 to +140
private CacheConfiguration getCacheConfiguration() {
return new CacheConfiguration<>()

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
private CacheConfiguration getCacheConfiguration() {
return new CacheConfiguration<>()
private CacheConfiguration<String, Integer> getCacheConfiguration() {
return new CacheConfiguration<String, Integer>()

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 avoid raw usage of type

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