英文:
Ignite ClusterGroup.forAttribute works for client nodes?
问题
我刚刚在另一个问题中了解到我可以在客户端节点上运行计算任务,这非常好。
然而,我不想在所有客户端上执行任务,只想在选定的客户端节点上执行。我通过其配置中的属性来识别节点:
<property name="userAttributes">
<map>
<entry key="Role" value="FOR_COMPUTE" />
</map>
</property>
然后我使用:
ignite.cluster().forClients().forAttribute("Role", "FOR_COMPUTE");
这似乎不能让我得到具有设置属性的那些客户端的集群组。这对于客户端节点不起作用吗?
英文:
I just learned in another question that I can run compute tasks on client nodes, which is great.
However, I don't want to execute tasks on all clients, only selected client nodes. I identify nodes by attributes in their config:
<property name="userAttributes">
<map>
<entry key="Role" value="FOR_COMPUTE" />
</map>
</property>
Then I use:
ignite.cluster().forClients().forAttribute("Role", "FOR_COMPUTE");
This doesn't seem to get me a clusergroup with those clients that have the attribute set. Does this not work for client nodes?
答案1
得分: 1
用户属性确实起作用。
仔细检查您的设置。确保您使用正确的配置启动客户端。
运行以下测试:
IgniteConfiguration serverConfig = new IgniteConfiguration();
serverConfig.setIgniteInstanceName("server");
Ignition.start(serverConfig);
IgniteConfiguration clientConfig = new IgniteConfiguration();
clientConfig.setClientMode(true);
clientConfig.setIgniteInstanceName("client");
Map<String, String> userAttributes = new HashMap<>();
userAttributes.put("Role", "FOR_COMPUTE");
clientConfig.setUserAttributes(userAttributes);
Ignite ignite = Ignition.start(clientConfig);
System.out.println("Role user attribute value: " + ignite.cluster().localNode().attribute("Role"));
ClusterGroup filteredNodes = ignite.cluster().forClients().forAttribute("Role", "FOR_COMPUTE");
for (ClusterNode node: filteredNodes.nodes()) {
System.out.println("filtered id: "+ node.id());
}
您应该会看到正确的结果。
英文:
The user attributes do work.
Double check your setup. Make sure you are starting your client with the correct config.
Run the following test:
IgniteConfiguration serverConfig = new IgniteConfiguration();
serverConfig.setIgniteInstanceName("server");
Ignition.start(serverConfig);
IgniteConfiguration clientConfig = new IgniteConfiguration();
clientConfig.setClientMode(true);
clientConfig.setIgniteInstanceName("client");
Map<String, String> userAttributes = new HashMap<>();
userAttributes.put("Role", "FOR_COMPUTE");
clientConfig.setUserAttributes(userAttributes);
Ignite ignite = Ignition.start(clientConfig);
System.out.println("Role user attribute value: " + ignite.cluster().localNode().attribute("Role"));
ClusterGroup filteredNodes = ignite.cluster().forClients().forAttribute("Role", "FOR_COMPUTE");
for (ClusterNode node: filteredNodes.nodes()) {
System.out.println("filtered id: "+ node.id());
}
You should see the correct results.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论