Skip to content

Commit e2eea99

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

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
@@ -97,6 +98,17 @@ func (s *step2RecycleChunk) Execute(ctx *context.Context) error {
9798
if err != nil {
9899
errno.ERR_RUN_SCRIPT_FAILED.E(err)
99100
}
101+
102+
walDir := dc.GetWalDir()
103+
if walDir != "" {
104+
source = fmt.Sprintf("%s/%s", walDir, LAYOUT_CURVEBS_COPYSETS_DIR)
105+
dest = fmt.Sprintf("%s/%s", walDir, LAYOUT_CURVEBS_WALFILE_POOL_DIR)
106+
cmd = ctx.Module().Shell().BashScript(s.recycleScriptPath, source, dest, chunkSize)
107+
_, err = cmd.Execute(s.execOptions)
108+
if err != nil {
109+
errno.ERR_RUN_SCRIPT_FAILED.E(err)
110+
}
111+
}
100112
return nil
101113
}
102114

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

internal/task/task/common/create_container.go

+3
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ func getArguments(dc *topology.DeployConfig) string {
107107
layout := dc.GetProjectLayout()
108108
dataDir := layout.ServiceDataDir
109109
walDir := layout.ServiceWalDir
110+
if dc.GetWalDir() == "" {
111+
walDir = dataDir
112+
}
110113
chunkserverArguments := map[string]interface{}{
111114
// chunkserver
112115
"conf": layout.ServiceConfPath,

0 commit comments

Comments
 (0)