[
https://issues.apache.org/jira/browse/IGNITE-5357?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16186027#comment-16186027
]
Alexei Scherbakov commented on IGNITE-5357:
-------------------------------------------
[~mlipkovich],
Yes, you should choose among alive nodes in case of locked topology.
Something like:
{code}
// Always use primary, if reads from backups are not allowed.
if (!cctx.config().isReadFromBackup())
return affNodes.get(0);
Object mac = cctx.localNode().attribute(IgniteNodeAttributes.ATTR_MACS);
assert mac != null;
int r = ThreadLocalRandom8.current().nextInt(affNodes.size());
int c = 0;
ClusterNode n0 = null;
int lastMatch = -1;
for (int i = 0; i < affNodes.size(); i++) {
ClusterNode node = affNodes.get(i);
if (canRemap || cctx.discovery().alive(node)) {
// Prefer collocated node.
if (mac.equals(node.attribute(IgniteNodeAttributes.ATTR_MACS)))
return node;
if (c++ == r)
n0 = node;
lastMatch = i;
}
}
if (n0 == null && lastMatch != -1)
n0 = affNodes.get(lastMatch);
return n0;
{code}
> Replicated cache reads load balancing.
> --------------------------------------
>
> Key: IGNITE-5357
> URL: https://issues.apache.org/jira/browse/IGNITE-5357
> Project: Ignite
> Issue Type: Bug
> Components: cache
> Affects Versions: 1.6
> Reporter: Alexei Scherbakov
> Assignee: Mikhail Lipkovich
> Labels: newbie
> Fix For: 2.3
>
>
> Currently all read requests from client node to replicated cache will go
> through primary node for key.
> Need to select random affinity node in topology and send request here (only
> if readFromBackups=true)
> If where are server nodes collocated on same host with client, must select
> target node from them.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)