Kishore,
Thanks for the reply. When I tried to implement, the instances always come
back with an empty list. Can you let me know if I am missing something?
Regards,
Rob
ExternalView for data2:
{
"id" : "data2",
"mapFields" : {
"data2_0" : {
"localhost_7002" : "MASTER",
"localhost_7003" : "SLAVE"
},
"data2_1" : {
"localhost_7002" : "SLAVE",
"localhost_7003" : "MASTER"
},
"data2_2" : {
"localhost_7002" : "SLAVE",
"localhost_7003" : "MASTER"
},
"data2_3" : {
"localhost_7002" : "SLAVE",
"localhost_7003" : "MASTER"
},
"data2_4" : {
"localhost_7002" : "SLAVE",
"localhost_7003" : "MASTER"
},
"data2_5" : {
"localhost_7002" : "MASTER",
"localhost_7003" : "SLAVE"
}
},
"listFields" : {
},
"simpleFields" : {
"BUCKET_SIZE" : "0",
"IDEAL_STATE_MODE" : "AUTO",
"NUM_PARTITIONS" : "6",
"REBALANCE_MODE" : "SEMI_AUTO",
"REBALANCE_STRATEGY" : "DEFAULT",
"REPLICAS" : "3",
"STATE_MODEL_DEF_REF" : "MasterSlave",
"STATE_MODEL_FACTORY_NAME" : "DEFAULT"
}
}
Code Snippet:
try {
HelixManager manager = HelixManagerFactory.getZKHelixManager(
Conf.CLUSTER_NAME,
"spec_1",
InstanceType.SPECTATOR,
Conf.ZK_ADDRESS);
manager.connect();
RoutingTableProvider routingTableProvider = new RoutingTableProvider();
manager.addExternalViewChangeListener(routingTableProvider);
List<InstanceConfig> list =
routingTableProvider.getInstances("data2", "data2_0",
"MASTER");
System.out.println(list.size()); // This is coming back as zero
} catch (Exception e) {
e.printStackTrace();
}
On Tue, Oct 2, 2018 at 9:15 AM kishore g <[email protected]> wrote:
> That's right.
>
> manager = HelixManagerFactory.getZKHelixManager(clusterName, instanceName,
> InstanceType.SPECTATOR, zkAddr);
> zkAddress = zkAddr;
> helixClusterName = clusterName;
>
> manager.connect();
> routingTableProvider = new RoutingTableProvider();
> manager.addExternalViewChangeListener(routingTableProvider);
>
>
> to route
>
> instances = routingTable.getInstances(resourceName, partionName, state);//
> state can be MASTER in your case
>
>
>
> On Tue, Oct 2, 2018 at 5:51 AM Rob McKinnon <[email protected]>
> wrote:
>
>> Lets say that I have a cluster of 5 nodes with 10 partitions and I have
>> an http request that needs to get data from a specific partition. What is
>> the pattern to make sure requests are routed to the correct node, in this
>> case a node that is the master of that particular partition?
>>
>> Regards,
>>
>> Rob
>>
>