mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-14 18:02:31 +08:00
fix compile errors from merge
This commit is contained in:
parent
43c7146d86
commit
1d3a129070
@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* TenantManagement.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 <string>
|
|
||||||
#include <map>
|
|
||||||
#include "fdbclient/SystemData.h"
|
|
||||||
#include "fdbclient/TenantManagement.actor.h"
|
|
||||||
#include "fdbclient/Tuple.h"
|
|
||||||
#include "flow/actorcompiler.h" // has to be last include
|
|
||||||
|
|
||||||
namespace TenantAPI {
|
|
||||||
|
|
||||||
Key getTenantGroupIndexKey(TenantGroupNameRef tenantGroup, Optional<TenantNameRef> tenant) {
|
|
||||||
Tuple tuple;
|
|
||||||
tuple.append(tenantGroup);
|
|
||||||
if (tenant.present()) {
|
|
||||||
tuple.append(tenant.get());
|
|
||||||
}
|
|
||||||
return tenantGroupTenantIndexKeys.begin.withSuffix(tuple.pack());
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace TenantAPI
|
|
@ -61,7 +61,7 @@ public:
|
|||||||
bool matchesConfiguration(TenantMapEntry const& other) const;
|
bool matchesConfiguration(TenantMapEntry const& other) const;
|
||||||
void configure(Standalone<StringRef> parameter, Optional<Value> value);
|
void configure(Standalone<StringRef> parameter, Optional<Value> value);
|
||||||
|
|
||||||
Value encode() const { return ObjectWriter::toValue(*this, IncludeVersion(ProtocolVersion::withTenantGroups())); }
|
Value encode() const { return ObjectWriter::toValue(*this, IncludeVersion(ProtocolVersion::withTenants())); }
|
||||||
|
|
||||||
static TenantMapEntry decode(ValueRef const& value) {
|
static TenantMapEntry decode(ValueRef const& value) {
|
||||||
TenantMapEntry entry;
|
TenantMapEntry entry;
|
||||||
|
@ -371,8 +371,6 @@ Future<std::vector<std::pair<TenantName, TenantMapEntry>>> listTenants(Reference
|
|||||||
|
|
||||||
ACTOR template <class Transaction>
|
ACTOR template <class Transaction>
|
||||||
Future<Void> renameTenantTransaction(Transaction tr, TenantNameRef oldName, TenantNameRef newName) {
|
Future<Void> renameTenantTransaction(Transaction tr, TenantNameRef oldName, TenantNameRef newName) {
|
||||||
state Key oldNameKey = oldName.withPrefix(tenantMapPrefix);
|
|
||||||
state Key newNameKey = newName.withPrefix(tenantMapPrefix);
|
|
||||||
tr->setOption(FDBTransactionOptions::RAW_ACCESS);
|
tr->setOption(FDBTransactionOptions::RAW_ACCESS);
|
||||||
state Optional<TenantMapEntry> oldEntry;
|
state Optional<TenantMapEntry> oldEntry;
|
||||||
state Optional<TenantMapEntry> newEntry;
|
state Optional<TenantMapEntry> newEntry;
|
||||||
|
@ -367,7 +367,8 @@ public:
|
|||||||
ManagementAPIError::toJsonString(false, "rename tenant", "tenant rename conflict"));
|
ManagementAPIError::toJsonString(false, "rename tenant", "tenant rename conflict"));
|
||||||
throw special_keys_api_failure();
|
throw special_keys_api_failure();
|
||||||
}
|
}
|
||||||
tenantManagementFutures.push_back(changeTenantConfig(ryw, configMutation.first, configMutation.second));
|
tenantManagementFutures.push_back(
|
||||||
|
changeTenantConfig(ryw, configMutation.first, configMutation.second, &tenantGroupNetTenantDelta));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto renameMutation : renameMutations) {
|
for (auto renameMutation : renameMutations) {
|
||||||
|
@ -791,7 +791,7 @@ struct TenantManagementWorkload : TestWorkload {
|
|||||||
return Void();
|
return Void();
|
||||||
}
|
}
|
||||||
|
|
||||||
ACTOR Future<Void> renameTenant(Database cx, TenantManagementWorkload* self) {
|
ACTOR static Future<Void> renameTenant(Database cx, TenantManagementWorkload* self) {
|
||||||
state OperationType operationType = TenantManagementWorkload::randomOperationType();
|
state OperationType operationType = TenantManagementWorkload::randomOperationType();
|
||||||
state int numTenants = 1;
|
state int numTenants = 1;
|
||||||
state Reference<ReadYourWritesTransaction> tr = makeReference<ReadYourWritesTransaction>(cx);
|
state Reference<ReadYourWritesTransaction> tr = makeReference<ReadYourWritesTransaction>(cx);
|
||||||
@ -928,89 +928,6 @@ struct TenantManagementWorkload : TestWorkload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ACTOR Future<Void> configureTenant(Database cx, TenantManagementWorkload* self) {
|
|
||||||
state TenantName tenant = self->chooseTenantName(true);
|
|
||||||
auto itr = self->createdTenants.find(tenant);
|
|
||||||
state bool exists = itr != self->createdTenants.end();
|
|
||||||
state Reference<ReadYourWritesTransaction> tr = makeReference<ReadYourWritesTransaction>(cx);
|
|
||||||
|
|
||||||
state std::map<Standalone<StringRef>, Optional<Value>> configuration;
|
|
||||||
state Optional<TenantGroupName> newTenantGroup;
|
|
||||||
state bool hasInvalidOption = deterministicRandom()->random01() < 0.1;
|
|
||||||
|
|
||||||
if (!hasInvalidOption || deterministicRandom()->coinflip()) {
|
|
||||||
newTenantGroup = self->chooseTenantGroup();
|
|
||||||
configuration["tenant_group"_sr] = newTenantGroup;
|
|
||||||
}
|
|
||||||
if (hasInvalidOption) {
|
|
||||||
configuration["invalid_option"_sr] = ""_sr;
|
|
||||||
hasInvalidOption = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
state bool hasInvalidSpecialKeyTuple = deterministicRandom()->random01() < 0.05;
|
|
||||||
|
|
||||||
loop {
|
|
||||||
try {
|
|
||||||
tr->setOption(FDBTransactionOptions::SPECIAL_KEY_SPACE_ENABLE_WRITES);
|
|
||||||
for (auto [config, value] : configuration) {
|
|
||||||
Tuple t;
|
|
||||||
if (hasInvalidSpecialKeyTuple) {
|
|
||||||
// Wrong number of items
|
|
||||||
if (deterministicRandom()->coinflip()) {
|
|
||||||
int numItems = deterministicRandom()->randomInt(0, 3);
|
|
||||||
if (numItems > 0) {
|
|
||||||
t.append(tenant);
|
|
||||||
}
|
|
||||||
if (numItems > 1) {
|
|
||||||
t.append(config).append(""_sr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Wrong data types
|
|
||||||
else {
|
|
||||||
if (deterministicRandom()->coinflip()) {
|
|
||||||
t.append(0).append(config);
|
|
||||||
} else {
|
|
||||||
t.append(tenant).append(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
t.append(tenant).append(config);
|
|
||||||
}
|
|
||||||
if (value.present()) {
|
|
||||||
tr->set(self->specialKeysTenantConfigPrefix.withSuffix(t.pack()), value.get());
|
|
||||||
} else {
|
|
||||||
tr->clear(self->specialKeysTenantConfigPrefix.withSuffix(t.pack()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
wait(tr->commit());
|
|
||||||
|
|
||||||
ASSERT(exists);
|
|
||||||
ASSERT(!hasInvalidOption);
|
|
||||||
ASSERT(!hasInvalidSpecialKeyTuple);
|
|
||||||
|
|
||||||
self->createdTenants[tenant].tenantGroup = newTenantGroup;
|
|
||||||
return Void();
|
|
||||||
} catch (Error& e) {
|
|
||||||
state Error error = e;
|
|
||||||
if (e.code() == error_code_tenant_not_found) {
|
|
||||||
ASSERT(!exists);
|
|
||||||
return Void();
|
|
||||||
} else if (e.code() == error_code_special_keys_api_failure) {
|
|
||||||
ASSERT(hasInvalidSpecialKeyTuple || hasInvalidOption);
|
|
||||||
return Void();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
wait(tr->onError(e));
|
|
||||||
} catch (Error&) {
|
|
||||||
TraceEvent(SevError, "ConfigureTenantFailure").error(error).detail("TenantName", tenant);
|
|
||||||
return Void();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Changes the configuration of a tenant
|
// Changes the configuration of a tenant
|
||||||
ACTOR static Future<Void> configureImpl(Reference<ReadYourWritesTransaction> tr,
|
ACTOR static Future<Void> configureImpl(Reference<ReadYourWritesTransaction> tr,
|
||||||
TenantName tenant,
|
TenantName tenant,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user