Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,15 @@ public class Transform extends Plugin implements SystemIndexPlugin, PersistentTa
);

/**
* @deprecated
*
* Only kept for BWC to nodes before 7.13
*
* Node attributes for transform, automatically created and retrievable via cluster state.
* These attributes should never be set directly, use the node setting counter parts instead.
*/
public static final String TRANSFORM_ENABLED_NODE_ATTR = "transform.node";
@Deprecated
private static final String TRANSFORM_ENABLED_NODE_ATTR = "transform.node";

/**
* Setting whether transform (the coordinator task) can run on this node.
Expand Down Expand Up @@ -332,6 +337,7 @@ public List<Setting<?>> getSettings() {

@Override
public Settings additionalSettings() {
// TODO: TRANSFORM_ENABLED_NODE_ATTR has been deprecated in 7.x, remove for 8.0
String transformEnabledNodeAttribute = "node.attr." + TRANSFORM_ENABLED_NODE_ATTR;

if (settings.get(transformEnabledNodeAttribute) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,8 @@ public static boolean nodeCanRunThisTransform(DiscoveryNode node, TransformTaskP
return false;
}

final Map<String, String> nodeAttributes = node.getAttributes();

// transform enabled?
if (Boolean.parseBoolean(nodeAttributes.get(Transform.TRANSFORM_ENABLED_NODE_ATTR)) == false) {
if (node.getRoles().contains(Transform.TRANSFORM_ROLE) == false) {
if (explain != null) {
explain.put(node.getId(), "not a transform node");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import static org.hamcrest.Matchers.equalTo;
Expand Down Expand Up @@ -179,8 +177,10 @@ public void testVerifyIndicesPrimaryShardsAreActive() {
csBuilder.metadata(metadata);

ClusterState cs = csBuilder.build();
assertEquals(0,
TransformPersistentTasksExecutor.verifyIndicesPrimaryShardsAreActive(cs, TestIndexNameExpressionResolver.newInstance()).size());
assertEquals(
0,
TransformPersistentTasksExecutor.verifyIndicesPrimaryShardsAreActive(cs, TestIndexNameExpressionResolver.newInstance()).size()
);

metadata = new Metadata.Builder(cs.metadata());
routingTable = new RoutingTable.Builder(cs.routingTable());
Expand Down Expand Up @@ -249,21 +249,17 @@ private DiscoveryNodes.Builder buildNodes(
boolean transformLocalOnlyNodes,
boolean currentDataNode
) {

Map<String, String> transformNodeAttributes = new HashMap<>();
transformNodeAttributes.put(Transform.TRANSFORM_ENABLED_NODE_ATTR, "true");
Map<String, String> transformNodeAttributesDisabled = new HashMap<>();
transformNodeAttributesDisabled.put(Transform.TRANSFORM_ENABLED_NODE_ATTR, "false");

DiscoveryNodes.Builder nodes = DiscoveryNodes.builder();

if (dedicatedTransformNode) {
nodes.add(
new DiscoveryNode(
"dedicated-transform-node",
buildNewFakeTransportAddress(),
transformNodeAttributes,
new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE)),
Collections.emptyMap(),
new HashSet<>(
Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE, Transform.TRANSFORM_ROLE)
),
Version.CURRENT
)
);
Expand All @@ -274,10 +270,15 @@ private DiscoveryNodes.Builder buildNodes(
new DiscoveryNode(
"past-data-node-1",
buildNewFakeTransportAddress(),
transformNodeAttributes,
new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE,
DiscoveryNodeRole.MASTER_ROLE,
DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE)),
Collections.emptyMap(),
new HashSet<>(
Arrays.asList(
DiscoveryNodeRole.DATA_ROLE,
DiscoveryNodeRole.MASTER_ROLE,
DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE,
Transform.TRANSFORM_ROLE
)
),
Version.V_7_7_0
)
);
Expand All @@ -288,17 +289,25 @@ private DiscoveryNodes.Builder buildNodes(
new DiscoveryNode(
"current-data-node-with-2-tasks",
buildNewFakeTransportAddress(),
transformNodeAttributes,
new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE)),
Collections.emptyMap(),
new HashSet<>(
Arrays.asList(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE, Transform.TRANSFORM_ROLE)
),
Version.CURRENT
)
)
.add(
new DiscoveryNode(
"current-data-node-with-1-tasks",
buildNewFakeTransportAddress(),
transformNodeAttributes,
new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE)),
Collections.emptyMap(),
new HashSet<>(
Arrays.asList(
DiscoveryNodeRole.MASTER_ROLE,
DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE,
Transform.TRANSFORM_ROLE
)
),
Version.CURRENT
)
);
Expand All @@ -309,8 +318,8 @@ private DiscoveryNodes.Builder buildNodes(
new DiscoveryNode(
"current-data-node-with-0-tasks-transform-remote-disabled",
buildNewFakeTransportAddress(),
transformNodeAttributes,
new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.MASTER_ROLE)),
Collections.emptyMap(),
new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.MASTER_ROLE, Transform.TRANSFORM_ROLE)),
Version.CURRENT
)
);
Expand All @@ -321,7 +330,7 @@ private DiscoveryNodes.Builder buildNodes(
new DiscoveryNode(
"current-data-node-with-transform-disabled",
buildNewFakeTransportAddress(),
transformNodeAttributesDisabled,
Collections.emptyMap(),
Set.of(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE),
Version.CURRENT
)
Expand Down