76 lines
2.7 KiB
C++
76 lines
2.7 KiB
C++
/*
|
|
* BulkSetup.actor.cpp
|
|
*
|
|
* This source file is part of the FoundationDB open source project
|
|
*
|
|
* Copyright 2013-2022 Apple Inc. and the FoundationDB project authors
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#include "fdbrpc/ContinuousSample.h"
|
|
#include "fdbclient/NativeAPI.actor.h"
|
|
#include "fdbserver/TesterInterface.actor.h"
|
|
#include "fdbserver/workloads/workloads.actor.h"
|
|
#include "fdbserver/workloads/BulkSetup.actor.h"
|
|
#include "flow/actorcompiler.h" // This must be the last #include.
|
|
|
|
struct BulkSetupWorkload : TestWorkload {
|
|
|
|
std::vector<TenantName> tenantNames;
|
|
int nodeCount;
|
|
double transactionsPerSecond;
|
|
Key keyPrefix;
|
|
|
|
BulkSetupWorkload(WorkloadContext const& wcx) : TestWorkload(wcx) {
|
|
transactionsPerSecond = getOption(options, "transactionsPerSecond"_sr, 5000.0) / clientCount;
|
|
nodeCount = getOption(options, "nodeCount"_sr, transactionsPerSecond * clientCount);
|
|
keyPrefix = unprintable(getOption(options, "keyPrefix"_sr, ""_sr).toString());
|
|
std::vector<std::string> tenants = getOption(options, "tenants"_sr, std::vector<std::string>());
|
|
for (std::string tenant : tenants) {
|
|
tenantNames.push_back(TenantName(tenant));
|
|
}
|
|
}
|
|
|
|
std::string description() const override { return "BulkSetup"; }
|
|
|
|
void getMetrics(std::vector<PerfMetric>& m) override {}
|
|
|
|
Key keyForIndex(int n) { return key(n); }
|
|
Key key(int n) { return doubleToTestKey((double)n / nodeCount, keyPrefix); }
|
|
Value value(int n) { return doubleToTestKey(n, keyPrefix); }
|
|
|
|
Standalone<KeyValueRef> operator()(int n) { return KeyValueRef(key(n), value((n + 1) % nodeCount)); }
|
|
|
|
Future<Void> start(Database const& cx) override {
|
|
return bulkSetup(cx,
|
|
this,
|
|
nodeCount,
|
|
Promise<double>(),
|
|
false,
|
|
0.0,
|
|
1e12,
|
|
std::vector<uint64_t>(),
|
|
Promise<std::vector<std::pair<uint64_t, double>>>(),
|
|
0,
|
|
0.1,
|
|
0,
|
|
0,
|
|
this->tenantNames);
|
|
}
|
|
|
|
Future<bool> check(Database const& cx) override { return true; }
|
|
};
|
|
|
|
WorkloadFactory<BulkSetupWorkload> BulkSetupWorkloadFactory("BulkSetup");
|