helix-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hahn Jiang <hahn.jiang....@gmail.com>
Subject Helix newer use Rebalance
Date Tue, 28 Jul 2015 09:26:20 GMT
I use Helix 0.7.1
I start three participants and I want to assign a resource to two of them.
    List<String> preferenceList = new ArrayList<>();
    preferenceList.add("localhost_6101");
    preferenceList.add("localhost_6102");

Then I add preferenceList to resource: partitionNum=6  replicationNum=2
    admin.addResource(clusterName, resourceKey,
partitionNum,StateModelDefId.MasterSlave.stringify(), "SEMI_AUTO");
    IdealState idealState = admin.getResourceIdealState(clusterName,
resourceKey);
    idealState.setRebalanceMode(IdealState.RebalanceMode.SEMI_AUTO);
    idealState.setReplicas(replicationNum+"");
    for (int i = 0; i < partitionNum; ++i) {
      idealState.setPreferenceList(resourceKey + "_" + i, preferenceList);
    }
    admin.setResourceIdealState(clusterName, resourceKey, idealState);

At Last, I will rebalence cluster:
    admin.rebalance(clusterName, resourceName, replcaNum);

But it doesn't work. I saw the helix source code.
ZNRecord newIdealState =
DefaultTwoStateStrategy.calculateIdealState(instanceNames, partitions,
replica, keyPrefix, masterStateValue, slaveStateValue);

// for now keep mapField in SEMI_AUTO mode and remove listField in
CUSTOMIZED mode
if (idealState.getRebalanceMode() == RebalanceMode.SEMI_AUTO) {
  idealState.getRecord().setListFields(newIdealState.getListFields());
  idealState.getRecord().setMapFields(newIdealState.getMapFields());
}
if (idealState.getRebalanceMode() == RebalanceMode.CUSTOMIZED) {
  idealState.getRecord().setMapFields(newIdealState.getMapFields());
}

If my idealState is SEMI_AUTO, it will setListFields, my option will
override.
Is my option right?

Thanks

Mime
View raw message