def update_path(self, path, updater, createPaths, stat, options):
        """
        Returns T
        Parameters:
            path: Stringupdater: DataUpdater<T>createPaths: List<String>stat: Statoptions: int


        """
        # CreateMode
        mode = AccessOption.getMode(options)
        if mode == None:
            self.LOG.error("Invalid update mode. options: " + str(options))
            return None

        # boolean
        retry = True

        # T
        updatedData = None
        while retry:
            retry = False
            try:
                # Stat
                readStat = HelixZNodeStat()
                # T
                oldData = self._zkClient.readData(path, readStat)
                # T
                newData = updater.update(oldData)
                # Stat
                setStat = self._zkClient.writeDataGetStat(
                    path, newData, readStat.getVersion())
                if stat != None:
                    stat = copy.copy(setStat)
#                    DataTree.copyStat(setStat, stat)

                updatedData = newData
            except BadVersionException, e:
                retry = True
            except NoNodeException, e:
                try:
                    # T
                    newData = updater.update(None)
                    # RetCode
                    rc = self.create(path, newData, createPaths, options)
                    if rc == RetCode.OK:
                        updatedData = newData
                    elif rc == RetCode.NODE_EXISTS:
                        retry = True
                    else:
                        self.LOG.error("Fail to update path by creating: " +
                                       str(path))
                        return None
#                except Exception, e1:
# TODO
                except KeyboardInterrupt, e1:
                    self.LOG.error(
                        "Exception while updating path by creating: " +
                        str(path) + str(e1))
                    return None
    def update_path(self, path, updater, createPaths, stat, options):
        """
        Returns T
        Parameters:
            path: Stringupdater: DataUpdater<T>createPaths: List<String>stat: Statoptions: int


        """
        # CreateMode
        mode = AccessOption.getMode(options)
        if mode == None: 
            self.LOG.error("Invalid update mode. options: " + str(options))
            return None

        # boolean
        retry = True
        
        # T
        updatedData = None
        while retry:
            retry = False
            try:
                # Stat
                readStat = HelixZNodeStat()
                # T
                oldData = self._zkClient.readData(path, readStat)
                # T
                newData = updater.update(oldData)
                # Stat
                setStat = self._zkClient.writeDataGetStat(path, newData, readStat.getVersion())
                if stat != None:
                    stat = copy.copy(setStat)
#                    DataTree.copyStat(setStat, stat)

                updatedData = newData
            except BadVersionException, e:
                retry = True
            except NoNodeException, e:
                try:
                    # T
                    newData = updater.update(None)
                    # RetCode
                    rc = self.create(path, newData, createPaths, options)
                    if rc == RetCode.OK:
                        updatedData = newData
                    elif rc == RetCode.NODE_EXISTS:
                        retry = True
                    else:
                        self.LOG.error("Fail to update path by creating: " + str(path))
                        return None
#                except Exception, e1:
                # TODO
                except KeyboardInterrupt, e1:
                    self.LOG.error("Exception while updating path by creating: " + str(path)+ str(e1))
                    return None
    def set_path(self, path, record, pathsCreated, setstat, expectVersion,
                 options):
        """
        Returns boolean
        Parameters:
            path: Stringrecord: TpathsCreated: List<String>setstat: StatexpectVersion: intoptions: int


        """
        # CreateMode
        mode = AccessOption.getMode(options)
        if mode == None:
            self.LOG.error("Invalid set mode. options: " + str(options))
            return False

        # boolean
        retry = True

        while retry:
            retry = False
            try:
                # Stat
                setStat = self._zkClient.writeDataGetStat(
                    path, record, expectVersion)
                if setstat != None:
                    setstat = copy.copy(setStat)
#                    DataTree.copyStat(setStat, setstat)
            except NoNodeException, e:
                #                try:
                # RetCode
                rc = self.create(path, record, pathsCreated, options)
                if rc == RetCode.OK: pass
                elif rc == RetCode.NODE_EXISTS:
                    retry = True
                else:
                    self.LOG.error("Fail to set path by creating: " +
                                   str(path))
                    return False
                # TODO: enable the catch?
