Currently we have a pair of controller nodes, a master and a slave for
These are separate from the nodes that handle client requests.  When a
file change occurs, we restart the controllers sequentially, to force them
to see
the changed config, and add or delete resources as necessary.

In the current implementation, the logic executing at controller startup
reads the config file is surrounded by an "if" so that it executes only if
it is
master.  So when the slave restarts, it comes back up as a slave, and
load the config.  Likewise, when the master restarts, the slave becomes
but doesn't reload the config, since that is done only at startup.  And the
master comes back up as a slave so it doesn't load the config either.  One
to fix things would be to add code that reads the config when a controller
becomes master, although we are not sure how much we like that solution.  We
need to think more about it and consider alternatives.  But knowing that
there is
a mechanism for executing a callback on becoming master is
useful information, just so we know what is possible.


On Sat, Jan 27, 2018 at 10:27 AM, kishore g <> wrote:

> Yes, You can add a ControllerChangeListener on the HelixManager. Can you
> describe the scenario where you plan to use this?
> MyControllerChangeLister implements ControllerChangeListener {
>   onControllerChange(NotificationContext context) {
>   HelixDataAccessor accessor = changeContext.getManager().
> getHelixDataAccessor();
>    // double check if this controller is the leader
>    Builder keyBuilder = accessor.keyBuilder();
>    LiveInstance leader = accessor.getProperty(
> keyBuilder.controllerLeader());
>    if (leader == null) {
>     //No leader
>    } else {
>      String leaderInstanceName = leader.getInstanceName();
>    }
>   }
> }
> On Fri, Jan 26, 2018 at 2:56 PM, Dave Peterson <>
> wrote:
>> Does the Helix API provide a way to register a callback that gets called
>> when a Helix controller becomes master?
>> Thanks,
>> Dave

Reply via email to