1
0
mirror of https://github.com/apple/foundationdb.git synced 2025-05-23 23:59:58 +08:00

Fix some merge issues

This commit is contained in:
A.J. Beamon 2022-07-07 11:55:31 -07:00
parent 1519f24f77
commit a32cc5218c
6 changed files with 13 additions and 33 deletions

@ -361,9 +361,7 @@ void fdb_cluster_destroy_v609(FDBCluster* c) {
// If it does and this is an external client loaded though the multi-version API, then it may inadvertently call // If it does and this is an external client loaded though the multi-version API, then it may inadvertently call
// the version of the function in the primary library if it was loaded into the global symbols. // the version of the function in the primary library if it was loaded into the global symbols.
fdb_error_t fdb_create_database_impl(const char* cluster_file_path, FDBDatabase** out_database) { fdb_error_t fdb_create_database_impl(const char* cluster_file_path, FDBDatabase** out_database) {
CATCH_AND_RETURN(*out_database = CATCH_AND_RETURN(*out_database = (FDBDatabase*)API->createDatabase(cluster_file_path).extractPtr(););
(FDBDatabase*)API->createDatabase(ClusterConnectionFile::openOrDefault(cluster_file_path))
.extractPtr(););
} }
FDBFuture* fdb_cluster_create_database_v609(FDBCluster* c, uint8_t const* db_name, int db_name_length) { FDBFuture* fdb_cluster_create_database_v609(FDBCluster* c, uint8_t const* db_name, int db_name_length) {

@ -1095,7 +1095,7 @@ ACTOR Future<int> cli(CLIOptions opt, LineNoise* plinenoise) {
if (!opt.exec.present()) { if (!opt.exec.present()) {
printf("Using cluster file `%s'.\n", ccf->getLocation().c_str()); printf("Using cluster file `%s'.\n", ccf->getLocation().c_str());
} }
db = API->createDatabase(ccf); db = API->createDatabase(resolvedClusterFile.first.c_str());
} catch (Error& e) { } catch (Error& e) {
fprintf(stderr, "ERROR: %s (%d)\n", e.what(), e.code()); fprintf(stderr, "ERROR: %s (%d)\n", e.what(), e.code());
printf("Unable to connect to cluster from `%s'\n", ccf->getLocation().c_str()); printf("Unable to connect to cluster from `%s'\n", ccf->getLocation().c_str());

@ -18,6 +18,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include "fdbclient/ClusterConnectionMemoryRecord.h"
#include "fdbclient/DatabaseContext.h" #include "fdbclient/DatabaseContext.h"
#include "fdbclient/FDBTypes.h" #include "fdbclient/FDBTypes.h"
#include "fdbclient/MetaclusterManagement.actor.h" #include "fdbclient/MetaclusterManagement.actor.h"
@ -27,14 +28,15 @@
namespace MetaclusterAPI { namespace MetaclusterAPI {
ACTOR Future<Reference<IDatabase>> openDatabase(ClusterConnectionString connectionString) { ACTOR Future<Reference<IDatabase>> openDatabase(ClusterConnectionString connectionString) {
Reference<IClusterConnectionRecord> clusterFile = makeReference<ClusterConnectionMemoryRecord>(connectionString);
if (g_network->isSimulated()) { if (g_network->isSimulated()) {
Reference<IClusterConnectionRecord> clusterFile =
makeReference<ClusterConnectionMemoryRecord>(connectionString);
Database nativeDb = Database::createDatabase(clusterFile, -1); Database nativeDb = Database::createDatabase(clusterFile, -1);
Reference<IDatabase> threadSafeDb = Reference<IDatabase> threadSafeDb =
wait(unsafeThreadFutureToFuture(ThreadSafeDatabase::createFromExistingDatabase(nativeDb))); wait(unsafeThreadFutureToFuture(ThreadSafeDatabase::createFromExistingDatabase(nativeDb)));
return MultiVersionDatabase::debugCreateFromExistingDatabase(threadSafeDb); return MultiVersionDatabase::debugCreateFromExistingDatabase(threadSafeDb);
} else { } else {
return MultiVersionApi::api->createDatabase(clusterFile); return MultiVersionApi::api->createDatabaseFromConnectionString(connectionString.toString().c_str());
} }
} }

@ -859,35 +859,13 @@ Reference<IDatabase> DLApi::createDatabase609(const char* clusterFilePath) {
return makeReference<DLDatabase>(api, dbFuture); return makeReference<DLDatabase>(api, dbFuture);
} }
Reference<IDatabase> DLApi::createDatabaseFromFile(std::string filename) { Reference<IDatabase> DLApi::createDatabase(const char* clusterFilePath) {
if (headerVersion >= 610) { if (headerVersion >= 610) {
FdbCApi::FDBDatabase* db; FdbCApi::FDBDatabase* db;
throwIfError(api->createDatabase(filename.c_str(), &db)); throwIfError(api->createDatabase(clusterFilePath, &db));
return Reference<IDatabase>(new DLDatabase(api, db)); return Reference<IDatabase>(new DLDatabase(api, db));
} else { } else {
return DLApi::createDatabase609(filename.c_str()); return DLApi::createDatabase609(clusterFilePath);
}
}
Reference<IDatabase> DLApi::createDatabaseFromConnectionString(std::string connectionString) {
if (api->createDatabaseFromConnectionString == nullptr) {
throw unsupported_operation();
}
FdbCApi::FDBDatabase* db;
throwIfError(api->createDatabaseFromConnectionString(connectionString.c_str(), &db));
return Reference<IDatabase>(new DLDatabase(api, db));
}
Reference<IDatabase> DLApi::createDatabase(Reference<IClusterConnectionRecord> connectionRecord) {
if (!connectionRecord->supportedExternally()) {
throw unsupported_operation();
}
Optional<std::string> filename = connectionRecord->getFilename();
if (filename.present()) {
return createDatabaseFromFile(filename.get());
} else {
return createDatabaseFromConnectionString(connectionRecord->getConnectionString().toString());
} }
} }

@ -20,6 +20,7 @@
#include <cstdint> #include <cstdint>
#include <limits> #include <limits>
#include "fdbclient/ClusterConnectionMemoryRecord.h"
#include "fdbclient/FDBOptions.g.h" #include "fdbclient/FDBOptions.g.h"
#include "fdbclient/GenericManagementAPI.actor.h" #include "fdbclient/GenericManagementAPI.actor.h"
#include "fdbclient/MetaclusterManagement.actor.h" #include "fdbclient/MetaclusterManagement.actor.h"

@ -20,6 +20,7 @@
#include <cstdint> #include <cstdint>
#include <limits> #include <limits>
#include "fdbclient/ClusterConnectionMemoryRecord.h"
#include "fdbclient/FDBOptions.g.h" #include "fdbclient/FDBOptions.g.h"
#include "fdbclient/GenericManagementAPI.actor.h" #include "fdbclient/GenericManagementAPI.actor.h"
#include "fdbclient/MetaclusterManagement.actor.h" #include "fdbclient/MetaclusterManagement.actor.h"
@ -1017,7 +1018,7 @@ struct TenantManagementWorkload : TestWorkload {
ASSERT(newTenantEntry.present()); ASSERT(newTenantEntry.present());
// Update Internal Tenant Map and check for correctness // Update Internal Tenant Map and check for correctness
TenantState tState = self->createdTenants[oldTenantName]; TenantData tState = self->createdTenants[oldTenantName];
self->createdTenants[newTenantName] = tState; self->createdTenants[newTenantName] = tState;
self->createdTenants.erase(oldTenantName); self->createdTenants.erase(oldTenantName);
if (!tState.empty) { if (!tState.empty) {
@ -1032,7 +1033,7 @@ struct TenantManagementWorkload : TestWorkload {
} }
} }
} }
wait(self->checkTenant(cx, self, newTenantName, self->createdTenants[newTenantName])); wait(self->checkTenantContents(self, newTenantName, self->createdTenants[newTenantName]));
} }
return Void(); return Void();
} catch (Error& e) { } catch (Error& e) {