#                except Exception, e1:
#                    self.LOG.error("Exception while setting path by creating: " + str(path)+ str(e1))
#                    return False

            except BadVersionException, e:
                raise e
    def set_path(self, path, record, pathsCreated, setstat, expectVersion, options):
        """
        Returns boolean
        Parameters:
            path: Stringrecord: TpathsCreated: List<String>setstat: StatexpectVersion: intoptions: int


        """
        # CreateMode
        mode = AccessOption.getMode(options)
        if mode == None: 
            self.LOG.error("Invalid set mode. options: " + str(options))
            return False

        # boolean
        retry = True
        
        while retry:
            retry = False
            try:
                # Stat
                setStat = self._zkClient.writeDataGetStat(path, record, expectVersion)
                if setstat != None:
                    setstat = copy.copy(setStat)
#                    DataTree.copyStat(setStat, setstat)
            except NoNodeException, e:
#                try:
                    # RetCode
                    rc = self.create(path, record, pathsCreated, options)
                    if rc == RetCode.OK: pass
                    elif rc == RetCode.NODE_EXISTS:
                            retry = True
                    else:
                        self.LOG.error("Fail to set path by creating: " + str(path))
                        return False
                    # TODO: enable the catch?
#                except Exception, e1:
#                    self.LOG.error("Exception while setting path by creating: " + str(path)+ str(e1))
#                    return False

            except BadVersionException, e:
                raise e
    def create_path(self, path, record, pathCreated, options):
        """
        Returns RetCode
        Parameters:
            path: Stringrecord: TpathCreated: List<String>options: int


        """
        # CreateMode
        mode = AccessOption.getMode(options)
        if mode == None:
            self.LOG.error("Invalid create mode. options: " + str(options))
            return RetCode.ERROR

        # boolean
        retry = True

        while retry:
            retry = False
            try:
                self._zkClient.create(path, record, mode)
                if pathCreated != None:
                    pathCreated.add(path)
                return RetCode.OK
            except NoNodeException, e:
                # String
                parentPath = os.path.abspath(os.path.join(
                    path, os.path.pardir))
                #                parentPath = File(path).getParent()
                try:
                    # RetCode
                    rc = self.create(parentPath, None, pathCreated,
                                     AccessOption.PERSISTENT)
                    if rc == RetCode.OK or rc == RetCode.NODE_EXISTS:
                        retry = True
                # TODO:
#                except Exception, e1:
                except KeyboardInterrupt, e1:
                    self.LOG.error("Exception while creating path: " +
                                   str(parentPath) + str(e1))
                    return RetCode.ERROR
    def createChildren(self, paths, records, options):
        """
        Returns boolean[]
        Parameters:
            paths: List<String>records: List<T>options: int
        @Override


        """
        # boolean[]
        success = [False for path in paths]
        #        success = new boolean[paths.__len__()]
        # CreateMode
        mode = AccessOption.getMode(options)
        if mode == None:
            self.LOG.error("Invalid async create mode. options: " +
                           str(options))
            return success

        # boolean[]
#        needCreate = new boolean[paths.__len__()]
#        Arrays.fill(needCreate, True)
        needCreate = [True for path in paths]
        # List<List<String>>
        #        pathsCreated = ArrayList<List<String>>(Collections.nCopies(paths.__len__(), None))
        pathsCreated = [None for path in paths]
        # long
        startT = time.time()
        try:
            # CreateCallbackHandler[]
            cbList = self.create(paths, records, needCreate, pathsCreated,
                                 options)
            for i in range(len(cbList)):  # CreateCallbackHandler
                cb = cbList[i]
                #                success[i] = (Code.get(cb.getRc()) == Code.OK)
                success[i] = cb.isSuccessful()

            return success
        finally:
            # long
            endT = time.time()
    def get(self, path, stat, options):
        """
        Returns T
        Parameters:
            path: Stringstat: Statoptions: int
        @Override


        """
        # T
        if isinstance(path, list):
            if isinstance(options, list):
                return self.getList(path, stat, options)
            else:
                return self.getMulti(path, stat, options)

        data = None
        try:
            data = self._zkClient.readData(path, stat)
        except NoNodeException, e:
            if AccessOption.isThrowExceptionIfNotExist(options):
                raise e
    def createChildren(self, paths, records, options):
        """
        Returns boolean[]
        Parameters:
            paths: List<String>records: List<T>options: int
        @Override


        """
        # boolean[]
        success = [False for path in paths]
#        success = new boolean[paths.__len__()]
        # CreateMode
        mode = AccessOption.getMode(options)
        if mode == None: 
            self.LOG.error("Invalid async create mode. options: " + str(options))
            return success

        # boolean[]
#        needCreate = new boolean[paths.__len__()]
#        Arrays.fill(needCreate, True)
        needCreate = [True for path in paths]
        # List<List<String>>
#        pathsCreated = ArrayList<List<String>>(Collections.nCopies(paths.__len__(), None))
        pathsCreated = [None for path in paths]
        # long
        startT = time.time()
        try:
            # CreateCallbackHandler[]
            cbList = self.create(paths, records, needCreate, pathsCreated, options)
            for i in range(len(cbList)): # CreateCallbackHandler
                cb = cbList[i]
#                success[i] = (Code.get(cb.getRc()) == Code.OK)
                success[i] = cb.isSuccessful()

            return success
        finally:
                # long
                endT = time.time()
    def get(self, path, stat, options):
        """
        Returns T
        Parameters:
            path: Stringstat: Statoptions: int
        @Override


        """
        # T
        if isinstance(path,list):
            if isinstance(options,list):
                return self.getList(path, stat, options)
            else:
                return self.getMulti(path, stat, options)

        data = None
        try:
            data = self._zkClient.readData(path, stat)
        except NoNodeException, e:
            if AccessOption.isThrowExceptionIfNotExist(options): 
                raise e
    def create_path(self, path, record, pathCreated, options):
        """
        Returns RetCode
        Parameters:
            path: Stringrecord: TpathCreated: List<String>options: int


        """
        # CreateMode
        mode = AccessOption.getMode(options)
        if mode == None: 
            self.LOG.error("Invalid create mode. options: " + str(options))
            return RetCode.ERROR

        # boolean
        retry = True
        
        while retry:
            retry = False
            try:
                self._zkClient.create(path, record, mode)
                if pathCreated != None: 
                    pathCreated.add(path)
                return RetCode.OK
            except NoNodeException, e:
                # String
                parentPath = os.path.abspath(os.path.join(path, os.path.pardir))
#                parentPath = File(path).getParent()
                try:
                    # RetCode
                    rc = self.create(parentPath, None, pathCreated, AccessOption.PERSISTENT)
                    if rc == RetCode.OK or rc == RetCode.NODE_EXISTS: 
                        retry = True
                # TODO:
