rename APIs
This commit is contained in:
parent
445c2953e4
commit
851b6e7e56
|
@ -237,7 +237,7 @@ public class TenantManagement {
|
|||
* @return an iterator where each item is a KeyValue object where the key is the tenant name
|
||||
* and the value is the unprocessed JSON string containing the tenant's metadata
|
||||
*/
|
||||
public static CloseableAsyncIterator<KeyValue> listTenants(Database db, Tuple begin, Tuple end, int limit) {
|
||||
public static CloseableAsyncIterator<KeyValue> listTenantMetadata(Database db, Tuple begin, Tuple end, int limit) {
|
||||
return listTenants_internal(db.createTransaction(), begin.pack(), end.pack(), limit);
|
||||
}
|
||||
|
||||
|
@ -304,7 +304,7 @@ public class TenantManagement {
|
|||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
if (FDB.instance().warnOnUnclosed && !closed) {
|
||||
System.err.println("CloseableAsyncIterator not closed (listTenants)");
|
||||
System.err.println("CloseableAsyncIterator not closed (listTenantMetadata)");
|
||||
}
|
||||
if (!closed) {
|
||||
close();
|
||||
|
|
|
@ -489,7 +489,7 @@ public class AsyncStackTester {
|
|||
byte[] begin = (byte[])params.get(0);
|
||||
byte[] end = (byte[])params.get(1);
|
||||
int limit = StackUtils.getInt(params.get(2));
|
||||
CloseableAsyncIterator<KeyValue> tenantIter = TenantManagement.listTenants(inst.context.db, begin, end, limit);
|
||||
CloseableAsyncIterator<KeyValue> tenantIter = TenantManagement.listTenantMetadata(inst.context.db, begin, end, limit);
|
||||
List<byte[]> result = new ArrayList();
|
||||
try {
|
||||
while (tenantIter.hasNext()) {
|
||||
|
|
|
@ -434,7 +434,7 @@ public class StackTester {
|
|||
byte[] begin = (byte[])params.get(0);
|
||||
byte[] end = (byte[])params.get(1);
|
||||
int limit = StackUtils.getInt(params.get(2));
|
||||
CloseableAsyncIterator<KeyValue> tenantIter = TenantManagement.listTenants(inst.context.db, begin, end, limit);
|
||||
CloseableAsyncIterator<KeyValue> tenantIter = TenantManagement.listTenantMetadata(inst.context.db, begin, end, limit);
|
||||
List<byte[]> result = new ArrayList();
|
||||
try {
|
||||
while (tenantIter.hasNext()) {
|
||||
|
|
|
@ -366,7 +366,7 @@ ACTOR Future<bool> tenantListCommand(Reference<IDatabase> db, std::vector<String
|
|||
state std::vector<TenantName> tenantNames;
|
||||
if (clusterType == ClusterType::METACLUSTER_MANAGEMENT) {
|
||||
std::vector<std::pair<TenantName, TenantMapEntry>> tenants =
|
||||
wait(MetaclusterAPI::listTenants(db, beginTenant, endTenant, limit, offset, filters));
|
||||
wait(MetaclusterAPI::listTenantMetadata(db, beginTenant, endTenant, limit, offset, filters));
|
||||
for (auto tenant : tenants) {
|
||||
tenantNames.push_back(tenant.first);
|
||||
}
|
||||
|
|
|
@ -605,7 +605,7 @@ struct RegisterClusterImpl {
|
|||
tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS);
|
||||
|
||||
state Future<std::vector<std::pair<TenantName, int64_t>>> existingTenantsFuture =
|
||||
TenantAPI::listTenantIdsTransaction(tr, ""_sr, "\xff\xff"_sr, 1);
|
||||
TenantAPI::listTenantsTransaction(tr, ""_sr, "\xff\xff"_sr, 1);
|
||||
state ThreadFuture<RangeResult> existingDataFuture = tr->getRange(normalKeys, 1);
|
||||
|
||||
// Check whether this cluster has already been registered
|
||||
|
@ -1545,37 +1545,33 @@ Future<Void> deleteTenant(Reference<DB> db, int64_t id) {
|
|||
}
|
||||
|
||||
template <class Transaction>
|
||||
Future<std::vector<std::pair<TenantName, int64_t>>> listTenantIdsTransaction(Transaction tr,
|
||||
Future<std::vector<std::pair<TenantName, int64_t>>> listTenantsTransaction(Transaction tr,
|
||||
TenantName begin,
|
||||
TenantName end,
|
||||
int limit) {
|
||||
tr->setOption(FDBTransactionOptions::READ_SYSTEM_KEYS);
|
||||
auto future = ManagementClusterMetadata::tenantMetadata().tenantNameIndex.getRange(tr, begin, end, limit);
|
||||
return fmap([](auto f) -> std::vector<std::pair<TenantName, int64_t>> { return f.results; }, future);
|
||||
}
|
||||
|
||||
template <class DB>
|
||||
Future<std::vector<std::pair<TenantName, int64_t>>> listTenantIds(Reference<DB> db,
|
||||
Future<std::vector<std::pair<TenantName, int64_t>>> listTenants(Reference<DB> db,
|
||||
TenantName begin,
|
||||
TenantName end,
|
||||
int limit) {
|
||||
return runTransaction(
|
||||
db, [=](Reference<typename DB::TransactionT> tr) {
|
||||
tr->setOption(FDBTransactionOptions::LOCK_AWARE);
|
||||
return listTenantIdsTransaction(tr, begin, end, limit);
|
||||
tr->setOption(FDBTransactionOptions::READ_SYSTEM_KEYS);
|
||||
return listTenantsTransaction(tr, begin, end, limit);
|
||||
});
|
||||
}
|
||||
|
||||
ACTOR template <class Transaction>
|
||||
Future<std::vector<std::pair<TenantName, TenantMapEntry>>> listTenantsTransaction(Transaction tr,
|
||||
Future<std::vector<std::pair<TenantName, TenantMapEntry>>> listTenantMetadataTransaction(Transaction tr,
|
||||
TenantNameRef begin,
|
||||
TenantNameRef end,
|
||||
int limit) {
|
||||
tr->setOption(FDBTransactionOptions::RAW_ACCESS);
|
||||
|
||||
state KeyBackedRangeResult<std::pair<TenantName, int64_t>> matchingTenants =
|
||||
wait(ManagementClusterMetadata::tenantMetadata().tenantNameIndex.getRange(tr, begin, end, limit));
|
||||
|
||||
state KeyBackedRangeResult<std::pair<TenantName, int64_t>> matchingTenants = wait(listTenantsTransaction(tr, begin, end, limit));
|
||||
state std::vector<Future<TenantMapEntry>> tenantEntryFutures;
|
||||
for (auto const& [name, id] : matchingTenants.results) {
|
||||
tenantEntryFutures.push_back(getTenantTransaction(tr, id));
|
||||
|
@ -1593,7 +1589,7 @@ Future<std::vector<std::pair<TenantName, TenantMapEntry>>> listTenantsTransactio
|
|||
}
|
||||
|
||||
ACTOR template <class DB>
|
||||
Future<std::vector<std::pair<TenantName, TenantMapEntry>>> listTenants(
|
||||
Future<std::vector<std::pair<TenantName, TenantMapEntry>>> listTenantMetadata(
|
||||
Reference<DB> db,
|
||||
TenantName begin,
|
||||
TenantName end,
|
||||
|
@ -1605,8 +1601,10 @@ Future<std::vector<std::pair<TenantName, TenantMapEntry>>> listTenants(
|
|||
|
||||
loop {
|
||||
try {
|
||||
tr->setOption(FDBTransactionOptions::READ_SYSTEM_KEYS);
|
||||
|
||||
if (filters.empty()) {
|
||||
wait(store(results, MetaclusterAPI::listTenantsTransaction(tr, begin, end, limit + offset)));
|
||||
wait(store(results, MetaclusterAPI::listTenantMetadataTransaction(tr, begin, end, limit + offset)));
|
||||
|
||||
if (offset >= results.size()) {
|
||||
results.clear();
|
||||
|
@ -1620,7 +1618,7 @@ Future<std::vector<std::pair<TenantName, TenantMapEntry>>> listTenants(
|
|||
state int count = 0;
|
||||
loop {
|
||||
std::vector<std::pair<TenantName, TenantMapEntry>> tenantBatch =
|
||||
wait(MetaclusterAPI::listTenantsTransaction(tr, begin, end, std::max(limit + offset, 1000)));
|
||||
wait(MetaclusterAPI::listTenantMetadataTransaction(tr, begin, end, std::max(limit + offset, 1000)));
|
||||
|
||||
if (tenantBatch.empty()) {
|
||||
return results;
|
||||
|
|
|
@ -475,33 +475,33 @@ Future<Void> configureTenantTransaction(Transaction tr,
|
|||
}
|
||||
|
||||
template <class Transaction>
|
||||
Future<std::vector<std::pair<TenantName, int64_t>>> listTenantIdsTransaction(Transaction tr,
|
||||
Future<std::vector<std::pair<TenantName, int64_t>>> listTenantsTransaction(Transaction tr,
|
||||
TenantName begin,
|
||||
TenantName end,
|
||||
int limit) {
|
||||
tr->setOption(FDBTransactionOptions::READ_SYSTEM_KEYS);
|
||||
auto future = TenantMetadata::tenantNameIndex().getRange(tr, begin, end, limit);
|
||||
return fmap([](auto f) -> std::vector<std::pair<TenantName, int64_t>> { return f.results; }, future);
|
||||
}
|
||||
|
||||
template <class DB>
|
||||
Future<std::vector<std::pair<TenantName, int64_t>>> listTenantIds(Reference<DB> db,
|
||||
Future<std::vector<std::pair<TenantName, int64_t>>> listTenants(Reference<DB> db,
|
||||
TenantName begin,
|
||||
TenantName end,
|
||||
int limit) {
|
||||
return runTransaction(
|
||||
db, [=](Reference<typename DB::TransactionT> tr) {
|
||||
tr->setOption(FDBTransactionOptions::READ_SYSTEM_KEYS);
|
||||
tr->setOption(FDBTransactionOptions::LOCK_AWARE);
|
||||
return listTenantIdsTransaction(tr, begin, end, limit);
|
||||
return listTenantsTransaction(tr, begin, end, limit);
|
||||
});
|
||||
}
|
||||
|
||||
ACTOR template <class Transaction>
|
||||
Future<std::vector<std::pair<TenantName, TenantMapEntry>>> listTenantsTransaction(Transaction tr,
|
||||
Future<std::vector<std::pair<TenantName, TenantMapEntry>>> listTenantMetadataTransaction(Transaction tr,
|
||||
TenantName begin,
|
||||
TenantName end,
|
||||
int limit) {
|
||||
std::vector<std::pair<TenantName, int64_t>> matchingTenants = wait(listTenantIdsTransaction(tr, begin, end, limit));
|
||||
std::vector<std::pair<TenantName, int64_t>> matchingTenants = wait(listTenantsTransaction(tr, begin, end, limit));
|
||||
|
||||
state std::vector<Future<TenantMapEntry>> tenantEntryFutures;
|
||||
for (auto const& [name, id] : matchingTenants) {
|
||||
|
@ -519,14 +519,15 @@ Future<std::vector<std::pair<TenantName, TenantMapEntry>>> listTenantsTransactio
|
|||
}
|
||||
|
||||
template <class DB>
|
||||
Future<std::vector<std::pair<TenantName, TenantMapEntry>>> listTenants(Reference<DB> db,
|
||||
Future<std::vector<std::pair<TenantName, TenantMapEntry>>> listTenantMetadata(Reference<DB> db,
|
||||
TenantName begin,
|
||||
TenantName end,
|
||||
int limit) {
|
||||
return runTransaction(
|
||||
db, [=](Reference<typename DB::TransactionT> tr) {
|
||||
tr->setOption(FDBTransactionOptions::LOCK_AWARE);
|
||||
return listTenantsTransaction(tr, begin, end, limit);
|
||||
tr->setOption(FDBTransactionOptions::READ_SYSTEM_KEYS);
|
||||
return listTenantMetadataTransaction(tr, begin, end, limit);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ private:
|
|||
RangeResult* results,
|
||||
GetRangeLimits limitsHint) {
|
||||
std::vector<std::pair<TenantName, TenantMapEntry>> tenants =
|
||||
wait(TenantAPI::listTenantsTransaction(&ryw->getTransaction(), kr.begin, kr.end, limitsHint.rows));
|
||||
wait(TenantAPI::listTenantMetadataTransaction(&ryw->getTransaction(), kr.begin, kr.end, limitsHint.rows));
|
||||
|
||||
for (auto tenant : tenants) {
|
||||
std::string jsonString = tenant.second.toJson();
|
||||
|
@ -203,7 +203,7 @@ private:
|
|||
TenantName endTenant,
|
||||
std::map<TenantGroupName, int>* tenantGroupNetTenantDelta) {
|
||||
state std::vector<std::pair<TenantName, int64_t>> tenants = wait(
|
||||
TenantAPI::listTenantIdsTransaction(&ryw->getTransaction(), beginTenant, endTenant, CLIENT_KNOBS->TOO_MANY));
|
||||
TenantAPI::listTenantsTransaction(&ryw->getTransaction(), beginTenant, endTenant, CLIENT_KNOBS->TOO_MANY));
|
||||
|
||||
if (tenants.size() == CLIENT_KNOBS->TOO_MANY) {
|
||||
TraceEvent(SevWarn, "DeleteTenantRangeTooLange")
|
||||
|
|
|
@ -403,7 +403,7 @@ struct MetaclusterManagementWorkload : TestWorkload {
|
|||
state TenantMapEntry checkEntry2;
|
||||
wait(store(checkEntry2, MetaclusterAPI::getTenant(self->managementDb, tenant)) &&
|
||||
store(tenantList,
|
||||
MetaclusterAPI::listTenants(self->managementDb, ""_sr, "\xff\xff"_sr, 10e6, 0, filters)));
|
||||
MetaclusterAPI::listTenantMetadata(self->managementDb, ""_sr, "\xff\xff"_sr, 10e6, 0, filters)));
|
||||
bool found = false;
|
||||
for (auto pair : tenantList) {
|
||||
ASSERT(pair.second.tenantState == checkState);
|
||||
|
@ -863,7 +863,7 @@ struct MetaclusterManagementWorkload : TestWorkload {
|
|||
store(metaclusterRegistration,
|
||||
MetaclusterMetadata::metaclusterRegistration().get(clusterData.db.getReference())) &&
|
||||
store(tenants,
|
||||
TenantAPI::listTenantIdsTransaction(tr, ""_sr, "\xff\xff"_sr, clusterData.tenants.size() + 1)));
|
||||
TenantAPI::listTenantsTransaction(tr, ""_sr, "\xff\xff"_sr, clusterData.tenants.size() + 1)));
|
||||
break;
|
||||
} catch (Error& e) {
|
||||
wait(safeThreadFutureToFuture(tr->onError(e)));
|
||||
|
@ -893,7 +893,7 @@ struct MetaclusterManagementWorkload : TestWorkload {
|
|||
|
||||
if (deleteTenants) {
|
||||
state std::vector<std::pair<TenantName, int64_t>> tenants =
|
||||
wait(MetaclusterAPI::listTenantIds(self->managementDb, ""_sr, "\xff\xff"_sr, 10e6));
|
||||
wait(MetaclusterAPI::listTenants(self->managementDb, ""_sr, "\xff\xff"_sr, 10e6));
|
||||
|
||||
state std::vector<Future<Void>> deleteTenantFutures;
|
||||
for (auto [tenantName, tid] : tenants) {
|
||||
|
|
|
@ -1170,12 +1170,13 @@ struct TenantManagementWorkload : TestWorkload {
|
|||
TenantManagementWorkload::jsonToTenantMapEntry(result.value)));
|
||||
}
|
||||
} else if (operationType == OperationType::MANAGEMENT_DATABASE) {
|
||||
wait(store(tenants, TenantAPI::listTenants(self->dataDb.getReference(), beginTenant, endTenant, limit)));
|
||||
wait(store(tenants,
|
||||
TenantAPI::listTenantMetadata(self->dataDb.getReference(), beginTenant, endTenant, limit)));
|
||||
} else if (operationType == OperationType::MANAGEMENT_TRANSACTION) {
|
||||
tr->setOption(FDBTransactionOptions::READ_SYSTEM_KEYS);
|
||||
wait(store(tenants, TenantAPI::listTenantsTransaction(tr, beginTenant, endTenant, limit)));
|
||||
wait(store(tenants, TenantAPI::listTenantMetadataTransaction(tr, beginTenant, endTenant, limit)));
|
||||
} else {
|
||||
wait(store(tenants, MetaclusterAPI::listTenants(self->mvDb, beginTenant, endTenant, limit)));
|
||||
wait(store(tenants, MetaclusterAPI::listTenantMetadata(self->mvDb, beginTenant, endTenant, limit)));
|
||||
}
|
||||
|
||||
return tenants;
|
||||
|
@ -1765,7 +1766,7 @@ struct TenantManagementWorkload : TestWorkload {
|
|||
loop {
|
||||
// Read the tenant list from the data cluster.
|
||||
state std::vector<std::pair<TenantName, TenantMapEntry>> dataClusterTenants =
|
||||
wait(TenantAPI::listTenants(self->dataDb.getReference(), beginTenant, endTenant, 1000));
|
||||
wait(TenantAPI::listTenantMetadata(self->dataDb.getReference(), beginTenant, endTenant, 1000));
|
||||
|
||||
auto dataItr = dataClusterTenants.begin();
|
||||
|
||||
|
|
Loading…
Reference in New Issue