Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
yujun777 authored and deardeng committed Jul 24, 2024
1 parent 6d81c23 commit 8c20ac9
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 19 deletions.
29 changes: 22 additions & 7 deletions docker/runtime/doris-compose/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,10 @@ def compose(self):

class FE(Node):

def init(self):
super().init()
self.init_is_follower()

def get_add_init_config(self):
cfg = []
if self.cluster.fe_config:
Expand All @@ -382,10 +386,20 @@ def get_add_init_config(self):

return cfg

def init_is_follower(self):
if self.cluster.is_cloud and self.cluster.fe_follower:
with open(self._is_follower_path(), "w") as f:
f.write("true")

def _is_follower_path(self):
return "{}/conf/is_follower".format(self.get_path())

def docker_env(self):
envs = super().docker_env()
if self.cluster.is_cloud:
envs["CLOUD_UNIQUE_ID"] = self.cloud_unique_id()
if os.path.exists(self._is_follower_path()):
envs["IS_FE_FOLLOWER"] = 1
return envs

def cloud_unique_id(self):
Expand Down Expand Up @@ -598,8 +612,8 @@ def expose_sub_dirs(self):
class Cluster(object):

def __init__(self, name, subnet, image, is_cloud, fe_config, be_config,
ms_config, recycle_config, be_disks, be_cluster, reg_be,
coverage_dir, cloud_store_config):
ms_config, recycle_config, fe_follower, be_disks, be_cluster,
reg_be, coverage_dir, cloud_store_config):
self.name = name
self.subnet = subnet
self.image = image
Expand All @@ -608,6 +622,7 @@ def __init__(self, name, subnet, image, is_cloud, fe_config, be_config,
self.be_config = be_config
self.ms_config = ms_config
self.recycle_config = recycle_config
self.fe_follower = fe_follower
self.be_disks = be_disks
self.be_cluster = be_cluster
self.reg_be = reg_be
Expand All @@ -620,8 +635,8 @@ def __init__(self, name, subnet, image, is_cloud, fe_config, be_config,

@staticmethod
def new(name, image, is_cloud, fe_config, be_config, ms_config,
recycle_config, be_disks, be_cluster, reg_be, coverage_dir,
cloud_store_config):
recycle_config, fe_follower, be_disks, be_cluster, reg_be,
coverage_dir, cloud_store_config):
if not os.path.exists(LOCAL_DORIS_PATH):
os.makedirs(LOCAL_DORIS_PATH, exist_ok=True)
os.chmod(LOCAL_DORIS_PATH, 0o777)
Expand All @@ -630,9 +645,9 @@ def new(name, image, is_cloud, fe_config, be_config, ms_config,
os.chmod(lock_file, 0o666)
subnet = gen_subnet_prefix16()
cluster = Cluster(name, subnet, image, is_cloud, fe_config,
be_config, ms_config, recycle_config, be_disks,
be_cluster, reg_be, coverage_dir,
cloud_store_config)
be_config, ms_config, recycle_config,
fe_follower, be_disks, be_cluster, reg_be,
coverage_dir, cloud_store_config)
os.makedirs(cluster.get_path(), exist_ok=True)
os.makedirs(get_status_path(name), exist_ok=True)
cluster._save_meta()
Expand Down
18 changes: 12 additions & 6 deletions docker/runtime/doris-compose/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ def add_parser(self, args_parsers):
type=str,
help="Specify recycle configs for doris_cloud.conf. "\
"Example: --recycle-config \"log_level = warn\".")
group1.add_argument(
"--fe-follower",
default=False,
action=self._get_parser_bool_action(True),
help=
"The new added fe is follower but not observer. Only support in cloud mode."
)
group1.add_argument("--be-disks",
nargs="*",
default=["HDD=1"],
Expand Down Expand Up @@ -383,12 +390,11 @@ def run(self, args):
args.add_ms_num = 0
args.add_recycle_num = 0

cluster = CLUSTER.Cluster.new(args.NAME, args.IMAGE, args.cloud,
args.fe_config, args.be_config,
args.ms_config, args.recycle_config,
args.be_disks, args.be_cluster,
args.reg_be, args.coverage_dir,
cloud_store_config)
cluster = CLUSTER.Cluster.new(
args.NAME, args.IMAGE, args.cloud, args.fe_config,
args.be_config, args.ms_config, args.recycle_config,
args.fe_follower, args.be_disks, args.be_cluster, args.reg_be,
args.coverage_dir, cloud_store_config)
LOG.info("Create new cluster {} succ, cluster path is {}".format(
args.NAME, cluster.get_path()))

Expand Down
15 changes: 9 additions & 6 deletions docker/runtime/doris-compose/resource/init_fe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ fe_daemon() {
done
}

add_cloud_fe() {
start_cloud_fe() {
if [ -f "$REGISTER_FILE" ]; then
bash $DORIS_HOME/bin/start_fe.sh --daemon
return
fi

Expand All @@ -96,6 +97,10 @@ add_cloud_fe() {
node_type=FE_OBSERVER
fi

if [ "a$IS_FE_FOLLOWER" == "a1" ]; then
node_type=FE_FOLLOWER
fi

nodes='{
"cloud_unique_id": "'"${CLOUD_UNIQUE_ID}"'",
"ip": "'"${MY_IP}"'",
Expand Down Expand Up @@ -141,6 +146,9 @@ add_cloud_fe() {
touch $REGISTER_FILE
if [ "$MY_ID" == "1" ]; then
echo $MY_IP >$MASTER_FE_IP_FILE
bash $DORIS_HOME/bin/start_fe.sh --daemon
else
bash $DORIS_HOME/bin/start_fe.sh --helper $MASTER_FE_IP:$FE_EDITLOG_PORT --daemon
fi
}

Expand Down Expand Up @@ -182,11 +190,6 @@ start_local_fe() {
fi
}

start_cloud_fe() {
add_cloud_fe
bash $DORIS_HOME/bin/start_fe.sh --daemon
}

main() {
trap stop_frontend SIGTERM

Expand Down

0 comments on commit 8c20ac9

Please sign in to comment.