Hey Bruno -
First off, welcome to the Helix community! We're excited to have you use it
and we welcome any feedback or contribution you'd like to make.
1. The underlying ZK connection for the ConfigAccessor object actually does
get closed. See the following:
finally {
// Use a try-finally to make sure zkclient connection is closed
properly
if (dedicatedZkClient != null && !dedicatedZkClient.isClosed()) {
*dedicatedZkClient.close(); // this has the same effect of closing
ConfigAccessor*
}
}
2. We do not explicitly close the event processor since almost all use
cases of manager.disconnect(), which disconnects the participant, assume
that the lifecycle of the deployable ends with the disconnect, and
therefore, the JVM itself will be shut down.
All in all though, I don't at quick glance see why your
manager.disconnect() should hang. Can you try to put a debugger and see
what stage of disconnect() call it's hanging?
Hunter
On Sun, Nov 1, 2020 at 11:11 AM Bruno Freudensprung <
[email protected]> wrote:
>
> Hi,
>
> I am a new user of Apache Helix, I started prototyping and so far I'm
> excited about it :).
>
> I have a question related to stopping participants and controllers.
>
> The demo code is the following :
>
> HelixManager manager = HelixManagerFactory.getZKHelixManager(CLUSTER_NAME,
> "localhost_7000", InstanceType.PARTICIPANT, ZK_ADDRESS);
> try {
> StateMachineEngine stateMach = manager.getStateMachineEngine();
> MasterSlaveStateModelFactory stateModelFactory = new
> MasterSlaveStateModelFactory();
> stateMach.registerStateModelFactory(STATE_MODEL_NAME,
> stateModelFactory);
> manager.connect();
> System.in.read(); // wait for user input before stopping the participant
> } catch (Exception e) {
> e.printStackTrace();
> } finally {
> manager.disconnect();
> }
>
> My problem is the program is hanging after manager.disconnect() because
> some threads are still alive. They are created here:
>
> 1 - First one is created in the constructor of ZKHelixManager that is
> calling HelixPropertyFactory.getInstance().getHelixManagerProperty(zkAddress,
> clusterName)), that is creating a ConfigAccessor object that is creating
> a ZkClient (I don't know how to close it).
>
> 2 - Second one is the static SubscribeChangeEventProcessor thread of the
> org.apache.helix.manager.zk.CallbackHandler class.
>
> Could you tell me if I forgot something in my program?
> I guess I can try to call setDaemon(true) on SubscribeChangeEventProcessor,
> but I don't know how I can close the ZkClient.
>
> Thank you!
>
> Bruno.
>