def install(self, version, core_count, read_replica_count, initial_port, password, verbose=False): try: package = create_controller().download("enterprise", version, self.path, verbose=verbose) port_gen = count(initial_port) self.initial_discovery_members = self._install_cores(self.path, package, core_count, port_gen) self._install_read_replicas(self.path, package, self.initial_discovery_members, read_replica_count, port_gen) self._set_initial_password(password) return realpath(self.path) except HTTPError as error: if error.code == 401: raise RuntimeError("Missing or incorrect authorization") elif error.code == 403: raise RuntimeError("Could not download package from %s (403 Forbidden)" % error.url) else: raise
def _install_read_replicas(cls, path, package, initial_discovery_members, read_replica_count, port_generator): controller = create_controller() for read_replica_idx in range(0, read_replica_count): read_replica_dir = READ_REPLICA_DIR_FORMAT % read_replica_idx read_replica_path = path_join(path, READ_REPLICAS_DIR, read_replica_dir) read_replica_home = controller.extract(package, read_replica_path) bolt_listen_address = _localhost(next(port_generator)) http_listen_address = _localhost(next(port_generator)) https_listen_address = _localhost(next(port_generator)) transaction_listen_address = _localhost(next(port_generator)) read_replica_config = config.for_read_replica(initial_discovery_members, bolt_listen_address, http_listen_address, https_listen_address, transaction_listen_address) os_dependent_config = controller.os_dependent_config(read_replica_dir) read_replica_config.update(os_dependent_config) config.update(read_replica_home, read_replica_config)
def _install_cores(cls, path, package, core_count, port_generator): discovery_listen_addresses = [] transaction_listen_addresses = [] raft_listen_addresses = [] bolt_listen_addresses = [] http_listen_addresses = [] https_listen_addresses = [] for core_idx in range(0, core_count): discovery_listen_addresses.append(_localhost(next(port_generator))) transaction_listen_addresses.append(_localhost(next(port_generator))) raft_listen_addresses.append(_localhost(next(port_generator))) bolt_listen_addresses.append(_localhost(next(port_generator))) http_listen_addresses.append(_localhost(next(port_generator))) https_listen_addresses.append(_localhost(next(port_generator))) initial_discovery_members = ",".join(discovery_listen_addresses) controller = create_controller() for core_idx in range(0, core_count): core_dir = CORE_DIR_FORMAT % core_idx core_member_path = path_join(path, CORES_DIR, core_dir) core_member_home = controller.extract(package, core_member_path) core_config = config.for_core(core_count, initial_discovery_members, discovery_listen_addresses[core_idx], transaction_listen_addresses[core_idx], raft_listen_addresses[core_idx], bolt_listen_addresses[core_idx], http_listen_addresses[core_idx], https_listen_addresses[core_idx]) os_dependent_config = controller.os_dependent_config(core_dir) core_config.update(os_dependent_config) config.update(core_member_home, core_config) return initial_discovery_members
def _cluster_member_set_initial_password(cls, path, password): controller = create_controller(path) return controller.set_initial_password(password)
def _cluster_member_kill(cls, path): controller = create_controller(path) controller.stop(True)
def _cluster_member_stop(cls, path): controller = create_controller(path) controller.stop(False)
def _cluster_member_start(cls, path): controller = create_controller(path) return controller.start()