fun createNode(path: String?, watch: Boolean, ephimeral: Boolean): String? { var createdNodePath: String? = null createdNodePath = try { val nodeStat: Stat = zooKeeper.exists(path, watch) if (nodeStat == null) { zooKeeper.create( path, ByteArray(0), Ids.OPEN_ACL_UNSAFE, if (ephimeral) CreateMode.EPHEMERAL_SEQUENTIAL else CreateMode.PERSISTENT ) } else { path } } catch (e: KeeperException) { throw IllegalStateException(e) } catch (e: InterruptedException) { throw IllegalStateException(e) } return createdNodePath }
Create a zookeeper node