Skip to content

Commit 887af1f

Browse files
committed
Added cnacel-on-file-finish flag
1 parent f6a6332 commit 887af1f

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

ydb/tests/tools/fqrun/fqrun.cpp

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,15 @@ class TMain : public TMainBase {
185185
.Handler1([this](const NLastGetopt::TOptsParser* option) {
186186
TStringBuf topicName, others;
187187
TStringBuf(option->CurVal()).Split('@', topicName, others);
188+
188189
TStringBuf path, partitionCountStr;
189190
TStringBuf(others).Split(':', path, partitionCountStr);
190191
size_t partitionCount = !partitionCountStr.empty() ? FromString<size_t>(partitionCountStr) : 1;
192+
if (!partitionCount) {
193+
ythrow yexception() << "Topic partition count should be at least one";
194+
}
191195
if (topicName.empty() || path.empty()) {
192-
ythrow yexception() << "Incorrect PQ file mapping, expected form topic@path[:partitions_count]" << Endl;
196+
ythrow yexception() << "Incorrect PQ file mapping, expected form topic@path[:partitions_count]";
193197
}
194198
if (!PqFilesMapping.emplace(topicName, NYql::TDummyTopic("pq", TString(topicName), TString(path), partitionCount)).second) {
195199
ythrow yexception() << "Got duplicated topic name: " << topicName;
@@ -199,15 +203,7 @@ class TMain : public TMainBase {
199203
options.AddLongOption("cnacel-on-file-finish", "Cancel emulate YDS topics when topic file finished")
200204
.RequiredArgument("topic")
201205
.Handler1([this](const NLastGetopt::TOptsParser* option) {
202-
TStringBuf topicName;
203-
TStringBuf filePath;
204-
TStringBuf(option->CurVal()).Split('@', topicName, filePath);
205-
if (topicName.empty() || filePath.empty()) {
206-
ythrow yexception() << "Incorrect PQ file mapping, expected form topic@file";
207-
}
208-
if (!PqFilesMapping.emplace(topicName, filePath).second) {
209-
ythrow yexception() << "Got duplicated topic name: " << topicName;
210-
}
206+
TopicsSettings[option->CurVal()].CancelOnFileFinish = true;
211207
});
212208

213209
// Outputs
@@ -259,11 +255,18 @@ class TMain : public TMainBase {
259255

260256
if (!PqFilesMapping.empty()) {
261257
auto fileGateway = MakeIntrusive<NYql::TDummyPqGateway>();
262-
for (const auto& [_, topic] : PqFilesMapping) {
258+
for (auto [_, topic] : PqFilesMapping) {
259+
if (const auto it = TopicsSettings.find(topic.TopicName); it != TopicsSettings.end()) {
260+
topic.CancelOnFileFinish = it->second.CancelOnFileFinish;
261+
TopicsSettings.erase(it);
262+
}
263263
fileGateway->AddDummyTopic(topic);
264264
}
265265
RunnerOptions.FqSettings.PqGateway = std::move(fileGateway);
266266
}
267+
if (!TopicsSettings.empty()) {
268+
ythrow yexception() << "Found topic settings for not existing topic: '" << TopicsSettings.begin()->first << "'";
269+
}
267270

268271
#ifdef PROFILE_MEMORY_ALLOCATIONS
269272
if (RunnerOptions.FqSettings.VerboseLevel >= EVerbose::Info) {
@@ -302,6 +305,11 @@ class TMain : public TMainBase {
302305
TExecutionOptions ExecutionOptions;
303306
TRunnerOptions RunnerOptions;
304307
std::unordered_map<TString, NYql::TDummyTopic> PqFilesMapping;
308+
309+
struct TTopicSettings {
310+
bool CancelOnFileFinish = false;
311+
};
312+
std::unordered_map<TString, TTopicSettings> TopicsSettings;
305313
};
306314

307315
} // anonymous namespace

0 commit comments

Comments
 (0)