#                except Exception, e1:
                except KeyboardInterrupt, e1:
                    self.LOG.error("Exception while creating path: " + str(parentPath)+ str(e1))
                    return RetCode.ERROR
    def update_paths(self, paths, updaters, pathsCreated, stats, options):
        """
        Returns List<T>
        Parameters:
            paths: List<String>updaters: List<DataUpdater<T>>pathsCreated: List<List<String>>stats: List<Stat>options: int


        """
        if paths == None or len(paths) == 0:
            self.LOG.error("paths is null or empty")
            #            return Collections.emptyList()
            return []

        if len(updaters) != len(paths) or (pathsCreated != None and
                                           len(pathsCreated) != len(paths)):
            raise IllegalArgumentException(
                "paths, updaters, and pathsCreated should be of same size")

        # List<Stat>
        setStats = [ZnodeStat for path in paths]
        # List<T>
        updateData = [None for path in paths]
        # CreateMode
        mode = AccessOption.getMode(options)
        if mode == None:
            self.LOG.error("Invalid update mode. options: " + str(options))
            return updateData

        # SetDataCallbackHandler[]
        cbList = [SetDataCallbackHandler() for path in paths]
        # CreateCallbackHandler[]
        createCbList = None
        # boolean[]
        needUpdate = [True for path in paths]
        # long
        startT = time.time()
        try:
            # boolean
            retry = True

            while retry:
                retry = False
                # boolean[]
                needCreate = [False for path in paths]
                # boolean
                failOnNoNode = False
                # List<Stat>
                curStats = []
                # List<T>
                curDataList = self.get(paths, curStats, copy.copy(needUpdate))
                # List<T>
                newDataList = []
                #                newDataList = ArrayList<T>()
                for i in range(len(paths)):
                    if not needUpdate[i]:
                        newDataList.append(None)
                        continue

                    # String
                    path = paths[i]
                    # DataUpdater<T>
                    updater = updaters[i]
                    # T
                    newData = updater.update(curDataList[i])
                    newDataList.append(newData)
                    # Stat
                    curStat = curStats[i]
                    if curStat == None:
                        failOnNoNode = True
                        needCreate[i] = True
                    else:
                        cbList[i] = SetDataCallbackHandler()
                        self._zkClient.asyncSetData(path, newData,
                                                    curStat.getVersion(),
                                                    cbList[i])

                # boolean
                failOnBadVersion = False
                for i in range(len(paths)):  # SetDataCallbackHandler
                    cb = cbList[i]
                    if cb == None:
                        continue
                    cb.waitForSuccess()
                    #                    switch(Code.get(cb.getRc())) {
                    #                        case OK:
                    if cb.isSuccessful():
                        updateData.__setitem__(i, newDataList[i])
                        setStats.__setitem__(i, cb.getStat())
                        needUpdate[i] = False
#                        case NONODE:
                    elif cb.isNoNodeError():
                        failOnNoNode = True
                        needCreate[i] = True
#                        case BADVERSION:
                    elif cb.isBadVersionError():
                        failOnBadVersion = True
                    else:
                        needUpdate[i] = False
                        break

                if failOnNoNode:
                    createCbList = self.create(paths, newDataList, needCreate,
                                               pathsCreated, options)
                    for i in range(len(paths)):  # CreateCallbackHandler
                        createCb = createCbList[i]
                        if createCb == None:
                            continue

#                        switch(Code.get(createCb.getRc())) {
#                            case OK:
                        if createCb.isSuccessful():
                            needUpdate[i] = False
                            updateData.__setitem__(i, newDataList[i])
                            setStats.__setitem__(i, ZNode.ZERO_STAT)
#                            case NODEEXISTS:
                        elif createCb.isNodeExistsError:
                            retry = True
                        else:
                            needUpdate[i] = False

                if failOnBadVersion:
                    retry = True

            if stats != None:
                stats = copy.copy(setStats)
#                stats.clear()
#                stats.addAll(setStats)

            return updateData
        finally:
            # long
            endT = time.time()
            #                if self.LOG.isDebugEnabled():
            self.LOG.debug("setData_async, size: " + str(paths.__len__()) +
                           ", paths: " + str(paths.__getitem__(0)) +
                           ",... time: " + str((endT - startT)) + " ns")
    def set_paths(self, paths, records, pathsCreated, stats, options):
        """
        Returns boolean[]
        Parameters:
            paths: List<String>records: List<T>pathsCreated: List<List<String>>stats: List<Stat>options: int
f

        """
        if paths == None or paths.__len__() == 0:
            #            return new boolean[0]
            return []

        if (records != None and len(records) != len(paths)
                or (pathsCreated != None and len(pathsCreated) != len(paths))):
            raise IllegalArgumentException(
                "paths, records, and pathsCreated should be of same size")

        # boolean[]
        success = [False for path in paths]
        # CreateMode
        mode = AccessOption.getMode(options)
        if mode == None:
            self.LOG.error("Invalid async set mode. options: " + str(options))
            return success

        # List<Stat>
