private void start() { if (started){ return; } doStart(); }
public void restart(){ try { boolean locked = RESTART_LOCK.tryLock(30, TimeUnit.SECONDS); if (!locked){ log.warn("timeout to get the restart lock, maybe it's locked by another."); return; } if (client.getZookeeperClient().isConnected()){ return; } if (client != null){ // close old connection client.close(); } doStart(); } catch (InterruptedException e) { log.error("failed to get the restart lock, cause: {}", Throwables.getStackTraceAsString(e)); } finally { RESTART_LOCK.unlock(); } }