Skip to content

Commit

Permalink
issue-1932: added explicit shard count setting (--shard-count) to fil…
Browse files Browse the repository at this point in the history
…estore-client
  • Loading branch information
qkrorlqr committed Jan 7, 2025
1 parent 62aa5c6 commit 7f017b9
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 1 deletion.
7 changes: 7 additions & 0 deletions cloud/filestore/apps/client/lib/create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class TCreateCommand final
NCloud::NProto::EStorageMediaKind StorageMediaKind =
NCloud::NProto::STORAGE_MEDIA_HDD;
TString StorageMediaKindArg;
ui32 ShardCount = 0;

public:
TCreateCommand()
Expand Down Expand Up @@ -54,6 +55,11 @@ class TCreateCommand final
Opts.AddLongOption("storage-media-kind")
.RequiredArgument("STR")
.StoreResult(&StorageMediaKindArg);

Opts.AddLongOption("shard-count")
.RequiredArgument("NUM")
.Help("explicitly specifies the required shard count")
.StoreResult(&ShardCount);
}

bool Execute() override
Expand All @@ -80,6 +86,7 @@ class TCreateCommand final
}

request->SetStorageMediaKind(StorageMediaKind);
request->SetShardCount(ShardCount);

PerformanceProfileParams.FillRequest(*request);

Expand Down
7 changes: 7 additions & 0 deletions cloud/filestore/apps/client/lib/resize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class TResizeCommand final

ui64 BlocksCount = 0;
bool Force = false;
ui32 ShardCount = 0;

public:
TResizeCommand()
Expand All @@ -29,6 +30,11 @@ class TResizeCommand final
Opts.AddLongOption("force")
.StoreTrue(&Force)
.Help("force flag allows to decrease the size of the file store");

Opts.AddLongOption("shard-count")
.RequiredArgument("NUM")
.Help("explicitly specifies the required shard count")
.StoreResult(&ShardCount);
}

bool Execute() override
Expand All @@ -39,6 +45,7 @@ class TResizeCommand final
request->SetFileSystemId(FileSystemId);
request->SetBlocksCount(BlocksCount);
request->SetForce(Force);
request->SetShardCount(ShardCount);

PerformanceProfileParams.FillRequest(*request);

Expand Down
3 changes: 3 additions & 0 deletions cloud/filestore/tests/client_sharded/canondata/result.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"test.test_explicit_shard_count_addition": {
"uri": "file://test.test_explicit_shard_count_addition/results.txt"
},
"test.test_shard_autoaddition": {
"uri": "file://test.test_shard_autoaddition/results.txt"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{"Sessions":[{"SessionId":"session0","ClientId":"client0"}]}
{"Sessions":[{"SessionId":"session0","ClientId":"client0"}]}
SEVERITY_ERROR | FACILITY_SCHEMESHARD | 2 Path not found
SEVERITY_ERROR | FACILITY_SCHEMESHARD | 2 Path not found
{"Sessions":[{"SessionId":"session0","ClientId":"client0"}]}
{"Sessions":[{"SessionId":"session0","ClientId":"client0"}]}
{"Sessions":[{"SessionId":"session0","ClientId":"client0"}]}
{"Sessions":[{"SessionId":"session0","ClientId":"client0"}]}
38 changes: 38 additions & 0 deletions cloud/filestore/tests/client_sharded/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,41 @@ def test_shard_autoaddition():

ret = common.canonical_file(results_path, local=True)
return ret


def test_explicit_shard_count_addition():
client, results_path = __init_test()
out = client.create(
"fs0",
"test_cloud",
"test_folder",
BLOCK_SIZE,
int(SHARD_SIZE / BLOCK_SIZE))

data_file = os.path.join(common.output_path(), "data.txt")
with open(data_file, "w") as f:
f.write("some data")

client.create_session("fs0", "session0", "client0")
out = client.execute_action("describesessions", {"FileSystemId": "fs0"})
out += client.execute_action("describesessions", {"FileSystemId": "fs0_s1"})
out += client.execute_action("describesessions", {"FileSystemId": "fs0_s2"})
out += client.execute_action("describesessions", {"FileSystemId": "fs0_s3"})
client.destroy_session("fs0", "session0", "client0")

out += client.resize("fs0", int(SHARD_SIZE / BLOCK_SIZE), shard_count=3)

client.create_session("fs0", "session0", "client0")
out += client.execute_action("describesessions", {"FileSystemId": "fs0"})
out += client.execute_action("describesessions", {"FileSystemId": "fs0_s1"})
out += client.execute_action("describesessions", {"FileSystemId": "fs0_s2"})
out += client.execute_action("describesessions", {"FileSystemId": "fs0_s3"})
client.destroy_session("fs0", "session0", "client0")

out += client.destroy("fs0")

with open(results_path, "wb") as results_file:
results_file.write(out)

ret = common.canonical_file(results_path, local=True)
return ret
5 changes: 4 additions & 1 deletion cloud/filestore/tests/python/lib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def mount(self, fs, path, mount_seqno=0, readonly=False):

return pid

def resize(self, fs, blk_count, force=False):
def resize(self, fs, blk_count, force=False, shard_count=None):
cmd = [
self.__binary_path, "resize",
"--filesystem", fs,
Expand All @@ -123,6 +123,9 @@ def resize(self, fs, blk_count, force=False):
if force:
cmd.append("--force")

if shard_count is not None:
cmd += ["--shard-count", str(shard_count)]

logger.info("resizing filestore: " + " ".join(cmd))
return common.execute(cmd, env=self.__env, check_exit_code=self.__check_exit_code).stdout

Expand Down

0 comments on commit 7f017b9

Please sign in to comment.