#        setStats = [None for path in paths]
        setStats = [HelixZNodeStat() for path in paths]
        #        setStats = ArrayList<Stat>(Collections.nCopies(paths.__len__(), None))
        # SetDataCallbackHandler[]
        cbList = [SetDataCallbackHandler for path in paths]
        # CreateCallbackHandler[]
        createCbList = None
        # boolean[]
        needSet = [True for path in paths]
        # long
        startT = time.time()
        try:
            # boolean
            retry = True

            while retry:
                retry = False
                for i in range(len(paths)):
                    if not needSet[i]:
                        continue
                    # String
                    path = paths[i]
                    # T
                    record = records[i]
                    cbList[i] = SetDataCallbackHandler()
                    self._zkClient.asyncSetData(path, record, -1, cbList[i])

                # boolean
                failOnNoNode = False
                for i in range(len(cbList)):  # SetDataCallbackHandler
                    cb = cbList[i]
                    cb.waitForSuccess()
                    # Code
                    #                    rc = Code.get(cb.getRc())
                    #                    switch(rc) {
                    if cb.isSuccessful():
                        setStats[i] = cb.getStat()
                        needSet[i] = False
#                        case NONODE:
                    elif cb.isNoNodeError():
                        failOnNoNode = True
                    else:
                        needSet[i] = False

                if failOnNoNode:
                    # boolean[]
                    needCreate = copy.copy(needSet)
                    createCbList = self.create(paths, records, needCreate,
                                               pathsCreated, options)
                    for i in range(len(createCbList)):  # CreateCallbackHandler
                        createCb = createCbList[i]
                        if createCb == None:
                            continue

                        # Code
#                        rc = Code.get(createCb.getRc())
#                        switch(rc) {
#                            case OK:
                        if createCb.isSuccessful():
                            setStats[i] = ZNode.ZERO_STAT
                            needSet[i] = False
#                        case NODEEXISTS:
                        elif createCb.isNodeExistsError():
                            retry = True
                        else:
                            needSet[i] = False

            for i in range(len(cbList)):  # SetDataCallbackHandler
                cb = cbList[i]
                # Code
                #                rc = Code.get(cb.getRc())
                #                if rc == Code.OK:
                if cb.isSuccessful():
                    success[i] = True
                elif cb.isNoNodeError():
                    #                    if rc == Code.NONODE:
                    # CreateCallbackHandler
                    createCb = createCbList[i]
                    #                    if Code.get(createCb.getRc()) == Code.OK:
                    if createCb.isSuccessful():
                        success[i] = True

            if stats != None:
                stats = copy.copy(setStats)
#                stats.clear()
#                stats.addAll(setStats)

            return success
        finally:
            # long
            endT = time.time()
            #if self.LOG.isDebugEnabled():
            self.LOG.debug("setData_async, size: " + str(paths.__len__()) +
                           ", paths: " + str(paths.__getitem__(0)) +
                           ",... time: " + str((endT - startT)) + " ns")
    def create_paths(self, paths, records, needCreate, pathsCreated, options):
        """
        Returns CreateCallbackHandler[]
        Parameters:
            paths: List<String>records: List<T>needCreate: boolean[]pathsCreated: List<List<String>>options: int


        """
        if (records != None and records.__len__() != paths.__len__()
            ) or needCreate.__len__() != paths.__len__() or (
                pathsCreated != None
                and pathsCreated.__len__() != paths.__len__()):
            raise IllegalArgumentException(
                "paths, records, needCreate, and pathsCreated should be of same size"
            )

        # CreateCallbackHandler[]
        cbList = [CreateCallbackHandler() for path in paths]
        # CreateMode
        mode = AccessOption.getMode(options)
        if mode == None:
            self.LOG.error("Invalid async set mode. options: " + str(options))
            return cbList

        # boolean
        retry = True

        while retry:
            retry = False
            for i in range(paths.__len__()):
                if not needCreate[i]:
                    continue
                # String
                path = paths[i]
                # T
                record = ternary(records == None, None, records[i])
                cbList[i] = CreateCallbackHandler()
                self._zkClient.asyncCreate(path, record, mode, cbList[i])

            # List<String>
