MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / DeployTablet

Function DeployTablet

tools/deploy.py:212–249  ·  view source on GitHub ↗
(zk_cluster, zk_root_path, tablet_conf, teardown)

Source from the content-addressed store, hash-verified

210 print("execute cmd[{}] success".format(cmd))
211
212def DeployTablet(zk_cluster, zk_root_path, tablet_conf, teardown):
213 source_file = tablet_conf["package"]
214 file_name = os.path.basename(source_file)
215 version = file_name.split("-")[-1][:-7]
216 for item in tablet_conf["address_arr"]:
217 real_path = ''
218 if "path" in item:
219 real_path = item["path"]
220 else:
221 real_path = tablet_conf["path"]
222 host = item["address"].split(":")[0]
223 (prefix, suffix, is_local) = GetPrefixAndSuffix(host)
224 work_path = real_path + "/fedb-tablet-" + version
225 cmd_arr = []
226 if teardown:
227 print("teardown tablet on {}. path: {}".format(host, real_path))
228 cmd_arr.append("{} cd {}; sh bin/start.sh stop {}".format(prefix, work_path, suffix))
229 cmd_arr.append("{} cd {}; rm {}; rm -rf {} {}".format(prefix, real_path, file_name, "fedb-tablet-*", suffix))
230 else:
231 print("start tablet on {}. path: {}".format(host, real_path))
232 cmd_arr.append("{} mkdir -p {} {}".format(prefix, real_path, suffix))
233 if is_local:
234 cmd_arr.append("cp {} {}".format(source_file, real_path))
235 else:
236 cmd_arr.append("scp {} {}:{}".format(source_file, host, real_path))
237 cmd_arr.append("{} cd {}; tar -zxvf {}; mv {} fedb-tablet-{} {}".format(prefix, real_path, file_name, file_name[:-7], version, suffix))
238 cmd_arr.append("{} cd {}; sed -i 's/--endpoint=.*/--endpoint={}/g' conf/tablet.flags {}".format(prefix, work_path, item["address"], suffix))
239 if zk_cluster != "":
240 cmd_arr.append("{} cd {}; sed -i 's/#--zk_cluster=.*/--zk_cluster={}/g' conf/tablet.flags;"
241 "sed -i 's/#--zk_root_path=.*/--zk_root_path={}/g' conf/tablet.flags {}".format(
242 prefix, work_path, zk_cluster, zk_root_path.replace("/", "\/"), suffix))
243 cmd_arr.append("{} cd {}; sh bin/start.sh start {}".format(prefix, work_path, suffix))
244 for cmd in cmd_arr:
245 (returncode,output,errout) = RunWithRetunCode(cmd)
246 if returncode != 0:
247 print("execute cmd[{}] failed! error msg: {}".format(cmd, errout))
248 return
249 print("execute cmd[{}] success".format(cmd))
250
251if __name__ == "__main__":
252 conf_file = sys.argv[1]

Callers 1

deploy.pyFile · 0.85

Calls 3

GetPrefixAndSuffixFunction · 0.85
RunWithRetunCodeFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected