Skip to content

Commit 22bd5db

Browse files
committed
[fix] some bug fix, and support clean walfiles
Signed-off-by: zyb521 <[email protected]>
1 parent 0324b70 commit 22bd5db

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

internal/configure/topology/dc_get.go

+6
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const (
4646
LAYOUT_TOOLS_DIR = "/tools"
4747
LAYOUT_TOOLS_V2_DIR = "/tools-v2"
4848
LAYOUT_CURVEBS_CHUNKFILE_POOL_DIR = "chunkfilepool"
49+
LAYOUT_CURVEBS_WALFILE_POOL_DIR = "walfilepool"
4950
LAYOUT_CURVEBS_COPYSETS_DIR = "copysets"
5051
LAYOUT_CURVEBS_RECYCLER_DIR = "recycler"
5152
LAYOUT_CURVEBS_TOOLS_CONFIG_SYSTEM_PATH = "/etc/curve/tools.conf"
@@ -58,6 +59,7 @@ const (
5859
BINARY_CURVEFS_TOOL = "curvefs_tool"
5960
BINARY_CURVE_TOOL_V2 = "curve"
6061
METAFILE_CHUNKFILE_POOL = "chunkfilepool.meta"
62+
METAFILE_WALFILE_POOL = "walfilepool.meta"
6163
METAFILE_CHUNKSERVER_ID = "chunkserver.dat"
6264
)
6365

@@ -285,6 +287,7 @@ func (dc *DeployConfig) GetProjectLayout() Layout {
285287

286288
// format
287289
chunkserverDataDir := fmt.Sprintf("%s/%s%s", root, ROLE_CHUNKSERVER, LAYOUT_SERVICE_DATA_DIR)
290+
chunkserverWalDir := fmt.Sprintf("%s/%s%s", root, ROLE_CHUNKSERVER, LAYOUT_SERVICE_WAL_DIR)
288291

289292
return Layout{
290293
// project
@@ -324,6 +327,9 @@ func (dc *DeployConfig) GetProjectLayout() Layout {
324327
ChunkfilePoolRootDir: chunkserverDataDir,
325328
ChunkfilePoolDir: fmt.Sprintf("%s/%s", chunkserverDataDir, LAYOUT_CURVEBS_CHUNKFILE_POOL_DIR),
326329
ChunkfilePoolMetaPath: fmt.Sprintf("%s/%s", chunkserverDataDir, METAFILE_CHUNKFILE_POOL),
330+
WalfilePoolRootDir: chunkserverWalDir,
331+
WalfilePoolDir: fmt.Sprintf("%s/%s", chunkserverWalDir, LAYOUT_CURVEBS_WALFILE_POOL_DIR),
332+
WalfilePoolMetaPath: fmt.Sprintf("%s/%s", chunkserverWalDir, METAFILE_WALFILE_POOL),
327333

328334
// core
329335
CoreSystemDir: LAYOUT_CORE_SYSTEM_DIR,

internal/task/task/common/clean_service.go

+17
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import (
4646

4747
const (
4848
LAYOUT_CURVEBS_CHUNKFILE_POOL_DIR = topology.LAYOUT_CURVEBS_CHUNKFILE_POOL_DIR
49+
LAYOUT_CURVEBS_WALFILE_POOL_DIR = topology.LAYOUT_CURVEBS_WALFILE_POOL_DIR
4950
LAYOUT_CURVEBS_COPYSETS_DIR = topology.LAYOUT_CURVEBS_COPYSETS_DIR
5051
LAYOUT_CURVEBS_RECYCLER_DIR = topology.LAYOUT_CURVEBS_RECYCLER_DIR
5152
METAFILE_CHUNKSERVER_ID = topology.METAFILE_CHUNKSERVER_ID
@@ -96,6 +97,17 @@ func (s *step2RecycleChunk) Execute(ctx *context.Context) error {
9697
if err != nil {
9798
errno.ERR_RUN_SCRIPT_FAILED.E(err)
9899
}
100+
101+
walDir := dc.GetWalDir()
102+
if walDir != "" {
103+
source = fmt.Sprintf("%s/%s", walDir, LAYOUT_CURVEBS_COPYSETS_DIR)
104+
dest = fmt.Sprintf("%s/%s", walDir, LAYOUT_CURVEBS_WALFILE_POOL_DIR)
105+
cmd = ctx.Module().Shell().BashScript(s.recycleScriptPath, source, dest, chunkSize)
106+
_, err = cmd.Execute(s.execOptions)
107+
if err != nil {
108+
errno.ERR_RUN_SCRIPT_FAILED.E(err)
109+
}
110+
}
99111
return nil
100112
}
101113

@@ -132,9 +144,14 @@ func getCleanFiles(clean map[string]bool, dc *topology.DeployConfig, recycle boo
132144
files = append(files, dc.GetDataDir())
133145
} else {
134146
dataDir := dc.GetDataDir()
147+
walDir := dc.GetWalDir()
135148
copysetsDir := fmt.Sprintf("%s/%s", dataDir, LAYOUT_CURVEBS_COPYSETS_DIR)
136149
chunkserverIdMetafile := fmt.Sprintf("%s/%s", dataDir, METAFILE_CHUNKSERVER_ID)
137150
files = append(files, copysetsDir, chunkserverIdMetafile)
151+
if walDir != "" {
152+
walCopysetsDir := fmt.Sprintf("%s/%s", walDir, LAYOUT_CURVEBS_COPYSETS_DIR)
153+
files = append(files, walCopysetsDir)
154+
}
138155
}
139156
}
140157
}

internal/task/task/common/create_container.go

+3
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ func getArguments(dc *topology.DeployConfig) string {
112112
layout := dc.GetProjectLayout()
113113
dataDir := layout.ServiceDataDir
114114
walDir := layout.ServiceWalDir
115+
if dc.GetWalDir() == "" {
116+
walDir = dataDir
117+
}
115118
chunkserverArguments := map[string]interface{}{
116119
// chunkserver
117120
"conf": layout.ServiceConfPath,

0 commit comments

Comments
 (0)