#            parentPaths = ArrayList<String>(Collections.nCopies(paths.__len__(), None))
            parentPaths = [None for path in paths]
            # boolean
            failOnNoNode = False
            for i in range(paths.__len__()):
                if not needCreate[i]:
                    continue
                # CreateCallbackHandler
                cb = cbList[i]
                cb.waitForSuccess()
                # String
                path = paths[i]
                #                if Code.get(cb.getRc()) == Code.NONODE:
                if cb.isNoNodeError():
                    # String
                    parentPath = os.path.abspath(
                        os.path.join(path, os.path.pardir))
                    #                    parentPath = File(path).getParent()
                    parentPaths[i] = parentPath
                    failOnNoNode = True
                else:
                    needCreate[i] = False
                    #                    if Code.get(cb.getRc()) == Code.OK and pathsCreated != None:
                    if cb.isSuccessful() and pathsCreated != None:
                        if pathsCreated[i] == None:
                            pathsCreated[i] = []
                        pathsCreated[i].add(path)

            if failOnNoNode:
                # boolean[]
                #                needCreateParent = Arrays.copyOf(needCreate, needCreate.length)
                needCreateParent = [x for x in needCreate]
                # CreateCallbackHandler[]
                parentCbList = self.create(parentPaths, None, needCreateParent,
                                           pathsCreated,
                                           AccessOption.PERSISTENT)
                for parentCb in parentCbList:  # CreateCallbackHandler
                    #                    parentCb = parentCbList[i]
                    if parentCb == None:
                        continue
                    # Code
                    if parentCb.isSuccessful() or parentCb.isNodeExistError():
                        #                    rc = Code.get(parentCb.getRc())
                        #                    if rc == Code.OK or rc == Code.NODEEXISTS:
                        retry = True
                        break

        return cbList
    def update_paths(self, paths, updaters, pathsCreated, stats, options):
        """
        Returns List<T>
        Parameters:
            paths: List<String>updaters: List<DataUpdater<T>>pathsCreated: List<List<String>>stats: List<Stat>options: int


        """
        if paths == None or len(paths) == 0:
            self.LOG.error("paths is null or empty")
#            return Collections.emptyList()
            return []

        if len(updaters) != len(paths) or (pathsCreated != None and len(pathsCreated) != len(paths)):
            raise IllegalArgumentException("paths, updaters, and pathsCreated should be of same size")


        # List<Stat>
        setStats = [ZnodeStat for path in paths]
        # List<T>
        updateData = [None for path in paths]
        # CreateMode
        mode = AccessOption.getMode(options)
        if mode == None: 
            self.LOG.error("Invalid update mode. options: " + str(options))
            return updateData

        # SetDataCallbackHandler[]
        cbList =[SetDataCallbackHandler() for path in paths]
        # CreateCallbackHandler[]
        createCbList = None
        # boolean[]
        needUpdate = [True for path in paths]
        # long
        startT = time.time()
        try:
            # boolean
            retry = True
            
            while retry:
                retry = False
                # boolean[]
                needCreate = [False for path in paths]
                # boolean
                failOnNoNode = False
                # List<Stat>
                curStats = []
                # List<T>
                curDataList = self.get(paths, curStats, copy.copy(needUpdate))
                # List<T>
                newDataList = []
#                newDataList = ArrayList<T>()
                for i in range(len(paths)):
                    if not needUpdate[i]:
                        newDataList.append(None)
                        continue

                    # String
                    path = paths[i]
                    # DataUpdater<T>
                    updater = updaters[i]
                    # T
                    newData = updater.update(curDataList[i])
                    newDataList.append(newData)
                    # Stat
                    curStat = curStats[i]
                    if curStat == None: 
                        failOnNoNode = True
                        needCreate[i] = True
                    else:
                        cbList[i] = SetDataCallbackHandler()
                        self._zkClient.asyncSetData(path, newData, curStat.getVersion(), cbList[i])


                # boolean
                failOnBadVersion = False
                for i in range(len(paths)): # SetDataCallbackHandler
                    cb = cbList[i]
                    if cb == None: 
                        continue
                    cb.waitForSuccess()
