mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-25 00:30:00 +08:00
66 lines
2.6 KiB
C++
66 lines
2.6 KiB
C++
/*
|
|
* BackupToBlob.actor.cpp
|
|
*
|
|
* This source file is part of the FoundationDB open source project
|
|
*
|
|
* Copyright 2013-2018 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/simulator.h"
|
|
#include "fdbclient/BackupAgent.actor.h"
|
|
#include "fdbclient/BackupContainer.h"
|
|
#include "fdbserver/workloads/workloads.actor.h"
|
|
#include "flow/actorcompiler.h" // This must be the last #include.
|
|
|
|
struct BackupToBlobWorkload : TestWorkload {
|
|
double backupAfter;
|
|
Key backupTag;
|
|
Standalone<StringRef> backupURL;
|
|
int snapshotInterval = 100000;
|
|
|
|
static constexpr const char* DESCRIPTION = "BackupToBlob";
|
|
|
|
BackupToBlobWorkload(WorkloadContext const& wcx) : TestWorkload(wcx) {
|
|
backupAfter = getOption(options, LiteralStringRef("backupAfter"), 10.0);
|
|
backupTag = getOption(options, LiteralStringRef("backupTag"), BackupAgentBase::getDefaultTag());
|
|
backupURL = getOption(options, LiteralStringRef("backupURL"), LiteralStringRef("http://0.0.0.0:10000"));
|
|
}
|
|
|
|
std::string description() override { return DESCRIPTION; }
|
|
|
|
Future<Void> setup(Database const& cx) override { return Void(); }
|
|
|
|
ACTOR static Future<Void> _start(Database cx, BackupToBlobWorkload* self) {
|
|
state FileBackupAgent backupAgent;
|
|
state Standalone<VectorRef<KeyRangeRef>> backupRanges;
|
|
backupRanges.push_back_deep(backupRanges.arena(), normalKeys);
|
|
|
|
wait(delay(self->backupAfter));
|
|
wait(backupAgent.submitBackup(cx, self->backupURL, self->snapshotInterval, self->backupTag.toString(),
|
|
backupRanges));
|
|
EBackupState backupStatus = wait(backupAgent.waitBackup(cx, self->backupTag.toString(), true));
|
|
TraceEvent("BackupToBlob_BackupStatus").detail("Status", BackupAgentBase::getStateText(backupStatus));
|
|
return Void();
|
|
}
|
|
|
|
Future<Void> start(Database const& cx) override { return clientId ? Void() : _start(cx, this); }
|
|
|
|
Future<bool> check(Database const& cx) override { return true; }
|
|
|
|
void getMetrics(std::vector<PerfMetric>& m) override {}
|
|
};
|
|
|
|
WorkloadFactory<BackupToBlobWorkload> BackupToBlobWorkloadFactory(BackupToBlobWorkload::DESCRIPTION);
|