#                    switch(Code.get(cb.getRc())) {
#                        case OK:
                    if cb.isSuccessful():
                            updateData.__setitem__(i, newDataList[i])
                            setStats.__setitem__(i, cb.getStat())
                            needUpdate[i] = False
#                        case NONODE:
                    elif cb.isNoNodeError():
                            failOnNoNode = True
                            needCreate[i] = True
#                        case BADVERSION:
                    elif cb.isBadVersionError():
                            failOnBadVersion = True
                    else:
                            needUpdate[i] = False
                            break

                if failOnNoNode: 
                    createCbList = self.create(paths, newDataList, needCreate, pathsCreated, options)
                    for i in range(len(paths)): # CreateCallbackHandler
                        createCb = createCbList[i]
                        if createCb == None: 
                            continue

#                        switch(Code.get(createCb.getRc())) {
#                            case OK:
                        if createCb.isSuccessful():
                                needUpdate[i] = False
                                updateData.__setitem__(i, newDataList[i])
                                setStats.__setitem__(i, ZNode.ZERO_STAT)
#                            case NODEEXISTS:
                        elif createCb.isNodeExistsError:
                                retry = True
                        else:
                                needUpdate[i] = False

                if failOnBadVersion: 
                    retry = True

            if stats != None:
                stats = copy.copy(setStats)
#                stats.clear()
#                stats.addAll(setStats)

            return updateData
        finally:
                # long
                endT = time.time()
#                if self.LOG.isDebugEnabled():
                self.LOG.debug("setData_async, size: " + str(paths.__len__())+ ", paths: " + str(paths.__getitem__(0))+ ",... time: " + str((endT - startT) )+ " ns")
    def set_paths(self, paths, records, pathsCreated, stats, options):
        """
        Returns boolean[]
        Parameters:
            paths: List<String>records: List<T>pathsCreated: List<List<String>>stats: List<Stat>options: int
f

        """
        if paths == None or paths.__len__() == 0:
#            return new boolean[0]
            return []

        if (records != None and len(records) != len(paths) or (pathsCreated != None and len(pathsCreated) != len(paths))):
            raise IllegalArgumentException("paths, records, and pathsCreated should be of same size")


        # boolean[]
        success = [False for path in paths]
        # CreateMode
        mode = AccessOption.getMode(options)
        if mode == None: 
            self.LOG.error("Invalid async set mode. options: " + str(options))
            return success

        # List<Stat>
#        setStats = [None for path in paths]
        setStats = [HelixZNodeStat() for path in paths]
#        setStats = ArrayList<Stat>(Collections.nCopies(paths.__len__(), None))
        # SetDataCallbackHandler[]
        cbList = [SetDataCallbackHandler for path in paths]
        # CreateCallbackHandler[]
        createCbList = None
        # boolean[]
        needSet = [True for path in paths]
        # long
        startT = time.time()
        try:
            # boolean
            retry = True
            
            while retry:
                retry = False
                for i in range(len(paths)):
                    if not needSet[i]:
                        continue
                    # String
                    path = paths[i]
                    # T
                    record = records[i]
                    cbList[i] = SetDataCallbackHandler()
                    self._zkClient.asyncSetData(path, record, -1, cbList[i])

                # boolean
                failOnNoNode = False
                for i in range(len(cbList)): # SetDataCallbackHandler
                    cb = cbList[i]
                    cb.waitForSuccess()
                    # Code
#                    rc = Code.get(cb.getRc())
#                    switch(rc) {
                    if cb.isSuccessful():
                        setStats[i] = cb.getStat()
                        needSet[i] = False
#                        case NONODE:
                    elif cb.isNoNodeError():
                        failOnNoNode = True
                    else:
                        needSet[i] = False

                if failOnNoNode: 
                    # boolean[]
                    needCreate = copy.copy(needSet)
                    createCbList = self.create(paths, records, needCreate, pathsCreated, options)
                    for i in range(len(createCbList)): # CreateCallbackHandler
                        createCb = createCbList[i]
                        if createCb == None: 
                            continue

                        # Code
#                        rc = Code.get(createCb.getRc())
#                        switch(rc) {
#                            case OK:
                        if createCb.isSuccessful():
                            setStats[i] = ZNode.ZERO_STAT
                            needSet[i] = False
#                        case NODEEXISTS:
                        elif createCb.isNodeExistsError():
                            retry = True
                        else:
                            needSet[i] = False

            for i in range(len(cbList)): # SetDataCallbackHandler
                cb = cbList[i]
                # Code
#                rc = Code.get(cb.getRc())
#                if rc == Code.OK:
                if cb.isSuccessful():
                    success[i] = True
                elif cb.isNoNodeError():
#                    if rc == Code.NONODE:
                        # CreateCallbackHandler
                    createCb = createCbList[i]
#                    if Code.get(createCb.getRc()) == Code.OK:
                    if createCb.isSuccessful():
                        success[i] = True


            if stats != None:
                stats = copy.copy(setStats)
#                stats.clear()
#                stats.addAll(setStats)

            return success
        finally:
            # long
            endT = time.time()
            #if self.LOG.isDebugEnabled():
            self.LOG.debug("setData_async, size: " + str(paths.__len__())+ ", paths: " + str(paths.__getitem__(0))+ ",... time: " + str((endT - startT) )+ " ns")
    def create_paths(self, paths, records, needCreate, pathsCreated, options):
        """
        Returns CreateCallbackHandler[]
        Parameters:
            paths: List<String>records: List<T>needCreate: boolean[]pathsCreated: List<List<String>>options: int


        """
        if (records != None and records.__len__() != paths.__len__()) or needCreate.__len__() != paths.__len__() or (pathsCreated != None and pathsCreated.__len__() != paths.__len__()):
            raise IllegalArgumentException("paths, records, needCreate, and pathsCreated should be of same size")


        # CreateCallbackHandler[]
        cbList = [CreateCallbackHandler() for path in paths]
        # CreateMode
        mode = AccessOption.getMode(options)
        if mode == None: 
            self.LOG.error("Invalid async set mode. options: " + str(options))
            return cbList

        # boolean
        retry = True
        
        while retry:
            retry = False
            for i in range(paths.__len__()):
                if not needCreate[i]:
                    continue
                # String
                path = paths[i]
                # T
                record = ternary(records == None, None, records[i])
                cbList[i] = CreateCallbackHandler()
                self._zkClient.asyncCreate(path, record, mode, cbList[i])

            # List<String>
#            parentPaths = ArrayList<String>(Collections.nCopies(paths.__len__(), None))
            parentPaths = [None for path in paths]
            # boolean
            failOnNoNode = False
            for i in range(paths.__len__()):
                if not needCreate[i]:
                    continue
                # CreateCallbackHandler
                cb = cbList[i]
                cb.waitForSuccess()
                # String
                path = paths[i]
#                if Code.get(cb.getRc()) == Code.NONODE:
                if cb.isNoNodeError():
                    # String
                    parentPath = os.path.abspath(os.path.join(path, os.path.pardir))
#                    parentPath = File(path).getParent()
                    parentPaths[i] = parentPath
                    failOnNoNode = True
                else:
                    needCreate[i] = False
#                    if Code.get(cb.getRc()) == Code.OK and pathsCreated != None:
                    if cb.isSuccessful() and pathsCreated != None:
                        if pathsCreated[i] == None:
                            pathsCreated[i] = []
                        pathsCreated[i].add(path)

            if failOnNoNode:
                # boolean[]
#                needCreateParent = Arrays.copyOf(needCreate, needCreate.length)
                needCreateParent = [x for x in needCreate]
                # CreateCallbackHandler[]
                parentCbList = self.create(parentPaths, None, needCreateParent, pathsCreated, AccessOption.PERSISTENT)
                for parentCb in parentCbList: # CreateCallbackHandler
#                    parentCb = parentCbList[i]
                    if parentCb == None: 
                        continue
                    # Code
                    if parentCb.isSuccessful() or parentCb.isNodeExistError():
#                    rc = Code.get(parentCb.getRc())
#                    if rc == Code.OK or rc == Code.NODEEXISTS:
                        retry = True
                        break

        return cbList