diff --git a/Makefile b/Makefile index cf8fcb228c..f90e325995 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ ifeq ($(MCS),) MCS := /usr/bin/dmcs endif -CFLAGS := -Werror -Wno-error=format -fPIC -DNO_INTELLISENSE -fvisibility=hidden -DNDEBUG=1 -Wreturn-type +CFLAGS := -Werror -Wno-error=format -fPIC -DNO_INTELLISENSE -fvisibility=hidden -DNDEBUG=1 -Wreturn-type -fno-omit-frame-pointer ifeq ($(RELEASE),true) CFLAGS += -DFDB_CLEAN_BUILD endif diff --git a/bindings/bindingtester/__init__.py b/bindings/bindingtester/__init__.py index 9b164ee812..b780f71ad4 100644 --- a/bindings/bindingtester/__init__.py +++ b/bindings/bindingtester/__init__.py @@ -25,7 +25,7 @@ sys.path[:0]=[os.path.join(os.path.dirname(__file__), '..', '..', 'bindings', 'p import util -FDB_API_VERSION = 500 +FDB_API_VERSION = 510 LOGGING = { 'version' : 1, diff --git a/bindings/bindingtester/bindingtester.py b/bindings/bindingtester/bindingtester.py index 0a19832d60..867ffddd21 100755 --- a/bindings/bindingtester/bindingtester.py +++ b/bindings/bindingtester/bindingtester.py @@ -133,7 +133,7 @@ def choose_api_version(selected_api_version, tester_min_version, tester_max_vers elif random.random() < 0.7: api_version = min_version elif random.random() < 0.9: - api_version = random.choice([v for v in [13, 14, 16, 21, 22, 23, 100, 200, 300, 400, 410, 420, 430, 440, 450, 460, 500] if v >= min_version and v <= max_version]) + api_version = random.choice([v for v in [13, 14, 16, 21, 22, 23, 100, 200, 300, 400, 410, 420, 430, 440, 450, 460, 500, 510] if v >= min_version and v <= max_version]) else: api_version = random.randint(min_version, max_version) diff --git a/bindings/bindingtester/known_testers.py b/bindings/bindingtester/known_testers.py index a8d2c6b9a1..0b9d042885 100644 --- a/bindings/bindingtester/known_testers.py +++ b/bindings/bindingtester/known_testers.py @@ -20,7 +20,7 @@ import os -MAX_API_VERSION = 500 +MAX_API_VERSION = 510 class Tester: def __init__(self, name, cmd, max_int_bits=64, min_api_version=0, max_api_version=MAX_API_VERSION, threads_enabled=True): @@ -44,11 +44,11 @@ class Tester: def _absolute_path(path): return os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', path) -_java_cmd = 'java -ea -cp %s:%s com.apple.cie.foundationdb.test.' % ( +_java_cmd = 'java -ea -cp %s:%s com.apple.foundationdb.test.' % ( _absolute_path('java/foundationdb-client.jar'), _absolute_path('java/foundationdb-tests.jar')) -_java_completable_cmd = 'java -ea -cp %s:%s com.apple.cie.foundationdb.test.' % ( +_java_completable_cmd = 'java -ea -cp %s:%s com.apple.foundationdb.test.' % ( _absolute_path('java/foundationdb-client-completable.jar'), _absolute_path('java/foundationdb-tests-completable.jar')) diff --git a/bindings/bindingtester/tests/api.py b/bindings/bindingtester/tests/api.py index 703e50c458..561cad221f 100644 --- a/bindings/bindingtester/tests/api.py +++ b/bindings/bindingtester/tests/api.py @@ -164,7 +164,7 @@ class ApiTest(Test): op_choices += write_conflicts op_choices += resets - idempotent_atomic_ops = [u'BIT_AND', u'BIT_OR', u'MAX', u'MIN'] + idempotent_atomic_ops = [u'BIT_AND', u'BIT_OR', u'MAX', u'MIN', u'BYTE_MIN', u'BYTE_MAX'] atomic_ops = idempotent_atomic_ops + [u'ADD', u'BIT_XOR'] if args.concurrency > 1: diff --git a/bindings/bindingtester/tests/scripted.py b/bindings/bindingtester/tests/scripted.py index 4237613e42..6b9c755bdf 100644 --- a/bindings/bindingtester/tests/scripted.py +++ b/bindings/bindingtester/tests/scripted.py @@ -32,7 +32,7 @@ fdb.api_version(FDB_API_VERSION) # SOMEDAY: This should probably be broken up into smaller tests class ScriptedTest(Test): - TEST_API_VERSION = 500 + TEST_API_VERSION = 510 def __init__(self, subspace): super(ScriptedTest, self).__init__(subspace, ScriptedTest.TEST_API_VERSION, ScriptedTest.TEST_API_VERSION) diff --git a/bindings/c/fdb_c.cpp b/bindings/c/fdb_c.cpp index a9981003e8..47833ad21f 100644 --- a/bindings/c/fdb_c.cpp +++ b/bindings/c/fdb_c.cpp @@ -18,7 +18,7 @@ * limitations under the License. */ -#define FDB_API_VERSION 500 +#define FDB_API_VERSION 510 #include "fdbclient/MultiVersionTransaction.h" #include "foundationdb/fdb_c.h" @@ -70,7 +70,7 @@ fdb_bool_t fdb_error_predicate( int predicate_test, fdb_error_t code ) { } if(predicate_test == FDBErrorPredicates::RETRYABLE_NOT_COMMITTED) { return code == error_code_not_committed || - code == error_code_past_version || + code == error_code_transaction_too_old || code == error_code_future_version || code == error_code_database_locked; } @@ -124,6 +124,12 @@ fdb_error_t fdb_stop_network() { CATCH_AND_RETURN( API->stopNetwork(); ); } +extern "C" DLLEXPORT +fdb_error_t fdb_add_network_thread_completion_hook(void (*hook)(void*), void *hook_parameter) { + CATCH_AND_RETURN( API->addNetworkThreadCompletionHook(hook, hook_parameter); ); +} + + extern "C" DLLEXPORT FDBFuture* fdb_cluster_configure_database( FDBCluster* c, int config_type, int config_mode, uint8_t const* db_name, diff --git a/bindings/c/foundationdb/fdb_c.h b/bindings/c/foundationdb/fdb_c.h index 9a9a60578b..e8324318d0 100644 --- a/bindings/c/foundationdb/fdb_c.h +++ b/bindings/c/foundationdb/fdb_c.h @@ -28,10 +28,10 @@ #endif #if !defined(FDB_API_VERSION) -#error You must #define FDB_API_VERSION prior to including fdb_c.h (current version is 500) +#error You must #define FDB_API_VERSION prior to including fdb_c.h (current version is 510) #elif FDB_API_VERSION < 13 #error API version no longer supported (upgrade to 13) -#elif FDB_API_VERSION > 500 +#elif FDB_API_VERSION > 510 #error Requested API version requires a newer version of this header #endif @@ -89,6 +89,8 @@ extern "C" { DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_stop_network(); + DLLEXPORT WARN_UNUSED_RESULT fdb_error_t fdb_add_network_thread_completion_hook(void (*hook)(void*), void *hook_parameter); + #pragma pack(push, 4) typedef struct keyvalue { const void* key; diff --git a/bindings/c/test/performance_test.c b/bindings/c/test/performance_test.c index 5af01b0678..71eaf1c162 100644 --- a/bindings/c/test/performance_test.c +++ b/bindings/c/test/performance_test.c @@ -602,7 +602,7 @@ void runTests(struct ResultSet *rs) { int main(int argc, char **argv) { srand(time(NULL)); struct ResultSet *rs = newResultSet(); - checkError(fdb_select_api_version(500), "select API version", rs); + checkError(fdb_select_api_version(510), "select API version", rs); printf("Running performance test at client version: %s\n", fdb_get_client_version()); valueStr = (uint8_t*)malloc((sizeof(uint8_t))*valueSize); diff --git a/bindings/c/test/ryw_benchmark.c b/bindings/c/test/ryw_benchmark.c index 1a780bf1b3..fb4e7a9cad 100644 --- a/bindings/c/test/ryw_benchmark.c +++ b/bindings/c/test/ryw_benchmark.c @@ -243,7 +243,7 @@ void runTests(struct ResultSet *rs) { int main(int argc, char **argv) { srand(time(NULL)); struct ResultSet *rs = newResultSet(); - checkError(fdb_select_api_version(500), "select API version", rs); + checkError(fdb_select_api_version(510), "select API version", rs); printf("Running RYW Benchmark test at client version: %s\n", fdb_get_client_version()); keys = generateKeys(numKeys, keySize); diff --git a/bindings/c/test/test.h b/bindings/c/test/test.h index 9cb1d9f2ae..9e91e81337 100644 --- a/bindings/c/test/test.h +++ b/bindings/c/test/test.h @@ -27,7 +27,7 @@ #include #ifndef FDB_API_VERSION -#define FDB_API_VERSION 500 +#define FDB_API_VERSION 510 #endif #include diff --git a/bindings/flow/DirectoryLayer.actor.cpp b/bindings/flow/DirectoryLayer.actor.cpp old mode 100755 new mode 100644 index 085c3cb51a..242c46f812 --- a/bindings/flow/DirectoryLayer.actor.cpp +++ b/bindings/flow/DirectoryLayer.actor.cpp @@ -131,7 +131,7 @@ namespace FDB { } else { if(versionBytes.get().size() != 12) { - throw invalid_database_value(); + throw invalid_directory_layer_metadata(); } if(((uint32_t*)versionBytes.get().begin())[0] > DirectoryLayer::VERSION[0]) { throw incompatible_directory_version(); diff --git a/bindings/flow/HighContentionAllocator.actor.cpp b/bindings/flow/HighContentionAllocator.actor.cpp old mode 100755 new mode 100644 index e6981cfaa5..db6ba09b3b --- a/bindings/flow/HighContentionAllocator.actor.cpp +++ b/bindings/flow/HighContentionAllocator.actor.cpp @@ -51,7 +51,7 @@ namespace FDB { int64_t count = 0; if(countValue.present()) { if(countValue.get().size() != 8) { - throw invalid_database_value(); + throw invalid_directory_layer_metadata(); } count = *(int64_t*)countValue.get().begin(); } diff --git a/bindings/flow/fdb_flow.actor.cpp b/bindings/flow/fdb_flow.actor.cpp index 816c13fb72..9ed7b7bb16 100644 --- a/bindings/flow/fdb_flow.actor.cpp +++ b/bindings/flow/fdb_flow.actor.cpp @@ -33,7 +33,7 @@ THREAD_FUNC networkThread(void* fdb) { } ACTOR Future _test() { - API *fdb = FDB::API::selectAPIVersion(500); + API *fdb = FDB::API::selectAPIVersion(510); auto c = fdb->createCluster( std::string() ); auto db = c->createDatabase(); state Reference tr( new Transaction(db) ); @@ -77,7 +77,7 @@ ACTOR Future _test() { } void fdb_flow_test() { - API *fdb = FDB::API::selectAPIVersion(500); + API *fdb = FDB::API::selectAPIVersion(510); fdb->setupNetwork(); startThread(networkThread, fdb); diff --git a/bindings/flow/fdb_flow.h b/bindings/flow/fdb_flow.h index cc138878c2..2cc148c6e1 100644 --- a/bindings/flow/fdb_flow.h +++ b/bindings/flow/fdb_flow.h @@ -23,7 +23,7 @@ #include -#define FDB_API_VERSION 500 +#define FDB_API_VERSION 510 #include #undef DLLEXPORT diff --git a/bindings/flow/tester/Tester.actor.cpp b/bindings/flow/tester/Tester.actor.cpp index e659d3c44b..eb89079ad9 100644 --- a/bindings/flow/tester/Tester.actor.cpp +++ b/bindings/flow/tester/Tester.actor.cpp @@ -1506,10 +1506,37 @@ REGISTER_INSTRUCTION_FUNC(AtomicOPFunc); struct UnitTestsFunc : InstructionFunc { static const char* name; - static Future call(Reference const& data, Reference const& instruction) { + ACTOR static Future call(Reference data, Reference instruction) { ASSERT(data->api->evaluatePredicate(FDBErrorPredicate::FDB_ERROR_PREDICATE_RETRYABLE, Error(1020))); ASSERT(!data->api->evaluatePredicate(FDBErrorPredicate::FDB_ERROR_PREDICATE_RETRYABLE, Error(10))); + + state Reference tr(new Transaction(data->db)); + tr->setOption(FDBTransactionOption::FDB_TR_OPTION_PRIORITY_SYSTEM_IMMEDIATE); + tr->setOption(FDBTransactionOption::FDB_TR_OPTION_PRIORITY_SYSTEM_IMMEDIATE); + tr->setOption(FDBTransactionOption::FDB_TR_OPTION_PRIORITY_BATCH); + tr->setOption(FDBTransactionOption::FDB_TR_OPTION_CAUSAL_READ_RISKY); + tr->setOption(FDBTransactionOption::FDB_TR_OPTION_CAUSAL_WRITE_RISKY); + tr->setOption(FDBTransactionOption::FDB_TR_OPTION_READ_YOUR_WRITES_DISABLE); + tr->setOption(FDBTransactionOption::FDB_TR_OPTION_READ_AHEAD_DISABLE); + tr->setOption(FDBTransactionOption::FDB_TR_OPTION_READ_SYSTEM_KEYS); + tr->setOption(FDBTransactionOption::FDB_TR_OPTION_ACCESS_SYSTEM_KEYS); + tr->setOption(FDBTransactionOption::FDB_TR_OPTION_DURABILITY_DEV_NULL_IS_WEB_SCALE); + const uint64_t timeout = 60*1000; + tr->setOption(FDBTransactionOption::FDB_TR_OPTION_TIMEOUT, Optional(StringRef((const uint8_t*)&timeout, 8))); + const uint64_t retryLimit = 50; + tr->setOption(FDBTransactionOption::FDB_TR_OPTION_RETRY_LIMIT, Optional(StringRef((const uint8_t*)&retryLimit, 8))); + const uint64_t maxRetryDelay = 100; + tr->setOption(FDBTransactionOption::FDB_TR_OPTION_MAX_RETRY_DELAY, Optional(StringRef((const uint8_t*)&maxRetryDelay, 8))); + tr->setOption(FDBTransactionOption::FDB_TR_OPTION_USED_DURING_COMMIT_PROTECTION_DISABLE); + tr->setOption(FDBTransactionOption::FDB_TR_OPTION_TRANSACTION_LOGGING_ENABLE, Optional(LiteralStringRef("my_transaction"))); + tr->setOption(FDBTransactionOption::FDB_TR_OPTION_READ_LOCK_AWARE); + tr->setOption(FDBTransactionOption::FDB_TR_OPTION_LOCK_AWARE); + + Optional > _ = wait(tr->get(LiteralStringRef("\xff"))); + tr->cancel(); + return Void(); + } }; const char* UnitTestsFunc::name = "UNIT_TESTS"; @@ -1585,7 +1612,7 @@ ACTOR static Future doInstructions(Reference data) { } catch (Error& e) { if(LOG_ERRORS) { - printf("Error: %s (%d)\n", e.what(), e.code()); + printf("Error: %s (%d)\n", e.name(), e.code()); fflush(stdout); } @@ -1631,6 +1658,8 @@ void populateAtomicOpMap() { optionInfo["MIN"] = FDBMutationType::FDB_MUTATION_TYPE_MIN; optionInfo["SET_VERSIONSTAMPED_KEY"] = FDBMutationType::FDB_MUTATION_TYPE_SET_VERSIONSTAMPED_KEY; optionInfo["SET_VERSIONSTAMPED_VALUE"] = FDBMutationType::FDB_MUTATION_TYPE_SET_VERSIONSTAMPED_VALUE; + optionInfo["BYTE_MIN"] = FDBMutationType::FDB_MUTATION_TYPE_BYTE_MIN; + optionInfo["BYTE_MAX"] = FDBMutationType::FDB_MUTATION_TYPE_BYTE_MAX; } void populateOpsThatCreateDirectories() { @@ -1673,7 +1702,7 @@ ACTOR void startTest(std::string clusterFilename, StringRef prefix, int apiVersi catch(Error &e) { TraceEvent("ErrorRunningTest").error(e); if(LOG_ERRORS) { - printf("Flow tester encountered error: %s\n", e.what()); + printf("Flow tester encountered error: %s\n", e.name()); fflush(stdout); } flushAndExit(1); @@ -1685,7 +1714,7 @@ ACTOR void _test_versionstamp() { try { g_network = newNet2(NetworkAddress(), false); - API *fdb = FDB::API::selectAPIVersion(500); + API *fdb = FDB::API::selectAPIVersion(510); fdb->setupNetwork(); startThread(networkThread, fdb); @@ -1715,7 +1744,7 @@ ACTOR void _test_versionstamp() { catch (Error &e) { TraceEvent("ErrorRunningTest").error(e); if (LOG_ERRORS) { - printf("Flow tester encountered error: %s\n", e.what()); + printf("Flow tester encountered error: %s\n", e.name()); fflush(stdout); } flushAndExit(1); @@ -1756,7 +1785,7 @@ int main( int argc, char** argv ) { flushAndExit(FDB_EXIT_SUCCESS); } catch (Error& e) { - fprintf(stderr, "Error: %s\n", e.what()); + fprintf(stderr, "Error: %s\n", e.name()); TraceEvent(SevError, "MainError").error(e); flushAndExit(FDB_EXIT_MAIN_ERROR); } diff --git a/bindings/go/README.md b/bindings/go/README.md index 13e8f07940..d06a5dc656 100644 --- a/bindings/go/README.md +++ b/bindings/go/README.md @@ -8,7 +8,7 @@ This package requires: - Go 1.1+ with CGO enabled - FoundationDB C API 2.0.x, 3.0.x, or 4.x.y (part of the [FoundationDB clients package](https://files.foundationdb.org/fdb-c/)) -Use of this package requires the selection of a FoundationDB API version at runtime. This package currently supports FoundationDB API versions 200-500. +Use of this package requires the selection of a FoundationDB API version at runtime. This package currently supports FoundationDB API versions 200-510. To build this package, in the top level of this repository run: diff --git a/bindings/go/src/_stacktester/stacktester.go b/bindings/go/src/_stacktester/stacktester.go index 615e851f86..999269656e 100644 --- a/bindings/go/src/_stacktester/stacktester.go +++ b/bindings/go/src/_stacktester/stacktester.go @@ -745,6 +745,8 @@ func (sm *StackMachine) processInst(idx int, inst tuple.Tuple) { tr.Options().SetMaxRetryDelay(100) tr.Options().SetUsedDuringCommitProtectionDisable() tr.Options().SetTransactionLoggingEnable("my_transaction") + tr.Options().SetReadLockAware() + tr.Options().SetLockAware() return tr.Get(fdb.Key("\xff")).MustGet(), nil }) diff --git a/bindings/go/src/fdb/cluster.go b/bindings/go/src/fdb/cluster.go index 908021c7f7..a62d2026b7 100644 --- a/bindings/go/src/fdb/cluster.go +++ b/bindings/go/src/fdb/cluster.go @@ -23,7 +23,7 @@ package fdb /* - #define FDB_API_VERSION 500 + #define FDB_API_VERSION 510 #include */ import "C" diff --git a/bindings/go/src/fdb/database.go b/bindings/go/src/fdb/database.go index af72e41211..8b5ee7635b 100644 --- a/bindings/go/src/fdb/database.go +++ b/bindings/go/src/fdb/database.go @@ -23,7 +23,7 @@ package fdb /* - #define FDB_API_VERSION 500 + #define FDB_API_VERSION 510 #include */ import "C" diff --git a/bindings/go/src/fdb/errors.go b/bindings/go/src/fdb/errors.go index b8df4793d7..37eba3a22c 100644 --- a/bindings/go/src/fdb/errors.go +++ b/bindings/go/src/fdb/errors.go @@ -23,7 +23,7 @@ package fdb /* - #define FDB_API_VERSION 500 + #define FDB_API_VERSION 510 #include */ import "C" diff --git a/bindings/go/src/fdb/fdb.go b/bindings/go/src/fdb/fdb.go index 0fd4407160..d3c9acbaa7 100644 --- a/bindings/go/src/fdb/fdb.go +++ b/bindings/go/src/fdb/fdb.go @@ -23,7 +23,7 @@ package fdb /* - #define FDB_API_VERSION 500 + #define FDB_API_VERSION 510 #include #include */ @@ -109,7 +109,7 @@ func (opt NetworkOptions) setOpt(code int, param []byte) error { // library, an error will be returned. APIVersion must be called prior to any // other functions in the fdb package. // -// Currently, this package supports API versions 200 through 500. +// Currently, this package supports API versions 200 through 510. // // Warning: When using the multi-version client API, setting an API version that // is not supported by a particular client library will prevent that client from @@ -117,7 +117,7 @@ func (opt NetworkOptions) setOpt(code int, param []byte) error { // the API version of your application after upgrading your client until the // cluster has also been upgraded. func APIVersion(version int) error { - headerVersion := 500 + headerVersion := 510 networkMutex.Lock() defer networkMutex.Unlock() @@ -129,7 +129,7 @@ func APIVersion(version int) error { return errAPIVersionAlreadySet } - if version < 200 || version > 500 { + if version < 200 || version > 510 { return errAPIVersionNotSupported } diff --git a/bindings/go/src/fdb/futures.go b/bindings/go/src/fdb/futures.go index 25ac0421ef..e23e2dce97 100644 --- a/bindings/go/src/fdb/futures.go +++ b/bindings/go/src/fdb/futures.go @@ -24,7 +24,7 @@ package fdb /* #cgo LDFLAGS: -lfdb_c -lm - #define FDB_API_VERSION 500 + #define FDB_API_VERSION 510 #include #include diff --git a/bindings/go/src/fdb/range.go b/bindings/go/src/fdb/range.go index db9ecfd5ae..d23af20bd5 100644 --- a/bindings/go/src/fdb/range.go +++ b/bindings/go/src/fdb/range.go @@ -23,7 +23,7 @@ package fdb /* - #define FDB_API_VERSION 500 + #define FDB_API_VERSION 510 #include */ import "C" diff --git a/bindings/go/src/fdb/transaction.go b/bindings/go/src/fdb/transaction.go index 9749a68a03..7714e12cda 100644 --- a/bindings/go/src/fdb/transaction.go +++ b/bindings/go/src/fdb/transaction.go @@ -23,7 +23,7 @@ package fdb /* - #define FDB_API_VERSION 500 + #define FDB_API_VERSION 510 #include */ import "C" diff --git a/bindings/java/fdbJNI.cpp b/bindings/java/fdbJNI.cpp index 056882e7dc..af3ad876f5 100644 --- a/bindings/java/fdbJNI.cpp +++ b/bindings/java/fdbJNI.cpp @@ -21,7 +21,7 @@ #include #include -#define FDB_API_VERSION 500 +#define FDB_API_VERSION 510 #include @@ -38,8 +38,18 @@ #error Missing thread local storage #endif +static JavaVM* g_jvm = 0; static thread_local JNIEnv* g_thread_jenv = 0; // Defined for the network thread once it is running, and for any thread that has called registerCallback static thread_local jmethodID g_IFutureCallback_call_methodID = 0; +static thread_local bool is_external = false; + +void detachIfExternalThread(void *ignore) { + if(is_external && g_thread_jenv != 0) { + g_thread_jenv = 0; + g_IFutureCallback_call_methodID = 0; + g_jvm->DetachCurrentThread(); + } +} void throwOutOfMem(JNIEnv *jenv) { const char *className = "java/lang/OutOfMemoryError"; @@ -59,7 +69,7 @@ void throwOutOfMem(JNIEnv *jenv) { } static jthrowable getThrowable(JNIEnv *jenv, fdb_error_t e, const char* msg = NULL) { - jclass excepClass = jenv->FindClass("com/apple/cie/foundationdb/FDBException"); + jclass excepClass = jenv->FindClass("com/apple/foundationdb/FDBException"); if(jenv->ExceptionOccurred()) return JNI_NULL; @@ -103,12 +113,6 @@ void throwParamNotNull(JNIEnv *jenv) { extern "C" { #endif -static void callCallback( FDBFuture* f, void* data ) { - jobject callback = (jobject)data; - g_thread_jenv->CallVoidMethod( callback, g_IFutureCallback_call_methodID ); - g_thread_jenv->DeleteGlobalRef(callback); -} - // If the methods are not found, exceptions are thrown and this will return false. // Returns TRUE on success, false otherwise. static bool findCallbackMethods(JNIEnv *jenv) { @@ -123,6 +127,27 @@ static bool findCallbackMethods(JNIEnv *jenv) { return true; } +static void callCallback( FDBFuture* f, void* data ) { + if (g_thread_jenv == 0) { + // We are on an external thread and must attach to the JVM. + // The shutdown hook will later detach this thread. + is_external = true; + if( g_jvm != 0 && g_jvm->AttachCurrentThreadAsDaemon((void **) &g_thread_jenv, JNI_NULL) == JNI_OK ) { + if( !findCallbackMethods( g_thread_jenv ) ) { + g_thread_jenv->FatalError("FDB: Could not find callback method.\n"); + } + } else { + // Can't call FatalError, because we don't have a pointer to the jenv... + // There will be a segmentation fault from the attempt to call the callback method. + fprintf(stderr, "FDB: Could not attach external client thread to the JVM as daemon.\n"); + } + } + + jobject callback = (jobject)data; + g_thread_jenv->CallVoidMethod( callback, g_IFutureCallback_call_methodID ); + g_thread_jenv->DeleteGlobalRef(callback); +} + // Attempts to throw 't', attempts to shut down the JVM if this fails. void safeThrow( JNIEnv *jenv, jthrowable t ) { if( jenv->Throw( t ) != 0 ) { @@ -130,7 +155,7 @@ void safeThrow( JNIEnv *jenv, jthrowable t ) { } } -JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_NativeFuture_Future_1registerCallback(JNIEnv *jenv, jobject cls, jlong future, jobject callback) { +JNIEXPORT void JNICALL Java_com_apple_foundationdb_NativeFuture_Future_1registerCallback(JNIEnv *jenv, jobject cls, jlong future, jobject callback) { // SOMEDAY: Do this on module load instead. Can we cache method ids across threads? if( !g_IFutureCallback_call_methodID ) { if( !findCallbackMethods( jenv ) ) { @@ -163,7 +188,7 @@ JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_NativeFuture_Future_1regi } } -JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_NativeFuture_Future_1blockUntilReady(JNIEnv *jenv, jobject, jlong future) { +JNIEXPORT void JNICALL Java_com_apple_foundationdb_NativeFuture_Future_1blockUntilReady(JNIEnv *jenv, jobject, jlong future) { if( !future ) { throwParamNotNull(jenv); return; @@ -175,7 +200,7 @@ JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_NativeFuture_Future_1bloc safeThrow( jenv, getThrowable( jenv, err ) ); } -JNIEXPORT jthrowable JNICALL Java_com_apple_cie_foundationdb_NativeFuture_Future_1getError(JNIEnv *jenv, jobject, jlong future) { +JNIEXPORT jthrowable JNICALL Java_com_apple_foundationdb_NativeFuture_Future_1getError(JNIEnv *jenv, jobject, jlong future) { if( !future ) { throwParamNotNull(jenv); return JNI_NULL; @@ -184,7 +209,7 @@ JNIEXPORT jthrowable JNICALL Java_com_apple_cie_foundationdb_NativeFuture_Future return getThrowable( jenv, fdb_future_get_error( sav ) ); } -JNIEXPORT jboolean JNICALL Java_com_apple_cie_foundationdb_NativeFuture_Future_1isReady(JNIEnv *jenv, jobject, jlong future) { +JNIEXPORT jboolean JNICALL Java_com_apple_foundationdb_NativeFuture_Future_1isReady(JNIEnv *jenv, jobject, jlong future) { if( !future ) { throwParamNotNull(jenv); return JNI_FALSE; @@ -193,7 +218,7 @@ JNIEXPORT jboolean JNICALL Java_com_apple_cie_foundationdb_NativeFuture_Future_1 return (jboolean)fdb_future_is_ready(var); } -JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_NativeFuture_Future_1dispose(JNIEnv *jenv, jobject, jlong future) { +JNIEXPORT void JNICALL Java_com_apple_foundationdb_NativeFuture_Future_1dispose(JNIEnv *jenv, jobject, jlong future) { if( !future ) { throwParamNotNull(jenv); return; @@ -202,7 +227,7 @@ JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_NativeFuture_Future_1disp fdb_future_destroy(var); } -JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_NativeFuture_Future_1cancel(JNIEnv *jenv, jobject, jlong future) { +JNIEXPORT void JNICALL Java_com_apple_foundationdb_NativeFuture_Future_1cancel(JNIEnv *jenv, jobject, jlong future) { if( !future ) { throwParamNotNull(jenv); return; @@ -211,7 +236,7 @@ JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_NativeFuture_Future_1canc fdb_future_cancel(var); } -JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_NativeFuture_Future_1releaseMemory(JNIEnv *jenv, jobject, jlong future) { +JNIEXPORT void JNICALL Java_com_apple_foundationdb_NativeFuture_Future_1releaseMemory(JNIEnv *jenv, jobject, jlong future) { if( !future ) { throwParamNotNull(jenv); return; @@ -220,7 +245,7 @@ JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_NativeFuture_Future_1rele fdb_future_release_memory(var); } -JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FutureVersion_FutureVersion_1get(JNIEnv *jenv, jobject, jlong future) { +JNIEXPORT jlong JNICALL Java_com_apple_foundationdb_FutureVersion_FutureVersion_1get(JNIEnv *jenv, jobject, jlong future) { if( !future ) { throwParamNotNull(jenv); return 0; @@ -237,7 +262,7 @@ JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FutureVersion_FutureVers return (jlong)version; } -JNIEXPORT jobject JNICALL Java_com_apple_cie_foundationdb_FutureStrings_FutureStrings_1get(JNIEnv *jenv, jobject, jlong future) { +JNIEXPORT jobject JNICALL Java_com_apple_foundationdb_FutureStrings_FutureStrings_1get(JNIEnv *jenv, jobject, jlong future) { if( !future ) { throwParamNotNull(jenv); return JNI_NULL; @@ -278,13 +303,13 @@ JNIEXPORT jobject JNICALL Java_com_apple_cie_foundationdb_FutureStrings_FutureSt return arr; } -JNIEXPORT jobject JNICALL Java_com_apple_cie_foundationdb_FutureResults_FutureResults_1getSummary(JNIEnv *jenv, jobject, jlong future) { +JNIEXPORT jobject JNICALL Java_com_apple_foundationdb_FutureResults_FutureResults_1getSummary(JNIEnv *jenv, jobject, jlong future) { if( !future ) { throwParamNotNull(jenv); return JNI_NULL; } - jclass resultCls = jenv->FindClass("com/apple/cie/foundationdb/RangeResultSummary"); + jclass resultCls = jenv->FindClass("com/apple/foundationdb/RangeResultSummary"); if( jenv->ExceptionOccurred() ) return JNI_NULL; jmethodID resultCtorId = jenv->GetMethodID(resultCls, "", "([BIZ)V"); @@ -322,13 +347,13 @@ JNIEXPORT jobject JNICALL Java_com_apple_cie_foundationdb_FutureResults_FutureRe } // SOMEDAY: explore doing this more efficiently with Direct ByteBuffers -JNIEXPORT jobject JNICALL Java_com_apple_cie_foundationdb_FutureResults_FutureResults_1get(JNIEnv *jenv, jobject, jlong future) { +JNIEXPORT jobject JNICALL Java_com_apple_foundationdb_FutureResults_FutureResults_1get(JNIEnv *jenv, jobject, jlong future) { if( !future ) { throwParamNotNull(jenv); return JNI_NULL; } - jclass resultCls = jenv->FindClass("com/apple/cie/foundationdb/RangeResult"); + jclass resultCls = jenv->FindClass("com/apple/foundationdb/RangeResult"); jmethodID resultCtorId = jenv->GetMethodID(resultCls, "", "([B[IZ)V"); FDBFuture *f = (FDBFuture *)future; @@ -353,10 +378,18 @@ JNIEXPORT jobject JNICALL Java_com_apple_cie_foundationdb_FutureResults_FutureRe throwOutOfMem(jenv); return JNI_NULL; } + uint8_t *keyvalues_barr = (uint8_t *)jenv->GetByteArrayElements(keyValueArray, NULL); + if (!keyvalues_barr) { + throwRuntimeEx( jenv, "Error getting handle to native resources" ); + return JNI_NULL; + } + jintArray lengthArray = jenv->NewIntArray(count * 2); if( !lengthArray ) { if( !jenv->ExceptionOccurred() ) throwOutOfMem(jenv); + + jenv->ReleaseByteArrayElements(keyValueArray, (jbyte *)keyvalues_barr, 0); return JNI_NULL; } @@ -364,20 +397,23 @@ JNIEXPORT jobject JNICALL Java_com_apple_cie_foundationdb_FutureResults_FutureRe if( !length_barr ) { if( !jenv->ExceptionOccurred() ) throwOutOfMem(jenv); + + jenv->ReleaseByteArrayElements(keyValueArray, (jbyte *)keyvalues_barr, 0); return JNI_NULL; } int offset = 0; for(int i = 0; i < count; i++) { - jenv->SetByteArrayRegion(keyValueArray, offset, kvs[i].key_length, (jbyte *)kvs[i].key); + memcpy(keyvalues_barr + offset, kvs[i].key, kvs[i].key_length); length_barr[ i * 2 ] = kvs[i].key_length; offset += kvs[i].key_length; - jenv->SetByteArrayRegion(keyValueArray, offset, kvs[i].value_length, (jbyte *)kvs[i].value); + memcpy(keyvalues_barr + offset, kvs[i].value, kvs[i].value_length); length_barr[ (i * 2) + 1 ] = kvs[i].value_length; offset += kvs[i].value_length; } + jenv->ReleaseByteArrayElements(keyValueArray, (jbyte *)keyvalues_barr, 0); jenv->ReleaseIntArrayElements(lengthArray, length_barr, 0); jobject result = jenv->NewObject(resultCls, resultCtorId, keyValueArray, lengthArray, (jboolean)more); @@ -388,7 +424,7 @@ JNIEXPORT jobject JNICALL Java_com_apple_cie_foundationdb_FutureResults_FutureRe } // SOMEDAY: explore doing this more efficiently with Direct ByteBuffers -JNIEXPORT jbyteArray JNICALL Java_com_apple_cie_foundationdb_FutureResult_FutureResult_1get(JNIEnv *jenv, jobject, jlong future) { +JNIEXPORT jbyteArray JNICALL Java_com_apple_foundationdb_FutureResult_FutureResult_1get(JNIEnv *jenv, jobject, jlong future) { if( !future ) { throwParamNotNull(jenv); return JNI_NULL; @@ -418,7 +454,7 @@ JNIEXPORT jbyteArray JNICALL Java_com_apple_cie_foundationdb_FutureResult_Future return result; } -JNIEXPORT jbyteArray JNICALL Java_com_apple_cie_foundationdb_FutureKey_FutureKey_1get(JNIEnv * jenv, jclass, jlong future) { +JNIEXPORT jbyteArray JNICALL Java_com_apple_foundationdb_FutureKey_FutureKey_1get(JNIEnv * jenv, jclass, jlong future) { if( !future ) { throwParamNotNull(jenv); return JNI_NULL; @@ -444,7 +480,7 @@ JNIEXPORT jbyteArray JNICALL Java_com_apple_cie_foundationdb_FutureKey_FutureKey return result; } -JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FutureCluster_FutureCluster_1get(JNIEnv *jenv, jobject, jlong future) { +JNIEXPORT jlong JNICALL Java_com_apple_foundationdb_FutureCluster_FutureCluster_1get(JNIEnv *jenv, jobject, jlong future) { if( !future ) { throwParamNotNull(jenv); return 0; @@ -460,7 +496,7 @@ JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FutureCluster_FutureClus return (jlong)cluster; } -JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FutureDatabase_FutureDatabase_1get(JNIEnv *jenv, jobject, jlong future) { +JNIEXPORT jlong JNICALL Java_com_apple_foundationdb_FutureDatabase_FutureDatabase_1get(JNIEnv *jenv, jobject, jlong future) { if( !future ) { throwParamNotNull(jenv); return 0; @@ -476,7 +512,7 @@ JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FutureDatabase_FutureDat return (jlong)database; } -JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FDBDatabase_Database_1createTransaction(JNIEnv *jenv, jobject, jlong dbPtr) { +JNIEXPORT jlong JNICALL Java_com_apple_foundationdb_FDBDatabase_Database_1createTransaction(JNIEnv *jenv, jobject, jlong dbPtr) { if( !dbPtr ) { throwParamNotNull(jenv); return 0; @@ -491,7 +527,7 @@ JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FDBDatabase_Database_1cr return (jlong)tr; } -JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDBDatabase_Database_1dispose(JNIEnv *jenv, jobject, jlong dPtr) { +JNIEXPORT void JNICALL Java_com_apple_foundationdb_FDBDatabase_Database_1dispose(JNIEnv *jenv, jobject, jlong dPtr) { if( !dPtr ) { throwParamNotNull(jenv); return; @@ -499,7 +535,7 @@ JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDBDatabase_Database_1dis fdb_database_destroy( (FDBDatabase *)dPtr ); } -JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDBDatabase_Database_1setOption(JNIEnv *jenv, jobject, jlong dPtr, jint code, jbyteArray value) { +JNIEXPORT void JNICALL Java_com_apple_foundationdb_FDBDatabase_Database_1setOption(JNIEnv *jenv, jobject, jlong dPtr, jint code, jbyteArray value) { if( !dPtr ) { throwParamNotNull(jenv); return; @@ -524,11 +560,11 @@ JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDBDatabase_Database_1set } } -JNIEXPORT jboolean JNICALL Java_com_apple_cie_foundationdb_FDB_Error_1predicate(JNIEnv *jenv, jobject, jint predicate, jint code) { +JNIEXPORT jboolean JNICALL Java_com_apple_foundationdb_FDB_Error_1predicate(JNIEnv *jenv, jobject, jint predicate, jint code) { return (jboolean)fdb_error_predicate(predicate, code); } -JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FDB_Cluster_1create(JNIEnv *jenv, jobject, jstring clusterFileName) { +JNIEXPORT jlong JNICALL Java_com_apple_foundationdb_FDB_Cluster_1create(JNIEnv *jenv, jobject, jstring clusterFileName) { const char* fileName = 0; if(clusterFileName != 0) { fileName = jenv->GetStringUTFChars(clusterFileName, 0); @@ -541,7 +577,7 @@ JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FDB_Cluster_1create(JNIE return (jlong)cluster; } -JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_Cluster_Cluster_1setOption(JNIEnv *jenv, jobject, jlong cPtr, jint code, jbyteArray value) { +JNIEXPORT void JNICALL Java_com_apple_foundationdb_Cluster_Cluster_1setOption(JNIEnv *jenv, jobject, jlong cPtr, jint code, jbyteArray value) { if( !cPtr ) { throwParamNotNull(jenv); return; @@ -566,7 +602,7 @@ JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_Cluster_Cluster_1setOptio } } -JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_Cluster_Cluster_1dispose(JNIEnv *jenv, jobject, jlong cPtr) { +JNIEXPORT void JNICALL Java_com_apple_foundationdb_Cluster_Cluster_1dispose(JNIEnv *jenv, jobject, jlong cPtr) { if( !cPtr ) { throwParamNotNull(jenv); return; @@ -574,7 +610,7 @@ JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_Cluster_Cluster_1dispose( fdb_cluster_destroy( (FDBCluster *)cPtr ); } -JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_Cluster_Cluster_1createDatabase(JNIEnv *jenv, jobject, jlong cPtr, jbyteArray dbNameBytes) { +JNIEXPORT jlong JNICALL Java_com_apple_foundationdb_Cluster_Cluster_1createDatabase(JNIEnv *jenv, jobject, jlong cPtr, jbyteArray dbNameBytes) { if( !cPtr || !dbNameBytes ) { throwParamNotNull(jenv); return 0; @@ -593,7 +629,7 @@ JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_Cluster_Cluster_1createD return (jlong)f; } -JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transaction_1setVersion(JNIEnv *jenv, jobject, jlong tPtr, jlong version) { +JNIEXPORT void JNICALL Java_com_apple_foundationdb_FDBTransaction_Transaction_1setVersion(JNIEnv *jenv, jobject, jlong tPtr, jlong version) { if( !tPtr ) { throwParamNotNull(jenv); return; @@ -602,7 +638,7 @@ JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transactio fdb_transaction_set_read_version( tr, version ); } -JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transaction_1getReadVersion(JNIEnv *jenv, jobject, jlong tPtr) { +JNIEXPORT jlong JNICALL Java_com_apple_foundationdb_FDBTransaction_Transaction_1getReadVersion(JNIEnv *jenv, jobject, jlong tPtr) { if( !tPtr ) { throwParamNotNull(jenv); return 0; @@ -612,7 +648,7 @@ JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transacti return (jlong)f; } -JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transaction_1get(JNIEnv *jenv, jobject, jlong tPtr, jbyteArray keyBytes, jboolean snapshot) { +JNIEXPORT jlong JNICALL Java_com_apple_foundationdb_FDBTransaction_Transaction_1get(JNIEnv *jenv, jobject, jlong tPtr, jbyteArray keyBytes, jboolean snapshot) { if( !tPtr || !keyBytes ) { throwParamNotNull(jenv); return 0; @@ -631,7 +667,7 @@ JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transacti return (jlong)f; } -JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transaction_1getKey(JNIEnv *jenv, jobject, jlong tPtr, +JNIEXPORT jlong JNICALL Java_com_apple_foundationdb_FDBTransaction_Transaction_1getKey(JNIEnv *jenv, jobject, jlong tPtr, jbyteArray keyBytes, jboolean orEqual, jint offset, jboolean snapshot) { if( !tPtr || !keyBytes ) { throwParamNotNull(jenv); @@ -651,7 +687,7 @@ JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transacti return (jlong)f; } -JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transaction_1getRange +JNIEXPORT jlong JNICALL Java_com_apple_foundationdb_FDBTransaction_Transaction_1getRange (JNIEnv *jenv, jobject, jlong tPtr, jbyteArray keyBeginBytes, jboolean orEqualBegin, jint offsetBegin, jbyteArray keyEndBytes, jboolean orEqualEnd, jint offsetEnd, jint rowLimit, jint targetBytes, jint streamingMode, jint iteration, jboolean snapshot, jboolean reverse) { @@ -685,7 +721,7 @@ JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transacti return (jlong)f; } -JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transaction_1set(JNIEnv *jenv, jobject, jlong tPtr, jbyteArray keyBytes, jbyteArray valueBytes) { +JNIEXPORT void JNICALL Java_com_apple_foundationdb_FDBTransaction_Transaction_1set(JNIEnv *jenv, jobject, jlong tPtr, jbyteArray keyBytes, jbyteArray valueBytes) { if( !tPtr || !keyBytes || !valueBytes ) { throwParamNotNull(jenv); return; @@ -714,7 +750,7 @@ JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transactio jenv->ReleaseByteArrayElements( valueBytes, (jbyte *)barrValue, JNI_ABORT ); } -JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transaction_1clear__J_3B(JNIEnv *jenv, jobject, jlong tPtr, jbyteArray keyBytes) { +JNIEXPORT void JNICALL Java_com_apple_foundationdb_FDBTransaction_Transaction_1clear__J_3B(JNIEnv *jenv, jobject, jlong tPtr, jbyteArray keyBytes) { if( !tPtr || !keyBytes ) { throwParamNotNull(jenv); return; @@ -732,7 +768,7 @@ JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transactio jenv->ReleaseByteArrayElements( keyBytes, (jbyte *)barr, JNI_ABORT ); } -JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transaction_1clear__J_3B_3B(JNIEnv *jenv, jobject, jlong tPtr, jbyteArray keyBeginBytes, jbyteArray keyEndBytes) { +JNIEXPORT void JNICALL Java_com_apple_foundationdb_FDBTransaction_Transaction_1clear__J_3B_3B(JNIEnv *jenv, jobject, jlong tPtr, jbyteArray keyBeginBytes, jbyteArray keyEndBytes) { if( !tPtr || !keyBeginBytes || !keyEndBytes ) { throwParamNotNull(jenv); return; @@ -761,7 +797,7 @@ JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transactio jenv->ReleaseByteArrayElements( keyEndBytes, (jbyte *)barrKeyEnd, JNI_ABORT ); } -JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transaction_1mutate(JNIEnv *jenv, jobject, jlong tPtr, jint code, +JNIEXPORT void JNICALL Java_com_apple_foundationdb_FDBTransaction_Transaction_1mutate(JNIEnv *jenv, jobject, jlong tPtr, jint code, jbyteArray key, jbyteArray value ) { if( !tPtr || !key || !value ) { throwParamNotNull(jenv); @@ -793,7 +829,7 @@ JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transactio jenv->ReleaseByteArrayElements( value, (jbyte *)barrValue, JNI_ABORT ); } -JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transaction_1commit(JNIEnv *jenv, jobject, jlong tPtr) { +JNIEXPORT jlong JNICALL Java_com_apple_foundationdb_FDBTransaction_Transaction_1commit(JNIEnv *jenv, jobject, jlong tPtr) { if( !tPtr ) { throwParamNotNull(jenv); return 0; @@ -803,7 +839,7 @@ JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transacti return (jlong)f; } -JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transaction_1setOption(JNIEnv *jenv, jobject, jlong tPtr, jint code, jbyteArray value) { +JNIEXPORT void JNICALL Java_com_apple_foundationdb_FDBTransaction_Transaction_1setOption(JNIEnv *jenv, jobject, jlong tPtr, jint code, jbyteArray value) { if( !tPtr ) { throwParamNotNull(jenv); return; @@ -829,7 +865,7 @@ JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transactio } } -JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transaction_1getCommittedVersion(JNIEnv *jenv, jobject, jlong tPtr) { +JNIEXPORT jlong JNICALL Java_com_apple_foundationdb_FDBTransaction_Transaction_1getCommittedVersion(JNIEnv *jenv, jobject, jlong tPtr) { if( !tPtr ) { throwParamNotNull(jenv); return 0; @@ -844,7 +880,7 @@ JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transacti return (jlong)version; } -JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transaction_1getVersionstamp(JNIEnv *jenv, jobject, jlong tPtr) { +JNIEXPORT jlong JNICALL Java_com_apple_foundationdb_FDBTransaction_Transaction_1getVersionstamp(JNIEnv *jenv, jobject, jlong tPtr) { if (!tPtr) { throwParamNotNull(jenv); return 0; @@ -854,7 +890,7 @@ JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transacti return (jlong)f; } -JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transaction_1getKeyLocations(JNIEnv *jenv, jobject, jlong tPtr, jbyteArray key) { +JNIEXPORT jlong JNICALL Java_com_apple_foundationdb_FDBTransaction_Transaction_1getKeyLocations(JNIEnv *jenv, jobject, jlong tPtr, jbyteArray key) { if( !tPtr || !key ) { throwParamNotNull(jenv); return 0; @@ -875,7 +911,7 @@ JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transacti return (jlong)f; } -JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transaction_1onError(JNIEnv *jenv, jobject, jlong tPtr, jint errorCode) { +JNIEXPORT jlong JNICALL Java_com_apple_foundationdb_FDBTransaction_Transaction_1onError(JNIEnv *jenv, jobject, jlong tPtr, jint errorCode) { if( !tPtr ) { throwParamNotNull(jenv); return 0; @@ -885,7 +921,7 @@ JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transacti return (jlong)f; } -JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transaction_1dispose(JNIEnv *jenv, jobject, jlong tPtr) { +JNIEXPORT void JNICALL Java_com_apple_foundationdb_FDBTransaction_Transaction_1dispose(JNIEnv *jenv, jobject, jlong tPtr) { if( !tPtr ) { throwParamNotNull(jenv); return; @@ -893,7 +929,7 @@ JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transactio fdb_transaction_destroy( (FDBTransaction *)tPtr ); } -JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transaction_1reset(JNIEnv *jenv, jobject, jlong tPtr) { +JNIEXPORT void JNICALL Java_com_apple_foundationdb_FDBTransaction_Transaction_1reset(JNIEnv *jenv, jobject, jlong tPtr) { if( !tPtr ) { throwParamNotNull(jenv); return; @@ -901,7 +937,7 @@ JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transactio fdb_transaction_reset( (FDBTransaction *)tPtr ); } -JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transaction_1watch(JNIEnv *jenv, jobject, jlong tPtr, jbyteArray key) { +JNIEXPORT jlong JNICALL Java_com_apple_foundationdb_FDBTransaction_Transaction_1watch(JNIEnv *jenv, jobject, jlong tPtr, jbyteArray key) { if( !tPtr || !key ) { throwParamNotNull(jenv); return 0; @@ -921,7 +957,7 @@ JNIEXPORT jlong JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transacti return (jlong)f; } -JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transaction_1cancel(JNIEnv *jenv, jobject, jlong tPtr) { +JNIEXPORT void JNICALL Java_com_apple_foundationdb_FDBTransaction_Transaction_1cancel(JNIEnv *jenv, jobject, jlong tPtr) { if( !tPtr ) { throwParamNotNull(jenv); return; @@ -929,7 +965,7 @@ JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transactio fdb_transaction_cancel( (FDBTransaction *)tPtr ); } -JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transaction_1addConflictRange( +JNIEXPORT void JNICALL Java_com_apple_foundationdb_FDBTransaction_Transaction_1addConflictRange( JNIEnv *jenv, jobject, jlong tPtr, jbyteArray keyBegin, jbyteArray keyEnd, jint conflictType) { if( !tPtr || !keyBegin || !keyEnd ) { throwParamNotNull(jenv); @@ -964,7 +1000,7 @@ JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDBTransaction_Transactio } } -JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDB_Select_1API_1version(JNIEnv *jenv, jclass, jint version) { +JNIEXPORT void JNICALL Java_com_apple_foundationdb_FDB_Select_1API_1version(JNIEnv *jenv, jclass, jint version) { fdb_error_t err = fdb_select_api_version( (int)version ); if( err ) { if( err == 2203 ) { @@ -989,7 +1025,7 @@ JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDB_Select_1API_1version( } } -JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDB_Network_1setOption(JNIEnv *jenv, jobject, jint code, jbyteArray value) { +JNIEXPORT void JNICALL Java_com_apple_foundationdb_FDB_Network_1setOption(JNIEnv *jenv, jobject, jint code, jbyteArray value) { uint8_t *barr = NULL; int size = 0; if(value != 0) { @@ -1009,14 +1045,14 @@ JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDB_Network_1setOption(JN } } -JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDB_Network_1setup(JNIEnv *jenv, jobject) { +JNIEXPORT void JNICALL Java_com_apple_foundationdb_FDB_Network_1setup(JNIEnv *jenv, jobject) { fdb_error_t err = fdb_setup_network(); if( err ) { safeThrow( jenv, getThrowable( jenv, err ) ); } } -JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDB_Network_1run(JNIEnv *jenv, jobject) { +JNIEXPORT void JNICALL Java_com_apple_foundationdb_FDB_Network_1run(JNIEnv *jenv, jobject) { // initialize things for the callbacks on the network thread g_thread_jenv = jenv; if( !g_IFutureCallback_call_methodID ) { @@ -1024,19 +1060,29 @@ JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDB_Network_1run(JNIEnv * return; } + fdb_error_t hookErr = fdb_add_network_thread_completion_hook( &detachIfExternalThread, NULL ); + if( hookErr ) { + safeThrow( jenv, getThrowable( jenv, hookErr ) ); + } + fdb_error_t err = fdb_run_network(); if( err ) { safeThrow( jenv, getThrowable( jenv, err ) ); } } -JNIEXPORT void JNICALL Java_com_apple_cie_foundationdb_FDB_Network_1stop(JNIEnv *jenv, jobject) { +JNIEXPORT void JNICALL Java_com_apple_foundationdb_FDB_Network_1stop(JNIEnv *jenv, jobject) { fdb_error_t err = fdb_stop_network(); if( err ) { safeThrow( jenv, getThrowable( jenv, err ) ); } } +jint JNI_OnLoad(JavaVM *vm, void *reserved) { + g_jvm = vm; + return JNI_VERSION_1_1; +} + #ifdef __cplusplus } #endif diff --git a/bindings/java/fdb_java.vcxproj b/bindings/java/fdb_java.vcxproj index 00ee28b5aa..ff38485c30 100644 --- a/bindings/java/fdb_java.vcxproj +++ b/bindings/java/fdb_java.vcxproj @@ -58,12 +58,12 @@ if exist "$(OutDir)fdb-java-*.jar" del "$(OutDir)fdb-java-*.jar" rmdir /S /Q classes mkdir classes\main mkdir classes\test -"C:\Program Files\Java\jdk6\bin\javac.exe" -source 1.6 -target 1.6 -d classes\main src\main\com\apple\cie\foundationdb\*.java src\main\com\apple\cie\foundationdb\async\*.java src\main\com\apple\cie\foundationdb\tuple\*.java src\main\com\apple\cie\foundationdb\directory\*.java src\main\com\apple\cie\foundationdb\subspace\*.java -"C:\Program Files\Java\jdk6\bin\javac.exe" -source 1.6 -target 1.6 -cp classes\main -d classes\test src\test\com\apple\cie\foundationdb\test\*.java +"C:\Program Files\Java\jdk6\bin\javac.exe" -source 1.6 -target 1.6 -d classes\main src\main\com\apple\foundationdb\*.java src\main\com\apple\foundationdb\async\*.java src\main\com\apple\foundationdb\tuple\*.java src\main\com\apple\foundationdb\directory\*.java src\main\com\apple\foundationdb\subspace\*.java +"C:\Program Files\Java\jdk6\bin\javac.exe" -source 1.6 -target 1.6 -cp classes\main -d classes\test src\test\com\apple\foundationdb\test\*.java mkdir classes\main\lib\windows\amd64 copy "$(TargetPath)" "classes\main\lib\windows\amd64" -"C:\Program Files\Java\jdk6\bin\jar.exe" cf "$(OutDir)fdb-java-$(Version)$(PreReleaseDecoration)-windows-$(Platform).jar" -C classes\main com\apple\cie\foundationdb -C classes\main lib\windows\amd64 -"C:\Program Files\Java\jdk6\bin\jar.exe" cf "$(OutDir)foundationdb-tests.jar" -C classes\test com\apple\cie\foundationdb +"C:\Program Files\Java\jdk6\bin\jar.exe" cf "$(OutDir)fdb-java-$(Version)$(PreReleaseDecoration)-windows-$(Platform).jar" -C classes\main com\apple\foundationdb -C classes\main lib\windows\amd64 +"C:\Program Files\Java\jdk6\bin\jar.exe" cf "$(OutDir)foundationdb-tests.jar" -C classes\test com\apple\foundationdb FOR /F "tokens=1" %%i in ('hg.exe id') do copy /Y "$(TargetPath)" "$(TargetPath)-%%i" @@ -121,4 +121,4 @@ FOR /F "tokens=1" %%i in ('hg.exe id') do copy /Y "$(TargetPath)" "$(TargetPath) - \ No newline at end of file + diff --git a/bindings/java/local.mk b/bindings/java/local.mk index 30cac01290..8e0b1f34ab 100644 --- a/bindings/java/local.mk +++ b/bindings/java/local.mk @@ -40,22 +40,22 @@ endif define add_java_binding_targets - JAVA$(1)_GENERATED_SOURCES := bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/NetworkOptions.java bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/ClusterOptions.java bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/DatabaseOptions.java bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/TransactionOptions.java bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/StreamingMode.java bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/ConflictRangeType.java bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/MutationType.java bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/FDBException.java + JAVA$(1)_GENERATED_SOURCES := bindings/java/src$(1)/main/com/apple/foundationdb/NetworkOptions.java bindings/java/src$(1)/main/com/apple/foundationdb/ClusterOptions.java bindings/java/src$(1)/main/com/apple/foundationdb/DatabaseOptions.java bindings/java/src$(1)/main/com/apple/foundationdb/TransactionOptions.java bindings/java/src$(1)/main/com/apple/foundationdb/StreamingMode.java bindings/java/src$(1)/main/com/apple/foundationdb/ConflictRangeType.java bindings/java/src$(1)/main/com/apple/foundationdb/MutationType.java bindings/java/src$(1)/main/com/apple/foundationdb/FDBException.java - JAVA$(1)_SOURCES := $$(JAVA$(1)_GENERATED_SOURCES) bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/*.java bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/async/*.java bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/tuple/*.java bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/directory/*.java bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/subspace/*.java bindings/java/src$(1)/test/com/apple/apple/foundationdbdb/test/*.java + JAVA$(1)_SOURCES := $$(JAVA$(1)_GENERATED_SOURCES) bindings/java/src$(1)/main/com/apple/foundationdb/*.java bindings/java/src$(1)/main/com/apple/foundationdb/async/*.java bindings/java/src$(1)/main/com/apple/foundationdb/tuple/*.java bindings/java/src$(1)/main/com/apple/foundationdb/directory/*.java bindings/java/src$(1)/main/com/apple/foundationdb/subspace/*.java bindings/java/src$(1)/test/com/apple/foundationdb/test/*.java fdb_java$(1): bindings/java/foundationdb-client$(1).jar bindings/java/foundationdb-tests$(1).jar bindings/java/foundationdb-tests$(1).jar: bindings/java/.classstamp$(1) @echo "Building $$@" - @jar cf $$@ -C bindings/java/classes$(1)/test com/apple/apple/foundationdbdb + @jar cf $$@ -C bindings/java/classes$(1)/test com/apple/foundationdb bindings/java/foundationdb-client$(1).jar: bindings/java/.classstamp$(1) lib/libfdb_java.$(DLEXT) @echo "Building $$@" @rm -rf bindings/java/classes$(1)/main/lib/$$(PLATFORM)/$$(java_ARCH) @mkdir -p bindings/java/classes$(1)/main/lib/$$(PLATFORM)/$$(java_ARCH) @cp lib/libfdb_java.$$(DLEXT) bindings/java/classes$(1)/main/lib/$$(PLATFORM)/$$(java_ARCH)/libfdb_java.$$(java_DLEXT) - @jar cf $$@ -C bindings/java/classes$(1)/main com/apple/apple/foundationdbdb -C bindings/java/classes$(1)/main lib + @jar cf $$@ -C bindings/java/classes$(1)/main com/apple/foundationdb -C bindings/java/classes$(1)/main lib fdb_java$(1)_jar_clean: @rm -rf $$(JAVA$(1)_GENERATED_SOURCES) @@ -65,20 +65,20 @@ define add_java_binding_targets # Redefinition of a target already defined in generated.mk, but it's "okay" and the way things were done before. fdb_java_clean: fdb_java$(1)_jar_clean - bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/StreamingMode.java: bin/vexillographer.exe fdbclient/vexillographer/fdb.options + bindings/java/src$(1)/main/com/apple/foundationdb/StreamingMode.java: bin/vexillographer.exe fdbclient/vexillographer/fdb.options @echo "Building Java options" @$$(MONO) bin/vexillographer.exe fdbclient/vexillographer/fdb.options java $$(@D) - bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/MutationType.java: bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/StreamingMode.java + bindings/java/src$(1)/main/com/apple/foundationdb/MutationType.java: bindings/java/src$(1)/main/com/apple/foundationdb/StreamingMode.java @true - bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/ConflictRangeType.java: bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/StreamingMode.java + bindings/java/src$(1)/main/com/apple/foundationdb/ConflictRangeType.java: bindings/java/src$(1)/main/com/apple/foundationdb/StreamingMode.java @true - bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/FDBException.java: bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/StreamingMode.java + bindings/java/src$(1)/main/com/apple/foundationdb/FDBException.java: bindings/java/src$(1)/main/com/apple/foundationdb/StreamingMode.java @true - bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/%Options.java: bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/StreamingMode.java + bindings/java/src$(1)/main/com/apple/foundationdb/%Options.java: bindings/java/src$(1)/main/com/apple/foundationdb/StreamingMode.java @true bindings/java/src$(1)/main/overview.html: bindings/java/src$(1)/main/overview.html.in $$(ALL_MAKEFILES) versions.target @@ -89,8 +89,8 @@ define add_java_binding_targets @rm -rf bindings/java/classes$(1) @mkdir -p bindings/java/classes$(1)/main @mkdir -p bindings/java/classes$(1)/test - @$$(JAVAC) $$(JAVA$(1)FLAGS) -d bindings/java/classes$(1)/main bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/*.java bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/async/*.java bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/tuple/*.java bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/directory/*.java bindings/java/src$(1)/main/com/apple/apple/foundationdbdb/subspace/*.java - @$$(JAVAC) $$(JAVA$(1)FLAGS) -cp bindings/java/classes$(1)/main -d bindings/java/classes$(1)/test bindings/java/src$(1)/test/com/apple/apple/foundationdbdb/test/*.java + @$$(JAVAC) $$(JAVA$(1)FLAGS) -d bindings/java/classes$(1)/main bindings/java/src$(1)/main/com/apple/foundationdb/*.java bindings/java/src$(1)/main/com/apple/foundationdb/async/*.java bindings/java/src$(1)/main/com/apple/foundationdb/tuple/*.java bindings/java/src$(1)/main/com/apple/foundationdb/directory/*.java bindings/java/src$(1)/main/com/apple/foundationdb/subspace/*.java + @$$(JAVAC) $$(JAVA$(1)FLAGS) -cp bindings/java/classes$(1)/main -d bindings/java/classes$(1)/test bindings/java/src$(1)/test/com/apple/foundationdb/test/*.java @echo timestamp > bindings/java/.classstamp$(1) javadoc$(1): $$(JAVA$(1)_SOURCES) bindings/java/src$(1)/main/overview.html @@ -101,7 +101,7 @@ define add_java_binding_targets -windowtitle "FoundationDB Java Client API" \ -doctitle "FoundationDB Java Client API" \ -link "http://docs.oracle.com/javase/8/docs/api" \ - com.apple.cie.foundationdb.org.apple.cie.foundationdb.async com.apple.cie.foundationdb.tuple com.apple.cie.foundationdb.directory com.apple.cie.foundationdb.subspace + com.apple.foundationdb.org.apple.foundationdb.async com.apple.foundationdb.tuple com.apple.foundationdb.directory com.apple.foundationdb.subspace javadoc$(1)_clean: @rm -rf $$(JAVADOC_DIR)/javadoc$(1) @@ -152,7 +152,7 @@ define add_java_binding_targets packages/fdb-java$(1)-$$(JARVER)-sources.jar: $$(JAVA$(1)_GENERATED_SOURCES) versions.target @echo "Building $$@" @rm -f $$@ - @jar cf $(TOPDIR)/$$@ -C bindings/java/src$(1)/main com/apple/apple/foundationdbdb + @jar cf $(TOPDIR)/$$@ -C bindings/java/src$(1)/main com/apple/foundationdb packages/fdb-java$(1)-$$(JARVER)-javadoc.jar: javadoc$(1) versions.target @echo "Building $$@" diff --git a/bindings/java/src-completable/junit/com/apple/cie/foundationdb/tuple/AllTests.java b/bindings/java/src-completable/junit/com/apple/foundationdb/tuple/AllTests.java similarity index 95% rename from bindings/java/src-completable/junit/com/apple/cie/foundationdb/tuple/AllTests.java rename to bindings/java/src-completable/junit/com/apple/foundationdb/tuple/AllTests.java index 8be6513092..bc15ca7e45 100644 --- a/bindings/java/src-completable/junit/com/apple/cie/foundationdb/tuple/AllTests.java +++ b/bindings/java/src-completable/junit/com/apple/foundationdb/tuple/AllTests.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.tuple; +package com.apple.foundationdb.tuple; import org.junit.runner.RunWith; import org.junit.runners.Suite; diff --git a/bindings/java/src-completable/junit/com/apple/cie/foundationdb/tuple/ArrayUtilTests.java b/bindings/java/src-completable/junit/com/apple/foundationdb/tuple/ArrayUtilTests.java similarity index 98% rename from bindings/java/src-completable/junit/com/apple/cie/foundationdb/tuple/ArrayUtilTests.java rename to bindings/java/src-completable/junit/com/apple/foundationdb/tuple/ArrayUtilTests.java index a984a6d9ef..5f6400fad9 100644 --- a/bindings/java/src-completable/junit/com/apple/cie/foundationdb/tuple/ArrayUtilTests.java +++ b/bindings/java/src-completable/junit/com/apple/foundationdb/tuple/ArrayUtilTests.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.tuple; +package com.apple.foundationdb.tuple; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; @@ -29,7 +29,7 @@ import static org.junit.Assert.fail; import java.util.ArrayList; import java.util.List; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.tuple.ByteArrayUtil; import org.junit.Test; /** diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/Cluster.java b/bindings/java/src-completable/main/com/apple/foundationdb/Cluster.java similarity index 98% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/Cluster.java rename to bindings/java/src-completable/main/com/apple/foundationdb/Cluster.java index 60a5006a01..4e4fc66a44 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/Cluster.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/Cluster.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.nio.charset.Charset; import java.util.concurrent.Executor; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/Database.java b/bindings/java/src-completable/main/com/apple/foundationdb/Database.java similarity index 99% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/Database.java rename to bindings/java/src-completable/main/com/apple/foundationdb/Database.java index 6e8a12be4b..0d586fc222 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/Database.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/Database.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/DefaultDisposableImpl.java b/bindings/java/src-completable/main/com/apple/foundationdb/DefaultDisposableImpl.java similarity index 98% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/DefaultDisposableImpl.java rename to bindings/java/src-completable/main/com/apple/foundationdb/DefaultDisposableImpl.java index c7c0464447..6f1b366446 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/DefaultDisposableImpl.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/DefaultDisposableImpl.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantReadWriteLock; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/Disposable.java b/bindings/java/src-completable/main/com/apple/foundationdb/Disposable.java similarity index 96% rename from bindings/java/src/main/com/apple/cie/foundationdb/Disposable.java rename to bindings/java/src-completable/main/com/apple/foundationdb/Disposable.java index b1e211c013..7772065bd3 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/Disposable.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/Disposable.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; /** * A FoundationDB object with native resources that can be freed. It is not mandatory to call diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/FDB.java b/bindings/java/src-completable/main/com/apple/foundationdb/FDB.java similarity index 98% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/FDB.java rename to bindings/java/src-completable/main/com/apple/foundationdb/FDB.java index ac0b9a560e..6ae5c026f1 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/FDB.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/FDB.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; @@ -34,7 +34,7 @@ import java.util.concurrent.ThreadFactory; * This call is required before using any other part of the API. The call allows * an error to be thrown at this point to prevent client code from accessing a later library * with incorrect assumptions from the current version. The API version documented here is version - * {@code 500}.

+ * {@code 510}.

* FoundationDB encapsulates multiple versions of its interface by requiring * the client to explicitly specify the version of the API it uses. The purpose * of this design is to allow you to upgrade the server, client libraries, or @@ -157,15 +157,15 @@ public class FDB { } if(version < 500) throw new IllegalArgumentException("API version not supported (minimum 500)"); - if(version > 500) - throw new IllegalArgumentException("API version not supported (maximum 500)"); + if(version > 510) + throw new IllegalArgumentException("API version not supported (maximum 510)"); Select_API_version(version); return singleton = new FDB(version); } /** * Connects to the cluster specified by the - * default fdb.cluster file. + * default fdb.cluster file. * If the FoundationDB network has not been started, it will be started in the course of this call * as if {@link FDB#startNetwork()} had been called. * @@ -230,7 +230,7 @@ public class FDB { /** * Initializes networking, connects with the - * default fdb.cluster file, + * default fdb.cluster file, * and opens the database. * * @return a {@code CompletableFuture} that will be set to a FoundationDB {@link Database} diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/FDBDatabase.java b/bindings/java/src-completable/main/com/apple/foundationdb/FDBDatabase.java similarity index 97% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/FDBDatabase.java rename to bindings/java/src-completable/main/com/apple/foundationdb/FDBDatabase.java index be4b8fac98..feedab81ce 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/FDBDatabase.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/FDBDatabase.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; @@ -28,7 +28,7 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.function.BiFunction; import java.util.function.Function; -import com.apple.cie.foundationdb.async.AsyncUtil; +import com.apple.foundationdb.async.AsyncUtil; class FDBDatabase extends DefaultDisposableImpl implements Database, Disposable, OptionConsumer { private DatabaseOptions options; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/FDBTransaction.java b/bindings/java/src-completable/main/com/apple/foundationdb/FDBTransaction.java similarity index 99% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/FDBTransaction.java rename to bindings/java/src-completable/main/com/apple/foundationdb/FDBTransaction.java index 859a15f2cd..0e6e17eff6 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/FDBTransaction.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/FDBTransaction.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; @@ -26,8 +26,8 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; import java.util.function.Function; -import com.apple.cie.foundationdb.async.*; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.async.*; +import com.apple.foundationdb.tuple.ByteArrayUtil; class FDBTransaction extends DefaultDisposableImpl implements Disposable, Transaction, OptionConsumer { private final Database database; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/FutureCluster.java b/bindings/java/src-completable/main/com/apple/foundationdb/FutureCluster.java similarity index 97% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/FutureCluster.java rename to bindings/java/src-completable/main/com/apple/foundationdb/FutureCluster.java index 4413502b97..71b90c4773 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/FutureCluster.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/FutureCluster.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.Executor; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/FutureDatabase.java b/bindings/java/src-completable/main/com/apple/foundationdb/FutureDatabase.java similarity index 97% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/FutureDatabase.java rename to bindings/java/src-completable/main/com/apple/foundationdb/FutureDatabase.java index 561a2a0131..105e37c63e 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/FutureDatabase.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/FutureDatabase.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.Executor; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/FutureKey.java b/bindings/java/src-completable/main/com/apple/foundationdb/FutureKey.java similarity index 96% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/FutureKey.java rename to bindings/java/src-completable/main/com/apple/foundationdb/FutureKey.java index 8e6768decf..ea4f276660 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/FutureKey.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/FutureKey.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.Executor; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/FutureResult.java b/bindings/java/src-completable/main/com/apple/foundationdb/FutureResult.java similarity index 96% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/FutureResult.java rename to bindings/java/src-completable/main/com/apple/foundationdb/FutureResult.java index cb3541e226..7ed7b14359 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/FutureResult.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/FutureResult.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.Executor; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/FutureResults.java b/bindings/java/src-completable/main/com/apple/foundationdb/FutureResults.java similarity index 97% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/FutureResults.java rename to bindings/java/src-completable/main/com/apple/foundationdb/FutureResults.java index cd5c4572ba..44e1c94ec6 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/FutureResults.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/FutureResults.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.Executor; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/FutureStrings.java b/bindings/java/src-completable/main/com/apple/foundationdb/FutureStrings.java similarity index 96% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/FutureStrings.java rename to bindings/java/src-completable/main/com/apple/foundationdb/FutureStrings.java index 3f33bbd556..052b294e13 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/FutureStrings.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/FutureStrings.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.Executor; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/FutureVersion.java b/bindings/java/src-completable/main/com/apple/foundationdb/FutureVersion.java similarity index 96% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/FutureVersion.java rename to bindings/java/src-completable/main/com/apple/foundationdb/FutureVersion.java index 6be2a04e49..2b27bcca7d 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/FutureVersion.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/FutureVersion.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.Executor; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/FutureVoid.java b/bindings/java/src-completable/main/com/apple/foundationdb/FutureVoid.java similarity index 97% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/FutureVoid.java rename to bindings/java/src-completable/main/com/apple/foundationdb/FutureVoid.java index 9cdec3ce56..68a01f126a 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/FutureVoid.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/FutureVoid.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.Executor; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/JNIUtil.java b/bindings/java/src-completable/main/com/apple/foundationdb/JNIUtil.java similarity index 99% rename from bindings/java/src/main/com/apple/cie/foundationdb/JNIUtil.java rename to bindings/java/src-completable/main/com/apple/foundationdb/JNIUtil.java index fd310c7df8..cdb9d377ff 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/JNIUtil.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/JNIUtil.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.io.File; import java.io.FileOutputStream; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/KeySelector.java b/bindings/java/src-completable/main/com/apple/foundationdb/KeySelector.java similarity index 98% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/KeySelector.java rename to bindings/java/src-completable/main/com/apple/foundationdb/KeySelector.java index 31429c7639..7607d4888c 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/KeySelector.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/KeySelector.java @@ -18,9 +18,9 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.tuple.ByteArrayUtil; /** * A {@code KeySelector} identifies a particular key in the database. FoundationDB's diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/KeyValue.java b/bindings/java/src-completable/main/com/apple/foundationdb/KeyValue.java similarity index 98% rename from bindings/java/src/main/com/apple/cie/foundationdb/KeyValue.java rename to bindings/java/src-completable/main/com/apple/foundationdb/KeyValue.java index be034be2a5..c00e5e1256 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/KeyValue.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/KeyValue.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.Arrays; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/LocalityUtil.java b/bindings/java/src-completable/main/com/apple/foundationdb/LocalityUtil.java similarity index 97% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/LocalityUtil.java rename to bindings/java/src-completable/main/com/apple/foundationdb/LocalityUtil.java index 3fc4fcd9bc..9dc62dde0e 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/LocalityUtil.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/LocalityUtil.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.nio.charset.Charset; import java.util.Arrays; @@ -27,10 +27,10 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; import java.util.function.BiFunction; -import com.apple.cie.foundationdb.async.AsyncIterable; -import com.apple.cie.foundationdb.async.AsyncIterator; -import com.apple.cie.foundationdb.async.AsyncUtil; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.async.AsyncIterable; +import com.apple.foundationdb.async.AsyncIterator; +import com.apple.foundationdb.async.AsyncUtil; +import com.apple.foundationdb.tuple.ByteArrayUtil; /** * The FoundationDB API comes with a set of functions for discovering the diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/NativeFuture.java b/bindings/java/src-completable/main/com/apple/foundationdb/NativeFuture.java similarity index 98% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/NativeFuture.java rename to bindings/java/src-completable/main/com/apple/foundationdb/NativeFuture.java index 5d70de4d44..3052a16702 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/NativeFuture.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/NativeFuture.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/OptionConsumer.java b/bindings/java/src-completable/main/com/apple/foundationdb/OptionConsumer.java similarity index 97% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/OptionConsumer.java rename to bindings/java/src-completable/main/com/apple/foundationdb/OptionConsumer.java index 4d0c398f4d..1f7a01b9a5 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/OptionConsumer.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/OptionConsumer.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; /** * An object on which encoded options can be set. Rarely used outside of diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/OptionsSet.java b/bindings/java/src-completable/main/com/apple/foundationdb/OptionsSet.java similarity index 98% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/OptionsSet.java rename to bindings/java/src-completable/main/com/apple/foundationdb/OptionsSet.java index b3051aebb6..abe2d93455 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/OptionsSet.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/OptionsSet.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.nio.ByteBuffer; import java.nio.ByteOrder; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/Range.java b/bindings/java/src-completable/main/com/apple/foundationdb/Range.java similarity index 97% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/Range.java rename to bindings/java/src-completable/main/com/apple/foundationdb/Range.java index 6a0b091f8d..bb2c460bd3 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/Range.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/Range.java @@ -18,11 +18,11 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.Arrays; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.tuple.ByteArrayUtil; /** * A simple description of an exact range of keyspace, specified by a begin and end key. As with diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/RangeQuery.java b/bindings/java/src-completable/main/com/apple/foundationdb/RangeQuery.java similarity index 98% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/RangeQuery.java rename to bindings/java/src-completable/main/com/apple/foundationdb/RangeQuery.java index fc9d2317a1..38c9ea42ae 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/RangeQuery.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/RangeQuery.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.List; import java.util.NoSuchElementException; @@ -27,9 +27,9 @@ import java.util.concurrent.CompletableFuture; import java.util.function.BiConsumer; import java.util.function.Function; -import com.apple.cie.foundationdb.async.AsyncIterable; -import com.apple.cie.foundationdb.async.AsyncIterator; -import com.apple.cie.foundationdb.async.AsyncUtil; +import com.apple.foundationdb.async.AsyncIterable; +import com.apple.foundationdb.async.AsyncIterator; +import com.apple.foundationdb.async.AsyncUtil; /** * Represents a query against FoundationDB for a range of keys. The diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/RangeResult.java b/bindings/java/src-completable/main/com/apple/foundationdb/RangeResult.java similarity index 97% rename from bindings/java/src/main/com/apple/cie/foundationdb/RangeResult.java rename to bindings/java/src-completable/main/com/apple/foundationdb/RangeResult.java index 92d2e98431..5960e9328e 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/RangeResult.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/RangeResult.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.ArrayList; import java.util.List; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/RangeResultInfo.java b/bindings/java/src-completable/main/com/apple/foundationdb/RangeResultInfo.java similarity index 96% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/RangeResultInfo.java rename to bindings/java/src-completable/main/com/apple/foundationdb/RangeResultInfo.java index b44d10f1d9..baeaa45b84 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/RangeResultInfo.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/RangeResultInfo.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; class RangeResultInfo { RangeResultSummary getSummary() { diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/RangeResultSummary.java b/bindings/java/src-completable/main/com/apple/foundationdb/RangeResultSummary.java similarity index 96% rename from bindings/java/src/main/com/apple/cie/foundationdb/RangeResultSummary.java rename to bindings/java/src-completable/main/com/apple/foundationdb/RangeResultSummary.java index 433cb4a970..ee7aaa104d 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/RangeResultSummary.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/RangeResultSummary.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; class RangeResultSummary { final byte[] lastKey; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/ReadTransaction.java b/bindings/java/src-completable/main/com/apple/foundationdb/ReadTransaction.java similarity index 98% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/ReadTransaction.java rename to bindings/java/src-completable/main/com/apple/foundationdb/ReadTransaction.java index 79e32937d4..71174c5efb 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/ReadTransaction.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/ReadTransaction.java @@ -18,13 +18,13 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.CompletableFuture; -import com.apple.cie.foundationdb.async.AsyncIterable; -import com.apple.cie.foundationdb.async.AsyncIterator; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.async.AsyncIterable; +import com.apple.foundationdb.async.AsyncIterator; +import com.apple.foundationdb.tuple.Tuple; /** * A read-only subset of a FoundationDB {@link Transaction}. This is the interface that diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/ReadTransactionContext.java b/bindings/java/src-completable/main/com/apple/foundationdb/ReadTransactionContext.java similarity index 98% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/ReadTransactionContext.java rename to bindings/java/src-completable/main/com/apple/foundationdb/ReadTransactionContext.java index 865de398a6..187525350f 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/ReadTransactionContext.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/ReadTransactionContext.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/Transaction.java b/bindings/java/src-completable/main/com/apple/foundationdb/Transaction.java similarity index 99% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/Transaction.java rename to bindings/java/src-completable/main/com/apple/foundationdb/Transaction.java index f9dbb7137f..f7f3b7dfe3 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/Transaction.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/Transaction.java @@ -18,11 +18,11 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.CompletableFuture; import java.util.function.Function; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.tuple.Tuple; /** * A Transaction represents a FoundationDB database transaction. All operations on FoundationDB diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/TransactionContext.java b/bindings/java/src-completable/main/com/apple/foundationdb/TransactionContext.java similarity index 98% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/TransactionContext.java rename to bindings/java/src-completable/main/com/apple/foundationdb/TransactionContext.java index 386911d238..91ecf16789 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/TransactionContext.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/TransactionContext.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.CompletableFuture; import java.util.function.Function; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/async/AsyncIterable.java b/bindings/java/src-completable/main/com/apple/foundationdb/async/AsyncIterable.java similarity index 97% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/async/AsyncIterable.java rename to bindings/java/src-completable/main/com/apple/foundationdb/async/AsyncIterable.java index 8a6b511e08..fe3c2dad30 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/async/AsyncIterable.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/async/AsyncIterable.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.async; +package com.apple.foundationdb.async; import java.util.List; import java.util.concurrent.CompletableFuture; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/async/AsyncIterator.java b/bindings/java/src-completable/main/com/apple/foundationdb/async/AsyncIterator.java similarity index 97% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/async/AsyncIterator.java rename to bindings/java/src-completable/main/com/apple/foundationdb/async/AsyncIterator.java index c1067805c4..5def1f182e 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/async/AsyncIterator.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/async/AsyncIterator.java @@ -18,13 +18,13 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.async; +package com.apple.foundationdb.async; import java.util.Iterator; import java.util.NoSuchElementException; import java.util.concurrent.CompletableFuture; -import com.apple.cie.foundationdb.Disposable; +import com.apple.foundationdb.Disposable; /** * A version of {@code Iterator} that allows for non-blocking iteration over elements. diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/async/AsyncUtil.java b/bindings/java/src-completable/main/com/apple/foundationdb/async/AsyncUtil.java similarity index 98% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/async/AsyncUtil.java rename to bindings/java/src-completable/main/com/apple/foundationdb/async/AsyncUtil.java index 1d566b4945..bc0eba7fa7 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/async/AsyncUtil.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/async/AsyncUtil.java @@ -18,11 +18,11 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.async; +package com.apple.foundationdb.async; -import static com.apple.cie.foundationdb.FDB.DEFAULT_EXECUTOR; +import static com.apple.foundationdb.FDB.DEFAULT_EXECUTOR; -import com.apple.cie.foundationdb.FDBException; +import com.apple.foundationdb.FDBException; import java.util.ArrayList; import java.util.Collection; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/async/Cancellable.java b/bindings/java/src-completable/main/com/apple/foundationdb/async/Cancellable.java similarity index 97% rename from bindings/java/src/main/com/apple/cie/foundationdb/async/Cancellable.java rename to bindings/java/src-completable/main/com/apple/foundationdb/async/Cancellable.java index 4fd3980b68..70c734cc86 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/async/Cancellable.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/async/Cancellable.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.async; +package com.apple.foundationdb.async; /** * Describes an operation or signal that can be cancelled. Cancellation will be assumed diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/async/CloneableException.java b/bindings/java/src-completable/main/com/apple/foundationdb/async/CloneableException.java similarity index 96% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/async/CloneableException.java rename to bindings/java/src-completable/main/com/apple/foundationdb/async/CloneableException.java index c260479288..dd93a56c0e 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/async/CloneableException.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/async/CloneableException.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.async; +package com.apple.foundationdb.async; /** * An {@link Exception} that can be duplicated with a new backtrace. diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/async/package-info.java b/bindings/java/src-completable/main/com/apple/foundationdb/async/package-info.java similarity index 95% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/async/package-info.java rename to bindings/java/src-completable/main/com/apple/foundationdb/async/package-info.java index 8c116b32c1..e375f71e1f 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/async/package-info.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/async/package-info.java @@ -22,4 +22,4 @@ * Provides additional constructs for asynchronous programming against Java's {@link java.util.concurrent.CompletableFuture CompletableFuture}s. * */ -package com.apple.cie.foundationdb.async; +package com.apple.foundationdb.async; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/Directory.java b/bindings/java/src-completable/main/com/apple/foundationdb/directory/Directory.java similarity index 98% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/Directory.java rename to bindings/java/src-completable/main/com/apple/foundationdb/directory/Directory.java index 25c4f00ff2..1b178f7692 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/Directory.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/directory/Directory.java @@ -18,16 +18,16 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.directory; +package com.apple.foundationdb.directory; -import static com.apple.cie.foundationdb.directory.DirectoryLayer.EMPTY_BYTES; -import static com.apple.cie.foundationdb.directory.DirectoryLayer.EMPTY_PATH; +import static com.apple.foundationdb.directory.DirectoryLayer.EMPTY_BYTES; +import static com.apple.foundationdb.directory.DirectoryLayer.EMPTY_PATH; import java.util.List; import java.util.concurrent.CompletableFuture; -import com.apple.cie.foundationdb.ReadTransactionContext; -import com.apple.cie.foundationdb.TransactionContext; +import com.apple.foundationdb.ReadTransactionContext; +import com.apple.foundationdb.TransactionContext; /** * Represents a directory in the {@code DirectoryLayer}. A {@code Directory} stores the path diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/DirectoryAlreadyExistsException.java b/bindings/java/src-completable/main/com/apple/foundationdb/directory/DirectoryAlreadyExistsException.java similarity index 96% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/DirectoryAlreadyExistsException.java rename to bindings/java/src-completable/main/com/apple/foundationdb/directory/DirectoryAlreadyExistsException.java index 7f4e64f4f1..654fbafd0c 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/DirectoryAlreadyExistsException.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/directory/DirectoryAlreadyExistsException.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.directory; +package com.apple.foundationdb.directory; import java.util.List; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/directory/DirectoryException.java b/bindings/java/src-completable/main/com/apple/foundationdb/directory/DirectoryException.java similarity index 96% rename from bindings/java/src/main/com/apple/cie/foundationdb/directory/DirectoryException.java rename to bindings/java/src-completable/main/com/apple/foundationdb/directory/DirectoryException.java index a99e925587..b7bbaa6422 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/directory/DirectoryException.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/directory/DirectoryException.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.directory; +package com.apple.foundationdb.directory; import java.util.List; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/DirectoryLayer.java b/bindings/java/src-completable/main/com/apple/foundationdb/directory/DirectoryLayer.java similarity index 98% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/DirectoryLayer.java rename to bindings/java/src-completable/main/com/apple/foundationdb/directory/DirectoryLayer.java index 39cda2a0ee..921375f9ff 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/DirectoryLayer.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/directory/DirectoryLayer.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.directory; +package com.apple.foundationdb.directory; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -31,19 +31,19 @@ import java.util.Random; import java.util.concurrent.CompletableFuture; import java.util.function.Function; -import com.apple.cie.foundationdb.KeyValue; -import com.apple.cie.foundationdb.MutationType; -import com.apple.cie.foundationdb.Range; -import com.apple.cie.foundationdb.ReadTransaction; -import com.apple.cie.foundationdb.ReadTransactionContext; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.TransactionContext; -import com.apple.cie.foundationdb.async.AsyncIterable; -import com.apple.cie.foundationdb.async.AsyncIterator; -import com.apple.cie.foundationdb.async.AsyncUtil; -import com.apple.cie.foundationdb.subspace.Subspace; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.KeyValue; +import com.apple.foundationdb.MutationType; +import com.apple.foundationdb.Range; +import com.apple.foundationdb.ReadTransaction; +import com.apple.foundationdb.ReadTransactionContext; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.TransactionContext; +import com.apple.foundationdb.async.AsyncIterable; +import com.apple.foundationdb.async.AsyncIterator; +import com.apple.foundationdb.async.AsyncUtil; +import com.apple.foundationdb.subspace.Subspace; +import com.apple.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.tuple.Tuple; /** * Provides a class for managing directories in FoundationDB. diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/DirectoryMoveException.java b/bindings/java/src-completable/main/com/apple/foundationdb/directory/DirectoryMoveException.java similarity index 96% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/DirectoryMoveException.java rename to bindings/java/src-completable/main/com/apple/foundationdb/directory/DirectoryMoveException.java index cc9f7abb56..2d282ce056 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/DirectoryMoveException.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/directory/DirectoryMoveException.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.directory; +package com.apple.foundationdb.directory; import java.util.List; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/directory/DirectoryPartition.java b/bindings/java/src-completable/main/com/apple/foundationdb/directory/DirectoryPartition.java similarity index 94% rename from bindings/java/src/main/com/apple/cie/foundationdb/directory/DirectoryPartition.java rename to bindings/java/src-completable/main/com/apple/foundationdb/directory/DirectoryPartition.java index 2a4b33a655..c42147921b 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/directory/DirectoryPartition.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/directory/DirectoryPartition.java @@ -18,16 +18,16 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.directory; +package com.apple.foundationdb.directory; -import static com.apple.cie.foundationdb.directory.DirectoryLayer.DEFAULT_NODE_SUBSPACE_PREFIX; +import static com.apple.foundationdb.directory.DirectoryLayer.DEFAULT_NODE_SUBSPACE_PREFIX; import java.util.List; -import com.apple.cie.foundationdb.subspace.Subspace; -import com.apple.cie.foundationdb.Range; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.subspace.Subspace; +import com.apple.foundationdb.Range; +import com.apple.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.tuple.Tuple; /** * A {@code DirectoryPartition} is a {@link DirectorySubspace} whose prefix is prepended to all of its descendant directories' prefixes. diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/DirectorySubspace.java b/bindings/java/src-completable/main/com/apple/foundationdb/directory/DirectorySubspace.java similarity index 93% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/DirectorySubspace.java rename to bindings/java/src-completable/main/com/apple/foundationdb/directory/DirectorySubspace.java index 60f1a295fb..1a8aed73b1 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/DirectorySubspace.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/directory/DirectorySubspace.java @@ -18,20 +18,20 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.directory; +package com.apple.foundationdb.directory; -import static com.apple.cie.foundationdb.directory.DirectoryLayer.EMPTY_BYTES; -import static com.apple.cie.foundationdb.directory.DirectoryLayer.EMPTY_PATH; -import static com.apple.cie.foundationdb.tuple.ByteArrayUtil.printable; +import static com.apple.foundationdb.directory.DirectoryLayer.EMPTY_BYTES; +import static com.apple.foundationdb.directory.DirectoryLayer.EMPTY_PATH; +import static com.apple.foundationdb.tuple.ByteArrayUtil.printable; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; -import com.apple.cie.foundationdb.ReadTransactionContext; -import com.apple.cie.foundationdb.TransactionContext; -import com.apple.cie.foundationdb.subspace.Subspace; +import com.apple.foundationdb.ReadTransactionContext; +import com.apple.foundationdb.TransactionContext; +import com.apple.foundationdb.subspace.Subspace; /** * A DirectorySubspace represents the contents of a directory, but it diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/directory/DirectoryUtil.java b/bindings/java/src-completable/main/com/apple/foundationdb/directory/DirectoryUtil.java similarity index 96% rename from bindings/java/src/main/com/apple/cie/foundationdb/directory/DirectoryUtil.java rename to bindings/java/src-completable/main/com/apple/foundationdb/directory/DirectoryUtil.java index 2383f187e6..6433fe6607 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/directory/DirectoryUtil.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/directory/DirectoryUtil.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.directory; +package com.apple.foundationdb.directory; import java.util.List; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/DirectoryVersionException.java b/bindings/java/src-completable/main/com/apple/foundationdb/directory/DirectoryVersionException.java similarity index 96% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/DirectoryVersionException.java rename to bindings/java/src-completable/main/com/apple/foundationdb/directory/DirectoryVersionException.java index 406d66bd03..30a9a1b5bc 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/DirectoryVersionException.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/directory/DirectoryVersionException.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.directory; +package com.apple.foundationdb.directory; /** * An {@link Exception} that is thrown when the version of the directory layer diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/directory/MismatchedLayerException.java b/bindings/java/src-completable/main/com/apple/foundationdb/directory/MismatchedLayerException.java similarity index 93% rename from bindings/java/src/main/com/apple/cie/foundationdb/directory/MismatchedLayerException.java rename to bindings/java/src-completable/main/com/apple/foundationdb/directory/MismatchedLayerException.java index feea71e3f3..73fe153c34 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/directory/MismatchedLayerException.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/directory/MismatchedLayerException.java @@ -18,9 +18,9 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.directory; +package com.apple.foundationdb.directory; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.tuple.ByteArrayUtil; import java.util.List; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/NoSuchDirectoryException.java b/bindings/java/src-completable/main/com/apple/foundationdb/directory/NoSuchDirectoryException.java similarity index 95% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/NoSuchDirectoryException.java rename to bindings/java/src-completable/main/com/apple/foundationdb/directory/NoSuchDirectoryException.java index 00e8a6c5e5..8aa1d9396a 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/NoSuchDirectoryException.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/directory/NoSuchDirectoryException.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.directory; +package com.apple.foundationdb.directory; import java.util.List; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/directory/PathUtil.java b/bindings/java/src-completable/main/com/apple/foundationdb/directory/PathUtil.java similarity index 98% rename from bindings/java/src/main/com/apple/cie/foundationdb/directory/PathUtil.java rename to bindings/java/src-completable/main/com/apple/foundationdb/directory/PathUtil.java index 5b69f6579a..f11d9d47ee 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/directory/PathUtil.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/directory/PathUtil.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.directory; +package com.apple.foundationdb.directory; import java.util.Arrays; import java.util.LinkedList; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/directory/package-info.java b/bindings/java/src-completable/main/com/apple/foundationdb/directory/package-info.java similarity index 97% rename from bindings/java/src/main/com/apple/cie/foundationdb/directory/package-info.java rename to bindings/java/src-completable/main/com/apple/foundationdb/directory/package-info.java index 4616883692..73dfd7e925 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/directory/package-info.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/directory/package-info.java @@ -35,4 +35,4 @@ * directory documentation for information about how directories work and * interact with other parts of the built-in keyspace management features. */ -package com.apple.cie.foundationdb.directory; \ No newline at end of file +package com.apple.foundationdb.directory; \ No newline at end of file diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/package-info.java b/bindings/java/src-completable/main/com/apple/foundationdb/package-info.java similarity index 76% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/package-info.java rename to bindings/java/src-completable/main/com/apple/foundationdb/package-info.java index 13f9a3a638..ef9e093158 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/package-info.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/package-info.java @@ -20,16 +20,16 @@ /** * Provides an API for the FoundationDB transactional key/value store. Clients operating - * on a {@link com.apple.cie.foundationdb.Database} should, in most cases, use the - * {@link com.apple.cie.foundationdb.TransactionContext#run(Function) run(Function)} + * on a {@link com.apple.foundationdb.Database} should, in most cases, use the + * {@link com.apple.foundationdb.TransactionContext#run(Function) run(Function)} * or the - * {@link com.apple.cie.foundationdb.TransactionContext#runAsync(Function) runAsync(Function)} + * {@link com.apple.foundationdb.TransactionContext#runAsync(Function) runAsync(Function)} * constructs. These two functions (and their two derivations) implement a proper * retry loop around the work that needs to get done and, in the case of {@code Database}, - * assure that {@link com.apple.cie.foundationdb.Transaction#commit()} has returned successfully + * assure that {@link com.apple.foundationdb.Transaction#commit()} has returned successfully * before itself returning. If you are not able to use these functions for some reason * please closely read and understand the other * developer * documentation on FoundationDB transactions. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/subspace/Subspace.java b/bindings/java/src-completable/main/com/apple/foundationdb/subspace/Subspace.java similarity index 91% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/subspace/Subspace.java rename to bindings/java/src-completable/main/com/apple/foundationdb/subspace/Subspace.java index b2de6e2355..29e02bdb89 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/subspace/Subspace.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/subspace/Subspace.java @@ -18,16 +18,16 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.subspace; +package com.apple.foundationdb.subspace; -import static com.apple.cie.foundationdb.tuple.ByteArrayUtil.join; -import static com.apple.cie.foundationdb.tuple.ByteArrayUtil.printable; +import static com.apple.foundationdb.tuple.ByteArrayUtil.join; +import static com.apple.foundationdb.tuple.ByteArrayUtil.printable; import java.util.Arrays; -import com.apple.cie.foundationdb.Range; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.Range; +import com.apple.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.tuple.Tuple; /** * {@code Subspace} provide a convenient way to use {@link Tuple}s to define namespaces for @@ -110,6 +110,9 @@ public class Subspace } /** + * Create a human-readable string representation of this subspace. This is + * really only useful for debugging purposes, but it includes information + * on what raw prefix the subspace is using. * @return a printable representation of the subspace */ @Override @@ -117,6 +120,16 @@ public class Subspace return "Subspace(rawPrefix=" + printable(rawPrefix) + ")"; } + /** + * Returns a hash-table compatible hash of this subspace. This is based off + * of the hash of the underlying byte-array prefix. + * @return a hash of this subspace + */ + @Override + public int hashCode() { + return Arrays.hashCode(rawPrefix); + } + /** * Gets a new subspace which is equivalent to this subspace with its prefix {@link Tuple} extended by * the specified {@code Object}. The object will be inserted into a {@link Tuple} and passed to {@link #get(Tuple)}. diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/subspace/package-info.java b/bindings/java/src-completable/main/com/apple/foundationdb/subspace/package-info.java similarity index 96% rename from bindings/java/src/main/com/apple/cie/foundationdb/subspace/package-info.java rename to bindings/java/src-completable/main/com/apple/foundationdb/subspace/package-info.java index b632c787d9..29264626de 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/subspace/package-info.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/subspace/package-info.java @@ -30,4 +30,4 @@ * subspace documentation for information about how subspaces work and * interact with other parts of the built-in keyspace management features. */ -package com.apple.cie.foundationdb.subspace; \ No newline at end of file +package com.apple.foundationdb.subspace; \ No newline at end of file diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/tuple/ByteArrayUtil.java b/bindings/java/src-completable/main/com/apple/foundationdb/tuple/ByteArrayUtil.java similarity index 97% rename from bindings/java/src/main/com/apple/cie/foundationdb/tuple/ByteArrayUtil.java rename to bindings/java/src-completable/main/com/apple/foundationdb/tuple/ByteArrayUtil.java index 2257ae997d..0770d1284b 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/tuple/ByteArrayUtil.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/tuple/ByteArrayUtil.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.tuple; +package com.apple.foundationdb.tuple; import java.math.BigInteger; import java.nio.ByteBuffer; @@ -27,7 +27,7 @@ import java.util.Arrays; import java.util.LinkedList; import java.util.List; -import com.apple.cie.foundationdb.Transaction; +import com.apple.foundationdb.Transaction; /** * Utility functions for operating on byte arrays. Although built for @@ -368,12 +368,12 @@ public class ByteArrayUtil { /** * Encode an 64-bit integer (long) into a byte array. Encodes the integer in little * endian byte order. The result is valid for use with - * {@link Transaction#mutate(com.apple.cie.foundationdb.MutationType, byte[], byte[]) Transaction.mutate(...)}. + * {@link Transaction#mutate(com.apple.foundationdb.MutationType, byte[], byte[]) Transaction.mutate(...)}. * * @param i the number to encode * @return an 8-byte array containing the * - * @see Transaction#mutate(com.apple.cie.foundationdb.MutationType, byte[], byte[]) + * @see Transaction#mutate(com.apple.foundationdb.MutationType, byte[], byte[]) */ public static byte[] encodeInt(long i) { return ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN).putLong(i).array(); diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/tuple/IterableComparator.java b/bindings/java/src-completable/main/com/apple/foundationdb/tuple/IterableComparator.java similarity index 98% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/tuple/IterableComparator.java rename to bindings/java/src-completable/main/com/apple/foundationdb/tuple/IterableComparator.java index d09bf976de..270c29c05e 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/tuple/IterableComparator.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/tuple/IterableComparator.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.tuple; +package com.apple.foundationdb.tuple; import java.util.Comparator; import java.util.Iterator; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/tuple/Tuple.java b/bindings/java/src-completable/main/com/apple/foundationdb/tuple/Tuple.java similarity index 99% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/tuple/Tuple.java rename to bindings/java/src-completable/main/com/apple/foundationdb/tuple/Tuple.java index a09a150aa6..ef632618e9 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/tuple/Tuple.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/tuple/Tuple.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.tuple; +package com.apple.foundationdb.tuple; import java.math.BigInteger; import java.util.ArrayList; @@ -32,7 +32,7 @@ import java.util.UUID; import java.util.stream.Collectors; import java.util.stream.Stream; -import com.apple.cie.foundationdb.Range; +import com.apple.foundationdb.Range; /** * Represents a set of elements that make up a sortable, typed key. This object diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/tuple/TupleUtil.java b/bindings/java/src-completable/main/com/apple/foundationdb/tuple/TupleUtil.java similarity index 99% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/tuple/TupleUtil.java rename to bindings/java/src-completable/main/com/apple/foundationdb/tuple/TupleUtil.java index af611e0fd6..639a0a613d 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/tuple/TupleUtil.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/tuple/TupleUtil.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.tuple; +package com.apple.foundationdb.tuple; import java.math.BigInteger; import java.nio.ByteBuffer; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/tuple/package-info.java b/bindings/java/src-completable/main/com/apple/foundationdb/tuple/package-info.java similarity index 93% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/tuple/package-info.java rename to bindings/java/src-completable/main/com/apple/foundationdb/tuple/package-info.java index 3f1b37369a..e356ae7396 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/tuple/package-info.java +++ b/bindings/java/src-completable/main/com/apple/foundationdb/tuple/package-info.java @@ -20,10 +20,10 @@ /** * Provides a set of utilities for serializing and deserializing typed data - * for use in FoundationDB. When packed together into a {@link com.apple.cie.foundationdb.tuple.Tuple} + * for use in FoundationDB. When packed together into a {@link com.apple.foundationdb.tuple.Tuple} * this data is suitable for use as an index or organizational structure within FoundationDB * keyspace. See general Tuple * documentation for information about how Tuples sort and can be used to efficiently * model data. */ -package com.apple.cie.foundationdb.tuple; \ No newline at end of file +package com.apple.foundationdb.tuple; \ No newline at end of file diff --git a/bindings/java/src-completable/main/overview.html.in b/bindings/java/src-completable/main/overview.html.in index 131035a151..f9cd8db9a3 100644 --- a/bindings/java/src-completable/main/overview.html.in +++ b/bindings/java/src-completable/main/overview.html.in @@ -24,24 +24,24 @@ and add it to your classpath.

Getting started

To start using FoundationDB from Java, create an instance of the -{@link com.apple.cie.foundationdb.FDB FoundationDB API interface} with the version of the -API that you want to use (this release of the FoundationDB Java API supports only version {@code 500}). -With this API object you can then open {@link com.apple.cie.foundationdb.Cluster Cluster}s and -{@link com.apple.cie.foundationdb.Database Database}s and start using -{@link com.apple.cie.foundationdb.Transaction Transactions}s. +{@link com.apple.foundationdb.FDB FoundationDB API interface} with the version of the +API that you want to use (this release of the FoundationDB Java API supports versions between {@code 500} and {@code 510}). +With this API object you can then open {@link com.apple.foundationdb.Cluster Cluster}s and +{@link com.apple.foundationdb.Database Database}s and start using +{@link com.apple.foundationdb.Transaction Transactions}s. Here we give an example. The example relies on a cluster file at the default location for your platform and a running server.

 {@code
-import com.apple.cie.foundationdb.*;
+import com.apple.foundationdb.*;
 import Function;
 import Tuple;
 
 public class Example {
   public static void main(String[] args) {
-    FDB fdb = FDB.selectAPIVersion(500);
+    FDB fdb = FDB.selectAPIVersion(510);
     Database db = fdb.open();
 
     // Run an operation on the database
@@ -64,21 +64,21 @@ public class Example {
 }
 }
 
-

FoundationDB {@link com.apple.cie.foundationdb.tuple Tuple API}

-The {@link com.apple.cie.foundationdb.tuple Tuple API} is provided with the core Java API for FoundationDB. +

FoundationDB {@link com.apple.foundationdb.tuple Tuple API}

+The {@link com.apple.foundationdb.tuple Tuple API} is provided with the core Java API for FoundationDB. This layer is provided in some form in all official language bindings. It enables cross-language support for storing and retrieving typed data from the binary data that FoundationDB supports. And, just as importantly, data packed into {@code Tuple}s and used as keys sort in predictable and useful ways. See the -{@link com.apple.cie.foundationdb.tuple Tuple class documentation} for information about use in Java +{@link com.apple.foundationdb.tuple Tuple class documentation} for information about use in Java and general Tuple documentation for information about how Tuples sort and can be used to efficiently model data.
-

FoundationDB {@link com.apple.cie.foundationdb.directory Directory API}

-The {@link com.apple.cie.foundationdb.directory Directory API} is provided with the core +

FoundationDB {@link com.apple.foundationdb.directory Directory API}

+The {@link com.apple.foundationdb.directory Directory API} is provided with the core Java API for FoundationDB. This layer is provided in some form in all official language bindings. The FoundationDB API provides directories as a tool for -managing related {@link com.apple.cie.foundationdb.subspace.Subspace Subspace}s. Directories are a +managing related {@link com.apple.foundationdb.subspace.Subspace Subspace}s. Directories are a recommended approach for administering applications. Each application should create or open at least one directory to manage its subspaces. Directories are identified by hierarchical paths analogous to the paths in a Unix-like file system. diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/AbstractTester.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/AbstractTester.java similarity index 95% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/AbstractTester.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/AbstractTester.java index 2ef9abb340..4a7f3f393a 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/AbstractTester.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/AbstractTester.java @@ -18,16 +18,16 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; import java.nio.charset.Charset; import java.util.Random; public abstract class AbstractTester { - public static final int API_VERSION = 500; + public static final int API_VERSION = 510; protected static final int NUM_RUNS = 25; protected static final Charset ASCII = Charset.forName("ASCII"); diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/AsyncDirectoryExtension.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/AsyncDirectoryExtension.java similarity index 96% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/AsyncDirectoryExtension.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/AsyncDirectoryExtension.java index 1281b63ddb..198f2d7c16 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/AsyncDirectoryExtension.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/AsyncDirectoryExtension.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.ArrayList; import java.util.Arrays; @@ -27,15 +27,15 @@ import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.function.Function; -import com.apple.cie.foundationdb.Range; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.async.AsyncUtil; -import com.apple.cie.foundationdb.directory.Directory; -import com.apple.cie.foundationdb.directory.DirectoryLayer; -import com.apple.cie.foundationdb.directory.DirectorySubspace; -import com.apple.cie.foundationdb.subspace.Subspace; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.Range; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.async.AsyncUtil; +import com.apple.foundationdb.directory.Directory; +import com.apple.foundationdb.directory.DirectoryLayer; +import com.apple.foundationdb.directory.DirectorySubspace; +import com.apple.foundationdb.subspace.Subspace; +import com.apple.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.tuple.Tuple; class AsyncDirectoryExtension { List dirList = new ArrayList(); diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/AsyncPerformanceTester.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/AsyncPerformanceTester.java similarity index 95% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/AsyncPerformanceTester.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/AsyncPerformanceTester.java index d47e516429..dcecfdeff1 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/AsyncPerformanceTester.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/AsyncPerformanceTester.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; public class AsyncPerformanceTester { diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/AsyncStackTester.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/AsyncStackTester.java similarity index 97% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/AsyncStackTester.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/AsyncStackTester.java index a2e30863f5..eee191c995 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/AsyncStackTester.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/AsyncStackTester.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.math.BigInteger; import java.util.*; @@ -28,21 +28,21 @@ import java.nio.ByteOrder; import java.util.concurrent.CompletableFuture; import java.util.function.Function; -import com.apple.cie.foundationdb.Cluster; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.FDBException; -import com.apple.cie.foundationdb.KeySelector; -import com.apple.cie.foundationdb.KeyValue; -import com.apple.cie.foundationdb.MutationType; -import com.apple.cie.foundationdb.Range; -import com.apple.cie.foundationdb.ReadTransaction; -import com.apple.cie.foundationdb.StreamingMode; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.async.AsyncIterable; -import com.apple.cie.foundationdb.async.AsyncUtil; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.Cluster; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.FDBException; +import com.apple.foundationdb.KeySelector; +import com.apple.foundationdb.KeyValue; +import com.apple.foundationdb.MutationType; +import com.apple.foundationdb.Range; +import com.apple.foundationdb.ReadTransaction; +import com.apple.foundationdb.StreamingMode; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.async.AsyncIterable; +import com.apple.foundationdb.async.AsyncUtil; +import com.apple.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.tuple.Tuple; public class AsyncStackTester { static final String DIRECTORY_PREFIX = "DIRECTORY_"; @@ -593,6 +593,8 @@ public class AsyncStackTester { tr.options().setMaxRetryDelay(100); tr.options().setUsedDuringCommitProtectionDisable(); tr.options().setTransactionLoggingEnable("my_transaction"); + tr.options().setReadLockAware(); + tr.options().setLockAware(); if(!(new FDBException("Fake", 1020)).isRetryable() || (new FDBException("Fake", 10)).isRetryable()) diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/BlockingBenchmark.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/BlockingBenchmark.java similarity index 95% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/BlockingBenchmark.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/BlockingBenchmark.java index 4a6fd88130..8196d059b1 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/BlockingBenchmark.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/BlockingBenchmark.java @@ -18,22 +18,22 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.ArrayList; import java.util.concurrent.CompletableFuture; import java.util.function.Function; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.Transaction; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.Transaction; public class BlockingBenchmark { private static final int REPS = 100000; private static final int PARALLEL = 100; public static void main(String[] args) throws InterruptedException { - FDB fdb = FDB.selectAPIVersion(500); + FDB fdb = FDB.selectAPIVersion(510); // The cluster file DOES NOT need to be valid, although it must exist. // This is because the database is never really contacted in this test. diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/ConcurrentGetSetGet.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/ConcurrentGetSetGet.java similarity index 94% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/ConcurrentGetSetGet.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/ConcurrentGetSetGet.java index fc86ae6cc9..e8cb0fd602 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/ConcurrentGetSetGet.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/ConcurrentGetSetGet.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.nio.charset.Charset; import java.security.SecureRandom; @@ -28,9 +28,9 @@ import java.util.concurrent.Semaphore; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.Transaction; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.Transaction; public class ConcurrentGetSetGet { public static final Charset UTF8 = Charset.forName("UTF-8"); @@ -51,7 +51,7 @@ public class ConcurrentGetSetGet { } public static void main(String[] args) { - Database database = FDB.selectAPIVersion(500).open(); + Database database = FDB.selectAPIVersion(510).open(); new ConcurrentGetSetGet().apply(database); } diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/Context.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/Context.java similarity index 91% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/Context.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/Context.java index 275061f683..c955329949 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/Context.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/Context.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.HashMap; import java.util.LinkedList; @@ -29,14 +29,14 @@ import java.util.concurrent.CompletableFuture; import java.util.function.BiConsumer; import java.util.function.Function; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDBException; -import com.apple.cie.foundationdb.KeySelector; -import com.apple.cie.foundationdb.Range; -import com.apple.cie.foundationdb.StreamingMode; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDBException; +import com.apple.foundationdb.KeySelector; +import com.apple.foundationdb.Range; +import com.apple.foundationdb.StreamingMode; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.tuple.Tuple; abstract class Context implements Runnable { final Stack stack = new Stack(); diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/ContinuousSample.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/ContinuousSample.java similarity index 98% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/ContinuousSample.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/ContinuousSample.java index d1550b33ac..3602eb6e30 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/ContinuousSample.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/ContinuousSample.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.ArrayList; import java.util.Collections; diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/DirectoryExtension.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/DirectoryExtension.java similarity index 95% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/DirectoryExtension.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/DirectoryExtension.java index 12339e6c81..94859f5444 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/DirectoryExtension.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/DirectoryExtension.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.ArrayList; import java.util.Arrays; @@ -26,13 +26,13 @@ import java.util.List; import java.util.concurrent.CompletableFuture; -import com.apple.cie.foundationdb.Range; -import com.apple.cie.foundationdb.directory.Directory; -import com.apple.cie.foundationdb.directory.DirectoryLayer; -import com.apple.cie.foundationdb.directory.DirectorySubspace; -import com.apple.cie.foundationdb.subspace.Subspace; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.Range; +import com.apple.foundationdb.directory.Directory; +import com.apple.foundationdb.directory.DirectoryLayer; +import com.apple.foundationdb.directory.DirectorySubspace; +import com.apple.foundationdb.subspace.Subspace; +import com.apple.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.tuple.Tuple; class DirectoryExtension { List dirList = new ArrayList(); diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/DirectoryOperation.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/DirectoryOperation.java similarity index 97% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/DirectoryOperation.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/DirectoryOperation.java index 70b28051a3..0592141239 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/DirectoryOperation.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/DirectoryOperation.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; enum DirectoryOperation { DIRECTORY_CREATE_SUBSPACE(true), diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/DirectoryTest.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/DirectoryTest.java similarity index 84% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/DirectoryTest.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/DirectoryTest.java index d22f939a53..0832fcc9ce 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/DirectoryTest.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/DirectoryTest.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.ArrayList; import java.util.Arrays; @@ -26,20 +26,20 @@ import java.util.List; import java.util.function.Function; -import com.apple.cie.foundationdb.Cluster; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.TransactionContext; -import com.apple.cie.foundationdb.directory.DirectoryLayer; -import com.apple.cie.foundationdb.directory.DirectorySubspace; +import com.apple.foundationdb.Cluster; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.TransactionContext; +import com.apple.foundationdb.directory.DirectoryLayer; +import com.apple.foundationdb.directory.DirectorySubspace; public class DirectoryTest { private static final String CLUSTER_FILE = "/home/ajb/fdb.cluster"; public static void main(String[] args) throws Exception { try { - Cluster c = FDB.selectAPIVersion(500).createCluster(CLUSTER_FILE); + Cluster c = FDB.selectAPIVersion(510).createCluster(CLUSTER_FILE); Database db = c.openDatabase(); runTests(db); } catch(Throwable t) { diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/DirectoryUtil.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/DirectoryUtil.java similarity index 96% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/DirectoryUtil.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/DirectoryUtil.java index e5385a75ae..7ea1bf0f50 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/DirectoryUtil.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/DirectoryUtil.java @@ -18,15 +18,15 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.function.Function; -import com.apple.cie.foundationdb.async.AsyncUtil; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.async.AsyncUtil; +import com.apple.foundationdb.tuple.Tuple; class DirectoryUtil { private static class TuplePopper { diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/Example.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/Example.java similarity index 85% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/Example.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/Example.java index 73e0ea9c6f..eb7d648bf6 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/Example.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/Example.java @@ -18,19 +18,19 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.concurrent.ExecutionException; import java.util.function.Function; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.tuple.Tuple; public class Example { public static void main(String[] args) throws ExecutionException, InterruptedException { - FDB fdb = FDB.selectAPIVersion(500); + FDB fdb = FDB.selectAPIVersion(510); Database db = fdb.open(); // Run an operation on the database diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/Instruction.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/Instruction.java similarity index 90% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/Instruction.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/Instruction.java index 82adf957d2..074be963c2 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/Instruction.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/Instruction.java @@ -18,16 +18,16 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.concurrent.CompletableFuture; import java.util.function.Function; -import com.apple.cie.foundationdb.ReadTransaction; -import com.apple.cie.foundationdb.ReadTransactionContext; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.TransactionContext; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.ReadTransaction; +import com.apple.foundationdb.ReadTransactionContext; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.TransactionContext; +import com.apple.foundationdb.tuple.Tuple; import java.util.List; diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/IterableTest.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/IterableTest.java similarity index 84% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/IterableTest.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/IterableTest.java index 4c00d04e9a..f3cf2c2d65 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/IterableTest.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/IterableTest.java @@ -18,17 +18,17 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; -import com.apple.cie.foundationdb.Cluster; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.KeyValue; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.TransactionContext; +import com.apple.foundationdb.Cluster; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.KeyValue; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.TransactionContext; public class IterableTest { private static final String CLUSTER_FILE = "C:\\Users\\Ben\\workspace\\fdb\\fdb.cluster"; @@ -36,7 +36,7 @@ public class IterableTest { public static void main(String[] args) throws InterruptedException { final int reps = 1000; try { - Cluster cluster = FDB.selectAPIVersion(500).createCluster(CLUSTER_FILE); + Cluster cluster = FDB.selectAPIVersion(510).createCluster(CLUSTER_FILE); Database db = cluster.openDatabase(); runTests(reps, db); } catch(Throwable t) { diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/LocalityTests.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/LocalityTests.java similarity index 79% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/LocalityTests.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/LocalityTests.java index c5e6a15cc6..2ffeb532b6 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/LocalityTests.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/LocalityTests.java @@ -18,23 +18,23 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.List; import java.util.concurrent.CompletableFuture; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.LocalityUtil; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.async.AsyncIterable; -import com.apple.cie.foundationdb.async.AsyncUtil; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.LocalityUtil; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.async.AsyncIterable; +import com.apple.foundationdb.async.AsyncUtil; +import com.apple.foundationdb.tuple.ByteArrayUtil; public class LocalityTests { public static void main(String[] args) { - FDB fdb = FDB.selectAPIVersion(500); + FDB fdb = FDB.selectAPIVersion(510); Database database = fdb.open(args[0]); { Transaction tr = database.createTransaction(); diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/ParallelRandomScan.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/ParallelRandomScan.java similarity index 89% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/ParallelRandomScan.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/ParallelRandomScan.java index fda877ac27..bee8dbfaf5 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/ParallelRandomScan.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/ParallelRandomScan.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.nio.ByteBuffer; import java.util.Random; @@ -28,14 +28,14 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.function.BiConsumer; import java.util.function.Function; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.KeyValue; -import com.apple.cie.foundationdb.StreamingMode; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.async.AsyncIterable; -import com.apple.cie.foundationdb.async.AsyncIterator; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.KeyValue; +import com.apple.foundationdb.StreamingMode; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.async.AsyncIterable; +import com.apple.foundationdb.async.AsyncIterator; +import com.apple.foundationdb.tuple.ByteArrayUtil; public class ParallelRandomScan { private static final int ROWS = 1000000; @@ -45,7 +45,7 @@ public class ParallelRandomScan { private static final int PARALLELISM_STEP = 5; public static void main(String[] args) throws InterruptedException { - FDB api = FDB.selectAPIVersion(500); + FDB api = FDB.selectAPIVersion(510); Database database = api.open(args[0]); for(int i = PARALLELISM_MIN; i <= PARALLELISM_MAX; i += PARALLELISM_STEP) { diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/PerformanceTester.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/PerformanceTester.java similarity index 97% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/PerformanceTester.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/PerformanceTester.java index 97ae836ae1..5f604d22f5 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/PerformanceTester.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/PerformanceTester.java @@ -18,14 +18,14 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.KeySelector; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.TransactionContext; -import com.apple.cie.foundationdb.async.AsyncUtil; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.KeySelector; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.TransactionContext; +import com.apple.foundationdb.async.AsyncUtil; +import com.apple.foundationdb.tuple.ByteArrayUtil; import java.util.ArrayList; import java.util.Arrays; diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/RYWBenchmark.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/RYWBenchmark.java similarity index 97% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/RYWBenchmark.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/RYWBenchmark.java index 5b090b6328..501848a52c 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/RYWBenchmark.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/RYWBenchmark.java @@ -18,11 +18,11 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.tuple.ByteArrayUtil; import java.util.*; import java.util.function.Function; diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/RangeTest.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/RangeTest.java similarity index 93% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/RangeTest.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/RangeTest.java index 5474f4b2d1..6a8e2f4ce5 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/RangeTest.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/RangeTest.java @@ -18,23 +18,23 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.List; import java.util.concurrent.CompletionException; import java.util.function.Function; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.FDBException; -import com.apple.cie.foundationdb.KeySelector; -import com.apple.cie.foundationdb.KeyValue; -import com.apple.cie.foundationdb.Range; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.async.AsyncIterable; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.FDBException; +import com.apple.foundationdb.KeySelector; +import com.apple.foundationdb.KeyValue; +import com.apple.foundationdb.Range; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.async.AsyncIterable; public class RangeTest { - private static final int API_VERSION = 500; + private static final int API_VERSION = 510; public static void main(String[] args) { System.out.println("About to use version " + API_VERSION); diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/SerialInsertion.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/SerialInsertion.java similarity index 92% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/SerialInsertion.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/SerialInsertion.java index e9b32954a7..dde5606544 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/SerialInsertion.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/SerialInsertion.java @@ -18,15 +18,15 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.Transaction; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.Transaction; public class SerialInsertion { private static final int THREAD_COUNT = 10; @@ -34,7 +34,7 @@ public class SerialInsertion { private static final int NODES = 1000000; public static void main(String[] args) { - FDB api = FDB.selectAPIVersion(500); + FDB api = FDB.selectAPIVersion(510); Database database = api.open("T:\\circus\\tags\\RebarCluster-bbc\\cluster_id.txt"); long start = System.currentTimeMillis(); diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/SerialIteration.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/SerialIteration.java similarity index 89% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/SerialIteration.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/SerialIteration.java index fac1c93ca7..445f998edd 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/SerialIteration.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/SerialIteration.java @@ -18,20 +18,20 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; import java.util.Random; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.KeyValue; -import com.apple.cie.foundationdb.ReadTransaction; -import com.apple.cie.foundationdb.StreamingMode; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.async.AsyncIterable; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.KeyValue; +import com.apple.foundationdb.ReadTransaction; +import com.apple.foundationdb.StreamingMode; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.async.AsyncIterable; public class SerialIteration { private static final int ROWS = 1000000; @@ -39,7 +39,7 @@ public class SerialIteration { private static final int THREAD_COUNT = 1; public static void main(String[] args) throws InterruptedException { - FDB api = FDB.selectAPIVersion(500); + FDB api = FDB.selectAPIVersion(510); Database database = api.open(args[0]); for(int i = 1; i <= THREAD_COUNT; i++) { diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/SerialTest.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/SerialTest.java similarity index 87% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/SerialTest.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/SerialTest.java index 992461ac38..48ead15d57 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/SerialTest.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/SerialTest.java @@ -18,16 +18,16 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; -import com.apple.cie.foundationdb.Cluster; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.TransactionContext; +import com.apple.foundationdb.Cluster; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.TransactionContext; public class SerialTest { @@ -36,7 +36,7 @@ public class SerialTest { public static void main(String[] args) throws InterruptedException { final int reps = 1000; try { - Cluster c = FDB.selectAPIVersion(500).createCluster(CLUSTER_FILE); + Cluster c = FDB.selectAPIVersion(510).createCluster(CLUSTER_FILE); Database db = c.openDatabase(); runTests(reps, db); diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/Stack.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/Stack.java similarity index 96% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/Stack.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/Stack.java index ee3bfe0521..d7d75d4f9d 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/Stack.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/Stack.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; class Stack { java.util.Stack stack = new java.util.Stack(); diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/StackEntry.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/StackEntry.java similarity index 95% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/StackEntry.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/StackEntry.java index 1b6ff36634..a9f1f11cef 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/StackEntry.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/StackEntry.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; class StackEntry { int idx; diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/StackOperation.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/StackOperation.java similarity index 97% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/StackOperation.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/StackOperation.java index fc81d9104a..71aa52d33c 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/StackOperation.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/StackOperation.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; enum StackOperation { PUSH, diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/StackTester.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/StackTester.java similarity index 97% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/StackTester.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/StackTester.java index 63a4cc52e3..75dfc52676 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/StackTester.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/StackTester.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.math.BigInteger; import java.util.*; @@ -29,20 +29,20 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; import java.util.function.Function; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.FDBException; -import com.apple.cie.foundationdb.KeySelector; -import com.apple.cie.foundationdb.KeyValue; -import com.apple.cie.foundationdb.LocalityUtil; -import com.apple.cie.foundationdb.MutationType; -import com.apple.cie.foundationdb.Range; -import com.apple.cie.foundationdb.ReadTransaction; -import com.apple.cie.foundationdb.StreamingMode; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.async.AsyncIterable; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.FDBException; +import com.apple.foundationdb.KeySelector; +import com.apple.foundationdb.KeyValue; +import com.apple.foundationdb.LocalityUtil; +import com.apple.foundationdb.MutationType; +import com.apple.foundationdb.Range; +import com.apple.foundationdb.ReadTransaction; +import com.apple.foundationdb.StreamingMode; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.async.AsyncIterable; +import com.apple.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.tuple.Tuple; /** * Implements a cross-binding test of the FoundationDB API. @@ -408,6 +408,8 @@ public class StackTester { tr.options().setMaxRetryDelay(100); tr.options().setUsedDuringCommitProtectionDisable(); tr.options().setTransactionLoggingEnable("my_transaction"); + tr.options().setReadLockAware(); + tr.options().setLockAware(); if(!(new FDBException("Fake", 1020)).isRetryable() || (new FDBException("Fake", 10)).isRetryable()) diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/StackUtils.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/StackUtils.java similarity index 93% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/StackUtils.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/StackUtils.java index 502653b71a..5da664d60d 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/StackUtils.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/StackUtils.java @@ -18,17 +18,17 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.math.BigInteger; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; -import com.apple.cie.foundationdb.FDBException; -import com.apple.cie.foundationdb.KeySelector; -import com.apple.cie.foundationdb.async.AsyncUtil; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.FDBException; +import com.apple.foundationdb.KeySelector; +import com.apple.foundationdb.async.AsyncUtil; +import com.apple.foundationdb.tuple.Tuple; public class StackUtils { diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/TestResult.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/TestResult.java similarity index 99% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/TestResult.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/TestResult.java index 2ea112d50f..714fdfd116 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/TestResult.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/TestResult.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.io.BufferedWriter; import java.io.FileWriter; diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/TesterArgs.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/TesterArgs.java similarity index 97% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/TesterArgs.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/TesterArgs.java index a2b27457b2..20bacc0757 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/TesterArgs.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/TesterArgs.java @@ -18,10 +18,10 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; -import com.apple.cie.foundationdb.subspace.Subspace; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.subspace.Subspace; +import com.apple.foundationdb.tuple.Tuple; import java.util.ArrayList; import java.util.Arrays; @@ -106,7 +106,7 @@ public class TesterArgs { for (j = i + 1; j < args.length && args[j].charAt(0) != '-'; j++) { testsToRun.add(args[j]); } - i = j; + i = j - 1; } else { System.out.println("No tests specified with argument " + arg + "\n"); printUsage(); diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/TupleTest.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/TupleTest.java similarity index 84% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/TupleTest.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/TupleTest.java index 7ff1d877c0..3946cbf9be 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/TupleTest.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/TupleTest.java @@ -18,16 +18,16 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.function.Function; -import com.apple.cie.foundationdb.Cluster; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.TransactionContext; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.Cluster; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.TransactionContext; +import com.apple.foundationdb.tuple.Tuple; public class TupleTest { private static final String CLUSTER_FILE = "C:\\Users\\Ben\\workspace\\fdb\\fdb.cluster"; @@ -35,7 +35,7 @@ public class TupleTest { public static void main(String[] args) throws InterruptedException { final int reps = 1000; try { - Cluster c = FDB.selectAPIVersion(500).createCluster(CLUSTER_FILE); + Cluster c = FDB.selectAPIVersion(510).createCluster(CLUSTER_FILE); Database db = c.openDatabase(); runTests(reps, db); } catch(Throwable t) { diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/WatchTest.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/WatchTest.java similarity index 92% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/WatchTest.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/WatchTest.java index cae1a923f7..cf1d9e63c1 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/WatchTest.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/WatchTest.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.Random; import java.util.concurrent.CompletableFuture; @@ -26,15 +26,15 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.FDBException; -import com.apple.cie.foundationdb.Transaction; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.FDBException; +import com.apple.foundationdb.Transaction; public class WatchTest { public static void main(String[] args) { - FDB fdb = FDB.selectAPIVersion(500); + FDB fdb = FDB.selectAPIVersion(510); Database database = fdb.open(args[0]); database.options().setLocationCacheSize(42); Transaction tr = database.createTransaction(); diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/WhileTrueTest.java b/bindings/java/src-completable/test/com/apple/foundationdb/test/WhileTrueTest.java similarity index 93% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/WhileTrueTest.java rename to bindings/java/src-completable/test/com/apple/foundationdb/test/WhileTrueTest.java index e71f8c0fab..887051383f 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/WhileTrueTest.java +++ b/bindings/java/src-completable/test/com/apple/foundationdb/test/WhileTrueTest.java @@ -18,9 +18,9 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; -import com.apple.cie.foundationdb.async.AsyncUtil; +import com.apple.foundationdb.async.AsyncUtil; import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicInteger; diff --git a/bindings/java/src/junit/com/apple/cie/foundationdb/tuple/AllTests.java b/bindings/java/src/junit/com/apple/foundationdb/tuple/AllTests.java similarity index 95% rename from bindings/java/src/junit/com/apple/cie/foundationdb/tuple/AllTests.java rename to bindings/java/src/junit/com/apple/foundationdb/tuple/AllTests.java index 8be6513092..bc15ca7e45 100644 --- a/bindings/java/src/junit/com/apple/cie/foundationdb/tuple/AllTests.java +++ b/bindings/java/src/junit/com/apple/foundationdb/tuple/AllTests.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.tuple; +package com.apple.foundationdb.tuple; import org.junit.runner.RunWith; import org.junit.runners.Suite; diff --git a/bindings/java/src/junit/com/apple/cie/foundationdb/tuple/ArrayUtilTests.java b/bindings/java/src/junit/com/apple/foundationdb/tuple/ArrayUtilTests.java similarity index 98% rename from bindings/java/src/junit/com/apple/cie/foundationdb/tuple/ArrayUtilTests.java rename to bindings/java/src/junit/com/apple/foundationdb/tuple/ArrayUtilTests.java index a984a6d9ef..5f6400fad9 100644 --- a/bindings/java/src/junit/com/apple/cie/foundationdb/tuple/ArrayUtilTests.java +++ b/bindings/java/src/junit/com/apple/foundationdb/tuple/ArrayUtilTests.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.tuple; +package com.apple.foundationdb.tuple; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; @@ -29,7 +29,7 @@ import static org.junit.Assert.fail; import java.util.ArrayList; import java.util.List; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.tuple.ByteArrayUtil; import org.junit.Test; /** diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/Cluster.java b/bindings/java/src/main/com/apple/foundationdb/Cluster.java similarity index 98% rename from bindings/java/src/main/com/apple/cie/foundationdb/Cluster.java rename to bindings/java/src/main/com/apple/foundationdb/Cluster.java index 19a579d57a..42003ba141 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/Cluster.java +++ b/bindings/java/src/main/com/apple/foundationdb/Cluster.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.nio.charset.Charset; import java.util.concurrent.Executor; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/Database.java b/bindings/java/src/main/com/apple/foundationdb/Database.java similarity index 98% rename from bindings/java/src/main/com/apple/cie/foundationdb/Database.java rename to bindings/java/src/main/com/apple/foundationdb/Database.java index c222f4e033..23bd90f481 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/Database.java +++ b/bindings/java/src/main/com/apple/foundationdb/Database.java @@ -18,12 +18,12 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; -import com.apple.cie.foundationdb.async.Function; -import com.apple.cie.foundationdb.async.Future; -import com.apple.cie.foundationdb.async.PartialFunction; -import com.apple.cie.foundationdb.async.PartialFuture; +import com.apple.foundationdb.async.Function; +import com.apple.foundationdb.async.Future; +import com.apple.foundationdb.async.PartialFunction; +import com.apple.foundationdb.async.PartialFuture; import java.util.concurrent.Executor; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/DefaultDisposableImpl.java b/bindings/java/src/main/com/apple/foundationdb/DefaultDisposableImpl.java similarity index 98% rename from bindings/java/src/main/com/apple/cie/foundationdb/DefaultDisposableImpl.java rename to bindings/java/src/main/com/apple/foundationdb/DefaultDisposableImpl.java index c7c0464447..6f1b366446 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/DefaultDisposableImpl.java +++ b/bindings/java/src/main/com/apple/foundationdb/DefaultDisposableImpl.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantReadWriteLock; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/Disposable.java b/bindings/java/src/main/com/apple/foundationdb/Disposable.java similarity index 96% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/Disposable.java rename to bindings/java/src/main/com/apple/foundationdb/Disposable.java index b1e211c013..7772065bd3 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/Disposable.java +++ b/bindings/java/src/main/com/apple/foundationdb/Disposable.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; /** * A FoundationDB object with native resources that can be freed. It is not mandatory to call diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/FDB.java b/bindings/java/src/main/com/apple/foundationdb/FDB.java similarity index 98% rename from bindings/java/src/main/com/apple/cie/foundationdb/FDB.java rename to bindings/java/src/main/com/apple/foundationdb/FDB.java index 3f652a4ab3..8fe6a535d6 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/FDB.java +++ b/bindings/java/src/main/com/apple/foundationdb/FDB.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; @@ -34,7 +34,7 @@ import java.util.concurrent.ThreadFactory; * This call is required before using any other part of the API. The call allows * an error to be thrown at this point to prevent client code from accessing a later library * with incorrect assumptions from the current version. The API version documented here is version - * {@code 500}.

+ * {@code 510}.

* FoundationDB encapsulates multiple versions of its interface by requiring * the client to explicitly specify the version of the API it uses. The purpose * of this design is to allow you to upgrade the server, client libraries, or @@ -157,15 +157,15 @@ public class FDB { } if(version < 500) throw new IllegalArgumentException("API version not supported (minimum 500)"); - if(version > 500) - throw new IllegalArgumentException("API version not supported (maximum 500)"); + if(version > 510) + throw new IllegalArgumentException("API version not supported (maximum 510)"); Select_API_version(version); return singleton = new FDB(version); } /** * Connects to the cluster specified by the - * default fdb.cluster file. + * default fdb.cluster file. * If the FoundationDB network has not been started, it will be started in the course of this call * as if {@link FDB#startNetwork()} had been called. * @@ -230,7 +230,7 @@ public class FDB { /** * Initializes networking, connects with the - * default fdb.cluster file, + * default fdb.cluster file, * and opens the database. * * @return a {@code Future} that will be set to a FoundationDB {@link Database} diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/FDBDatabase.java b/bindings/java/src/main/com/apple/foundationdb/FDBDatabase.java similarity index 96% rename from bindings/java/src/main/com/apple/cie/foundationdb/FDBDatabase.java rename to bindings/java/src/main/com/apple/foundationdb/FDBDatabase.java index 6eff53a0c9..5ef272349e 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/FDBDatabase.java +++ b/bindings/java/src/main/com/apple/foundationdb/FDBDatabase.java @@ -18,16 +18,16 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.Executor; import java.util.concurrent.atomic.AtomicReference; -import com.apple.cie.foundationdb.async.AsyncUtil; -import com.apple.cie.foundationdb.async.Function; -import com.apple.cie.foundationdb.async.Future; -import com.apple.cie.foundationdb.async.PartialFunction; -import com.apple.cie.foundationdb.async.PartialFuture; +import com.apple.foundationdb.async.AsyncUtil; +import com.apple.foundationdb.async.Function; +import com.apple.foundationdb.async.Future; +import com.apple.foundationdb.async.PartialFunction; +import com.apple.foundationdb.async.PartialFuture; class FDBDatabase extends DefaultDisposableImpl implements Database, Disposable, OptionConsumer { private Executor executor; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/FDBTransaction.java b/bindings/java/src/main/com/apple/foundationdb/FDBTransaction.java similarity index 97% rename from bindings/java/src/main/com/apple/cie/foundationdb/FDBTransaction.java rename to bindings/java/src/main/com/apple/foundationdb/FDBTransaction.java index a1b05380be..96c145c840 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/FDBTransaction.java +++ b/bindings/java/src/main/com/apple/foundationdb/FDBTransaction.java @@ -18,18 +18,18 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.Executor; -import com.apple.cie.foundationdb.async.*; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; -import com.apple.cie.foundationdb.async.AsyncIterable; -import com.apple.cie.foundationdb.async.AsyncUtil; -import com.apple.cie.foundationdb.async.Future; -import com.apple.cie.foundationdb.async.PartialFunction; -import com.apple.cie.foundationdb.async.PartialFuture; -import com.apple.cie.foundationdb.async.ReadyFuture; +import com.apple.foundationdb.async.*; +import com.apple.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.async.AsyncIterable; +import com.apple.foundationdb.async.AsyncUtil; +import com.apple.foundationdb.async.Future; +import com.apple.foundationdb.async.PartialFunction; +import com.apple.foundationdb.async.PartialFuture; +import com.apple.foundationdb.async.ReadyFuture; class FDBTransaction extends DefaultDisposableImpl implements Disposable, Transaction, OptionConsumer { private final Executor executor; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/FutureCluster.java b/bindings/java/src/main/com/apple/foundationdb/FutureCluster.java similarity index 96% rename from bindings/java/src/main/com/apple/cie/foundationdb/FutureCluster.java rename to bindings/java/src/main/com/apple/foundationdb/FutureCluster.java index 08cd8e44dd..e4c61cc74f 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/FutureCluster.java +++ b/bindings/java/src/main/com/apple/foundationdb/FutureCluster.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.Executor; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/FutureDatabase.java b/bindings/java/src/main/com/apple/foundationdb/FutureDatabase.java similarity index 96% rename from bindings/java/src/main/com/apple/cie/foundationdb/FutureDatabase.java rename to bindings/java/src/main/com/apple/foundationdb/FutureDatabase.java index 67bcedc6f0..ed5a1f92b6 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/FutureDatabase.java +++ b/bindings/java/src/main/com/apple/foundationdb/FutureDatabase.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.Executor; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/FutureKey.java b/bindings/java/src/main/com/apple/foundationdb/FutureKey.java similarity index 96% rename from bindings/java/src/main/com/apple/cie/foundationdb/FutureKey.java rename to bindings/java/src/main/com/apple/foundationdb/FutureKey.java index c0cf900694..853444a798 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/FutureKey.java +++ b/bindings/java/src/main/com/apple/foundationdb/FutureKey.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.Executor; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/FutureResult.java b/bindings/java/src/main/com/apple/foundationdb/FutureResult.java similarity index 96% rename from bindings/java/src/main/com/apple/cie/foundationdb/FutureResult.java rename to bindings/java/src/main/com/apple/foundationdb/FutureResult.java index fa9356059c..440250c9bb 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/FutureResult.java +++ b/bindings/java/src/main/com/apple/foundationdb/FutureResult.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.Executor; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/FutureResults.java b/bindings/java/src/main/com/apple/foundationdb/FutureResults.java similarity index 97% rename from bindings/java/src/main/com/apple/cie/foundationdb/FutureResults.java rename to bindings/java/src/main/com/apple/foundationdb/FutureResults.java index c1eef996d6..a900287a2e 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/FutureResults.java +++ b/bindings/java/src/main/com/apple/foundationdb/FutureResults.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.Executor; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/FutureStrings.java b/bindings/java/src/main/com/apple/foundationdb/FutureStrings.java similarity index 96% rename from bindings/java/src/main/com/apple/cie/foundationdb/FutureStrings.java rename to bindings/java/src/main/com/apple/foundationdb/FutureStrings.java index 2e934b12c1..3043683512 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/FutureStrings.java +++ b/bindings/java/src/main/com/apple/foundationdb/FutureStrings.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.Executor; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/FutureVersion.java b/bindings/java/src/main/com/apple/foundationdb/FutureVersion.java similarity index 96% rename from bindings/java/src/main/com/apple/cie/foundationdb/FutureVersion.java rename to bindings/java/src/main/com/apple/foundationdb/FutureVersion.java index 33591e6430..833e79cdc1 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/FutureVersion.java +++ b/bindings/java/src/main/com/apple/foundationdb/FutureVersion.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.Executor; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/FutureVoid.java b/bindings/java/src/main/com/apple/foundationdb/FutureVoid.java similarity index 97% rename from bindings/java/src/main/com/apple/cie/foundationdb/FutureVoid.java rename to bindings/java/src/main/com/apple/foundationdb/FutureVoid.java index 9ce80d76a0..5c6302c0e9 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/FutureVoid.java +++ b/bindings/java/src/main/com/apple/foundationdb/FutureVoid.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.concurrent.Executor; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/JNIUtil.java b/bindings/java/src/main/com/apple/foundationdb/JNIUtil.java similarity index 99% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/JNIUtil.java rename to bindings/java/src/main/com/apple/foundationdb/JNIUtil.java index fd310c7df8..cdb9d377ff 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/JNIUtil.java +++ b/bindings/java/src/main/com/apple/foundationdb/JNIUtil.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.io.File; import java.io.FileOutputStream; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/KeySelector.java b/bindings/java/src/main/com/apple/foundationdb/KeySelector.java similarity index 98% rename from bindings/java/src/main/com/apple/cie/foundationdb/KeySelector.java rename to bindings/java/src/main/com/apple/foundationdb/KeySelector.java index 31429c7639..7607d4888c 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/KeySelector.java +++ b/bindings/java/src/main/com/apple/foundationdb/KeySelector.java @@ -18,9 +18,9 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.tuple.ByteArrayUtil; /** * A {@code KeySelector} identifies a particular key in the database. FoundationDB's diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/KeyValue.java b/bindings/java/src/main/com/apple/foundationdb/KeyValue.java similarity index 98% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/KeyValue.java rename to bindings/java/src/main/com/apple/foundationdb/KeyValue.java index be034be2a5..c00e5e1256 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/KeyValue.java +++ b/bindings/java/src/main/com/apple/foundationdb/KeyValue.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.Arrays; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/LocalityUtil.java b/bindings/java/src/main/com/apple/foundationdb/LocalityUtil.java similarity index 95% rename from bindings/java/src/main/com/apple/cie/foundationdb/LocalityUtil.java rename to bindings/java/src/main/com/apple/foundationdb/LocalityUtil.java index 66394517c9..8319153a07 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/LocalityUtil.java +++ b/bindings/java/src/main/com/apple/foundationdb/LocalityUtil.java @@ -18,19 +18,19 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.nio.charset.Charset; import java.util.Arrays; import java.util.List; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; -import com.apple.cie.foundationdb.async.AsyncIterable; -import com.apple.cie.foundationdb.async.AsyncIterator; -import com.apple.cie.foundationdb.async.AsyncUtil; -import com.apple.cie.foundationdb.async.Function; -import com.apple.cie.foundationdb.async.Future; -import com.apple.cie.foundationdb.async.ReadyFuture; +import com.apple.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.async.AsyncIterable; +import com.apple.foundationdb.async.AsyncIterator; +import com.apple.foundationdb.async.AsyncUtil; +import com.apple.foundationdb.async.Function; +import com.apple.foundationdb.async.Future; +import com.apple.foundationdb.async.ReadyFuture; /** * The FoundationDB API comes with a set of functions for discovering the diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/NativeFuture.java b/bindings/java/src/main/com/apple/foundationdb/NativeFuture.java similarity index 98% rename from bindings/java/src/main/com/apple/cie/foundationdb/NativeFuture.java rename to bindings/java/src/main/com/apple/foundationdb/NativeFuture.java index 577d39d7f1..618783d20e 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/NativeFuture.java +++ b/bindings/java/src/main/com/apple/foundationdb/NativeFuture.java @@ -18,14 +18,14 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.io.IOException; import java.nio.channels.AsynchronousCloseException; import java.nio.channels.spi.AbstractInterruptibleChannel; import java.util.concurrent.Executor; -import com.apple.cie.foundationdb.async.AbstractFuture; +import com.apple.foundationdb.async.AbstractFuture; abstract class NativeFuture extends AbstractFuture { protected final long cPtr; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/OptionConsumer.java b/bindings/java/src/main/com/apple/foundationdb/OptionConsumer.java similarity index 97% rename from bindings/java/src/main/com/apple/cie/foundationdb/OptionConsumer.java rename to bindings/java/src/main/com/apple/foundationdb/OptionConsumer.java index 4d0c398f4d..1f7a01b9a5 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/OptionConsumer.java +++ b/bindings/java/src/main/com/apple/foundationdb/OptionConsumer.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; /** * An object on which encoded options can be set. Rarely used outside of diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/OptionsSet.java b/bindings/java/src/main/com/apple/foundationdb/OptionsSet.java similarity index 98% rename from bindings/java/src/main/com/apple/cie/foundationdb/OptionsSet.java rename to bindings/java/src/main/com/apple/foundationdb/OptionsSet.java index d5a8b0d702..8aac7dc13c 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/OptionsSet.java +++ b/bindings/java/src/main/com/apple/foundationdb/OptionsSet.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.nio.ByteBuffer; import java.nio.ByteOrder; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/Range.java b/bindings/java/src/main/com/apple/foundationdb/Range.java similarity index 97% rename from bindings/java/src/main/com/apple/cie/foundationdb/Range.java rename to bindings/java/src/main/com/apple/foundationdb/Range.java index 6a0b091f8d..bb2c460bd3 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/Range.java +++ b/bindings/java/src/main/com/apple/foundationdb/Range.java @@ -18,11 +18,11 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.Arrays; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.tuple.ByteArrayUtil; /** * A simple description of an exact range of keyspace, specified by a begin and end key. As with diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/RangeQuery.java b/bindings/java/src/main/com/apple/foundationdb/RangeQuery.java similarity index 97% rename from bindings/java/src/main/com/apple/cie/foundationdb/RangeQuery.java rename to bindings/java/src/main/com/apple/foundationdb/RangeQuery.java index d09a863fa7..1119d0b097 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/RangeQuery.java +++ b/bindings/java/src/main/com/apple/foundationdb/RangeQuery.java @@ -18,16 +18,16 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.List; import java.util.NoSuchElementException; import java.util.concurrent.CancellationException; -import com.apple.cie.foundationdb.async.*; -import com.apple.cie.foundationdb.async.AsyncIterable; -import com.apple.cie.foundationdb.async.Function; -import com.apple.cie.foundationdb.async.Future; +import com.apple.foundationdb.async.*; +import com.apple.foundationdb.async.AsyncIterable; +import com.apple.foundationdb.async.Function; +import com.apple.foundationdb.async.Future; /** * Represents a query against FoundationDB for a range of keys. The diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/RangeResult.java b/bindings/java/src/main/com/apple/foundationdb/RangeResult.java similarity index 97% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/RangeResult.java rename to bindings/java/src/main/com/apple/foundationdb/RangeResult.java index 92d2e98431..5960e9328e 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/RangeResult.java +++ b/bindings/java/src/main/com/apple/foundationdb/RangeResult.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; import java.util.ArrayList; import java.util.List; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/RangeResultSummary.java b/bindings/java/src/main/com/apple/foundationdb/RangeResultSummary.java similarity index 96% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/RangeResultSummary.java rename to bindings/java/src/main/com/apple/foundationdb/RangeResultSummary.java index 433cb4a970..ee7aaa104d 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/RangeResultSummary.java +++ b/bindings/java/src/main/com/apple/foundationdb/RangeResultSummary.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; class RangeResultSummary { final byte[] lastKey; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/ReadTransaction.java b/bindings/java/src/main/com/apple/foundationdb/ReadTransaction.java similarity index 97% rename from bindings/java/src/main/com/apple/cie/foundationdb/ReadTransaction.java rename to bindings/java/src/main/com/apple/foundationdb/ReadTransaction.java index 8b261dff22..f923d85302 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/ReadTransaction.java +++ b/bindings/java/src/main/com/apple/foundationdb/ReadTransaction.java @@ -18,13 +18,13 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; -import com.apple.cie.foundationdb.async.AsyncIterable; -import com.apple.cie.foundationdb.async.AsyncIterator; -import com.apple.cie.foundationdb.async.Function; -import com.apple.cie.foundationdb.async.Future; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.async.AsyncIterable; +import com.apple.foundationdb.async.AsyncIterator; +import com.apple.foundationdb.async.Function; +import com.apple.foundationdb.async.Future; +import com.apple.foundationdb.tuple.Tuple; /** * A read-only subset of a FoundationDB {@link Transaction}. This is the interface that diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/ReadTransactionContext.java b/bindings/java/src/main/com/apple/foundationdb/ReadTransactionContext.java similarity index 94% rename from bindings/java/src/main/com/apple/cie/foundationdb/ReadTransactionContext.java rename to bindings/java/src/main/com/apple/foundationdb/ReadTransactionContext.java index 40e90c74bd..8cd445376f 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/ReadTransactionContext.java +++ b/bindings/java/src/main/com/apple/foundationdb/ReadTransactionContext.java @@ -18,12 +18,12 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; -import com.apple.cie.foundationdb.async.Function; -import com.apple.cie.foundationdb.async.Future; -import com.apple.cie.foundationdb.async.PartialFunction; -import com.apple.cie.foundationdb.async.PartialFuture; +import com.apple.foundationdb.async.Function; +import com.apple.foundationdb.async.Future; +import com.apple.foundationdb.async.PartialFunction; +import com.apple.foundationdb.async.PartialFuture; import java.util.concurrent.Executor; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/Transaction.java b/bindings/java/src/main/com/apple/foundationdb/Transaction.java similarity index 98% rename from bindings/java/src/main/com/apple/cie/foundationdb/Transaction.java rename to bindings/java/src/main/com/apple/foundationdb/Transaction.java index b9d4d92a84..5c20a9c532 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/Transaction.java +++ b/bindings/java/src/main/com/apple/foundationdb/Transaction.java @@ -18,14 +18,14 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; -import com.apple.cie.foundationdb.async.Cancellable; -import com.apple.cie.foundationdb.async.Function; -import com.apple.cie.foundationdb.async.Future; -import com.apple.cie.foundationdb.async.PartialFunction; -import com.apple.cie.foundationdb.async.PartialFuture; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.async.Cancellable; +import com.apple.foundationdb.async.Function; +import com.apple.foundationdb.async.Future; +import com.apple.foundationdb.async.PartialFunction; +import com.apple.foundationdb.async.PartialFuture; +import com.apple.foundationdb.tuple.Tuple; /** * A Transaction represents a FoundationDB database transaction. All operations on FoundationDB diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/TransactionContext.java b/bindings/java/src/main/com/apple/foundationdb/TransactionContext.java similarity index 94% rename from bindings/java/src/main/com/apple/cie/foundationdb/TransactionContext.java rename to bindings/java/src/main/com/apple/foundationdb/TransactionContext.java index 8a82f176e4..ffb92a4dfc 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/TransactionContext.java +++ b/bindings/java/src/main/com/apple/foundationdb/TransactionContext.java @@ -18,12 +18,12 @@ * limitations under the License. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; -import com.apple.cie.foundationdb.async.Function; -import com.apple.cie.foundationdb.async.Future; -import com.apple.cie.foundationdb.async.PartialFunction; -import com.apple.cie.foundationdb.async.PartialFuture; +import com.apple.foundationdb.async.Function; +import com.apple.foundationdb.async.Future; +import com.apple.foundationdb.async.PartialFunction; +import com.apple.foundationdb.async.PartialFuture; import java.util.concurrent.Executor; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/async/AbstractFuture.java b/bindings/java/src/main/com/apple/foundationdb/async/AbstractFuture.java similarity index 98% rename from bindings/java/src/main/com/apple/cie/foundationdb/async/AbstractFuture.java rename to bindings/java/src/main/com/apple/foundationdb/async/AbstractFuture.java index 6b5e6f138d..74409039ed 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/async/AbstractFuture.java +++ b/bindings/java/src/main/com/apple/foundationdb/async/AbstractFuture.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.async; +package com.apple.foundationdb.async; import java.util.concurrent.Executor; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/async/AbstractPartialFuture.java b/bindings/java/src/main/com/apple/foundationdb/async/AbstractPartialFuture.java similarity index 98% rename from bindings/java/src/main/com/apple/cie/foundationdb/async/AbstractPartialFuture.java rename to bindings/java/src/main/com/apple/foundationdb/async/AbstractPartialFuture.java index 2730854c64..4b73ea87e3 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/async/AbstractPartialFuture.java +++ b/bindings/java/src/main/com/apple/foundationdb/async/AbstractPartialFuture.java @@ -18,13 +18,13 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.async; +package com.apple.foundationdb.async; import java.util.LinkedList; import java.util.concurrent.Executor; -import com.apple.cie.foundationdb.Disposable; -import com.apple.cie.foundationdb.FDBException; +import com.apple.foundationdb.Disposable; +import com.apple.foundationdb.FDBException; /** * An abstract implementation of part of the {@link PartialFuture} interface. This class should diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/async/AsyncIterable.java b/bindings/java/src/main/com/apple/foundationdb/async/AsyncIterable.java similarity index 97% rename from bindings/java/src/main/com/apple/cie/foundationdb/async/AsyncIterable.java rename to bindings/java/src/main/com/apple/foundationdb/async/AsyncIterable.java index baf1c75c84..6c631bd2a3 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/async/AsyncIterable.java +++ b/bindings/java/src/main/com/apple/foundationdb/async/AsyncIterable.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.async; +package com.apple.foundationdb.async; import java.util.List; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/async/AsyncIterator.java b/bindings/java/src/main/com/apple/foundationdb/async/AsyncIterator.java similarity index 97% rename from bindings/java/src/main/com/apple/cie/foundationdb/async/AsyncIterator.java rename to bindings/java/src/main/com/apple/foundationdb/async/AsyncIterator.java index 23638702c3..55e857a714 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/async/AsyncIterator.java +++ b/bindings/java/src/main/com/apple/foundationdb/async/AsyncIterator.java @@ -18,12 +18,12 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.async; +package com.apple.foundationdb.async; import java.util.Iterator; import java.util.NoSuchElementException; -import com.apple.cie.foundationdb.Disposable; +import com.apple.foundationdb.Disposable; /** * A version of {@code Iterator} that allows for non-blocking iteration over elements. diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/async/AsyncUtil.java b/bindings/java/src/main/com/apple/foundationdb/async/AsyncUtil.java similarity index 99% rename from bindings/java/src/main/com/apple/cie/foundationdb/async/AsyncUtil.java rename to bindings/java/src/main/com/apple/foundationdb/async/AsyncUtil.java index 0c979ce546..bfa5595cd4 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/async/AsyncUtil.java +++ b/bindings/java/src/main/com/apple/foundationdb/async/AsyncUtil.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.async; +package com.apple.foundationdb.async; import java.util.ArrayList; import java.util.Collection; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/async/Cancellable.java b/bindings/java/src/main/com/apple/foundationdb/async/Cancellable.java similarity index 97% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/async/Cancellable.java rename to bindings/java/src/main/com/apple/foundationdb/async/Cancellable.java index 4fd3980b68..70c734cc86 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/async/Cancellable.java +++ b/bindings/java/src/main/com/apple/foundationdb/async/Cancellable.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.async; +package com.apple.foundationdb.async; /** * Describes an operation or signal that can be cancelled. Cancellation will be assumed diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/async/CloneableException.java b/bindings/java/src/main/com/apple/foundationdb/async/CloneableException.java similarity index 96% rename from bindings/java/src/main/com/apple/cie/foundationdb/async/CloneableException.java rename to bindings/java/src/main/com/apple/foundationdb/async/CloneableException.java index c260479288..dd93a56c0e 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/async/CloneableException.java +++ b/bindings/java/src/main/com/apple/foundationdb/async/CloneableException.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.async; +package com.apple.foundationdb.async; /** * An {@link Exception} that can be duplicated with a new backtrace. diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/async/Function.java b/bindings/java/src/main/com/apple/foundationdb/async/Function.java similarity index 97% rename from bindings/java/src/main/com/apple/cie/foundationdb/async/Function.java rename to bindings/java/src/main/com/apple/foundationdb/async/Function.java index 60b28d38a9..0035b2c125 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/async/Function.java +++ b/bindings/java/src/main/com/apple/foundationdb/async/Function.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.async; +package com.apple.foundationdb.async; /** * Applies a process to an input with typed output. The function itself should return diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/async/Future.java b/bindings/java/src/main/com/apple/foundationdb/async/Future.java similarity index 99% rename from bindings/java/src/main/com/apple/cie/foundationdb/async/Future.java rename to bindings/java/src/main/com/apple/foundationdb/async/Future.java index b8ec2d2bba..0355e3843c 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/async/Future.java +++ b/bindings/java/src/main/com/apple/foundationdb/async/Future.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.async; +package com.apple.foundationdb.async; /** * The typed result of an asynchronous process. diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/async/PartialFunction.java b/bindings/java/src/main/com/apple/foundationdb/async/PartialFunction.java similarity index 97% rename from bindings/java/src/main/com/apple/cie/foundationdb/async/PartialFunction.java rename to bindings/java/src/main/com/apple/foundationdb/async/PartialFunction.java index acc6ff9e92..31ed10095d 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/async/PartialFunction.java +++ b/bindings/java/src/main/com/apple/foundationdb/async/PartialFunction.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.async; +package com.apple.foundationdb.async; /** * Applies a process to an input with typed output. A {@code PartialFunction} is, diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/async/PartialFuture.java b/bindings/java/src/main/com/apple/foundationdb/async/PartialFuture.java similarity index 99% rename from bindings/java/src/main/com/apple/cie/foundationdb/async/PartialFuture.java rename to bindings/java/src/main/com/apple/foundationdb/async/PartialFuture.java index 523fc516b0..e1194c58fd 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/async/PartialFuture.java +++ b/bindings/java/src/main/com/apple/foundationdb/async/PartialFuture.java @@ -18,9 +18,9 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.async; +package com.apple.foundationdb.async; -import com.apple.cie.foundationdb.Disposable; +import com.apple.foundationdb.Disposable; /** * The typed result of an asynchronous process. diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/async/ReadyFuture.java b/bindings/java/src/main/com/apple/foundationdb/async/ReadyFuture.java similarity index 99% rename from bindings/java/src/main/com/apple/cie/foundationdb/async/ReadyFuture.java rename to bindings/java/src/main/com/apple/foundationdb/async/ReadyFuture.java index c315954019..dd10d2f879 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/async/ReadyFuture.java +++ b/bindings/java/src/main/com/apple/foundationdb/async/ReadyFuture.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.async; +package com.apple.foundationdb.async; import java.util.concurrent.Executor; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/async/ReadyPartialFuture.java b/bindings/java/src/main/com/apple/foundationdb/async/ReadyPartialFuture.java similarity index 99% rename from bindings/java/src/main/com/apple/cie/foundationdb/async/ReadyPartialFuture.java rename to bindings/java/src/main/com/apple/foundationdb/async/ReadyPartialFuture.java index 52f0efc36a..80e1b10275 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/async/ReadyPartialFuture.java +++ b/bindings/java/src/main/com/apple/foundationdb/async/ReadyPartialFuture.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.async; +package com.apple.foundationdb.async; import java.util.concurrent.Executor; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/async/Settable.java b/bindings/java/src/main/com/apple/foundationdb/async/Settable.java similarity index 99% rename from bindings/java/src/main/com/apple/cie/foundationdb/async/Settable.java rename to bindings/java/src/main/com/apple/foundationdb/async/Settable.java index e41045ad5f..3345aa3f1d 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/async/Settable.java +++ b/bindings/java/src/main/com/apple/foundationdb/async/Settable.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.async; +package com.apple.foundationdb.async; /** * Used to communicate output to consumers of an asynchronous process. This is the general diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/async/SettableFuture.java b/bindings/java/src/main/com/apple/foundationdb/async/SettableFuture.java similarity index 98% rename from bindings/java/src/main/com/apple/cie/foundationdb/async/SettableFuture.java rename to bindings/java/src/main/com/apple/foundationdb/async/SettableFuture.java index f3399932af..4674e7acd5 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/async/SettableFuture.java +++ b/bindings/java/src/main/com/apple/foundationdb/async/SettableFuture.java @@ -18,13 +18,13 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.async; +package com.apple.foundationdb.async; import java.util.LinkedList; import java.util.List; import java.util.concurrent.Executor; -import com.apple.cie.foundationdb.FDBException; +import com.apple.foundationdb.FDBException; /** * Represents an {@link Future} that can be fulfilled via the {@link Settable} interface. diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/async/SettablePartial.java b/bindings/java/src/main/com/apple/foundationdb/async/SettablePartial.java similarity index 97% rename from bindings/java/src/main/com/apple/cie/foundationdb/async/SettablePartial.java rename to bindings/java/src/main/com/apple/foundationdb/async/SettablePartial.java index d62d9472ba..e8d21608ea 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/async/SettablePartial.java +++ b/bindings/java/src/main/com/apple/foundationdb/async/SettablePartial.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.async; +package com.apple.foundationdb.async; /** * Used to communicate output to consumers of an asynchronous process. This is a diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/async/SettablePartialFuture.java b/bindings/java/src/main/com/apple/foundationdb/async/SettablePartialFuture.java similarity index 98% rename from bindings/java/src/main/com/apple/cie/foundationdb/async/SettablePartialFuture.java rename to bindings/java/src/main/com/apple/foundationdb/async/SettablePartialFuture.java index f252adcd50..3b4aa25df7 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/async/SettablePartialFuture.java +++ b/bindings/java/src/main/com/apple/foundationdb/async/SettablePartialFuture.java @@ -18,13 +18,13 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.async; +package com.apple.foundationdb.async; import java.util.LinkedList; import java.util.List; import java.util.concurrent.Executor; -import com.apple.cie.foundationdb.FDBException; +import com.apple.foundationdb.FDBException; /** * Represents a {@link PartialFuture} that can be fulfilled via the {@link SettablePartial} diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/async/package-info.java b/bindings/java/src/main/com/apple/foundationdb/async/package-info.java similarity index 65% rename from bindings/java/src/main/com/apple/cie/foundationdb/async/package-info.java rename to bindings/java/src/main/com/apple/foundationdb/async/package-info.java index 128f6161ab..10a9f973a1 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/async/package-info.java +++ b/bindings/java/src/main/com/apple/foundationdb/async/package-info.java @@ -24,36 +24,36 @@ * *

Concepts

* In this library, the concepts from computer science of {@code Future}/{@code Promise} - * are present and named {@link com.apple.cie.foundationdb.async.Future}/{@link com.apple.cie.foundationdb.async.Settable}. + * are present and named {@link com.apple.foundationdb.async.Future}/{@link com.apple.foundationdb.async.Settable}. * As a way to deal in a reasonable manner with the presence of checked Exceptions in * Java (which essentially add information to the return signature of code) this library * adds the idea of {@code Partial}. Named after the mathematical concept of partial * functions -- which do not have an output defined for the full range of inputs -- - * {@link com.apple.cie.foundationdb.async.PartialFunction} are declared to throw + * {@link com.apple.foundationdb.async.PartialFunction} are declared to throw * {@link java.lang.Exception}s as some inputs will not have a valid output. Using - * the same names, {@link com.apple.cie.foundationdb.async.PartialFuture}s are the outputs - * of {@link com.apple.cie.foundationdb.async.PartialFunction}s and can have checked exceptions + * the same names, {@link com.apple.foundationdb.async.PartialFuture}s are the outputs + * of {@link com.apple.foundationdb.async.PartialFunction}s and can have checked exceptions * set as an unsuccessful output -- and those checked exceptions can be thrown from - * {@link com.apple.cie.foundationdb.async.PartialFuture#get()}. + * {@link com.apple.foundationdb.async.PartialFuture#get()}. * *

Practical Use

* Most client use of this library should either use a blocking structure with threads - * calling {@link com.apple.cie.foundationdb.async.Future#get()} or use the asynchronous "mapping" - * functions. Use {@link com.apple.cie.foundationdb.async.Future#map(Function)} when the output + * calling {@link com.apple.foundationdb.async.Future#get()} or use the asynchronous "mapping" + * functions. Use {@link com.apple.foundationdb.async.Future#map(Function)} when the output * of a {@code Future} needs only simple, fast transformation (e.g. for decoding small * pieces of data from one format to another). Use - * {@link com.apple.cie.foundationdb.async.Future#flatMap(Function)} when the output will serve + * {@link com.apple.foundationdb.async.Future#flatMap(Function)} when the output will serve * as the input to another longer running asynchronous process. * *

Cancellation

- * {@link com.apple.cie.foundationdb.async.Future} extends the interface - * {@link com.apple.cie.foundationdb.async.Cancellable} and therefore can represent an operation + * {@link com.apple.foundationdb.async.Future} extends the interface + * {@link com.apple.foundationdb.async.Cancellable} and therefore can represent an operation * that can be cancelled in some fashion. Cancelling a {@code Future} will cancel the * process behind it, even if the {@code Future} being cancelled is a derived result - * of another process (see {@link com.apple.cie.foundationdb.async.Future#flatMap(Function)}). + * of another process (see {@link com.apple.foundationdb.async.Future#flatMap(Function)}). * Therefore, {@code Future}s should only be cancelled when it is known that no other * piece of code depends on the output of this source process. Calling * {@code Future#cancel()} is the same as calling - * {@link com.apple.cie.foundationdb.async.Future#dispose()}. + * {@link com.apple.foundationdb.async.Future#dispose()}. */ -package com.apple.cie.foundationdb.async; +package com.apple.foundationdb.async; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/directory/Directory.java b/bindings/java/src/main/com/apple/foundationdb/directory/Directory.java similarity index 98% rename from bindings/java/src/main/com/apple/cie/foundationdb/directory/Directory.java rename to bindings/java/src/main/com/apple/foundationdb/directory/Directory.java index 7142e6e707..cc5252554e 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/directory/Directory.java +++ b/bindings/java/src/main/com/apple/foundationdb/directory/Directory.java @@ -18,13 +18,13 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.directory; +package com.apple.foundationdb.directory; import java.util.List; -import com.apple.cie.foundationdb.ReadTransactionContext; -import com.apple.cie.foundationdb.TransactionContext; -import com.apple.cie.foundationdb.async.Future; +import com.apple.foundationdb.ReadTransactionContext; +import com.apple.foundationdb.TransactionContext; +import com.apple.foundationdb.async.Future; /** * Represents a directory in the {@code DirectoryLayer}. A {@code Directory} stores the path diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/directory/DirectoryAlreadyExistsException.java b/bindings/java/src/main/com/apple/foundationdb/directory/DirectoryAlreadyExistsException.java similarity index 96% rename from bindings/java/src/main/com/apple/cie/foundationdb/directory/DirectoryAlreadyExistsException.java rename to bindings/java/src/main/com/apple/foundationdb/directory/DirectoryAlreadyExistsException.java index 7f4e64f4f1..654fbafd0c 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/directory/DirectoryAlreadyExistsException.java +++ b/bindings/java/src/main/com/apple/foundationdb/directory/DirectoryAlreadyExistsException.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.directory; +package com.apple.foundationdb.directory; import java.util.List; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/DirectoryException.java b/bindings/java/src/main/com/apple/foundationdb/directory/DirectoryException.java similarity index 96% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/DirectoryException.java rename to bindings/java/src/main/com/apple/foundationdb/directory/DirectoryException.java index a99e925587..b7bbaa6422 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/DirectoryException.java +++ b/bindings/java/src/main/com/apple/foundationdb/directory/DirectoryException.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.directory; +package com.apple.foundationdb.directory; import java.util.List; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/directory/DirectoryLayer.java b/bindings/java/src/main/com/apple/foundationdb/directory/DirectoryLayer.java similarity index 98% rename from bindings/java/src/main/com/apple/cie/foundationdb/directory/DirectoryLayer.java rename to bindings/java/src/main/com/apple/foundationdb/directory/DirectoryLayer.java index da64f48a7e..9725facc7a 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/directory/DirectoryLayer.java +++ b/bindings/java/src/main/com/apple/foundationdb/directory/DirectoryLayer.java @@ -18,9 +18,9 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.directory; +package com.apple.foundationdb.directory; -import static com.apple.cie.foundationdb.tuple.ByteArrayUtil.join; +import static com.apple.foundationdb.tuple.ByteArrayUtil.join; import java.nio.ByteBuffer; import java.nio.ByteOrder; @@ -31,22 +31,22 @@ import java.util.Collections; import java.util.List; import java.util.Random; -import com.apple.cie.foundationdb.subspace.Subspace; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; -import com.apple.cie.foundationdb.tuple.Tuple; -import com.apple.cie.foundationdb.KeyValue; -import com.apple.cie.foundationdb.MutationType; -import com.apple.cie.foundationdb.Range; -import com.apple.cie.foundationdb.ReadTransaction; -import com.apple.cie.foundationdb.ReadTransactionContext; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.TransactionContext; -import com.apple.cie.foundationdb.async.AsyncIterable; -import com.apple.cie.foundationdb.async.AsyncIterator; -import com.apple.cie.foundationdb.async.AsyncUtil; -import com.apple.cie.foundationdb.async.Function; -import com.apple.cie.foundationdb.async.Future; -import com.apple.cie.foundationdb.async.ReadyFuture; +import com.apple.foundationdb.subspace.Subspace; +import com.apple.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.tuple.Tuple; +import com.apple.foundationdb.KeyValue; +import com.apple.foundationdb.MutationType; +import com.apple.foundationdb.Range; +import com.apple.foundationdb.ReadTransaction; +import com.apple.foundationdb.ReadTransactionContext; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.TransactionContext; +import com.apple.foundationdb.async.AsyncIterable; +import com.apple.foundationdb.async.AsyncIterator; +import com.apple.foundationdb.async.AsyncUtil; +import com.apple.foundationdb.async.Function; +import com.apple.foundationdb.async.Future; +import com.apple.foundationdb.async.ReadyFuture; /** * Provides a class for managing directories in FoundationDB. diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/directory/DirectoryMoveException.java b/bindings/java/src/main/com/apple/foundationdb/directory/DirectoryMoveException.java similarity index 96% rename from bindings/java/src/main/com/apple/cie/foundationdb/directory/DirectoryMoveException.java rename to bindings/java/src/main/com/apple/foundationdb/directory/DirectoryMoveException.java index cc9f7abb56..2d282ce056 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/directory/DirectoryMoveException.java +++ b/bindings/java/src/main/com/apple/foundationdb/directory/DirectoryMoveException.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.directory; +package com.apple.foundationdb.directory; import java.util.List; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/DirectoryPartition.java b/bindings/java/src/main/com/apple/foundationdb/directory/DirectoryPartition.java similarity index 94% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/DirectoryPartition.java rename to bindings/java/src/main/com/apple/foundationdb/directory/DirectoryPartition.java index 2a4b33a655..c42147921b 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/DirectoryPartition.java +++ b/bindings/java/src/main/com/apple/foundationdb/directory/DirectoryPartition.java @@ -18,16 +18,16 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.directory; +package com.apple.foundationdb.directory; -import static com.apple.cie.foundationdb.directory.DirectoryLayer.DEFAULT_NODE_SUBSPACE_PREFIX; +import static com.apple.foundationdb.directory.DirectoryLayer.DEFAULT_NODE_SUBSPACE_PREFIX; import java.util.List; -import com.apple.cie.foundationdb.subspace.Subspace; -import com.apple.cie.foundationdb.Range; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.subspace.Subspace; +import com.apple.foundationdb.Range; +import com.apple.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.tuple.Tuple; /** * A {@code DirectoryPartition} is a {@link DirectorySubspace} whose prefix is prepended to all of its descendant directories' prefixes. diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/directory/DirectorySubspace.java b/bindings/java/src/main/com/apple/foundationdb/directory/DirectorySubspace.java similarity index 93% rename from bindings/java/src/main/com/apple/cie/foundationdb/directory/DirectorySubspace.java rename to bindings/java/src/main/com/apple/foundationdb/directory/DirectorySubspace.java index 2366e16919..d70de9ed2b 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/directory/DirectorySubspace.java +++ b/bindings/java/src/main/com/apple/foundationdb/directory/DirectorySubspace.java @@ -18,20 +18,20 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.directory; +package com.apple.foundationdb.directory; -import static com.apple.cie.foundationdb.directory.DirectoryLayer.EMPTY_BYTES; -import static com.apple.cie.foundationdb.directory.DirectoryLayer.EMPTY_PATH; -import static com.apple.cie.foundationdb.tuple.ByteArrayUtil.printable; +import static com.apple.foundationdb.directory.DirectoryLayer.EMPTY_BYTES; +import static com.apple.foundationdb.directory.DirectoryLayer.EMPTY_PATH; +import static com.apple.foundationdb.tuple.ByteArrayUtil.printable; import java.util.Arrays; import java.util.Collections; import java.util.List; -import com.apple.cie.foundationdb.TransactionContext; -import com.apple.cie.foundationdb.subspace.Subspace; -import com.apple.cie.foundationdb.ReadTransactionContext; -import com.apple.cie.foundationdb.async.Future; +import com.apple.foundationdb.TransactionContext; +import com.apple.foundationdb.subspace.Subspace; +import com.apple.foundationdb.ReadTransactionContext; +import com.apple.foundationdb.async.Future; /** * A DirectorySubspace represents the contents of a directory, but it diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/DirectoryUtil.java b/bindings/java/src/main/com/apple/foundationdb/directory/DirectoryUtil.java similarity index 96% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/DirectoryUtil.java rename to bindings/java/src/main/com/apple/foundationdb/directory/DirectoryUtil.java index 2383f187e6..6433fe6607 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/DirectoryUtil.java +++ b/bindings/java/src/main/com/apple/foundationdb/directory/DirectoryUtil.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.directory; +package com.apple.foundationdb.directory; import java.util.List; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/directory/DirectoryVersionException.java b/bindings/java/src/main/com/apple/foundationdb/directory/DirectoryVersionException.java similarity index 96% rename from bindings/java/src/main/com/apple/cie/foundationdb/directory/DirectoryVersionException.java rename to bindings/java/src/main/com/apple/foundationdb/directory/DirectoryVersionException.java index 406d66bd03..30a9a1b5bc 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/directory/DirectoryVersionException.java +++ b/bindings/java/src/main/com/apple/foundationdb/directory/DirectoryVersionException.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.directory; +package com.apple.foundationdb.directory; /** * An {@link Exception} that is thrown when the version of the directory layer diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/MismatchedLayerException.java b/bindings/java/src/main/com/apple/foundationdb/directory/MismatchedLayerException.java similarity index 93% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/MismatchedLayerException.java rename to bindings/java/src/main/com/apple/foundationdb/directory/MismatchedLayerException.java index feea71e3f3..73fe153c34 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/MismatchedLayerException.java +++ b/bindings/java/src/main/com/apple/foundationdb/directory/MismatchedLayerException.java @@ -18,9 +18,9 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.directory; +package com.apple.foundationdb.directory; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.tuple.ByteArrayUtil; import java.util.List; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/directory/NoSuchDirectoryException.java b/bindings/java/src/main/com/apple/foundationdb/directory/NoSuchDirectoryException.java similarity index 95% rename from bindings/java/src/main/com/apple/cie/foundationdb/directory/NoSuchDirectoryException.java rename to bindings/java/src/main/com/apple/foundationdb/directory/NoSuchDirectoryException.java index 00e8a6c5e5..8aa1d9396a 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/directory/NoSuchDirectoryException.java +++ b/bindings/java/src/main/com/apple/foundationdb/directory/NoSuchDirectoryException.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.directory; +package com.apple.foundationdb.directory; import java.util.List; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/PathUtil.java b/bindings/java/src/main/com/apple/foundationdb/directory/PathUtil.java similarity index 98% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/PathUtil.java rename to bindings/java/src/main/com/apple/foundationdb/directory/PathUtil.java index 5b69f6579a..f11d9d47ee 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/PathUtil.java +++ b/bindings/java/src/main/com/apple/foundationdb/directory/PathUtil.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.directory; +package com.apple.foundationdb.directory; import java.util.Arrays; import java.util.LinkedList; diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/package-info.java b/bindings/java/src/main/com/apple/foundationdb/directory/package-info.java similarity index 97% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/package-info.java rename to bindings/java/src/main/com/apple/foundationdb/directory/package-info.java index 4616883692..73dfd7e925 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/directory/package-info.java +++ b/bindings/java/src/main/com/apple/foundationdb/directory/package-info.java @@ -35,4 +35,4 @@ * directory documentation for information about how directories work and * interact with other parts of the built-in keyspace management features. */ -package com.apple.cie.foundationdb.directory; \ No newline at end of file +package com.apple.foundationdb.directory; \ No newline at end of file diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/package-info.java b/bindings/java/src/main/com/apple/foundationdb/package-info.java similarity index 73% rename from bindings/java/src/main/com/apple/cie/foundationdb/package-info.java rename to bindings/java/src/main/com/apple/foundationdb/package-info.java index ff4695b715..6cace3aac9 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/package-info.java +++ b/bindings/java/src/main/com/apple/foundationdb/package-info.java @@ -20,18 +20,18 @@ /** * Provides an API for the FoundationDB transactional key/value store. Clients operating - * on a {@link com.apple.cie.foundationdb.Database} should, in most cases, use the - * {@link com.apple.cie.foundationdb.TransactionContext#run(Function) run(Function)} + * on a {@link com.apple.foundationdb.Database} should, in most cases, use the + * {@link com.apple.foundationdb.TransactionContext#run(Function) run(Function)} * or the - * {@link com.apple.cie.foundationdb.TransactionContext#runAsync(Function) runAsync(Function)} + * {@link com.apple.foundationdb.TransactionContext#runAsync(Function) runAsync(Function)} * constructs. These two functions (and their two derivations) implement a proper * retry loop around the work that needs to get done and, in the case of {@code Database}, - * assure that {@link com.apple.cie.foundationdb.Transaction#commit()} has returned successfully + * assure that {@link com.apple.foundationdb.Transaction#commit()} has returned successfully * before itself returning. If you are not able to use these functions for some reason * please closely read and understand the other * developer * documentation on FoundationDB transactions. */ -package com.apple.cie.foundationdb; +package com.apple.foundationdb; -import com.apple.cie.foundationdb.async.Function; \ No newline at end of file +import com.apple.foundationdb.async.Function; \ No newline at end of file diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/subspace/Subspace.java b/bindings/java/src/main/com/apple/foundationdb/subspace/Subspace.java similarity index 91% rename from bindings/java/src/main/com/apple/cie/foundationdb/subspace/Subspace.java rename to bindings/java/src/main/com/apple/foundationdb/subspace/Subspace.java index b2de6e2355..29e02bdb89 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/subspace/Subspace.java +++ b/bindings/java/src/main/com/apple/foundationdb/subspace/Subspace.java @@ -18,16 +18,16 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.subspace; +package com.apple.foundationdb.subspace; -import static com.apple.cie.foundationdb.tuple.ByteArrayUtil.join; -import static com.apple.cie.foundationdb.tuple.ByteArrayUtil.printable; +import static com.apple.foundationdb.tuple.ByteArrayUtil.join; +import static com.apple.foundationdb.tuple.ByteArrayUtil.printable; import java.util.Arrays; -import com.apple.cie.foundationdb.Range; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.Range; +import com.apple.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.tuple.Tuple; /** * {@code Subspace} provide a convenient way to use {@link Tuple}s to define namespaces for @@ -110,6 +110,9 @@ public class Subspace } /** + * Create a human-readable string representation of this subspace. This is + * really only useful for debugging purposes, but it includes information + * on what raw prefix the subspace is using. * @return a printable representation of the subspace */ @Override @@ -117,6 +120,16 @@ public class Subspace return "Subspace(rawPrefix=" + printable(rawPrefix) + ")"; } + /** + * Returns a hash-table compatible hash of this subspace. This is based off + * of the hash of the underlying byte-array prefix. + * @return a hash of this subspace + */ + @Override + public int hashCode() { + return Arrays.hashCode(rawPrefix); + } + /** * Gets a new subspace which is equivalent to this subspace with its prefix {@link Tuple} extended by * the specified {@code Object}. The object will be inserted into a {@link Tuple} and passed to {@link #get(Tuple)}. diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/subspace/package-info.java b/bindings/java/src/main/com/apple/foundationdb/subspace/package-info.java similarity index 96% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/subspace/package-info.java rename to bindings/java/src/main/com/apple/foundationdb/subspace/package-info.java index b632c787d9..29264626de 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/subspace/package-info.java +++ b/bindings/java/src/main/com/apple/foundationdb/subspace/package-info.java @@ -30,4 +30,4 @@ * subspace documentation for information about how subspaces work and * interact with other parts of the built-in keyspace management features. */ -package com.apple.cie.foundationdb.subspace; \ No newline at end of file +package com.apple.foundationdb.subspace; \ No newline at end of file diff --git a/bindings/java/src-completable/main/com/apple/cie/foundationdb/tuple/ByteArrayUtil.java b/bindings/java/src/main/com/apple/foundationdb/tuple/ByteArrayUtil.java similarity index 97% rename from bindings/java/src-completable/main/com/apple/cie/foundationdb/tuple/ByteArrayUtil.java rename to bindings/java/src/main/com/apple/foundationdb/tuple/ByteArrayUtil.java index 2257ae997d..0770d1284b 100644 --- a/bindings/java/src-completable/main/com/apple/cie/foundationdb/tuple/ByteArrayUtil.java +++ b/bindings/java/src/main/com/apple/foundationdb/tuple/ByteArrayUtil.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.tuple; +package com.apple.foundationdb.tuple; import java.math.BigInteger; import java.nio.ByteBuffer; @@ -27,7 +27,7 @@ import java.util.Arrays; import java.util.LinkedList; import java.util.List; -import com.apple.cie.foundationdb.Transaction; +import com.apple.foundationdb.Transaction; /** * Utility functions for operating on byte arrays. Although built for @@ -368,12 +368,12 @@ public class ByteArrayUtil { /** * Encode an 64-bit integer (long) into a byte array. Encodes the integer in little * endian byte order. The result is valid for use with - * {@link Transaction#mutate(com.apple.cie.foundationdb.MutationType, byte[], byte[]) Transaction.mutate(...)}. + * {@link Transaction#mutate(com.apple.foundationdb.MutationType, byte[], byte[]) Transaction.mutate(...)}. * * @param i the number to encode * @return an 8-byte array containing the * - * @see Transaction#mutate(com.apple.cie.foundationdb.MutationType, byte[], byte[]) + * @see Transaction#mutate(com.apple.foundationdb.MutationType, byte[], byte[]) */ public static byte[] encodeInt(long i) { return ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN).putLong(i).array(); diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/tuple/IterableComparator.java b/bindings/java/src/main/com/apple/foundationdb/tuple/IterableComparator.java similarity index 98% rename from bindings/java/src/main/com/apple/cie/foundationdb/tuple/IterableComparator.java rename to bindings/java/src/main/com/apple/foundationdb/tuple/IterableComparator.java index d09bf976de..270c29c05e 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/tuple/IterableComparator.java +++ b/bindings/java/src/main/com/apple/foundationdb/tuple/IterableComparator.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.tuple; +package com.apple.foundationdb.tuple; import java.util.Comparator; import java.util.Iterator; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/tuple/Tuple.java b/bindings/java/src/main/com/apple/foundationdb/tuple/Tuple.java similarity index 99% rename from bindings/java/src/main/com/apple/cie/foundationdb/tuple/Tuple.java rename to bindings/java/src/main/com/apple/foundationdb/tuple/Tuple.java index 64d4b58aad..4f70669680 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/tuple/Tuple.java +++ b/bindings/java/src/main/com/apple/foundationdb/tuple/Tuple.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.tuple; +package com.apple.foundationdb.tuple; import java.math.BigInteger; import java.util.ArrayList; @@ -30,7 +30,7 @@ import java.util.LinkedList; import java.util.List; import java.util.UUID; -import com.apple.cie.foundationdb.Range; +import com.apple.foundationdb.Range; /** * Represents a set of elements that make up a sortable, typed key. This object diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/tuple/TupleUtil.java b/bindings/java/src/main/com/apple/foundationdb/tuple/TupleUtil.java similarity index 99% rename from bindings/java/src/main/com/apple/cie/foundationdb/tuple/TupleUtil.java rename to bindings/java/src/main/com/apple/foundationdb/tuple/TupleUtil.java index 94d2ae3d0b..577feb3f24 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/tuple/TupleUtil.java +++ b/bindings/java/src/main/com/apple/foundationdb/tuple/TupleUtil.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.tuple; +package com.apple.foundationdb.tuple; import java.math.BigInteger; import java.nio.ByteBuffer; diff --git a/bindings/java/src/main/com/apple/cie/foundationdb/tuple/package-info.java b/bindings/java/src/main/com/apple/foundationdb/tuple/package-info.java similarity index 93% rename from bindings/java/src/main/com/apple/cie/foundationdb/tuple/package-info.java rename to bindings/java/src/main/com/apple/foundationdb/tuple/package-info.java index 3f1b37369a..e356ae7396 100644 --- a/bindings/java/src/main/com/apple/cie/foundationdb/tuple/package-info.java +++ b/bindings/java/src/main/com/apple/foundationdb/tuple/package-info.java @@ -20,10 +20,10 @@ /** * Provides a set of utilities for serializing and deserializing typed data - * for use in FoundationDB. When packed together into a {@link com.apple.cie.foundationdb.tuple.Tuple} + * for use in FoundationDB. When packed together into a {@link com.apple.foundationdb.tuple.Tuple} * this data is suitable for use as an index or organizational structure within FoundationDB * keyspace. See general Tuple * documentation for information about how Tuples sort and can be used to efficiently * model data. */ -package com.apple.cie.foundationdb.tuple; \ No newline at end of file +package com.apple.foundationdb.tuple; \ No newline at end of file diff --git a/bindings/java/src/main/overview.html.in b/bindings/java/src/main/overview.html.in index 892a5aa8c1..90bef9270d 100644 --- a/bindings/java/src/main/overview.html.in +++ b/bindings/java/src/main/overview.html.in @@ -24,24 +24,24 @@ and add it to your classpath.

Getting started

To start using FoundationDB from Java, create an instance of the -{@link com.apple.cie.foundationdb.FDB FoundationDB API interface} with the version of the -API that you want to use (this release of the FoundationDB Java API supports only version {@code 500}). -With this API object you can then open {@link com.apple.cie.foundationdb.Cluster}s and -{@link com.apple.cie.foundationdb.Database}s and start using -{@link com.apple.cie.foundationdb.Transaction}s. Here we give an example. The example relies on a +{@link com.apple.foundationdb.FDB FoundationDB API interface} with the version of the +API that you want to use (this release of the FoundationDB Java API supports versions between {@code 500} and {@code 510}). +With this API object you can then open {@link com.apple.foundationdb.Cluster}s and +{@link com.apple.foundationdb.Database}s and start using +{@link com.apple.foundationdb.Transaction}s. Here we give an example. The example relies on a cluster file at the default location for your platform and a running server.

 {@code
-import com.apple.cie.foundationdb.*;
+import com.apple.foundationdb.*;
 import Function;
 import Tuple;
 
 public class Example {
   public static void main(String[] args) {
-    FDB fdb = FDB.selectAPIVersion(500);
+    FDB fdb = FDB.selectAPIVersion(510);
     Database db = fdb.open();
 
     // Run an operation on the database
@@ -64,21 +64,21 @@ public class Example {
 }
 }
 
-

FoundationDB {@link com.apple.cie.foundationdb.tuple Tuple API}

-The {@link com.apple.cie.foundationdb.tuple Tuple API} is provided with the core Java API for FoundationDB. +

FoundationDB {@link com.apple.foundationdb.tuple Tuple API}

+The {@link com.apple.foundationdb.tuple Tuple API} is provided with the core Java API for FoundationDB. This layer is provided in some form in all official language bindings. It enables cross-language support for storing and retrieving typed data from the binary data that FoundationDB supports. And, just as importantly, data packed into {@code Tuple}s and used as keys sort in predictable and useful ways. See the -{@link com.apple.cie.foundationdb.tuple Tuple class documentation} for information about use in Java +{@link com.apple.foundationdb.tuple Tuple class documentation} for information about use in Java and general Tuple documentation for information about how Tuples sort and can be used to efficiently model data.
-

FoundationDB {@link com.apple.cie.foundationdb.directory Directory API}

-The {@link com.apple.cie.foundationdb.directory Directory API} is provided with the core +

FoundationDB {@link com.apple.foundationdb.directory Directory API}

+The {@link com.apple.foundationdb.directory Directory API} is provided with the core Java API for FoundationDB. This layer is provided in some form in all official language bindings. The FoundationDB API provides directories as a tool for -managing related {@link com.apple.cie.foundationdb.subspace.Subspace Subspace}s. Directories are a +managing related {@link com.apple.foundationdb.subspace.Subspace Subspace}s. Directories are a recommended approach for administering applications. Each application should create or open at least one directory to manage its subspaces. Directories are identified by hierarchical paths analogous to the paths in a Unix-like file system. @@ -87,16 +87,16 @@ subspace used to store its content. The layer maps each path to a short prefix u for the corresponding subspace. In effect, directories provide a level of indirection for access to subspaces.
-

{@link com.apple.cie.foundationdb.async.Future Future}s and asynchronous operation

-Asynchronous FoundationDB operations return {@link com.apple.cie.foundationdb.async.Future Future}s. -A {@link com.apple.cie.foundationdb.async.Future Future} can be used in a blocking way using the -{@link com.apple.cie.foundationdb.async.Future#get() get()} method or in a +

{@link com.apple.foundationdb.async.Future Future}s and asynchronous operation

+Asynchronous FoundationDB operations return {@link com.apple.foundationdb.async.Future Future}s. +A {@link com.apple.foundationdb.async.Future Future} can be used in a blocking way using the +{@link com.apple.foundationdb.async.Future#get() get()} method or in a fully-asynchronous way using the -{@link com.apple.cie.foundationdb.async.Future#map(Function) map()} and -{@link com.apple.cie.foundationdb.async.Future#flatMap(Function) flatMap()} +{@link com.apple.foundationdb.async.Future#map(Function) map()} and +{@link com.apple.foundationdb.async.Future#flatMap(Function) flatMap()} methods. Generally, the blocking style is more straightforward and the asynchronous style is more efficient. Mixing the two styles correctly can be tricky, so consider choosing -one or the other. See the {@linkplain com.apple.cie.foundationdb.async async Package documentation} +one or the other. See the {@linkplain com.apple.foundationdb.async async Package documentation} for more information. diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/AsListTest.java b/bindings/java/src/test/com/apple/foundationdb/test/AsListTest.java similarity index 85% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/AsListTest.java rename to bindings/java/src/test/com/apple/foundationdb/test/AsListTest.java index af76bf2fe3..90c24959bf 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/AsListTest.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/AsListTest.java @@ -18,18 +18,18 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.LocalityUtil; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.async.AsyncUtil; -import com.apple.cie.foundationdb.async.Function; -import com.apple.cie.foundationdb.async.Future; -import com.apple.cie.foundationdb.async.PartialFunction; -import com.apple.cie.foundationdb.async.PartialFuture; -import com.apple.cie.foundationdb.async.ReadyFuture; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.LocalityUtil; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.async.AsyncUtil; +import com.apple.foundationdb.async.Function; +import com.apple.foundationdb.async.Future; +import com.apple.foundationdb.async.PartialFunction; +import com.apple.foundationdb.async.PartialFuture; +import com.apple.foundationdb.async.ReadyFuture; public class AsListTest { /** @@ -37,7 +37,7 @@ public class AsListTest { * a bug made the the addition of the clear into the result returning 0 items. */ public static void main(String[] args) { - FDB fdb = FDB.selectAPIVersion(500); + FDB fdb = FDB.selectAPIVersion(510); Database database = fdb.open("T:\\circus\\tags\\RebarCluster-bbc\\cluster_id.txt"); database.options().setLocationCacheSize(42); Transaction tr = database.createTransaction(); diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/AsyncDirectoryExtension.java b/bindings/java/src/test/com/apple/foundationdb/test/AsyncDirectoryExtension.java similarity index 95% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/AsyncDirectoryExtension.java rename to bindings/java/src/test/com/apple/foundationdb/test/AsyncDirectoryExtension.java index 8e1568b484..f3a573e752 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/AsyncDirectoryExtension.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/AsyncDirectoryExtension.java @@ -18,24 +18,24 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import com.apple.cie.foundationdb.Range; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.async.AsyncUtil; -import com.apple.cie.foundationdb.async.Function; -import com.apple.cie.foundationdb.async.Future; -import com.apple.cie.foundationdb.async.ReadyFuture; -import com.apple.cie.foundationdb.directory.Directory; -import com.apple.cie.foundationdb.directory.DirectoryLayer; -import com.apple.cie.foundationdb.directory.DirectorySubspace; -import com.apple.cie.foundationdb.subspace.Subspace; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.Range; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.async.AsyncUtil; +import com.apple.foundationdb.async.Function; +import com.apple.foundationdb.async.Future; +import com.apple.foundationdb.async.ReadyFuture; +import com.apple.foundationdb.directory.Directory; +import com.apple.foundationdb.directory.DirectoryLayer; +import com.apple.foundationdb.directory.DirectorySubspace; +import com.apple.foundationdb.subspace.Subspace; +import com.apple.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.tuple.Tuple; class AsyncDirectoryExtension { List dirList = new ArrayList(); diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/AsyncStackTester.java b/bindings/java/src/test/com/apple/foundationdb/test/AsyncStackTester.java similarity index 97% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/AsyncStackTester.java rename to bindings/java/src/test/com/apple/foundationdb/test/AsyncStackTester.java index 81547d7718..06c3e94ce5 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/AsyncStackTester.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/AsyncStackTester.java @@ -18,30 +18,30 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.math.BigInteger; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.*; -import com.apple.cie.foundationdb.Cluster; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.FDBException; -import com.apple.cie.foundationdb.KeySelector; -import com.apple.cie.foundationdb.KeyValue; -import com.apple.cie.foundationdb.MutationType; -import com.apple.cie.foundationdb.Range; -import com.apple.cie.foundationdb.ReadTransaction; -import com.apple.cie.foundationdb.StreamingMode; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.async.AsyncIterable; -import com.apple.cie.foundationdb.async.Function; -import com.apple.cie.foundationdb.async.Future; -import com.apple.cie.foundationdb.async.ReadyFuture; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.Cluster; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.FDBException; +import com.apple.foundationdb.KeySelector; +import com.apple.foundationdb.KeyValue; +import com.apple.foundationdb.MutationType; +import com.apple.foundationdb.Range; +import com.apple.foundationdb.ReadTransaction; +import com.apple.foundationdb.StreamingMode; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.async.AsyncIterable; +import com.apple.foundationdb.async.Function; +import com.apple.foundationdb.async.Future; +import com.apple.foundationdb.async.ReadyFuture; +import com.apple.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.tuple.Tuple; public class AsyncStackTester { static final String DIRECTORY_PREFIX = "DIRECTORY_"; @@ -632,6 +632,8 @@ public class AsyncStackTester { tr.options().setMaxRetryDelay(100); tr.options().setUsedDuringCommitProtectionDisable(); tr.options().setTransactionLoggingEnable("my_transaction"); + tr.options().setReadLockAware(); + tr.options().setLockAware(); if(!(new FDBException("Fake", 1020)).isRetryable() || (new FDBException("Fake", 10)).isRetryable()) diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/BlockingBenchmark.java b/bindings/java/src/test/com/apple/foundationdb/test/BlockingBenchmark.java similarity index 92% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/BlockingBenchmark.java rename to bindings/java/src/test/com/apple/foundationdb/test/BlockingBenchmark.java index b10685da67..bca87cf305 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/BlockingBenchmark.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/BlockingBenchmark.java @@ -18,22 +18,22 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.ArrayList; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.async.Function; -import com.apple.cie.foundationdb.async.Future; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.async.Function; +import com.apple.foundationdb.async.Future; public class BlockingBenchmark { private static final int REPS = 100000; private static final int PARALLEL = 100; public static void main(String[] args) throws InterruptedException { - FDB fdb = FDB.selectAPIVersion(500); + FDB fdb = FDB.selectAPIVersion(510); // The cluster file DOES NOT need to be valid, although it must exist. // This is because the database is never really contacted in this test. diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/ConcurrentGetSetGet.java b/bindings/java/src/test/com/apple/foundationdb/test/ConcurrentGetSetGet.java similarity index 93% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/ConcurrentGetSetGet.java rename to bindings/java/src/test/com/apple/foundationdb/test/ConcurrentGetSetGet.java index 288b2bd9b5..216db6f704 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/ConcurrentGetSetGet.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/ConcurrentGetSetGet.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.nio.charset.Charset; import java.security.SecureRandom; @@ -26,12 +26,12 @@ import java.util.Random; import java.util.concurrent.Semaphore; import java.util.concurrent.atomic.AtomicInteger; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.async.Function; -import com.apple.cie.foundationdb.async.Future; -import com.apple.cie.foundationdb.async.ReadyFuture; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.async.Function; +import com.apple.foundationdb.async.Future; +import com.apple.foundationdb.async.ReadyFuture; public class ConcurrentGetSetGet { public static final Charset UTF8 = Charset.forName("UTF-8"); @@ -52,7 +52,7 @@ public class ConcurrentGetSetGet { } public static void main(String[] args) { - Database database = FDB.selectAPIVersion(500).open(); + Database database = FDB.selectAPIVersion(510).open(); new ConcurrentGetSetGet().apply(database); } diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/Context.java b/bindings/java/src/test/com/apple/foundationdb/test/Context.java similarity index 88% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/Context.java rename to bindings/java/src/test/com/apple/foundationdb/test/Context.java index c09e99bc1d..5d359d229e 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/Context.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/Context.java @@ -18,25 +18,25 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDBException; -import com.apple.cie.foundationdb.KeySelector; -import com.apple.cie.foundationdb.Range; -import com.apple.cie.foundationdb.StreamingMode; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.async.Function; -import com.apple.cie.foundationdb.async.Future; -import com.apple.cie.foundationdb.async.Settable; -import com.apple.cie.foundationdb.async.SettableFuture; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDBException; +import com.apple.foundationdb.KeySelector; +import com.apple.foundationdb.Range; +import com.apple.foundationdb.StreamingMode; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.async.Function; +import com.apple.foundationdb.async.Future; +import com.apple.foundationdb.async.Settable; +import com.apple.foundationdb.async.SettableFuture; +import com.apple.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.tuple.Tuple; abstract class Context implements Runnable { final Stack stack = new Stack(); diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/ContinuousSample.java b/bindings/java/src/test/com/apple/foundationdb/test/ContinuousSample.java similarity index 98% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/ContinuousSample.java rename to bindings/java/src/test/com/apple/foundationdb/test/ContinuousSample.java index d1550b33ac..3602eb6e30 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/ContinuousSample.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/ContinuousSample.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.ArrayList; import java.util.Collections; diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/DirectoryExtension.java b/bindings/java/src/test/com/apple/foundationdb/test/DirectoryExtension.java similarity index 94% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/DirectoryExtension.java rename to bindings/java/src/test/com/apple/foundationdb/test/DirectoryExtension.java index 38fd448673..df94665b50 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/DirectoryExtension.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/DirectoryExtension.java @@ -18,20 +18,20 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import com.apple.cie.foundationdb.Range; -import com.apple.cie.foundationdb.async.Future; -import com.apple.cie.foundationdb.directory.Directory; -import com.apple.cie.foundationdb.directory.DirectoryLayer; -import com.apple.cie.foundationdb.directory.DirectorySubspace; -import com.apple.cie.foundationdb.subspace.Subspace; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.Range; +import com.apple.foundationdb.async.Future; +import com.apple.foundationdb.directory.Directory; +import com.apple.foundationdb.directory.DirectoryLayer; +import com.apple.foundationdb.directory.DirectorySubspace; +import com.apple.foundationdb.subspace.Subspace; +import com.apple.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.tuple.Tuple; class DirectoryExtension { List dirList = new ArrayList(); diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/DirectoryOperation.java b/bindings/java/src/test/com/apple/foundationdb/test/DirectoryOperation.java similarity index 97% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/DirectoryOperation.java rename to bindings/java/src/test/com/apple/foundationdb/test/DirectoryOperation.java index 70b28051a3..0592141239 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/DirectoryOperation.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/DirectoryOperation.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; enum DirectoryOperation { DIRECTORY_CREATE_SUBSPACE(true), diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/DirectoryTest.java b/bindings/java/src/test/com/apple/foundationdb/test/DirectoryTest.java similarity index 82% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/DirectoryTest.java rename to bindings/java/src/test/com/apple/foundationdb/test/DirectoryTest.java index 3fcbaf4598..4ef2b4723b 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/DirectoryTest.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/DirectoryTest.java @@ -18,27 +18,27 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import com.apple.cie.foundationdb.Cluster; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.TransactionContext; -import com.apple.cie.foundationdb.async.PartialFunction; -import com.apple.cie.foundationdb.directory.DirectoryLayer; -import com.apple.cie.foundationdb.directory.DirectorySubspace; +import com.apple.foundationdb.Cluster; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.TransactionContext; +import com.apple.foundationdb.async.PartialFunction; +import com.apple.foundationdb.directory.DirectoryLayer; +import com.apple.foundationdb.directory.DirectorySubspace; public class DirectoryTest { private static final String CLUSTER_FILE = "/home/ajb/fdb.cluster"; public static void main(String[] args) throws Exception { try { - Cluster c = FDB.selectAPIVersion(500).createCluster(CLUSTER_FILE); + Cluster c = FDB.selectAPIVersion(510).createCluster(CLUSTER_FILE); Database db = c.openDatabase(); runTests(db); } catch(Throwable t) { diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/DirectoryUtil.java b/bindings/java/src/test/com/apple/foundationdb/test/DirectoryUtil.java similarity index 91% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/DirectoryUtil.java rename to bindings/java/src/test/com/apple/foundationdb/test/DirectoryUtil.java index f12c7df334..8e6bdd80b9 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/DirectoryUtil.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/DirectoryUtil.java @@ -18,16 +18,16 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.ArrayList; import java.util.List; -import com.apple.cie.foundationdb.async.AsyncUtil; -import com.apple.cie.foundationdb.async.Function; -import com.apple.cie.foundationdb.async.Future; -import com.apple.cie.foundationdb.async.ReadyFuture; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.async.AsyncUtil; +import com.apple.foundationdb.async.Function; +import com.apple.foundationdb.async.Future; +import com.apple.foundationdb.async.ReadyFuture; +import com.apple.foundationdb.tuple.Tuple; class DirectoryUtil { private static class TuplePopper { diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/Example.java b/bindings/java/src/test/com/apple/foundationdb/test/Example.java similarity index 80% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/Example.java rename to bindings/java/src/test/com/apple/foundationdb/test/Example.java index a5d9d3d678..a766ec1a24 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/Example.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/Example.java @@ -18,18 +18,18 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.*; -import com.apple.cie.foundationdb.async.Function; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.*; +import com.apple.foundationdb.async.Function; +import com.apple.foundationdb.tuple.Tuple; public class Example { public static void main(String[] args) { - FDB fdb = FDB.selectAPIVersion(500); + FDB fdb = FDB.selectAPIVersion(510); Database db = fdb.open(); // Run an operation on the database diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/Instruction.java b/bindings/java/src/test/com/apple/foundationdb/test/Instruction.java similarity index 87% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/Instruction.java rename to bindings/java/src/test/com/apple/foundationdb/test/Instruction.java index a23c9e8fba..ec59a43902 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/Instruction.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/Instruction.java @@ -18,15 +18,15 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; -import com.apple.cie.foundationdb.ReadTransaction; -import com.apple.cie.foundationdb.ReadTransactionContext; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.TransactionContext; -import com.apple.cie.foundationdb.async.Function; -import com.apple.cie.foundationdb.async.Future; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.ReadTransaction; +import com.apple.foundationdb.ReadTransactionContext; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.TransactionContext; +import com.apple.foundationdb.async.Function; +import com.apple.foundationdb.async.Future; +import com.apple.foundationdb.tuple.Tuple; import java.util.List; diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/IterableTest.java b/bindings/java/src/test/com/apple/foundationdb/test/IterableTest.java similarity index 82% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/IterableTest.java rename to bindings/java/src/test/com/apple/foundationdb/test/IterableTest.java index e3662a2637..e63c673d23 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/IterableTest.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/IterableTest.java @@ -18,17 +18,17 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.concurrent.atomic.AtomicInteger; -import com.apple.cie.foundationdb.Cluster; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.KeyValue; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.TransactionContext; -import com.apple.cie.foundationdb.async.Function; +import com.apple.foundationdb.Cluster; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.KeyValue; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.TransactionContext; +import com.apple.foundationdb.async.Function; public class IterableTest { private static final String CLUSTER_FILE = "C:\\Users\\Ben\\workspace\\fdb\\fdb.cluster"; @@ -36,7 +36,7 @@ public class IterableTest { public static void main(String[] args) throws InterruptedException { final int reps = 1000; try { - Cluster cluster = FDB.selectAPIVersion(500).createCluster(CLUSTER_FILE); + Cluster cluster = FDB.selectAPIVersion(510).createCluster(CLUSTER_FILE); Database db = cluster.openDatabase(); runTests(reps, db); } catch(Throwable t) { diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/LocalityTests.java b/bindings/java/src/test/com/apple/foundationdb/test/LocalityTests.java similarity index 77% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/LocalityTests.java rename to bindings/java/src/test/com/apple/foundationdb/test/LocalityTests.java index 6a516ee4bc..4d67f35e71 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/LocalityTests.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/LocalityTests.java @@ -18,23 +18,23 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.List; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.LocalityUtil; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.async.AsyncIterable; -import com.apple.cie.foundationdb.async.AsyncUtil; -import com.apple.cie.foundationdb.async.Future; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.LocalityUtil; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.async.AsyncIterable; +import com.apple.foundationdb.async.AsyncUtil; +import com.apple.foundationdb.async.Future; +import com.apple.foundationdb.tuple.ByteArrayUtil; public class LocalityTests { public static void main(String[] args) { - FDB fdb = FDB.selectAPIVersion(500); + FDB fdb = FDB.selectAPIVersion(510); Database database = fdb.open(args[0]); { diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/OSTest.java b/bindings/java/src/test/com/apple/foundationdb/test/OSTest.java similarity index 96% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/OSTest.java rename to bindings/java/src/test/com/apple/foundationdb/test/OSTest.java index 36577119dc..f0bb3ecdc9 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/OSTest.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/OSTest.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.io.InputStream; diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/ParallelRandomScan.java b/bindings/java/src/test/com/apple/foundationdb/test/ParallelRandomScan.java similarity index 87% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/ParallelRandomScan.java rename to bindings/java/src/test/com/apple/foundationdb/test/ParallelRandomScan.java index a07a136a75..4ce68de947 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/ParallelRandomScan.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/ParallelRandomScan.java @@ -18,23 +18,23 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.nio.ByteBuffer; import java.util.Random; import java.util.concurrent.Semaphore; import java.util.concurrent.atomic.AtomicInteger; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.KeyValue; -import com.apple.cie.foundationdb.StreamingMode; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.async.AsyncIterable; -import com.apple.cie.foundationdb.async.AsyncIterator; -import com.apple.cie.foundationdb.async.Function; -import com.apple.cie.foundationdb.async.Future; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.KeyValue; +import com.apple.foundationdb.StreamingMode; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.async.AsyncIterable; +import com.apple.foundationdb.async.AsyncIterator; +import com.apple.foundationdb.async.Function; +import com.apple.foundationdb.async.Future; +import com.apple.foundationdb.tuple.ByteArrayUtil; public class ParallelRandomScan { private static final int ROWS = 1000000; @@ -44,7 +44,7 @@ public class ParallelRandomScan { private static final int PARALLELISM_STEP = 5; public static void main(String[] args) throws InterruptedException { - FDB api = FDB.selectAPIVersion(500); + FDB api = FDB.selectAPIVersion(510); Database database = api.open(args[0]); for(int i = PARALLELISM_MIN; i <= PARALLELISM_MAX; i += PARALLELISM_STEP) { diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/RangeTest.java b/bindings/java/src/test/com/apple/foundationdb/test/RangeTest.java similarity index 92% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/RangeTest.java rename to bindings/java/src/test/com/apple/foundationdb/test/RangeTest.java index bee279c602..0b2ace065b 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/RangeTest.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/RangeTest.java @@ -18,22 +18,22 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.List; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.FDBException; -import com.apple.cie.foundationdb.KeySelector; -import com.apple.cie.foundationdb.KeyValue; -import com.apple.cie.foundationdb.Range; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.async.AsyncIterable; -import com.apple.cie.foundationdb.async.Function; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.FDBException; +import com.apple.foundationdb.KeySelector; +import com.apple.foundationdb.KeyValue; +import com.apple.foundationdb.Range; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.async.AsyncIterable; +import com.apple.foundationdb.async.Function; public class RangeTest { - private static final int API_VERSION = 500; + private static final int API_VERSION = 510; public static void main(String[] args) throws Exception { System.out.println("About to use version " + API_VERSION); diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/SerialInsertion.java b/bindings/java/src/test/com/apple/foundationdb/test/SerialInsertion.java similarity index 92% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/SerialInsertion.java rename to bindings/java/src/test/com/apple/foundationdb/test/SerialInsertion.java index 8d94e9ea86..1448471d3f 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/SerialInsertion.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/SerialInsertion.java @@ -18,15 +18,15 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.Transaction; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.Transaction; public class SerialInsertion { private static final int THREAD_COUNT = 10; @@ -34,7 +34,7 @@ public class SerialInsertion { private static final int NODES = 1000000; public static void main(String[] args) { - FDB api = FDB.selectAPIVersion(500); + FDB api = FDB.selectAPIVersion(510); Database database = api.open("T:\\circus\\tags\\RebarCluster-bbc\\cluster_id.txt"); long start = System.currentTimeMillis(); @@ -94,4 +94,4 @@ public class SerialInsertion { } } -} \ No newline at end of file +} diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/SerialIteration.java b/bindings/java/src/test/com/apple/foundationdb/test/SerialIteration.java similarity index 89% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/SerialIteration.java rename to bindings/java/src/test/com/apple/foundationdb/test/SerialIteration.java index fac1c93ca7..445f998edd 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/SerialIteration.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/SerialIteration.java @@ -18,20 +18,20 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; import java.util.Random; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.KeyValue; -import com.apple.cie.foundationdb.ReadTransaction; -import com.apple.cie.foundationdb.StreamingMode; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.async.AsyncIterable; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.KeyValue; +import com.apple.foundationdb.ReadTransaction; +import com.apple.foundationdb.StreamingMode; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.async.AsyncIterable; public class SerialIteration { private static final int ROWS = 1000000; @@ -39,7 +39,7 @@ public class SerialIteration { private static final int THREAD_COUNT = 1; public static void main(String[] args) throws InterruptedException { - FDB api = FDB.selectAPIVersion(500); + FDB api = FDB.selectAPIVersion(510); Database database = api.open(args[0]); for(int i = 1; i <= THREAD_COUNT; i++) { diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/SerialTest.java b/bindings/java/src/test/com/apple/foundationdb/test/SerialTest.java similarity index 86% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/SerialTest.java rename to bindings/java/src/test/com/apple/foundationdb/test/SerialTest.java index 99b14b90a4..bf5b91a741 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/SerialTest.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/SerialTest.java @@ -18,16 +18,16 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.concurrent.atomic.AtomicInteger; -import com.apple.cie.foundationdb.Cluster; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.TransactionContext; -import com.apple.cie.foundationdb.async.Function; +import com.apple.foundationdb.Cluster; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.TransactionContext; +import com.apple.foundationdb.async.Function; public class SerialTest { @@ -36,7 +36,7 @@ public class SerialTest { public static void main(String[] args) throws InterruptedException { final int reps = 1000; try { - Cluster c = FDB.selectAPIVersion(500).createCluster(CLUSTER_FILE); + Cluster c = FDB.selectAPIVersion(510).createCluster(CLUSTER_FILE); Database db = c.openDatabase(); runTests(reps, db); diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/Stack.java b/bindings/java/src/test/com/apple/foundationdb/test/Stack.java similarity index 96% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/Stack.java rename to bindings/java/src/test/com/apple/foundationdb/test/Stack.java index ee3bfe0521..d7d75d4f9d 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/Stack.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/Stack.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; class Stack { java.util.Stack stack = new java.util.Stack(); diff --git a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/StackEntry.java b/bindings/java/src/test/com/apple/foundationdb/test/StackEntry.java similarity index 95% rename from bindings/java/src-completable/test/com/apple/cie/foundationdb/test/StackEntry.java rename to bindings/java/src/test/com/apple/foundationdb/test/StackEntry.java index 1b6ff36634..a9f1f11cef 100644 --- a/bindings/java/src-completable/test/com/apple/cie/foundationdb/test/StackEntry.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/StackEntry.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; class StackEntry { int idx; diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/StackOperation.java b/bindings/java/src/test/com/apple/foundationdb/test/StackOperation.java similarity index 97% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/StackOperation.java rename to bindings/java/src/test/com/apple/foundationdb/test/StackOperation.java index fc81d9104a..71aa52d33c 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/StackOperation.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/StackOperation.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; enum StackOperation { PUSH, diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/StackTester.java b/bindings/java/src/test/com/apple/foundationdb/test/StackTester.java similarity index 96% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/StackTester.java rename to bindings/java/src/test/com/apple/foundationdb/test/StackTester.java index b7b50843bc..ed98fa0dba 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/StackTester.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/StackTester.java @@ -18,30 +18,30 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.math.BigInteger; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.*; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.FDBException; -import com.apple.cie.foundationdb.KeySelector; -import com.apple.cie.foundationdb.KeyValue; -import com.apple.cie.foundationdb.LocalityUtil; -import com.apple.cie.foundationdb.MutationType; -import com.apple.cie.foundationdb.Range; -import com.apple.cie.foundationdb.ReadTransaction; -import com.apple.cie.foundationdb.StreamingMode; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.async.AsyncIterable; -import com.apple.cie.foundationdb.async.Function; -import com.apple.cie.foundationdb.async.Future; -import com.apple.cie.foundationdb.async.ReadyFuture; -import com.apple.cie.foundationdb.tuple.ByteArrayUtil; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.FDBException; +import com.apple.foundationdb.KeySelector; +import com.apple.foundationdb.KeyValue; +import com.apple.foundationdb.LocalityUtil; +import com.apple.foundationdb.MutationType; +import com.apple.foundationdb.Range; +import com.apple.foundationdb.ReadTransaction; +import com.apple.foundationdb.StreamingMode; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.async.AsyncIterable; +import com.apple.foundationdb.async.Function; +import com.apple.foundationdb.async.Future; +import com.apple.foundationdb.async.ReadyFuture; +import com.apple.foundationdb.tuple.ByteArrayUtil; +import com.apple.foundationdb.tuple.Tuple; /** * Implements a cross-binding test of the FoundationDB API. @@ -439,6 +439,8 @@ public class StackTester { tr.options().setMaxRetryDelay(100); tr.options().setUsedDuringCommitProtectionDisable(); tr.options().setTransactionLoggingEnable("my_transaction"); + tr.options().setReadLockAware(); + tr.options().setLockAware(); if(!(new FDBException("Fake", 1020)).isRetryable() || (new FDBException("Fake", 10)).isRetryable()) diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/StackUtils.java b/bindings/java/src/test/com/apple/foundationdb/test/StackUtils.java similarity index 93% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/StackUtils.java rename to bindings/java/src/test/com/apple/foundationdb/test/StackUtils.java index ee681e03de..9a09e094e1 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/StackUtils.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/StackUtils.java @@ -18,15 +18,15 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.math.BigInteger; import java.util.List; -import com.apple.cie.foundationdb.FDBException; -import com.apple.cie.foundationdb.KeySelector; -import com.apple.cie.foundationdb.async.Future; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.FDBException; +import com.apple.foundationdb.KeySelector; +import com.apple.foundationdb.async.Future; +import com.apple.foundationdb.tuple.Tuple; public class StackUtils { diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/TestApp.java b/bindings/java/src/test/com/apple/foundationdb/test/TestApp.java similarity index 88% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/TestApp.java rename to bindings/java/src/test/com/apple/foundationdb/test/TestApp.java index 2ca9d543a2..59f06dd4b7 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/TestApp.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/TestApp.java @@ -18,20 +18,20 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; -import com.apple.cie.foundationdb.Cluster; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.FDBException; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.async.Future; +import com.apple.foundationdb.Cluster; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.FDBException; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.async.Future; public class TestApp { public static void main(String[] args) throws Exception { try { - Cluster cluster = FDB.selectAPIVersion(500).createCluster("C:\\Users\\Ben\\workspace\\fdb\\fdb.cluster"); + Cluster cluster = FDB.selectAPIVersion(510).createCluster("C:\\Users\\Ben\\workspace\\fdb\\fdb.cluster"); System.out.println("I now have the cluster"); Database db = cluster.openDatabase(); diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/TupleTest.java b/bindings/java/src/test/com/apple/foundationdb/test/TupleTest.java similarity index 82% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/TupleTest.java rename to bindings/java/src/test/com/apple/foundationdb/test/TupleTest.java index 6313e52367..dd910bfaca 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/TupleTest.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/TupleTest.java @@ -18,15 +18,15 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; -import com.apple.cie.foundationdb.Cluster; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.TransactionContext; -import com.apple.cie.foundationdb.async.Function; -import com.apple.cie.foundationdb.tuple.Tuple; +import com.apple.foundationdb.Cluster; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.TransactionContext; +import com.apple.foundationdb.async.Function; +import com.apple.foundationdb.tuple.Tuple; public class TupleTest { private static final String CLUSTER_FILE = "C:\\Users\\Ben\\workspace\\fdb\\fdb.cluster"; @@ -34,7 +34,7 @@ public class TupleTest { public static void main(String[] args) throws InterruptedException { final int reps = 1000; try { - Cluster c = FDB.selectAPIVersion(500).createCluster(CLUSTER_FILE); + Cluster c = FDB.selectAPIVersion(510).createCluster(CLUSTER_FILE); Database db = c.openDatabase(); runTests(reps, db); } catch(Throwable t) { diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/VersionstampExample.java b/bindings/java/src/test/com/apple/foundationdb/test/VersionstampExample.java similarity index 82% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/VersionstampExample.java rename to bindings/java/src/test/com/apple/foundationdb/test/VersionstampExample.java index 9d33540aaa..0a7f4267b3 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/VersionstampExample.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/VersionstampExample.java @@ -18,15 +18,15 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.*; -import com.apple.cie.foundationdb.async.Function; -import com.apple.cie.foundationdb.tuple.Tuple; -import com.apple.cie.foundationdb.async.Future; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.*; +import com.apple.foundationdb.async.Function; +import com.apple.foundationdb.tuple.Tuple; +import com.apple.foundationdb.async.Future; import java.lang.System; @@ -43,7 +43,7 @@ public class VersionstampExample { } public static void main(String[] args) { - FDB fdb = FDB.selectAPIVersion(500); + FDB fdb = FDB.selectAPIVersion(510); Database db = fdb.open(); Transaction tr = db.createTransaction(); tr.mutate(MutationType.SET_VERSIONSTAMPED_VALUE, "foo".getBytes(), "blahblahbl".getBytes()); diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/WatchTest.java b/bindings/java/src/test/com/apple/foundationdb/test/WatchTest.java similarity index 90% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/WatchTest.java rename to bindings/java/src/test/com/apple/foundationdb/test/WatchTest.java index 772cd049ac..0ddd3132de 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/WatchTest.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/WatchTest.java @@ -18,23 +18,23 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; import java.util.Random; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; -import com.apple.cie.foundationdb.Database; -import com.apple.cie.foundationdb.FDB; -import com.apple.cie.foundationdb.FDBException; -import com.apple.cie.foundationdb.Transaction; -import com.apple.cie.foundationdb.async.Future; +import com.apple.foundationdb.Database; +import com.apple.foundationdb.FDB; +import com.apple.foundationdb.FDBException; +import com.apple.foundationdb.Transaction; +import com.apple.foundationdb.async.Future; public class WatchTest { public static void main(String[] args) { - FDB fdb = FDB.selectAPIVersion(500); + FDB fdb = FDB.selectAPIVersion(510); Database database = fdb.open(args[0]); database.options().setLocationCacheSize(42); Transaction tr = database.createTransaction(); diff --git a/bindings/java/src/test/com/apple/cie/foundationdb/test/WhileTrueTest.java b/bindings/java/src/test/com/apple/foundationdb/test/WhileTrueTest.java similarity index 87% rename from bindings/java/src/test/com/apple/cie/foundationdb/test/WhileTrueTest.java rename to bindings/java/src/test/com/apple/foundationdb/test/WhileTrueTest.java index 2e55439bb8..2b035b95e7 100644 --- a/bindings/java/src/test/com/apple/cie/foundationdb/test/WhileTrueTest.java +++ b/bindings/java/src/test/com/apple/foundationdb/test/WhileTrueTest.java @@ -18,12 +18,12 @@ * limitations under the License. */ -package com.apple.cie.foundationdb.test; +package com.apple.foundationdb.test; -import com.apple.cie.foundationdb.async.AsyncUtil; -import com.apple.cie.foundationdb.async.Function; -import com.apple.cie.foundationdb.async.Future; -import com.apple.cie.foundationdb.async.ReadyFuture; +import com.apple.foundationdb.async.AsyncUtil; +import com.apple.foundationdb.async.Function; +import com.apple.foundationdb.async.Future; +import com.apple.foundationdb.async.ReadyFuture; public class WhileTrueTest { private static int count; diff --git a/bindings/nodejs/lib/fdb.js b/bindings/nodejs/lib/fdb.js index 308fde6ac5..b2f640f40a 100644 --- a/bindings/nodejs/lib/fdb.js +++ b/bindings/nodejs/lib/fdb.js @@ -43,8 +43,8 @@ module.exports = { throw new Error('Cannot select multiple different FDB API versions'); if(version < 500) throw new RangeError('FDB API versions before 500 are not supported'); - if(version > 500) - throw new RangeError('Latest known FDB API version is 500'); + if(version > 510) + throw new RangeError('Latest known FDB API version is 510'); if(!selectedApiVersion.value) { fdb.apiVersion(version); diff --git a/bindings/nodejs/src/Version.h b/bindings/nodejs/src/Version.h index 52afea41d5..e10f77febb 100644 --- a/bindings/nodejs/src/Version.h +++ b/bindings/nodejs/src/Version.h @@ -22,6 +22,6 @@ #ifndef FDB_NODE_VERSION_H #define FDB_NODE_VERSION_H -#define FDB_API_VERSION 500 +#define FDB_API_VERSION 510 #endif diff --git a/bindings/nodejs/tests/tester.js b/bindings/nodejs/tests/tester.js index 850989ff0f..1e041b8ee5 100755 --- a/bindings/nodejs/tests/tester.js +++ b/bindings/nodejs/tests/tester.js @@ -719,6 +719,8 @@ function processOperation(context, inst, cb) { tr.options.setMaxRetryDelay(100); tr.options.setUsedDuringCommitProtectionDisable(); tr.options.setTransactionLoggingEnable('my_transaction'); + tr.options.setReadLockAware() + tr.options.setLockAware() tr.get(fdb.buffer.fromByteLiteral('\xff'), innerCb); }) diff --git a/bindings/nodejs/tests/tuple_test.js b/bindings/nodejs/tests/tuple_test.js index 56efde8d78..ce3503cb08 100755 --- a/bindings/nodejs/tests/tuple_test.js +++ b/bindings/nodejs/tests/tuple_test.js @@ -18,7 +18,7 @@ * limitations under the License. */ -var fdb = require('../lib/fdb.js').apiVersion(500); +var fdb = require('../lib/fdb.js').apiVersion(510); var fdbModule = require('../lib/fdbModule.js'); console.log(fdb.tuple.pack([-Math.pow(2,53)])); diff --git a/bindings/python/fdb/__init__.py b/bindings/python/fdb/__init__.py index 4beab564e4..696ff4d7d2 100644 --- a/bindings/python/fdb/__init__.py +++ b/bindings/python/fdb/__init__.py @@ -36,7 +36,7 @@ def _add_symbols(module, symbols): globals()[symbol] = getattr(module, symbol) def api_version(ver): - header_version = 500 + header_version = 510 if '_version' in globals(): if globals()['_version'] != ver: diff --git a/bindings/python/fdb/locality.py b/bindings/python/fdb/locality.py index d459752dec..008c8cd48f 100644 --- a/bindings/python/fdb/locality.py +++ b/bindings/python/fdb/locality.py @@ -48,7 +48,7 @@ def _get_boundary_keys(db_or_tr, begin, end): begin = kv.key[13:]+b'\x00' begin = end except _impl.FDBError as e: - if e.code == 1007 and begin != lastbegin: # if we get a past_version and *something* has happened, then we are no longer transactional + if e.code == 1007 and begin != lastbegin: # if we get a transaction_too_old and *something* has happened, then we are no longer transactional tr = tr.db.create_transaction() else: tr.on_error(e).wait() diff --git a/bindings/python/tests/tester.py b/bindings/python/tests/tester.py index 54285b1f48..0743afb816 100755 --- a/bindings/python/tests/tester.py +++ b/bindings/python/tests/tester.py @@ -135,6 +135,8 @@ def test_options(tr): tr.options.set_max_retry_delay(100); tr.options.set_used_during_commit_protection_disable() tr.options.set_transaction_logging_enable('my_transaction') + tr.options.set_read_lock_aware() + tr.options.set_lock_aware() tr.get(b'\xff').wait() diff --git a/bindings/ruby/lib/fdb.rb b/bindings/ruby/lib/fdb.rb index ba4d71960b..5f5d2ebbc7 100644 --- a/bindings/ruby/lib/fdb.rb +++ b/bindings/ruby/lib/fdb.rb @@ -26,7 +26,7 @@ module FDB @@chosen_version = -1 def self.api_version(version) - header_version = 500 + header_version = 510 if @@chosen_version >= 0 if@@chosen_version != version raise "FDB API already loaded at version #{@@chosen_version}." diff --git a/bindings/ruby/tests/tester.rb b/bindings/ruby/tests/tester.rb index 33b7c073d7..f9081ef2f1 100755 --- a/bindings/ruby/tests/tester.rb +++ b/bindings/ruby/tests/tester.rb @@ -445,6 +445,8 @@ class Tester tr.options.set_max_retry_delay(100) tr.options.set_used_during_commit_protection_disable tr.options.set_transaction_logging_enable('my_transaction') + tr.options.set_read_lock_aware() + tr.options.set_lock_aware() tr.get("\xff").to_s end diff --git a/fdbbackup/backup.actor.cpp b/fdbbackup/backup.actor.cpp index c99cb7efbc..c5382c0ca7 100644 --- a/fdbbackup/backup.actor.cpp +++ b/fdbbackup/backup.actor.cpp @@ -73,11 +73,11 @@ enum enumProgramExe { }; enum enumBackupType { - BACKUP_UNDEFINED=0, BACKUP_START, BACKUP_STATUS, BACKUP_ABORT, BACKUP_WAIT, BACKUP_DISCONTINUE + BACKUP_UNDEFINED=0, BACKUP_START, BACKUP_STATUS, BACKUP_ABORT, BACKUP_WAIT, BACKUP_DISCONTINUE, BACKUP_DISABLE, BACKUP_ENABLE }; enum enumDBType { - DB_UNDEFINED=0, DB_START, DB_STATUS, DB_SWITCH, DB_ABORT + DB_UNDEFINED=0, DB_START, DB_STATUS, DB_SWITCH, DB_ABORT, DB_DISABLE, DB_ENABLE }; enum enumRestoreType { @@ -99,7 +99,7 @@ enum { OPT_CLUSTERFILE, OPT_QUIET, OPT_DRYRUN, OPT_FORCE, OPT_HELP, OPT_DEVHELP, OPT_VERSION, OPT_PARENTPID, OPT_CRASHONERROR, OPT_NOBUFSTDOUT, OPT_BUFSTDOUTERR, OPT_TRACE, OPT_TRACE_DIR, - OPT_KNOB, OPT_TRACE_LOG_GROUP, OPT_LOCALITY, + OPT_KNOB, OPT_TRACE_LOG_GROUP, OPT_MEMLIMIT, OPT_LOCALITY, //DB constants OPT_SOURCE_CLUSTER, @@ -123,6 +123,8 @@ CSimpleOpt::SOption g_rgAgentOptions[] = { { OPT_TRACE_DIR, "--logdir", SO_REQ_SEP }, { OPT_CRASHONERROR, "--crash", SO_NONE }, { OPT_LOCALITY, "--locality_", SO_REQ_SEP }, + { OPT_MEMLIMIT, "-m", SO_REQ_SEP }, + { OPT_MEMLIMIT, "--memory", SO_REQ_SEP }, { OPT_HELP, "-?", SO_NONE }, { OPT_HELP, "-h", SO_NONE }, { OPT_HELP, "--help", SO_NONE }, @@ -158,6 +160,8 @@ CSimpleOpt::SOption g_rgBackupStartOptions[] = { { OPT_VERSION, "--version", SO_NONE }, { OPT_VERSION, "-v", SO_NONE }, { OPT_CRASHONERROR, "--crash", SO_NONE }, + { OPT_MEMLIMIT, "-m", SO_REQ_SEP }, + { OPT_MEMLIMIT, "--memory", SO_REQ_SEP }, { OPT_HELP, "-?", SO_NONE }, { OPT_HELP, "-h", SO_NONE }, { OPT_HELP, "--help", SO_NONE }, @@ -184,6 +188,8 @@ CSimpleOpt::SOption g_rgBackupStatusOptions[] = { { OPT_QUIET, "-q", SO_NONE }, { OPT_QUIET, "--quiet", SO_NONE }, { OPT_CRASHONERROR, "--crash", SO_NONE }, + { OPT_MEMLIMIT, "-m", SO_REQ_SEP }, + { OPT_MEMLIMIT, "--memory", SO_REQ_SEP }, { OPT_HELP, "-?", SO_NONE }, { OPT_HELP, "-h", SO_NONE }, { OPT_HELP, "--help", SO_NONE }, @@ -207,6 +213,8 @@ CSimpleOpt::SOption g_rgBackupAbortOptions[] = { { OPT_VERSION, "--version", SO_NONE }, { OPT_VERSION, "-v", SO_NONE }, { OPT_CRASHONERROR, "--crash", SO_NONE }, + { OPT_MEMLIMIT, "-m", SO_REQ_SEP }, + { OPT_MEMLIMIT, "--memory", SO_REQ_SEP }, { OPT_HELP, "-?", SO_NONE }, { OPT_HELP, "-h", SO_NONE }, { OPT_HELP, "--help", SO_NONE }, @@ -232,6 +240,8 @@ CSimpleOpt::SOption g_rgBackupDiscontinueOptions[] = { { OPT_VERSION, "--version", SO_NONE }, { OPT_VERSION, "-v", SO_NONE }, { OPT_CRASHONERROR, "--crash", SO_NONE }, + { OPT_MEMLIMIT, "-m", SO_REQ_SEP }, + { OPT_MEMLIMIT, "--memory", SO_REQ_SEP }, { OPT_HELP, "-?", SO_NONE }, { OPT_HELP, "-h", SO_NONE }, { OPT_HELP, "--help", SO_NONE }, @@ -257,6 +267,31 @@ CSimpleOpt::SOption g_rgBackupWaitOptions[] = { { OPT_VERSION, "--version", SO_NONE }, { OPT_VERSION, "-v", SO_NONE }, { OPT_CRASHONERROR, "--crash", SO_NONE }, + { OPT_MEMLIMIT, "-m", SO_REQ_SEP }, + { OPT_MEMLIMIT, "--memory", SO_REQ_SEP }, + { OPT_HELP, "-?", SO_NONE }, + { OPT_HELP, "-h", SO_NONE }, + { OPT_HELP, "--help", SO_NONE }, + { OPT_DEVHELP, "--dev-help", SO_NONE }, + + SO_END_OF_OPTIONS +}; + +CSimpleOpt::SOption g_rgBackupDisableOptions[] = { +#ifdef _WIN32 + { OPT_PARENTPID, "--parentpid", SO_REQ_SEP }, +#endif + { OPT_CLUSTERFILE, "-C", SO_REQ_SEP }, + { OPT_CLUSTERFILE, "--cluster_file", SO_REQ_SEP }, + { OPT_TRACE, "--log", SO_NONE }, + { OPT_TRACE_DIR, "--logdir", SO_REQ_SEP }, + { OPT_QUIET, "-q", SO_NONE }, + { OPT_QUIET, "--quiet", SO_NONE }, + { OPT_VERSION, "--version", SO_NONE }, + { OPT_VERSION, "-v", SO_NONE }, + { OPT_CRASHONERROR, "--crash", SO_NONE }, + { OPT_MEMLIMIT, "-m", SO_REQ_SEP }, + { OPT_MEMLIMIT, "--memory", SO_REQ_SEP }, { OPT_HELP, "-?", SO_NONE }, { OPT_HELP, "-h", SO_NONE }, { OPT_HELP, "--help", SO_NONE }, @@ -292,6 +327,8 @@ CSimpleOpt::SOption g_rgRestoreOptions[] = { { OPT_FORCE, "-f", SO_NONE }, { OPT_FORCE, "--force", SO_NONE }, { OPT_CRASHONERROR, "--crash", SO_NONE }, + { OPT_MEMLIMIT, "-m", SO_REQ_SEP }, + { OPT_MEMLIMIT, "--memory", SO_REQ_SEP }, { OPT_HELP, "-?", SO_NONE }, { OPT_HELP, "-h", SO_NONE }, { OPT_HELP, "--help", SO_NONE }, @@ -318,6 +355,8 @@ CSimpleOpt::SOption g_rgDBAgentOptions[] = { { OPT_TRACE_DIR, "--logdir", SO_REQ_SEP }, { OPT_CRASHONERROR, "--crash", SO_NONE }, { OPT_LOCALITY, "--locality_", SO_REQ_SEP }, + { OPT_MEMLIMIT, "-m", SO_REQ_SEP }, + { OPT_MEMLIMIT, "--memory", SO_REQ_SEP }, { OPT_HELP, "-?", SO_NONE }, { OPT_HELP, "-h", SO_NONE }, { OPT_HELP, "--help", SO_NONE }, @@ -345,6 +384,8 @@ CSimpleOpt::SOption g_rgDBStartOptions[] = { { OPT_VERSION, "--version", SO_NONE }, { OPT_VERSION, "-v", SO_NONE }, { OPT_CRASHONERROR, "--crash", SO_NONE }, + { OPT_MEMLIMIT, "-m", SO_REQ_SEP }, + { OPT_MEMLIMIT, "--memory", SO_REQ_SEP }, { OPT_HELP, "-?", SO_NONE }, { OPT_HELP, "-h", SO_NONE }, { OPT_HELP, "--help", SO_NONE }, @@ -372,6 +413,8 @@ CSimpleOpt::SOption g_rgDBStatusOptions[] = { { OPT_QUIET, "-q", SO_NONE }, { OPT_QUIET, "--quiet", SO_NONE }, { OPT_CRASHONERROR, "--crash", SO_NONE }, + { OPT_MEMLIMIT, "-m", SO_REQ_SEP }, + { OPT_MEMLIMIT, "--memory", SO_REQ_SEP }, { OPT_HELP, "-?", SO_NONE }, { OPT_HELP, "-h", SO_NONE }, { OPT_HELP, "--help", SO_NONE }, @@ -397,6 +440,8 @@ CSimpleOpt::SOption g_rgDBSwitchOptions[] = { { OPT_VERSION, "--version", SO_NONE }, { OPT_VERSION, "-v", SO_NONE }, { OPT_CRASHONERROR, "--crash", SO_NONE }, + { OPT_MEMLIMIT, "-m", SO_REQ_SEP }, + { OPT_MEMLIMIT, "--memory", SO_REQ_SEP }, { OPT_HELP, "-?", SO_NONE }, { OPT_HELP, "-h", SO_NONE }, { OPT_HELP, "--help", SO_NONE }, @@ -423,6 +468,33 @@ CSimpleOpt::SOption g_rgDBAbortOptions[] = { { OPT_VERSION, "--version", SO_NONE }, { OPT_VERSION, "-v", SO_NONE }, { OPT_CRASHONERROR, "--crash", SO_NONE }, + { OPT_MEMLIMIT, "-m", SO_REQ_SEP }, + { OPT_MEMLIMIT, "--memory", SO_REQ_SEP }, + { OPT_HELP, "-?", SO_NONE }, + { OPT_HELP, "-h", SO_NONE }, + { OPT_HELP, "--help", SO_NONE }, + { OPT_DEVHELP, "--dev-help", SO_NONE }, + + SO_END_OF_OPTIONS +}; + +CSimpleOpt::SOption g_rgDBDisableOptions[] = { +#ifdef _WIN32 + { OPT_PARENTPID, "--parentpid", SO_REQ_SEP }, +#endif + { OPT_SOURCE_CLUSTER, "-s", SO_REQ_SEP }, + { OPT_SOURCE_CLUSTER, "--source", SO_REQ_SEP }, + { OPT_DEST_CLUSTER, "-d", SO_REQ_SEP }, + { OPT_DEST_CLUSTER, "--destination", SO_REQ_SEP }, + { OPT_TRACE, "--log", SO_NONE }, + { OPT_TRACE_DIR, "--logdir", SO_REQ_SEP }, + { OPT_QUIET, "-q", SO_NONE }, + { OPT_QUIET, "--quiet", SO_NONE }, + { OPT_VERSION, "--version", SO_NONE }, + { OPT_VERSION, "-v", SO_NONE }, + { OPT_CRASHONERROR, "--crash", SO_NONE }, + { OPT_MEMLIMIT, "-m", SO_REQ_SEP }, + { OPT_MEMLIMIT, "--memory", SO_REQ_SEP }, { OPT_HELP, "-?", SO_NONE }, { OPT_HELP, "-h", SO_NONE }, { OPT_HELP, "--help", SO_NONE }, @@ -436,6 +508,8 @@ CSimpleOpt::SOption g_rgBlobOptions[] = { { OPT_VERSION, "--version", SO_NONE }, { OPT_VERSION, "-v", SO_NONE }, { OPT_CRASHONERROR, "--crash", SO_NONE }, + { OPT_MEMLIMIT, "-m", SO_REQ_SEP }, + { OPT_MEMLIMIT, "--memory", SO_REQ_SEP }, { OPT_HELP, "-?", SO_NONE }, { OPT_HELP, "-h", SO_NONE }, { OPT_HELP, "--help", SO_NONE }, @@ -488,6 +562,9 @@ static void printAgentUsage(bool devhelp) { " --logdir PATH Specifes the output directory for trace files. If\n" " unspecified, defaults to the current directory. Has\n" " no effect unless --log is specified.\n"); + printf(" -m SIZE, --memory SIZE\n" + " Memory limit. The default value is 8GiB. When specified\n" + " without a unit, MiB is assumed.\n"); printf(" -v, --version Print version information and exit.\n"); printf(" -h, --help Display this help and exit.\n"); if (devhelp) { @@ -519,7 +596,7 @@ void printBackupContainerInfo() { static void printBackupUsage(bool devhelp) { printf("FoundationDB " FDB_VT_PACKAGE_NAME " (v" FDB_VT_VERSION ")\n"); - printf("Usage: %s (start | status | abort | wait | discontinue) [OPTIONS]\n\n", exeBackup.toString().c_str()); + printf("Usage: %s (start | status | abort | wait | discontinue | disable | enable) [OPTIONS]\n\n", exeBackup.toString().c_str()); printf(" -C CONNFILE The path of a file containing the connection string for the\n" " FoundationDB cluster. The default is first the value of the\n" " FDB_CLUSTER_FILE environment variable, then `./fdb.cluster',\n" @@ -596,6 +673,9 @@ static void printDBAgentUsage(bool devhelp) { " --logdir PATH Specifes the output directory for trace files. If\n" " unspecified, defaults to the current directory. Has\n" " no effect unless --log is specified.\n"); + printf(" -m SIZE, --memory SIZE\n" + " Memory limit. The default value is 8GiB. When specified\n" + " without a unit, MiB is assumed.\n"); printf(" -v, --version Print version information and exit.\n"); printf(" -h, --help Display this help and exit.\n"); if (devhelp) { @@ -612,7 +692,7 @@ static void printDBAgentUsage(bool devhelp) { static void printDBBackupUsage(bool devhelp) { printf("FoundationDB " FDB_VT_PACKAGE_NAME " (v" FDB_VT_VERSION ")\n"); - printf("Usage: %s (start | status | switch | abort) [OPTIONS]\n\n", exeDatabaseBackup.toString().c_str()); + printf("Usage: %s (start | status | switch | abort | disable | enable) [OPTIONS]\n\n", exeDatabaseBackup.toString().c_str()); printf(" -d, --destination CONNFILE\n" " The path of a file containing the connection string for the\n"); printf(" destination FoundationDB cluster.\n"); @@ -774,6 +854,8 @@ enumBackupType getBackupType(std::string backupType) values["abort"] = BACKUP_ABORT; values["wait"] = BACKUP_WAIT; values["discontinue"] = BACKUP_DISCONTINUE; + values["disable"] = BACKUP_DISABLE; + values["enable"] = BACKUP_ENABLE; } auto i = values.find(backupType); @@ -804,6 +886,8 @@ enumDBType getDBType(std::string dbType) values["status"] = DB_STATUS; values["switch"] = DB_SWITCH; values["abort"] = DB_ABORT; + values["disable"] = DB_DISABLE; + values["enable"] = DB_ENABLE; } auto i = values.find(dbType); @@ -832,7 +916,6 @@ ACTOR Future getLayerStatus(Reference tr op.create("version") = readVer + 120 * CLIENT_KNOBS->CORE_VERSIONSPERSECOND; layerRoot.create("instances_running.$sum") = 1; - layerRoot.create("total_workers.$sum") = CLIENT_KNOBS->BACKUP_TASKS_PER_AGENT; layerRoot.create("last_updated.$max") = now(); state JSONDoc o = layerRoot.subDoc("instances." + id); @@ -844,7 +927,7 @@ ACTOR Future getLayerStatus(Reference tr o.create("resident_size") = (int64_t)getResidentMemoryUsage(); o.create("main_thread_cpu_seconds") = getProcessorTimeThread(); o.create("process_cpu_seconds") = getProcessorTimeProcess(); - o.create("workers") = CLIENT_KNOBS->BACKUP_TASKS_PER_AGENT; + o.create("configured_workers") = CLIENT_KNOBS->BACKUP_TASKS_PER_AGENT; if(exe == EXE_AGENT) { static BlobStoreEndpoint::Stats last_stats; @@ -865,39 +948,45 @@ ACTOR Future getLayerStatus(Reference tr totalBlobStats.create(p.first + ".$sum") = p.second; state FileBackupAgent fba; - state Standalone backupTagNames = wait( tr->getRange(fba.tagNames.range(), 10000)); + state std::vector backupTags = wait(getAllBackupTags(tr)); state std::vector> tagLastRestorableVersions; - state std::vector> tagStates; + state std::vector> tagStates; state std::vector> tagContainers; state std::vector> tagRangeBytes; state std::vector> tagLogBytes; + state Future> fBackupDisabled = tr->get(fba.taskBucket->getDisableKey()); state int i = 0; - for(i = 0; i < backupTagNames.size(); i++) { - Standalone tagName = fba.tagNames.unpack(backupTagNames[i].key).getString(0); - UID tagUID = BinaryReader::fromStringRef(backupTagNames[i].value, Unversioned()); - tagLastRestorableVersions.push_back(fba.getLastRestorable(tr, tagName)); - tagStates.push_back(fba.getStateValue(tr, tagUID)); - tagContainers.push_back(fba.getLastBackupContainer(tr, tagUID)); - tagRangeBytes.push_back(fba.getRangeBytesWritten(tr, tagUID)); - tagLogBytes.push_back(fba.getLogBytesWritten(tr, tagUID)); + tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); + tr->setOption(FDBTransactionOptions::LOCK_AWARE); + state std::vector::iterator tag; + for (tag = backupTags.begin(); tag != backupTags.end(); tag++) { + UidAndAbortedFlagT uidAndAbortedFlag = wait(tag->getOrThrow(tr)); + BackupConfig config(uidAndAbortedFlag.first); + + tagStates.push_back(config.stateEnum().getOrThrow(tr)); + tagRangeBytes.push_back(config.rangeBytesWritten().getD(tr, 0)); + tagLogBytes.push_back(config.logBytesWritten().getD(tr, 0)); + tagContainers.push_back(config.backupContainer().getOrThrow(tr)); + tagLastRestorableVersions.push_back(fba.getLastRestorable(tr, StringRef(tag->tagName))); } - Void _ = wait( waitForAll(tagLastRestorableVersions) && waitForAll(tagStates) && waitForAll(tagContainers) && waitForAll(tagRangeBytes) && waitForAll(tagLogBytes)); + Void _ = wait( waitForAll(tagLastRestorableVersions) && waitForAll(tagStates) && waitForAll(tagContainers) && waitForAll(tagRangeBytes) && waitForAll(tagLogBytes) && success(fBackupDisabled)); JSONDoc tagsRoot = layerRoot.subDoc("tags.$latest"); layerRoot.create("tags.timestamp") = now(); + layerRoot.create("total_workers.$sum") = fBackupDisabled.get().present() ? 0 : CLIENT_KNOBS->BACKUP_TASKS_PER_AGENT; + layerRoot.create("disabled.$latest") = fBackupDisabled.get().present(); - for (int j = 0; j < backupTagNames.size(); j++) { - std::string tagName = fba.tagNames.unpack(backupTagNames[j].key).getString(0).toString(); - + int j = 0; + for (KeyBackedTag eachTag : backupTags) { Version last_restorable_version = tagLastRestorableVersions[j].get(); double last_restorable_seconds_behind = ((double)readVer - last_restorable_version) / CLIENT_KNOBS->CORE_VERSIONSPERSECOND; BackupAgentBase::enumState status = (BackupAgentBase::enumState)tagStates[j].get(); const char *statusText = fba.getStateText(status); // The object for this backup tag inside this instance's subdocument - JSONDoc tagRoot = tagsRoot.subDoc(tagName); + JSONDoc tagRoot = tagsRoot.subDoc(eachTag.tagName); tagRoot.create("current_container") = tagContainers[j].get(); tagRoot.create("current_status") = statusText; tagRoot.create("last_restorable_version") = tagLastRestorableVersions[j].get(); @@ -906,6 +995,8 @@ ACTOR Future getLayerStatus(Reference tr tagRoot.create("running_backup_is_restorable") = (status == BackupAgentBase::STATE_DIFFERENTIAL); tagRoot.create("range_bytes_written") = tagRangeBytes[j].get(); tagRoot.create("mutation_log_bytes_written") = tagLogBytes[j].get(); + + j++; } } else if(exe == EXE_DR_AGENT) { @@ -918,6 +1009,7 @@ ACTOR Future getLayerStatus(Reference tr state std::vector> backupStatus; state std::vector> tagRangeBytesDR; state std::vector> tagLogBytesDR; + state Future> fDRDisabled = tr->get(dba.taskBucket->getDisableKey()); for(int i = 0; i < tagNames.size(); i++) { backupVersion.push_back(tr2->get(tagNames[i].value.withPrefix(applyMutationsBeginRange.begin))); @@ -927,10 +1019,12 @@ ACTOR Future getLayerStatus(Reference tr tagLogBytesDR.push_back(dba.getLogBytesWritten(tr2, tagUID)); } - Void _ = wait(waitForAll(backupStatus) && waitForAll(backupVersion) && waitForAll(tagRangeBytesDR) && waitForAll(tagLogBytesDR)); + Void _ = wait(waitForAll(backupStatus) && waitForAll(backupVersion) && waitForAll(tagRangeBytesDR) && waitForAll(tagLogBytesDR) && success(fDRDisabled)); JSONDoc tagsRoot = layerRoot.subDoc("tags.$latest"); layerRoot.create("tags.timestamp") = now(); + layerRoot.create("total_workers.$sum") = fDRDisabled.get().present() ? 0 : CLIENT_KNOBS->BACKUP_TASKS_PER_AGENT; + layerRoot.create("disabled.$latest") = fDRDisabled.get().present(); for (int i = 0; i < tagNames.size(); i++) { std::string tagName = dba.sourceTagNames.unpack(tagNames[i].key).getString(0).toString(); @@ -1210,12 +1304,17 @@ ACTOR Future submitBackup(Database db, std::string destinationDir, Standal } if (dryRun) { - state UID logUid = wait(backupAgent.getLogUid(db, StringRef(tagName))); - state int backupStatus = wait(backupAgent.getStateValue(db, logUid)); + state KeyBackedTag tag = makeBackupTag(tagName); + Optional uidFlag = wait(tag.get(db)); - // Throw error if a backup is currently running until we support parallel backups - if (BackupAgentBase::isRunnable((BackupAgentBase::enumState)backupStatus)) { - throw backup_duplicate(); + if (uidFlag.present()) { + BackupConfig config(uidFlag.get().first); + EBackupState backupStatus = wait(config.stateEnum().getOrThrow(db)); + + // Throw error if a backup is currently running until we support parallel backups + if (BackupAgentBase::isRunnable((BackupAgentBase::enumState)backupStatus)) { + throw backup_duplicate(); + } } if (waitForCompletion) { @@ -1239,12 +1338,12 @@ ACTOR Future submitBackup(Database db, std::string destinationDir, Standal } else { - Void _ = wait(backupAgent.submitBackup(db, KeyRef(destinationDir), KeyRef(tagName), backupRanges, stopWhenDone)); + Void _ = wait(backupAgent.submitBackup(db, KeyRef(destinationDir), tagName, backupRanges, stopWhenDone)); // Wait for the backup to complete, if requested if (waitForCompletion) { printf("Submitted and now waiting for the backup on tag `%s' to complete.\n", printable(StringRef(tagName)).c_str()); - int _ = wait(backupAgent.waitBackup(db, StringRef(tagName))); + int _ = wait(backupAgent.waitBackup(db, tagName)); } else { // Check if a backup agent is running @@ -1344,7 +1443,7 @@ ACTOR Future statusBackup(Database db, std::string tagName, int errorLimit { state FileBackupAgent backupAgent; - std::string statusText = wait(backupAgent.getStatus(db, errorLimit, StringRef(tagName))); + std::string statusText = wait(backupAgent.getStatus(db, errorLimit, tagName)); printf("%s\n", statusText.c_str()); } catch (Error& e) { @@ -1393,7 +1492,7 @@ ACTOR Future abortBackup(Database db, std::string tagName) { { state FileBackupAgent backupAgent; - Void _ = wait(backupAgent.abortBackup(db, Key(tagName))); + Void _ = wait(backupAgent.abortBackup(db, tagName)); printf("The backup on tag `%s' was successfully aborted.\n", printable(StringRef(tagName)).c_str()); } @@ -1423,7 +1522,7 @@ ACTOR Future waitBackup(Database db, std::string tagName, bool stopWhenDon { state FileBackupAgent backupAgent; - int status = wait(backupAgent.waitBackup(db, StringRef(tagName), stopWhenDone)); + int status = wait(backupAgent.waitBackup(db, tagName, stopWhenDone)); printf("The backup on tag `%s' %s.\n", printable(StringRef(tagName)).c_str(), BackupAgentBase::getStateText((BackupAgentBase::enumState) status)); @@ -1448,7 +1547,7 @@ ACTOR Future discontinueBackup(Database db, std::string tagName, bool wait // Wait for the backup to complete, if requested if (waitForCompletion) { printf("Discontinued and now waiting for the backup on tag `%s' to complete.\n", printable(StringRef(tagName)).c_str()); - int _ = wait(backupAgent.waitBackup(db, StringRef(tagName))); + int _ = wait(backupAgent.waitBackup(db, tagName)); } else { printf("The backup on tag `%s' was successfully discontinued.\n", printable(StringRef(tagName)).c_str()); @@ -1479,6 +1578,38 @@ ACTOR Future discontinueBackup(Database db, std::string tagName, bool wait return Void(); } +ACTOR Future changeBackupEnabled(Database db, bool disable) { + try { + state FileBackupAgent backupAgent; + Void _ = wait(backupAgent.taskBucket->changeDisable(db, disable)); + printf("All backup agents have been %s.\n", disable ? "disabled" : "enabled"); + } + catch (Error& e) { + if(e.code() == error_code_actor_cancelled) + throw; + fprintf(stderr, "ERROR: %s\n", e.what()); + throw; + } + + return Void(); +} + +ACTOR Future changeDBBackupEnabled(Database src, Database dest, bool disable) { + try { + state DatabaseBackupAgent backupAgent(src); + Void _ = wait(backupAgent.taskBucket->changeDisable(dest, disable)); + printf("All DR agents have been %s.\n", disable ? "disabled" : "enabled"); + } + catch (Error& e) { + if(e.code() == error_code_actor_cancelled) + throw; + fprintf(stderr, "ERROR: %s\n", e.what()); + throw; + } + + return Void(); +} + ACTOR Future runRestore(Database db, std::string tagName, std::string container, Standalone> ranges, Version dbVersion, bool performRestore, bool verbose, bool waitForDone, std::string addPrefix, std::string removePrefix) { try { @@ -1880,6 +2011,12 @@ int main(int argc, char* argv[]) { case BACKUP_DISCONTINUE: args = new CSimpleOpt(argc - 1, &argv[1], g_rgBackupDiscontinueOptions, SO_O_EXACT); break; + case BACKUP_DISABLE: + args = new CSimpleOpt(argc - 1, &argv[1], g_rgBackupDisableOptions, SO_O_EXACT); + break; + case BACKUP_ENABLE: + args = new CSimpleOpt(argc - 1, &argv[1], g_rgBackupDisableOptions, SO_O_EXACT); + break; case BACKUP_UNDEFINED: default: // Display help, if requested @@ -1923,6 +2060,12 @@ int main(int argc, char* argv[]) { case DB_ABORT: args = new CSimpleOpt(argc - 1, &argv[1], g_rgDBAbortOptions, SO_O_EXACT); break; + case DB_DISABLE: + args = new CSimpleOpt(argc - 1, &argv[1], g_rgDBDisableOptions, SO_O_EXACT); + break; + case DB_ENABLE: + args = new CSimpleOpt(argc - 1, &argv[1], g_rgDBDisableOptions, SO_O_EXACT); + break; case DB_UNDEFINED: default: // Display help, if requested @@ -1998,6 +2141,8 @@ int main(int argc, char* argv[]) { ESOError lastError; bool partial = true; LocalityData localities; + uint64_t memLimit = 8LL << 30; + Optional ti; std::vector blobArgs; @@ -2196,6 +2341,15 @@ int main(int argc, char* argv[]) { case OPT_CRASHONERROR: g_crashOnError = true; break; + case OPT_MEMLIMIT: + ti = parse_with_suffix(args->OptionArg(), "MiB"); + if (!ti.present()) { + fprintf(stderr, "ERROR: Could not parse memory limit from `%s'\n", args->OptionArg()); + printHelpTeaser(argv[0]); + flushAndExit(FDB_EXIT_ERROR); + } + memLimit = ti.get(); + break; } } @@ -2317,6 +2471,7 @@ int main(int argc, char* argv[]) { setNetworkOption(FDBNetworkOptions::DISABLE_CLIENT_STATISTICS_LOGGING); Error::init(); std::set_new_handler( &platform::outOfMemory ); + setMemoryQuota( memLimit ); int total = 0; for(auto i = Error::errorCounts().begin(); i != Error::errorCounts().end(); ++i) @@ -2377,6 +2532,7 @@ int main(int argc, char* argv[]) { .detail("PackageName", FDB_VT_PACKAGE_NAME) .detailf("ActualTime", "%lld", DEBUG_DETERMINISM ? 0 : time(NULL)) .detail("CommandLine", commandLine) + .detail("MemoryLimit", memLimit) .trackLatest("ProgramStart"); db = cluster->createDatabase(databaseKey, localities).get(); @@ -2454,6 +2610,14 @@ int main(int argc, char* argv[]) { f = stopAfter( discontinueBackup(db, tagName, waitForDone) ); break; + case BACKUP_DISABLE: + f = stopAfter( changeBackupEnabled(db, true) ); + break; + + case BACKUP_ENABLE: + f = stopAfter( changeBackupEnabled(db, false) ); + break; + case BACKUP_UNDEFINED: default: fprintf(stderr, "ERROR: Unsupported backup action %s\n", argv[1]); @@ -2494,7 +2658,7 @@ int main(int argc, char* argv[]) { case EXE_DR_AGENT: f = stopAfter( runDBAgent(source_db, db) ); break; - case EXE_DB_BACKUP: //DB_START, DB_STATUS, DB_SWITCH, DB_ABORT, DB_CLEANUP + case EXE_DB_BACKUP: switch (dbType) { case DB_START: @@ -2509,6 +2673,12 @@ int main(int argc, char* argv[]) { case DB_ABORT: f = stopAfter( abortDBBackup(source_db, db, tagName, partial) ); break; + case DB_DISABLE: + f = stopAfter( changeDBBackupEnabled(source_db, db, true) ); + break; + case DB_ENABLE: + f = stopAfter( changeDBBackupEnabled(source_db, db, false) ); + break; case DB_UNDEFINED: default: fprintf(stderr, "ERROR: Unsupported DR action %s\n", argv[1]); diff --git a/fdbcli/fdbcli.actor.cpp b/fdbcli/fdbcli.actor.cpp index ca99631507..07b5941021 100644 --- a/fdbcli/fdbcli.actor.cpp +++ b/fdbcli/fdbcli.actor.cpp @@ -18,6 +18,7 @@ * limitations under the License. */ +#include "boost/lexical_cast.hpp" #include "fdbclient/NativeAPI.h" #include "fdbclient/Status.h" #include "fdbclient/StatusClient.h" @@ -503,6 +504,10 @@ void initHelp() { "kill all|list|
*", "attempts to kill one or more processes in the cluster", "If no addresses are specified, populates the list of processes which can be killed. Processes cannot be killed before this list has been populated.\n\nIf `all' is specified, attempts to kill all known processes.\n\nIf `list' is specified, displays all known processes. This is only useful when the database is unresponsive.\n\nFor each IP:port pair in
*, attempt to kill the specified process."); + helpMap["profile"] = CommandHelp( + " ", + "namespace for all the profiling-related commands.", + "Different types support different actions. Run `profile` to get a list of types, and iteratively explore the help.\n"); hiddenCommands.insert("expensive_data_check"); hiddenCommands.insert("datadistribution"); @@ -693,6 +698,8 @@ void printStatus(StatusObjectReader statusObj, StatusClient::StatusLevel level, description += format("\nNeed at least %d log servers, %d proxies and %d resolvers.", recoveryState["required_logs"].get_int(), recoveryState["required_proxies"].get_int(), recoveryState["required_resolvers"].get_int()); if (statusObjCluster.has("machines") && statusObjCluster.has("processes")) description += format("\nHave %d processes on %d machines.", statusObjCluster["processes"].get_obj().size(), statusObjCluster["machines"].get_obj().size()); + } else if (name == "locking_old_transaction_servers" && recoveryState["missing_logs"].get_str().size()) { + description += format("\nNeed one or more of the following log servers: %s", recoveryState["missing_logs"].get_str().c_str()); } description = lineWrap(description.c_str(), 80); if (!printedCoordinators && ( @@ -1653,6 +1660,7 @@ ACTOR Future exclude( Database db, std::vector tokens, Referenc StatusObject status = wait( makeInterruptable( StatusClient::statusFetcher( ccf ) ) ); state std::string errorString = "ERROR: Could not calculate the impact of this exclude on the total free space in the cluster.\n" + "Please try the exclude again in 30 seconds.\n" "Type `exclude FORCE
*' to exclude without checking free space.\n"; StatusObjectReader statusObj(status); @@ -2535,6 +2543,182 @@ ACTOR Future cli(CLIOptions opt, LineNoise* plinenoise) { continue; } + if (tokencmp(tokens[0], "profile")) { + if (tokens.size() == 1) { + printf("ERROR: Usage: profile \n"); + is_error = true; + continue; + } + if (tokencmp(tokens[1], "client")) { + getTransaction(db, tr, options, intrans); + tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); + if (tokens.size() == 2) { + printf("ERROR: Usage: profile client \n"); + is_error = true; + continue; + } + if (tokencmp(tokens[2], "get")) { + if (tokens.size() != 3) { + printf("ERROR: Addtional arguments to `get` are not supported.\n"); + is_error = true; + continue; + } + state Future>> sampleRateFuture = tr->get(fdbClientInfoTxnSampleRate); + state Future>> sizeLimitFuture = tr->get(fdbClientInfoTxnSizeLimit); + Void _ = wait(makeInterruptable(success(sampleRateFuture) && success(sizeLimitFuture))); + std::string sampleRateStr = "default", sizeLimitStr = "default"; + if (sampleRateFuture.get().present()) { + const double sampleRateDbl = BinaryReader::fromStringRef(sampleRateFuture.get().get(), Unversioned()); + if (!std::isinf(sampleRateDbl)) { + sampleRateStr = boost::lexical_cast(sampleRateDbl); + } + } + if (sizeLimitFuture.get().present()) { + const int64_t sizeLimit = BinaryReader::fromStringRef(sizeLimitFuture.get().get(), Unversioned()); + if (sizeLimit != -1) { + sizeLimitStr = boost::lexical_cast(sizeLimit); + } + } + printf("Client profiling rate is set to %s and size limit is set to %s.\n", sampleRateStr.c_str(), sizeLimitStr.c_str()); + continue; + } + if (tokencmp(tokens[2], "set")) { + if (tokens.size() != 5) { + printf("ERROR: Usage: profile client set \n"); + is_error = true; + continue; + } + double sampleRate; + if (tokencmp(tokens[3], "default")) { + sampleRate = std::numeric_limits::infinity(); + } else { + char* end; + sampleRate = std::strtod((const char*)tokens[3].begin(), &end); + if (!std::isspace(*end)) { + printf("ERROR: %s failed to parse.\n", printable(tokens[3]).c_str()); + is_error = true; + continue; + } + } + int64_t sizeLimit; + if (tokencmp(tokens[4], "default")) { + sizeLimit = -1; + } else { + Optional parsed = parse_with_suffix(tokens[4].toString()); + if (parsed.present()) { + sizeLimit = parsed.get(); + } else { + printf("ERROR: `%s` failed to parse.\n", printable(tokens[4]).c_str()); + is_error = true; + continue; + } + } + tr->set(fdbClientInfoTxnSampleRate, BinaryWriter::toValue(sampleRate, Unversioned())); + tr->set(fdbClientInfoTxnSizeLimit, BinaryWriter::toValue(sizeLimit, Unversioned())); + if (!intrans) { + Void _ = wait( commitTransaction( tr ) ); + } + continue; + } + printf("ERROR: Unknown action: %s\n", printable(tokens[2]).c_str()); + is_error = true; + continue; + } + if (tokencmp(tokens[1], "list")) { + if (tokens.size() != 2) { + printf("ERROR: Usage: profile list\n"); + is_error = true; + continue; + } + getTransaction(db, tr, options, intrans); + Standalone kvs = wait(makeInterruptable( + tr->getRange(KeyRangeRef(LiteralStringRef("\xff\xff/worker_interfaces"), + LiteralStringRef("\xff\xff\xff")), + 1))); + for (const auto& pair : kvs) { + printf("%s\n", printable(pair.key).c_str()); + } + continue; + } + if (tokencmp(tokens[1], "flow")) { + if (tokens.size() == 2) { + printf("ERROR: Usage: profile flow \n"); + is_error = true; + continue; + } + if (tokencmp(tokens[2], "run")) { + if (tokens.size() < 6) { + printf("ERROR: Usage: profile flow run \n"); + is_error = true; + continue; + } + getTransaction(db, tr, options, intrans); + Standalone kvs = wait(makeInterruptable( + tr->getRange(KeyRangeRef(LiteralStringRef("\xff\xff/worker_interfaces"), + LiteralStringRef("\xff\xff\xff")), + 1))); + char *duration_end; + int duration = std::strtol((const char*)tokens[3].begin(), &duration_end, 10); + if (!std::isspace(*duration_end)) { + printf("ERROR: Failed to parse %s as an integer.", printable(tokens[3]).c_str()); + is_error = true; + continue; + } + std::map interfaces; + state std::vector all_profiler_addresses; + state std::vector>> all_profiler_responses; + for (const auto& pair : kvs) { + interfaces.emplace(pair.key, BinaryReader::fromStringRef(pair.value, IncludeVersion())); + } + if (tokens.size() == 6 && tokencmp(tokens[5], "all")) { + for (const auto& pair : interfaces) { + ProfilerRequest profileRequest; + profileRequest.type = ProfilerRequest::Type::FLOW; + profileRequest.action = ProfilerRequest::Action::RUN; + profileRequest.duration = duration; + profileRequest.outputFile = tokens[4]; + all_profiler_addresses.push_back(pair.first); + all_profiler_responses.push_back(pair.second.profiler.tryGetReply(profileRequest)); + } + } else { + for (int tokenidx = 5; tokenidx < tokens.size(); tokenidx++) { + auto element = interfaces.find(tokens[tokenidx]); + if (element == interfaces.end()) { + printf("ERROR: process '%s' not recognized.\n", printable(tokens[tokenidx]).c_str()); + is_error = true; + } + } + if (!is_error) { + for (int tokenidx = 5; tokenidx < tokens.size(); tokenidx++) { + ProfilerRequest profileRequest; + profileRequest.type = ProfilerRequest::Type::FLOW; + profileRequest.action = ProfilerRequest::Action::RUN; + profileRequest.duration = duration; + profileRequest.outputFile = tokens[4]; + all_profiler_addresses.push_back(tokens[tokenidx]); + all_profiler_responses.push_back(interfaces[tokens[tokenidx]].profiler.tryGetReply(profileRequest)); + } + } + } + if (!is_error) { + Void _ = wait(waitForAll(all_profiler_responses)); + for (int i = 0; i < all_profiler_responses.size(); i++) { + const ErrorOr& err = all_profiler_responses[i].get(); + if (err.isError()) { + printf("ERROR: %s: %s: %s\n", printable(all_profiler_addresses[i]).c_str(), err.getError().name(), err.getError().what()); + } + } + } + all_profiler_addresses.clear(); + all_profiler_responses.clear(); + continue; + } + } + printf("ERROR: Unknown type: %s\n", printable(tokens[1]).c_str()); + is_error = true; + continue; + } + if (tokencmp(tokens[0], "expensive_data_check")) { getTransaction(db, tr, options, intrans); if (tokens.size() == 1) { @@ -2879,6 +3063,9 @@ int main(int argc, char **argv) { platformInit(); initSignalSafeUnwind(); Error::init(); + std::set_new_handler( &platform::outOfMemory ); + uint64_t memLimit = 8LL << 30; + setMemoryQuota( memLimit ); registerCrashHandler(); diff --git a/fdbclient/Atomic.h b/fdbclient/Atomic.h index 078c2be0eb..381a11569e 100644 --- a/fdbclient/Atomic.h +++ b/fdbclient/Atomic.h @@ -24,7 +24,8 @@ #include "CommitTransaction.h" -static ValueRef doLittleEndianAdd(const ValueRef& existingValue, const ValueRef& otherOperand, Arena& ar) { +static ValueRef doLittleEndianAdd(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { + const ValueRef& existingValue = existingValueOptional.present() ? existingValueOptional.get() : StringRef(); if(!existingValue.size()) return otherOperand; if(!otherOperand.size()) return otherOperand; @@ -46,7 +47,8 @@ static ValueRef doLittleEndianAdd(const ValueRef& existingValue, const ValueRef& return StringRef(buf, i); } -static ValueRef doAnd(const ValueRef& existingValue, const ValueRef& otherOperand, Arena& ar) { +static ValueRef doAnd(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { + const ValueRef& existingValue = existingValueOptional.present() ? existingValueOptional.get() : StringRef(); if(!otherOperand.size()) return otherOperand; uint8_t* buf = new (ar) uint8_t [otherOperand.size()]; @@ -60,7 +62,15 @@ static ValueRef doAnd(const ValueRef& existingValue, const ValueRef& otherOperan return StringRef(buf, i); } -static ValueRef doOr(const ValueRef& existingValue, const ValueRef& otherOperand, Arena& ar) { +static ValueRef doAndV2(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { + if (!existingValueOptional.present()) + return otherOperand; + + return doAnd(existingValueOptional, otherOperand, ar); +} + +static ValueRef doOr(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { + const ValueRef& existingValue = existingValueOptional.present() ? existingValueOptional.get() : StringRef(); if(!existingValue.size()) return otherOperand; if(!otherOperand.size()) return otherOperand; @@ -75,7 +85,8 @@ static ValueRef doOr(const ValueRef& existingValue, const ValueRef& otherOperand return StringRef(buf, i); } -static ValueRef doXor(const ValueRef& existingValue, const ValueRef& otherOperand, Arena& ar) { +static ValueRef doXor(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { + const ValueRef& existingValue = existingValueOptional.present() ? existingValueOptional.get() : StringRef(); if(!existingValue.size()) return otherOperand; if(!otherOperand.size()) return otherOperand; @@ -91,7 +102,8 @@ static ValueRef doXor(const ValueRef& existingValue, const ValueRef& otherOperan return StringRef(buf, i); } -static ValueRef doAppendIfFits(const ValueRef& existingValue, const ValueRef& otherOperand, Arena& ar) { +static ValueRef doAppendIfFits(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { + const ValueRef& existingValue = existingValueOptional.present() ? existingValueOptional.get() : StringRef(); if(!existingValue.size()) return otherOperand; if(!otherOperand.size()) return existingValue; if(existingValue.size() + otherOperand.size() > CLIENT_KNOBS->VALUE_SIZE_LIMIT) { @@ -111,7 +123,8 @@ static ValueRef doAppendIfFits(const ValueRef& existingValue, const ValueRef& ot return StringRef(buf, i+j); } -static ValueRef doMax(const ValueRef& existingValue, const ValueRef& otherOperand, Arena& ar) { +static ValueRef doMax(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { + const ValueRef& existingValue = existingValueOptional.present() ? existingValueOptional.get() : StringRef(); if (!existingValue.size()) return otherOperand; if (!otherOperand.size()) return otherOperand; @@ -142,9 +155,20 @@ static ValueRef doMax(const ValueRef& existingValue, const ValueRef& otherOperan return otherOperand; } -static ValueRef doMin(const ValueRef& existingValue, const ValueRef& otherOperand, Arena& ar) { +static ValueRef doByteMax(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { + if (!existingValueOptional.present()) return otherOperand; + + const ValueRef& existingValue = existingValueOptional.get(); + if (existingValue > otherOperand) + return existingValue; + + return otherOperand; +} + +static ValueRef doMin(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { if (!otherOperand.size()) return otherOperand; + const ValueRef& existingValue = existingValueOptional.present() ? existingValueOptional.get() : StringRef(); int i,j; for (i = otherOperand.size() - 1; i >= existingValue.size(); i--) { @@ -179,34 +203,22 @@ static ValueRef doMin(const ValueRef& existingValue, const ValueRef& otherOperan return otherOperand; } -static ValueRef doAtomicOp(const ValueRef& existingValue, const ValueRef& otherOperand, MutationRef::Type mutationType, Arena& ar) { - switch(mutationType) { - case MutationRef::AddValue: - return doLittleEndianAdd(existingValue, otherOperand, ar); - break; - case MutationRef::AppendIfFits: - return doAppendIfFits(existingValue, otherOperand, ar); - break; - case MutationRef::And: - return doAnd(existingValue, otherOperand, ar); - break; - case MutationRef::Or: - return doOr(existingValue, otherOperand, ar); - break; - case MutationRef::Xor: - return doXor(existingValue, otherOperand, ar); - break; - case MutationRef::Max: - return doMax(existingValue, otherOperand, ar); - break; - case MutationRef::Min: - return doMin(existingValue, otherOperand, ar); - break; - default: - throw operation_failed(); - } +static ValueRef doMinV2(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { + if (!existingValueOptional.present()) + return otherOperand; + + return doMin(existingValueOptional, otherOperand, ar); } +static ValueRef doByteMin(const Optional& existingValueOptional, const ValueRef& otherOperand, Arena& ar) { + if (!existingValueOptional.present()) return otherOperand; + + const ValueRef& existingValue = existingValueOptional.get(); + if (existingValue < otherOperand) + return existingValue; + + return otherOperand; +} /* * Returns the range corresponding to the specified versionstamp key. diff --git a/fdbclient/BackupAgent.h b/fdbclient/BackupAgent.h index 7cf8c33bb0..1134aed5cb 100644 --- a/fdbclient/BackupAgent.h +++ b/fdbclient/BackupAgent.h @@ -67,28 +67,6 @@ public: static const int logHeaderSize; - // The following function will return the textual name of the - // start status - static const char* getResultText(enumActionResult enResult) - { - switch (enResult) - { - case RESULT_SUCCESSFUL: - return "action was successful"; - break; - case RESULT_ERRORED: - return "error received during action process"; - break; - case RESULT_DUPLICATE: - return "requested action has already been performed"; - break; - case RESULT_UNNEEDED: - return "requested action is not needed"; - break; - } - return ""; - } - // Convert the status text to an enumerated value static enumState getState(std::string stateText) { @@ -184,12 +162,12 @@ public: return isRunnable; } - static bool isRunnable(std::string stateText) { - return isRunnable(getState(stateText)); + static const KeyRef getDefaultTag() { + return StringRef(defaultTagName); } - static const KeyRef getDefaultTag() { - return defaultTag; + static const std::string getDefaultTagName() { + return defaultTagName; } static Standalone getCurrentTime() { @@ -205,7 +183,7 @@ public: } protected: - static const KeyRef defaultTag; + static const std::string defaultTagName; }; class FileBackupAgent : public BackupAgentBase { @@ -214,27 +192,21 @@ public: FileBackupAgent( FileBackupAgent&& r ) noexcept(true) : subspace( std::move(r.subspace) ), - states( std::move(r.states) ), config( std::move(r.config) ), - errors( std::move(r.errors) ), - ranges( std::move(r.ranges) ), - tagNames( std::move(r.tagNames) ), lastRestorable( std::move(r.lastRestorable) ), taskBucket( std::move(r.taskBucket) ), - futureBucket( std::move(r.futureBucket) ), - sourceStates( std::move(r.sourceStates) ) {} + futureBucket( std::move(r.futureBucket) ) {} void operator=( FileBackupAgent&& r ) noexcept(true) { subspace = std::move(r.subspace); - states = std::move(r.states); config = std::move(r.config); - errors = std::move(r.errors); - ranges = std::move(r.ranges); - tagNames = std::move(r.tagNames); lastRestorable = std::move(r.lastRestorable), taskBucket = std::move(r.taskBucket); futureBucket = std::move(r.futureBucket); - sourceStates = std::move(r.sourceStates); + } + + KeyBackedProperty lastBackupTimestamp() { + return config.pack(LiteralStringRef(__FUNCTION__)); } Future run(Database cx, double *pollDelay, int maxConcurrentTasks) { @@ -272,8 +244,8 @@ public: /** BACKUP METHODS **/ - Future submitBackup(Reference tr, Key outContainer, Key tagName, Standalone> backupRanges, bool stopWhenDone = true); - Future submitBackup(Database cx, Key outContainer, Key tagName, Standalone> backupRanges, bool stopWhenDone = true) { + Future submitBackup(Reference tr, Key outContainer, std::string tagName, Standalone> backupRanges, bool stopWhenDone = true); + Future submitBackup(Database cx, Key outContainer, std::string tagName, Standalone> backupRanges, bool stopWhenDone = true) { return runRYWTransactionFailIfLocked(cx, [=](Reference tr){ return submitBackup(tr, outContainer, tagName, backupRanges, stopWhenDone); }); } @@ -282,44 +254,19 @@ public: return runRYWTransaction(cx, [=](Reference tr){ return discontinueBackup(tr, tagName); }); } - Future abortBackup(Reference tr, Key tagName); - Future abortBackup(Database cx, Key tagName) { + Future abortBackup(Reference tr, std::string tagName); + Future abortBackup(Database cx, std::string tagName) { return runRYWTransaction(cx, [=](Reference tr){ return abortBackup(tr, tagName); }); } - Future getStatus(Database cx, int errorLimit, Key tagName); - - Future getStateValue(Reference tr, UID logUid); - Future getStateValue(Database cx, UID logUid) { - return runRYWTransaction(cx, [=](Reference tr){ return getStateValue(tr, logUid); }); - } - - Future getStateStopVersion(Reference tr, UID logUid); - Future getStateStopVersion(Database cx, UID logUid) { - return runRYWTransaction(cx, [=](Reference tr){ return getStateStopVersion(tr, logUid); }); - } - - Future getLogUid(Reference tr, Key tagName); - Future getLogUid(Database cx, Key tagName) { - return runRYWTransaction(cx, [=](Reference tr){ return getLogUid(tr, tagName); }); - } + Future getStatus(Database cx, int errorLimit, std::string tagName); Future getLastRestorable(Reference tr, Key tagName); - Future getLastRestorable(Database cx, Key tagName) { - return runRYWTransaction(cx, [=](Reference tr){ return getLastRestorable(tr, tagName); }); - } - - Future getRangeBytesWritten(Reference tr, UID logUid); - Future getLogBytesWritten(Reference tr, UID logUid); // stopWhenDone will return when the backup is stopped, if enabled. Otherwise, it // will return when the backup directory is restorable. - Future waitBackup(Database cx, Key tagName, bool stopWhenDone = true); + Future waitBackup(Database cx, std::string tagName, bool stopWhenDone = true); - Future getLastBackupContainer(Reference tr, UID logUid); - Future getLastBackupContainer(Database cx, UID logUid) { - return runRYWTransaction(cx, [=](Reference tr){ return getLastBackupContainer(tr, logUid); }); - } static Future getBackupInfo(std::string backupContainer, Version* defaultVersion = NULL); static std::string getTempFilename(); @@ -330,7 +277,6 @@ public: static std::string getDataFilename(Version version, int64_t size, int blockSize); static std::string getLogFilename(Version beginVer, Version endVer, int64_t size, int blockSize); - static const Key keyBackupContainer; static const Key keyLastRestorable; Future getTaskCount(Reference tr) { return taskBucket->getTaskCount(tr); } @@ -343,13 +289,8 @@ public: static const int dataFooterSize; Subspace subspace; - Subspace states; Subspace config; - Subspace errors; - Subspace ranges; - Subspace tagNames; Subspace lastRestorable; - Subspace sourceStates; Reference taskBucket; Reference futureBucket; @@ -507,4 +448,176 @@ public: StringRef key; }; +typedef BackupAgentBase::enumState EBackupState; +template<> inline Tuple Codec::pack(EBackupState const &val) { return Tuple().append(val); } +template<> inline EBackupState Codec::unpack(Tuple const &val) { return (EBackupState)val.getInt(0); } + +// Key backed tags are a single-key slice of the TagUidMap, defined below. +// The Value type of the key is a UidAndAbortedFlagT which is a pair of {UID, aborted_flag} +// All tasks on the UID will have a validation key/value that requires aborted_flag to be +// false, so changing that value, such as changing the UID or setting aborted_flag to true, +// will kill all of the active tasks on that backup/restore UID. +typedef std::pair UidAndAbortedFlagT; +class KeyBackedTag : public KeyBackedProperty { +public: + KeyBackedTag() : KeyBackedProperty(StringRef()) {} + KeyBackedTag(std::string tagName, StringRef tagMapPrefix); + + Future cancel(Reference tr) { + std::string tag = tagName; + Key _tagMapPrefix = tagMapPrefix; + return map(get(tr), [tag, _tagMapPrefix, tr](Optional up) -> Void { + if (up.present()) { + // Set aborted flag to true + up.get().second = true; + KeyBackedTag(tag, _tagMapPrefix).set(tr, up.get()); + } + return Void(); + }); + } + + std::string tagName; + Key tagMapPrefix; +}; + +typedef KeyBackedMap TagMap; +// Map of tagName to {UID, aborted_flag} located in the fileRestorePrefixRange keyspace. +class TagUidMap : public KeyBackedMap { +public: + TagUidMap(const StringRef & prefix) : TagMap(LiteralStringRef("tag->uid/").withPrefix(prefix)), prefix(prefix) {} + + static Future> getAll_impl(TagUidMap * const & tagsMap, Reference const & tr); + + Future> getAll(Reference tr) { + return getAll_impl(this, tr); + } + + Key prefix; +}; + +static inline KeyBackedTag makeRestoreTag(std::string tagName) { + return KeyBackedTag(tagName, fileRestorePrefixRange.begin); +} + +static inline KeyBackedTag makeBackupTag(std::string tagName) { + return KeyBackedTag(tagName, fileBackupPrefixRange.begin); +} + +static inline Future> getAllRestoreTags(Reference tr) { + return TagUidMap(fileRestorePrefixRange.begin).getAll(tr); +} + +static inline Future> getAllBackupTags(Reference tr) { + return TagUidMap(fileBackupPrefixRange.begin).getAll(tr); +} + +class KeyBackedConfig { +public: + static struct { + static TaskParam uid() {return LiteralStringRef(__FUNCTION__); } + } TaskParams; + + KeyBackedConfig(StringRef prefix, UID uid = UID()) : + uid(uid), + prefix(prefix), + configSpace(uidPrefixKey(LiteralStringRef("uid->config/").withPrefix(prefix), uid)) {} + + KeyBackedConfig(StringRef prefix, Reference task) : KeyBackedConfig(prefix, TaskParams.uid().get(task)) {} + + Future toTask(Reference tr, Reference task) { + // Set the uid task parameter + TaskParams.uid().set(task, uid); + // Set the validation condition for the task which is that the restore uid's tag's uid is the same as the restore uid. + // Get this uid's tag, then get the KEY for the tag's uid but don't read it. That becomes the validation key + // which TaskBucket will check, and its value must be this restore config's uid. + UID u = uid; // 'this' could be invalid in lambda + Key p = prefix; + return map(tag().get(tr), [u,p,task](Optional const &tag) -> Void { + if(!tag.present()) + throw restore_error(); + // Validation contition is that the uidPair key must be exactly {u, false} + TaskBucket::setValidationCondition(task, KeyBackedTag(tag.get(), p).key, Codec::pack({u, false}).pack()); + return Void(); + }); + } + + KeyBackedProperty tag() { + return configSpace.pack(LiteralStringRef(__FUNCTION__)); + } + + UID getUid() { return uid; } + + Key getUidAsKey() { return BinaryWriter::toValue(uid, Unversioned()); } + + void clear(Reference tr) { + tr->clear(configSpace.range()); + } + + // lastError is a pair of error message and timestamp expressed as an int64_t + KeyBackedProperty> lastError() { + return configSpace.pack(LiteralStringRef(__FUNCTION__)); + } + +protected: + UID uid; + Key prefix; + Subspace configSpace; +}; + +class BackupConfig : public KeyBackedConfig { +public: + BackupConfig(UID uid = UID()) : KeyBackedConfig(fileBackupPrefixRange.begin, uid) {} + BackupConfig(Reference task) : KeyBackedConfig(fileBackupPrefixRange.begin, task) {} + + // rangeFileMap maps a keyrange file's End to its Begin and Filename + typedef std::pair KeyAndFilenameT; + typedef KeyBackedMap RangeFileMapT; + RangeFileMapT rangeFileMap() { + return configSpace.pack(LiteralStringRef(__FUNCTION__)); + } + + KeyBackedBinaryValue rangeBytesWritten() { + return configSpace.pack(LiteralStringRef(__FUNCTION__)); + } + + KeyBackedBinaryValue logBytesWritten() { + return configSpace.pack(LiteralStringRef(__FUNCTION__)); + } + + KeyBackedProperty stateEnum() { + return configSpace.pack(LiteralStringRef(__FUNCTION__)); + } + + KeyBackedProperty backupContainer() { + return configSpace.pack(LiteralStringRef(__FUNCTION__)); + } + + // Stop differntial logging if already started or don't start after completing KV ranges + KeyBackedProperty stopWhenDone() { + return configSpace.pack(LiteralStringRef(__FUNCTION__)); + } + + KeyBackedProperty stopVersion() { + return configSpace.pack(LiteralStringRef(__FUNCTION__)); + } + + KeyBackedProperty> backupRanges() { + return configSpace.pack(LiteralStringRef(__FUNCTION__)); + } + + void startMutationLogs(Reference tr, KeyRangeRef backupRange) { + Key mutationLogsDestKey = uidPrefixKey(backupLogKeys.begin, getUid()); + tr->set(logRangesEncodeKey(backupRange.begin, getUid()), logRangesEncodeValue(backupRange.end, mutationLogsDestKey)); + } + + Future logError(Database cx, Error e, std::string details, void *taskInstance = nullptr) { + if(!uid.isValid()) { + TraceEvent(SevError, "FileBackupErrorNoUID").error(e).detail("Description", details); + return Void(); + } + TraceEvent(SevWarn, "FileBackupError").error(e).detail("BackupUID", uid).detail("Description", details).detail("TaskInstance", (uint64_t)taskInstance); + std::string msg = format("ERROR: %s %s", e.what(), details.c_str()); + return lastError().set(cx, {msg, (int64_t)now()}); + } +}; #endif diff --git a/fdbclient/BackupAgentBase.actor.cpp b/fdbclient/BackupAgentBase.actor.cpp index 5e3f2b500d..6bd3c73ee4 100644 --- a/fdbclient/BackupAgentBase.actor.cpp +++ b/fdbclient/BackupAgentBase.actor.cpp @@ -369,7 +369,7 @@ ACTOR Future readCommitted(Database cx, PromiseStream(new ReadYourWritesTransaction(cx)); } @@ -463,7 +463,7 @@ ACTOR Future readCommitted(Database cx, PromiseStream results, Fu nextKey = firstGreaterThan(rangevalue.end()[-1].key); } catch (Error &e) { - if (e.code() != error_code_past_version && e.code() != error_code_future_version) + if (e.code() != error_code_transaction_too_old && e.code() != error_code_future_version) throw; Void _ = wait(tr->onError(e)); } @@ -547,14 +547,14 @@ ACTOR Future readCommitted(Database cx, PromiseStream results, Re nextKey = firstGreaterThan(rangevalue.end()[-1].key); } catch (Error &e) { - if (e.code() != error_code_past_version && e.code() != error_code_future_version) + if (e.code() != error_code_transaction_too_old && e.code() != error_code_future_version) throw; Void _ = wait(tr->onError(e)); } } } -ACTOR Future dumpData(Database cx, PromiseStream results, Reference lock, Key uid, Key addPrefix, Key removePrefix, RequestStream commit, +ACTOR Future dumpData(Database cx, PromiseStream results, Reference lock, Key uid, Key addPrefix, Key removePrefix, RequestStream commit, NotifiedVersion* committedVersion, Optional endVersion, Key rangeBegin, PromiseStream> addActor, FlowLock* commitLock, Reference> keyVersion ) { state Version lastVersion = invalidVersion; state bool endOfStream = false; @@ -595,9 +595,11 @@ ACTOR Future dumpData(Database cx, PromiseStream results, Referenc Key applyBegin = uid.withPrefix(applyMutationsBeginRange.begin); Key versionKey = BinaryWriter::toValue(newBeginVersion, Unversioned()); Key rangeEnd = getApplyKey(newBeginVersion, uid); - + req.transaction.mutations.push_back_deep(req.arena, MutationRef(MutationRef::SetValue, applyBegin, versionKey)); + req.transaction.write_conflict_ranges.push_back_deep(req.arena, singleKeyRange(applyBegin)); req.transaction.mutations.push_back_deep(req.arena, MutationRef(MutationRef::ClearRange, rangeBegin, rangeEnd)); + req.transaction.write_conflict_ranges.push_back_deep(req.arena, singleKeyRange(rangeBegin)); req.transaction.read_snapshot = committedVersion->get(); req.isLockAware = true; @@ -694,4 +696,4 @@ ACTOR Future applyMutations(Database cx, Key uid, Key addPrefix, Key remov TraceEvent(e.code() == error_code_restore_missing_data ? SevWarnAlways : SevError, "AM_error").error(e); throw; } -} \ No newline at end of file +} diff --git a/fdbclient/ClientWorkerInterface.h b/fdbclient/ClientWorkerInterface.h index a01f541d26..4e1de2c5eb 100644 --- a/fdbclient/ClientWorkerInterface.h +++ b/fdbclient/ClientWorkerInterface.h @@ -27,9 +27,12 @@ #include "Status.h" #include "ClientDBInfo.h" +// Streams from WorkerInterface that are safe and useful to call from a client. +// A ClientWorkerInterface is embedded as the first element of a WorkerInterface. struct ClientWorkerInterface { RequestStream< struct RebootRequest > reboot; - + RequestStream< struct ProfilerRequest > profiler; + bool operator == (ClientWorkerInterface const& r) const { return id() == r.id(); } bool operator != (ClientWorkerInterface const& r) const { return id() != r.id(); } UID id() const { return reboot.getEndpoint().token; } @@ -37,20 +40,47 @@ struct ClientWorkerInterface { template void serialize( Ar& ar ) { - ar & reboot; + ar & reboot & profiler; } }; struct RebootRequest { bool deleteData; bool checkData; - - RebootRequest(bool deleteData = false, bool checkData = false) : deleteData(deleteData), checkData(checkData) {} - + + explicit RebootRequest(bool deleteData = false, bool checkData = false) : deleteData(deleteData), checkData(checkData) {} + template void serialize(Ar& ar) { ar & deleteData & checkData; } }; -#endif \ No newline at end of file +struct ProfilerRequest { + ReplyPromise reply; + + enum class Type : std::int8_t { + GPROF = 1, + FLOW = 2 + }; + + enum class Action : std::int8_t { + DISABLE = 0, + ENABLE = 1, + RUN = 2 + }; + + Type type; + Action action; + int duration; + Standalone outputFile; + + template + void serialize( Ar& ar ) { + ar & reply & type & action & duration & outputFile; + } +}; +BINARY_SERIALIZABLE( ProfilerRequest::Type ); +BINARY_SERIALIZABLE( ProfilerRequest::Action ); + +#endif diff --git a/fdbclient/CommitTransaction.h b/fdbclient/CommitTransaction.h index d5ada27b3f..582cc7e240 100644 --- a/fdbclient/CommitTransaction.h +++ b/fdbclient/CommitTransaction.h @@ -26,8 +26,8 @@ struct MutationRef { static const int OVERHEAD_BYTES = 12; //12 is the size of Header in MutationList entries - enum Type : uint8_t { SetValue=0, ClearRange, AddValue, DebugKeyRange, DebugKey, NoOp, And, Or, Xor, AppendIfFits, AvailableForReuse, Reserved_For_LogProtocolMessage /* See fdbserver/LogProtocolMessage.h */, Max, Min, SetVersionstampedKey, SetVersionstampedValue, MAX_ATOMIC_OP }; - const char * typeString[MAX_ATOMIC_OP] = { "SetValue", "ClearRange", "AddValue", "DebugKeyRange", "DebugKey", "NoOp", "And", "Or", "Xor", "AppendIfFits", "AvailableForReuse", "Reserved_For_LogProtocolMessage", "Max", "Min", "SetVersionstampedKey", "SetVersionstampedValue" }; + enum Type : uint8_t { SetValue=0, ClearRange, AddValue, DebugKeyRange, DebugKey, NoOp, And, Or, Xor, AppendIfFits, AvailableForReuse, Reserved_For_LogProtocolMessage /* See fdbserver/LogProtocolMessage.h */, Max, Min, SetVersionstampedKey, SetVersionstampedValue, ByteMin, ByteMax, MinV2, AndV2, MAX_ATOMIC_OP }; + const char * typeString[MAX_ATOMIC_OP] = { "SetValue", "ClearRange", "AddValue", "DebugKeyRange", "DebugKey", "NoOp", "And", "Or", "Xor", "AppendIfFits", "AvailableForReuse", "Reserved_For_LogProtocolMessage", "Max", "Min", "SetVersionstampedKey", "SetVersionstampedValue", "ByteMin", "ByteMax", "MinV2", "AndV2" }; // This is stored this way for serialization purposes. uint8_t type; StringRef param1, param2; @@ -54,9 +54,9 @@ struct MutationRef { // These masks define which mutation types have particular properties (they are used to implement isSingleKeyMutation() etc) enum { - ATOMIC_MASK = (1 << AddValue) | (1 << And) | (1 << Or) | (1 << Xor) | (1 << AppendIfFits) | (1 << Max) | (1 << Min) | (1 << SetVersionstampedKey) | (1 << SetVersionstampedValue), + ATOMIC_MASK = (1 << AddValue) | (1 << And) | (1 << Or) | (1 << Xor) | (1 << AppendIfFits) | (1 << Max) | (1 << Min) | (1 << SetVersionstampedKey) | (1 << SetVersionstampedValue) | (1 << ByteMin) | (1 << ByteMax) | (1 << MinV2) | (1 << AndV2), SINGLE_KEY_MASK = ATOMIC_MASK | (1< (candidate.changeID.first() & mask)) { + return true; + } else { + return false; + } + } + + // All but the first 4 bits are used to represent process id + bool equalInternalId(LeaderInfo const& leaderInfo) const { + uint64_t mask = ~(15ll << 60); + if ((changeID.first() & mask) == (leaderInfo.changeID.first() & mask)) { + return true; + } else { + return false; + } + } + template void serialize(Ar& ar) { ar & changeID & serializedInfo & forward; diff --git a/fdbclient/DatabaseBackupAgent.actor.cpp b/fdbclient/DatabaseBackupAgent.actor.cpp old mode 100755 new mode 100644 index 827eb33624..a20bd4ea52 --- a/fdbclient/DatabaseBackupAgent.actor.cpp +++ b/fdbclient/DatabaseBackupAgent.actor.cpp @@ -1410,6 +1410,7 @@ public: TraceEvent("DBA_switchover_locked").detail("version", commitVersion); + // Wait for the destination to apply mutations up to the lock commit before switching over. state ReadYourWritesTransaction tr2(dest); loop { try { @@ -1459,6 +1460,27 @@ public: TraceEvent("DBA_switchover_started"); + state ReadYourWritesTransaction tr3(dest); + loop { + try { + tr3.setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); + tr3.setOption(FDBTransactionOptions::LOCK_AWARE); + Version destVersion = wait(tr3.getReadVersion()); + if (destVersion <= commitVersion) { + TraceEvent("DBA_switchover_version_upgrade").detail("src", commitVersion).detail("dest", destVersion); + TEST(true); // Forcing dest backup cluster to higher version + tr3.set(minRequiredCommitVersionKey, BinaryWriter::toValue(commitVersion+1, Unversioned())); + Void _ = wait(tr3.commit()); + } else { + break; + } + } catch( Error &e ) { + Void _ = wait(tr3.onError(e)); + } + } + + TraceEvent("DBA_switchover_version_upgraded"); + Void _ = wait( backupAgent->unlockBackup(dest, tagName) ); TraceEvent("DBA_switchover_unlocked"); @@ -1491,6 +1513,7 @@ public: ACTOR static Future abortBackup(DatabaseBackupAgent* backupAgent, Database cx, Key tagName, bool partial) { state Reference tr(new ReadYourWritesTransaction(cx)); + tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); tr->setOption(FDBTransactionOptions::LOCK_AWARE); state UID logUid; state Value backupUid; @@ -1505,6 +1528,7 @@ public: throw backup_unneeded(); } + state Version current = wait(tr->getReadVersion()); Optional _backupUid = wait(tr->get(backupAgent->states.get(BinaryWriter::toValue(logUid, Unversioned())).pack(DatabaseBackupAgent::keyFolderId))); backupUid = _backupUid.get(); @@ -1512,7 +1536,19 @@ public: tr->clear(backupAgent->config.get(BinaryWriter::toValue(logUid, Unversioned())).range()); // Clearing the end version of apply mutation cancels ongoing apply work - tr->clear(BinaryWriter::toValue(logUid, Unversioned()).withPrefix(applyMutationsEndRange.begin)); + const auto& log_uid = BinaryWriter::toValue(logUid, Unversioned()); + tr->clear(log_uid.withPrefix(applyMutationsEndRange.begin)); + + // Ensure that we're at a version higher than the data that we've written. + Optional lastApplied = wait(tr->get(log_uid.withPrefix(applyMutationsBeginRange.begin))); + if (lastApplied.present()) { + Version applied = BinaryReader::fromStringRef(lastApplied.get(), Unversioned()); + if (current <= applied) { + TraceEvent("DBA_abort_version_upgrade").detail("src", applied).detail("dest", current); + TEST(true); // Upgrading version of local database. + tr->set(minRequiredCommitVersionKey, BinaryWriter::toValue(applied+1, Unversioned())); + } + } Key logsPath = uidPrefixKey(applyLogKeys.begin, logUid); tr->clear(KeyRangeRef(logsPath, strinc(logsPath))); @@ -1601,6 +1637,8 @@ public: tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); tr->setOption(FDBTransactionOptions::LOCK_AWARE); + + state Future> fDisabled = tr->get(backupAgent->taskBucket->getDisableKey()); int backupStateInt = wait(backupAgent->getStateValue(tr, logUid)); state BackupAgentBase::enumState backupState = (BackupAgentBase::enumState)backupStateInt; @@ -1686,6 +1724,11 @@ public: } } + Optional disabled = wait(fDisabled); + if(disabled.present()) { + statusText += format("\nAll DR agents have been disabled.\n"); + } + break; } catch (Error &e) { diff --git a/fdbclient/FailureMonitorClient.actor.cpp b/fdbclient/FailureMonitorClient.actor.cpp index 46b0dd740f..19557960b3 100644 --- a/fdbclient/FailureMonitorClient.actor.cpp +++ b/fdbclient/FailureMonitorClient.actor.cpp @@ -139,4 +139,4 @@ ACTOR Future failureMonitorClient( Reference client = ci->get().present() ? failureMonitorClientLoop(monitor, ci->get().get(), fmState, trackMyStatus) : Void(); Void _ = wait( ci->onChange() ); } -} \ No newline at end of file +} diff --git a/fdbclient/FileBackupAgent.actor.cpp b/fdbclient/FileBackupAgent.actor.cpp index 58957ce8bd..a8ce2449cd 100644 --- a/fdbclient/FileBackupAgent.actor.cpp +++ b/fdbclient/FileBackupAgent.actor.cpp @@ -35,7 +35,6 @@ #include #include -const Key FileBackupAgent::keyBackupContainer = LiteralStringRef("output_container"); const Key FileBackupAgent::keyLastRestorable = LiteralStringRef("last_restorable"); // For convenience @@ -56,83 +55,22 @@ StringRef FileBackupAgent::restoreStateText(ERestoreState id) { template<> Tuple Codec::pack(ERestoreState const &val) { return Tuple().append(val); } template<> ERestoreState Codec::unpack(Tuple const &val) { return (ERestoreState)val.getInt(0); } -// Restore tags are a single-key slice of the RestoreTags map, defined below. -// The Value type of the key is a UidAndAbortedFlagT which is a pair of {UID, aborted_flag} -// All tasks on the UID will have a validation key/value that requires aborted_flag to be -// false, so changing that value, such as changing the UID or setting aborted_flag to true, -// will kill all of the active tasks on that restore UID. -typedef std::pair UidAndAbortedFlagT; -class RestoreTag : public KeyBackedProperty { -public: - RestoreTag(StringRef tagName = StringRef()); - - Future cancel(Reference tr) { - Key tag = tagName; // 'this' could be invalid in lambda - return map(get(tr), [tag,tr](Optional up) -> Void { - if(up.present()) { - // Set aborted flag to true - up.get().second = true; - RestoreTag(tag).set(tr, up.get()); - } - return Void(); - }); - } - - Key tagName; -}; - -// Map of tagName to {UID, aborted_flag} located in the fileRestorePrefixRange keyspace. -class RestoreTags : public KeyBackedMap { -public: - typedef KeyBackedMap RestoreTagMap; - - RestoreTags() : RestoreTagMap(LiteralStringRef("tag->uid/").withPrefix(fileRestorePrefixRange.begin)) {} - - ACTOR static Future> getAll_impl(RestoreTags *tags, Reference tr) { - RestoreTagMap::PairsType tagPairs = wait(tags->getRange(tr, KeyRef(), {}, 1e6)); - std::vector results; - for(auto &p : tagPairs) - results.push_back(p.first); - return results; - } - - Future> getAll(Reference tr) { - return getAll_impl(this, tr); - } -}; - -RestoreTag::RestoreTag(StringRef tagName) - : KeyBackedProperty(RestoreTags().getProperty(tagName)), tagName(tagName) { +ACTOR Future> TagUidMap::getAll_impl(TagUidMap *tagsMap, Reference tr) { + TagMap::PairsType tagPairs = wait(tagsMap->getRange(tr, std::string(), {}, 1e6)); + std::vector results; + for(auto &p : tagPairs) + results.push_back(KeyBackedTag(p.first, tagsMap->prefix)); + return results; } -class RestoreConfig { +KeyBackedTag::KeyBackedTag(std::string tagName, StringRef tagMapPrefix) + : KeyBackedProperty(TagUidMap(tagMapPrefix).getProperty(tagName)), tagName(tagName), tagMapPrefix(tagMapPrefix) {} + +class RestoreConfig : public KeyBackedConfig { public: - static struct { - static TaskParam uid() { return LiteralStringRef(__FUNCTION__); } - } TaskParams; + RestoreConfig(UID uid = UID()) : KeyBackedConfig(fileRestorePrefixRange.begin, uid) {} + RestoreConfig(Reference task) : KeyBackedConfig(fileRestorePrefixRange.begin, task) {} - RestoreConfig(UID uid = UID()) : uid(uid), configSpace(uidPrefixKey(LiteralStringRef("uid->config/").withPrefix(fileRestorePrefixRange.begin), uid)) {} - RestoreConfig(Reference task) : RestoreConfig(TaskParams.uid().get(task)) {} - - Future toTask(Reference tr, Reference task) { - // Set the uid task parameter - TaskParams.uid().set(task, uid); - // Set the validation condition for the task which is that the restore uid's tag's uid is the same as the restore uid. - // Get this uid's tag, then get the KEY for the tag's uid but don't read it. That becomes the validation key - // which TaskBucket will check, and its value must be this restore config's uid. - UID u = uid; // 'this' could be invalid in lambda - return map(tag().get(tr), [u,task](Optional const &tag) -> Void { - if(!tag.present()) - throw restore_error(); - // Validation contition is that the uidPair key must be exactly {u, false} - TaskBucket::setValidationCondition(task, RestoreTag(tag.get()).key, Codec::pack({u, false}).pack()); - return Void(); - }); - } - - KeyBackedProperty tag() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); - } KeyBackedProperty stateEnum() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } @@ -185,15 +123,6 @@ public: return configSpace.pack(LiteralStringRef(__FUNCTION__)); } - // lastError is a pair of error message and timestamp expressed as an int64_t - KeyBackedProperty> lastError() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); - } - - void clear(Reference tr) { - tr->clear(configSpace.range()); - } - Future isRunnable(Reference tr) { return map(stateEnum().getD(tr), [](ERestoreState s) -> bool { return s != ERestoreState::ABORTED && s != ERestoreState::COMPLETED @@ -206,17 +135,9 @@ public: TraceEvent(SevError, "FileRestoreErrorNoUID").error(e).detail("Description", details); return Void(); } - // Lambda might outlive 'this' so save uid, capture by value, and make a new RestoreConfig from it later. - UID u = uid; - return runRYWTransaction(cx, [u, cx, e, details, taskInstance](Reference tr) -> Future { - tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); - tr->setOption(FDBTransactionOptions::LOCK_AWARE); - TraceEvent(SevWarn, "FileRestoreError").error(e).detail("RestoreUID", u).detail("Description", details).detail("TaskInstance", (uint64_t)taskInstance); - std::string msg = format("ERROR: %s %s", e.what(), details.c_str()); - RestoreConfig restore(u); - restore.lastError().set(tr, {StringRef(msg), (int64_t)now()}); - return Void(); - }); + TraceEvent(SevWarn, "FileRestoreError").error(e).detail("RestoreUID", uid).detail("Description", details).detail("TaskInstance", (uint64_t)taskInstance); + std::string msg = format("ERROR: %s (%s)", details.c_str(), e.what()); + return lastError().set(cx, {msg, (int64_t)now()}); } Key mutationLogPrefix() { @@ -294,8 +215,6 @@ public: }); } - UID getUid() { return uid; } - static Future getProgress_impl(RestoreConfig const &restore, Reference const &tr); Future getProgress(Reference tr) { return getProgress_impl(*this, tr); @@ -305,10 +224,6 @@ public: Future getFullStatus(Reference tr) { return getFullStatus_impl(*this, tr); } - -private: - UID uid; - Subspace configSpace; }; ACTOR Future RestoreConfig::getProgress_impl(RestoreConfig restore, Reference tr) { @@ -322,8 +237,8 @@ ACTOR Future RestoreConfig::getProgress_impl(RestoreConfig restore, state Future bytesWritten = restore.bytesWritten().getD(tr); state Future status = restore.stateText(tr); state Future lag = restore.getApplyVersionLag(tr); - state Future tag = restore.tag().getD(tr); - state Future> lastError = restore.lastError().getD(tr); + state Future tag = restore.tag().getD(tr); + state Future> lastError = restore.lastError().getD(tr); // restore might no longer be valid after the first wait so make sure it is not needed anymore. state UID uid = restore.getUid(); @@ -331,11 +246,11 @@ ACTOR Future RestoreConfig::getProgress_impl(RestoreConfig restore, std::string errstr = "None"; if(lastError.get().second != 0) - errstr = format("'%s' %llds ago.\n", lastError.get().first.toString().c_str(), (int64_t)now() - lastError.get().second); + errstr = format("'%s' %llds ago.\n", lastError.get().first.c_str(), (int64_t)now() - lastError.get().second); TraceEvent("FileRestoreProgress") .detail("UID", uid) - .detail("Tag", tag.get().toString()) + .detail("Tag", tag.get()) .detail("State", status.get().toString()) .detail("FileCount", fileCount.get()) .detail("FileBlocksFinished", fileBlocksFinished.get()) @@ -347,7 +262,7 @@ ACTOR Future RestoreConfig::getProgress_impl(RestoreConfig restore, return format("Tag: %s UID: %s State: %s Blocks: %lld/%lld BlocksInProgress: %lld Files: %lld BytesWritten: %lld ApplyVersionLag: %lld LastError: %s", - tag.get().toString().c_str(), + tag.get().c_str(), uid.toString().c_str(), status.get().toString().c_str(), fileBlocksFinished.get(), @@ -386,66 +301,42 @@ ACTOR Future RestoreConfig::getFullStatus_impl(RestoreConfig restor ); } -// TODO: Grow this class so it does for backup what RestoreConfig does for restore, such as holding all useful backup metadata -// and handling binding to a Task, initializing from a Task, and setting Task validation parameters. -// NOTE that when doing this backup configs MUST be changed to use UNIQUE uids for each backup or bad things can happened -// such as stale backup tasks writing data into newer backups or reading the wrong kv manifest data or writing it to the wrong backup. -class BackupConfig { -public: - static struct { - // TODO: Use this, but it isn't compatible with the rest of the backup tasks yet. - // static TaskParam uid() { return LiteralStringRef(__FUNCTION__); } - } TaskParams; - - BackupConfig(UID uid = UID()) : uid(uid), configSpace(uidPrefixKey(LiteralStringRef("uid->config/").withPrefix(fileBackupPrefixRange.begin), uid)) {} - - // TODO: Make this use TaskParam like Restore does, for now it has to be compatible with old code. - BackupConfig(Reference task) : BackupConfig(BinaryReader::fromStringRef(task->params[FileBackupAgent::keyConfigLogUid], Unversioned())) {} - - // rangeFileMap maps a keyrange file's End to its Begin and Filename - typedef std::pair KeyAndFilenameT; - typedef KeyBackedMap RangeFileMapT; - RangeFileMapT rangeFileMap() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); - } - - KeyBackedBinaryValue rangeBytesWritten() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); - } - - KeyBackedBinaryValue logBytesWritten() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); - } - - void clear(Reference tr) { - tr->clear(configSpace.range()); - } - - UID getUid() { return uid; } - -private: - UID uid; - Subspace configSpace; -}; FileBackupAgent::FileBackupAgent() : subspace(Subspace(fileBackupPrefixRange.begin)) - // tagNames has tagName => logUID - , tagNames(subspace.get(BackupAgentBase::keyTagName)) // The other subspaces have logUID -> value - , lastRestorable(subspace.get(FileBackupAgent::keyLastRestorable)) - , states(subspace.get(BackupAgentBase::keyStates)) , config(subspace.get(BackupAgentBase::keyConfig)) - , errors(subspace.get(BackupAgentBase::keyErrors)) - , ranges(subspace.get(BackupAgentBase::keyRanges)) + , lastRestorable(subspace.get(FileBackupAgent::keyLastRestorable)) , taskBucket(new TaskBucket(subspace.get(BackupAgentBase::keyTasks), true, false, true)) , futureBucket(new FutureBucket(subspace.get(BackupAgentBase::keyFutures), true, true)) - , sourceStates(subspace.get(BackupAgentBase::keySourceStates)) { } namespace fileBackup { + // Try to save and extend task repeatedly until it fails or f is ready (or throws) + // In case the task was started or saveAndExtend'd recently, firstSaveAndExtendTimestamp can be used to indicate + // when the first saveAndExtend should be done. + ACTOR static Future saveAndExtendIncrementally(Database cx, Reference taskBucket, Reference task, Future f, double firstSaveAndExtendTimestamp = 0) { + // delaySeconds is half of the taskBucket task timeout. + state double delaySeconds = 0.5 * taskBucket->getTimeoutSeconds(); + state Future timeout = delayUntil(firstSaveAndExtendTimestamp); + loop { + choose { + when(Void _ = wait(f)) { + break; + } + when(Void _ = wait(timeout)) { + bool keepGoing = wait(taskBucket->saveAndExtend(cx, task)); + if(!keepGoing) + throw timed_out(); + timeout = delay(delaySeconds); + } + } + } + return Void(); + } + ACTOR static Future writeString(Reference file, Standalone s, int64_t *pOffset) { state uint32_t lenBuf = bigEndian32((uint32_t)s.size()); Void _ = wait(file->write(&lenBuf, sizeof(lenBuf), *pOffset)); @@ -761,24 +652,8 @@ namespace fileBackup { } } - bool copyDefaultParameters(Reference source, Reference dest) { - if (source) { - copyParameter(source, dest, BackupAgentBase::keyFolderId); - copyParameter(source, dest, BackupAgentBase::keyStateStop); - copyParameter(source, dest, BackupAgentBase::keyConfigBackupTag); - copyParameter(source, dest, BackupAgentBase::keyConfigLogUid); - copyParameter(source, dest, BackupAgentBase::keyErrors); - - copyParameter(source, dest, FileBackupAgent::keyBackupContainer); - - return true; - } - - return false; - } - // This is used to open files during BACKUP tasks. - ACTOR static Future> doOpenBackupFile(bool writeMode, std::string backupContainer, std::string fileName, Key keyErrors, Database cx) { + ACTOR static Future> doOpenBackupFile(bool writeMode, std::string backupContainer, std::string fileName, BackupConfig config, Database cx) { try { Reference container = IBackupContainer::openContainer(backupContainer); @@ -788,16 +663,16 @@ namespace fileBackup { } catch (Error &e) { state Error err = e; - Void _ = wait(logError(cx, keyErrors, format("ERROR: Failed to open file `%s' because of error %s", fileName.c_str(), err.what()))); + Void _ = wait(config.logError(cx, e, format("ERROR: Failed to open file `%s' because of error: %s", fileName.c_str(), err.what()))); throw err; } } - static Future> openBackupFile(bool writeMode, std::string backupContainer, std::string fileName, Key keyErrors, Database cx) { - return doOpenBackupFile(writeMode, backupContainer, fileName, keyErrors, cx); + static Future> openBackupFile(bool writeMode, std::string backupContainer, std::string fileName, BackupConfig config, Database cx) { + return doOpenBackupFile(writeMode, backupContainer, fileName, config, cx); } - ACTOR Future truncateCloseFile(Database cx, Key keyErrors, std::string backupContainer, std::string fileName, Reference file, int64_t truncateSize = -1) { + ACTOR Future truncateCloseFile(Database cx, BackupConfig config, std::string backupContainer, std::string fileName, Reference file, int64_t truncateSize = -1) { if (truncateSize == -1) { int64_t size = wait(file->size()); truncateSize = size; @@ -820,7 +695,7 @@ namespace fileBackup { throw; state Error err = e; - Void _ = wait(logError(cx, keyErrors, format("ERROR: Failed to write to file `%s' in container '%s' because of error %s", fileName.c_str(), backupContainer.c_str(), err.what()))); + Void _ = wait(config.logError(cx, err, format("ERROR: Failed to write to file `%s' in container '%s' because of error: %s", fileName.c_str(), backupContainer.c_str(), err.what()))); throw err; } @@ -831,56 +706,40 @@ namespace fileBackup { throw; TraceEvent("FBA_TruncateCloseFileSyncError").error(e); - state Transaction tr(cx); - loop { - try { - tr.setOption(FDBTransactionOptions::LOCK_AWARE); - Tuple t; - t.append(std::numeric_limits::max()); - t.append(StringRef()); - tr.set(t.pack().withPrefix(keyErrors), format("WARNING: Cannot sync file `%s' in container '%s'", fileName.c_str(), backupContainer.c_str())); - Void _ = wait( tr.commit() ); - break; - } catch( Error &e ) { - Void _ = wait( tr.onError(e)); - } - } + Void _ = wait(config.logError(cx, e, format("WARNING: Cannot sync file `%s' in container '%s'", fileName.c_str(), backupContainer.c_str()))); } file = Reference(); return Void(); } - ACTOR static Future getPath(Reference tr, Key configOutputPath) { - tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); - tr->setOption(FDBTransactionOptions::LOCK_AWARE); - state Optional dir = wait(tr->get(configOutputPath)); - - return dir.present() ? dir.get().toString() : ""; - } - - ACTOR template - Future checkTaskVersion(Tr tr, Reference task, StringRef name, uint32_t version) { + ACTOR Future checkTaskVersion(Database cx, Reference task, StringRef name, uint32_t version) { uint32_t taskVersion = task->getVersion(); if (taskVersion > version) { - TraceEvent(SevError, "BA_BackupRangeTaskFunc_execute").detail("taskVersion", taskVersion).detail("Name", printable(name)).detail("Version", version); - Void _ = wait(logError(tr, task->params[FileBackupAgent::keyErrors], - format("ERROR: %s task version `%lu' is greater than supported version `%lu'", task->params[Task::reservedTaskParamKeyType].toString().c_str(), (unsigned long)taskVersion, (unsigned long)version))); + state Error err = task_invalid_version(); - throw task_invalid_version(); + TraceEvent(SevError, "BA_BackupRangeTaskFunc_execute").detail("taskVersion", taskVersion).detail("Name", printable(name)).detail("Version", version); + if (KeyBackedConfig::TaskParams.uid().exists(task)) { + std::string msg = format("ERROR: %s task version `%lu' is greater than supported version `%lu'", task->params[Task::reservedTaskParamKeyType].toString().c_str(), (unsigned long)taskVersion, (unsigned long)version); + Void _ = wait(BackupConfig(task).logError(cx, err, msg)); + } + + throw err; } return Void(); } - ACTOR static Future writeRestoreFile(Reference tr, Key keyErrors, std::string backupContainer, UID logUid, - Version stopVersion, Key keyConfigBackupTag, Key keyConfigLogUid, Key keyConfigBackupRanges) + ACTOR static Future writeRestoreFile(Reference tr, BackupConfig config, Version stopVersion) { tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); tr->setOption(FDBTransactionOptions::LOCK_AWARE); + state UID uid = config.getUid(); + state std::string backupContainer = wait(config.backupContainer().getOrThrow(tr)); + state std::string tagName = wait(config.tag().getOrThrow(tr)); state std::string filename = "restorable"; state std::string tempFileName = FileBackupAgent::getTempFilename(); - state Reference f = wait(openBackupFile(true, backupContainer, tempFileName, keyErrors, tr->getDatabase())); + state Reference f = wait(openBackupFile(true, backupContainer, tempFileName, config, tr->getDatabase())); if (f) { state int64_t offset = wait(f->size()); @@ -890,17 +749,13 @@ namespace fileBackup { msg += format("%-15s %ld\n", "fdbbackupver:", backupVersion); msg += format("%-15s %lld\n", "restorablever:", stopVersion); - msg += format("%-15s %s\n", "tag:", printable(keyConfigBackupTag).c_str()); - msg += format("%-15s %s\n", "logUid:", logUid.toString().c_str()); - msg += format("%-15s %s\n", "logUidValue:", printable(keyConfigLogUid).c_str()); + msg += format("%-15s %s\n", "tag:", tagName.c_str()); + msg += format("%-15s %s\n", "logUid:", uid.toString().c_str()); + msg += format("%-15s %s\n", "logUidValue:", printable(config.getUidAsKey()).c_str()); // Deserialize the backup ranges - state Standalone> backupRanges; - BinaryReader br(keyConfigBackupRanges, IncludeVersion()); - br >> backupRanges; - + state std::vector backupRanges = wait(config.backupRanges().getOrThrow(tr)); msg += format("%-15s %d\n", "ranges:", backupRanges.size()); - for (auto &backupRange : backupRanges) { msg += format("%-15s %s\n", "rangebegin:", printable(backupRange.begin).c_str()); msg += format("%-15s %s\n", "rangeend:", printable(backupRange.end).c_str()); @@ -922,33 +777,77 @@ namespace fileBackup { throw; state Error err = e; - Void _ = wait(logError(tr->getDatabase(), keyErrors, format("ERROR: Failed to write to file `%s' because of error %s", filename.c_str(), err.what()))); + Void _ = wait(config.logError(tr->getDatabase(), err, format("ERROR: Failed to write to file `%s' because of error: %s", filename.c_str(), err.what()))); throw err; } - Void _ = wait(truncateCloseFile(tr->getDatabase(), keyErrors, backupContainer, filename, f, offset + msg.size())); + Void _ = wait(truncateCloseFile(tr->getDatabase(), config, backupContainer, filename, f, offset + msg.size())); Void _ = wait(IBackupContainer::openContainer(backupContainer)->renameFile(tempFileName, filename)); - tr->set(FileBackupAgent().lastRestorable.get(keyConfigBackupTag).pack(), BinaryWriter::toValue(stopVersion, Unversioned())); + tr->set(FileBackupAgent().lastRestorable.get(StringRef(tagName)).pack(), BinaryWriter::toValue(stopVersion, Unversioned())); } else { - Void _ = wait(logError(tr, keyErrors, "ERROR: Failed to open restorable file for unknown reason.")); + Void _ = wait(config.logError(tr->getDatabase(), io_error(), "ERROR: Failed to open restorable file for unknown reason.")); throw io_error(); } - TraceEvent("BA_WriteRestoreFile").detail("logUid", logUid).detail("stopVersion", stopVersion) + TraceEvent("BA_WriteRestoreFile").detail("logUid", uid).detail("stopVersion", stopVersion) .detail("backupContainer", backupContainer) - .detail("backupTag", printable(StringRef(keyConfigBackupTag))); + .detail("backupTag", tagName); return Void(); } + std::function)> NOP_SETUP_TASK_FN = [](Reference task) { /* NOP */ }; + ACTOR static Future addBackupTask(StringRef name, + uint32_t version, + Reference tr, + Reference taskBucket, + TaskCompletionKey completionKey, + BackupConfig config, + Reference waitFor = Reference(), + std::function)> setupTaskFn = NOP_SETUP_TASK_FN, + int priority = 0) { + tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); + tr->setOption(FDBTransactionOptions::LOCK_AWARE); + + Key doneKey = wait(completionKey.get(tr, taskBucket)); + state Reference task(new Task(name, version, doneKey, priority)); + + // Bind backup config to new task + Void _ = wait(config.toTask(tr, task)); + + // Set task specific params + setupTaskFn(task); + + if (!waitFor) { + return taskBucket->addTask(tr, task); + } + Void _ = wait(waitFor->onSetAddTask(tr, taskBucket, task)); + + return LiteralStringRef("OnSetAddTask"); + } + struct BackupRangeTaskFunc : TaskFuncBase { static StringRef name; static const uint32_t version; - static const Key keyAddBackupRangeTasks; - static const Key keyBackupRangeBeginKey; - static const Key keyFileSize; + static struct { + static TaskParam beginKey() { + return LiteralStringRef(__FUNCTION__); + } + static TaskParam endKey() { + return LiteralStringRef(__FUNCTION__); + } + static TaskParam backupRangeBeginKey() { + return LiteralStringRef(__FUNCTION__); + } + static TaskParam addBackupRangeTasks() { + return LiteralStringRef(__FUNCTION__); + } + static TaskParam fileSize() { + return LiteralStringRef(__FUNCTION__); + } + } Params; StringRef getName() const { return name; }; @@ -1008,23 +907,21 @@ namespace fileBackup { } ACTOR static Future addTask(Reference tr, Reference taskBucket, Reference parentTask, Key begin, Key end, TaskCompletionKey completionKey, Reference waitFor = Reference(), int priority = 0) { - Key doneKey = wait(completionKey.get(tr, taskBucket)); - Reference task(new Task(BackupRangeTaskFunc::name, BackupRangeTaskFunc::version, doneKey, priority)); - - copyDefaultParameters(parentTask, task); - - task->params[BackupAgentBase::keyBeginKey] = begin; - task->params[BackupAgentBase::keyEndKey] = end; - - if (!waitFor) { - return taskBucket->addTask(tr, task, parentTask->params[Task::reservedTaskParamValidKey], task->params[BackupAgentBase::keyFolderId]); - } - - Void _ = wait(waitFor->onSetAddTask(tr, taskBucket, task, parentTask->params[Task::reservedTaskParamValidKey], task->params[BackupAgentBase::keyFolderId])); - return LiteralStringRef("OnSetAddTask"); + Key key = wait(addBackupTask(BackupRangeTaskFunc::name, + BackupRangeTaskFunc::version, + tr, taskBucket, completionKey, + BackupConfig(parentTask), + waitFor, + [=](Reference task) { + Params.beginKey().set(task, begin); + Params.endKey().set(task, end); + Params.addBackupRangeTasks().set(task, false); + }, + priority)); + return key; } - ACTOR static Future endKeyRangeFile(Database cx, Key keyErrors, RangeFileWriter *rangeFile, std::string backupContainer, std::string *outFileName, Key endKey, Version atVersion) { + ACTOR static Future endKeyRangeFile(Database cx, BackupConfig config, RangeFileWriter *rangeFile, std::string backupContainer, std::string *outFileName, Key endKey, Version atVersion) { ASSERT(outFileName != nullptr); if (!rangeFile->file){ @@ -1034,7 +931,7 @@ namespace fileBackup { Void _ = wait(rangeFile->writeKey(endKey)); state std::string finalName = FileBackupAgent::getDataFilename(atVersion, rangeFile->offset, rangeFile->blockSize); - Void _ = wait(truncateCloseFile(cx, keyErrors, backupContainer, finalName, rangeFile->file, rangeFile->offset)); + Void _ = wait(truncateCloseFile(cx, config, backupContainer, finalName, rangeFile->file, rangeFile->offset)); Void _ = wait(IBackupContainer::openContainer(backupContainer)->renameFile(*outFileName, finalName)); *outFileName = finalName; @@ -1050,7 +947,7 @@ namespace fileBackup { // Find out if there is a shard boundary in(beginKey, endKey) Standalone> keys = wait(runRYWTransaction(cx, [=](Reference tr){ return getBlockOfShards(tr, task->params[FileBackupAgent::keyBeginKey], task->params[FileBackupAgent::keyEndKey], 1); })); if (keys.size() > 0) { - task->params[BackupRangeTaskFunc::keyAddBackupRangeTasks] = StringRef(); + Params.addBackupRangeTasks().set(task, true); return Void(); } @@ -1062,8 +959,8 @@ namespace fileBackup { state Version outVersion = -1; state std::string outFileName; - state Key beginKey = task->params[FileBackupAgent::keyBeginKey]; - state Key endKey = task->params[FileBackupAgent::keyEndKey]; + state Key beginKey = Params.beginKey().get(task); + state Key endKey = Params.endKey().get(task); state Key lastKey; state KeyRange range(KeyRangeRef(beginKey, endKey)); @@ -1075,6 +972,20 @@ namespace fileBackup { state int64_t fileSize = 0; state BackupConfig backup(task); + state std::string backupContainer; + loop { + try { + state Reference tr(new ReadYourWritesTransaction(cx)); + tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); + tr->setOption(FDBTransactionOptions::LOCK_AWARE); + + std::string ret = wait(backup.backupContainer().getOrThrow(tr)); + backupContainer = ret; + break; + } catch (Error &e) { + Void _ = wait(tr->onError(e)); + } + } loop{ try{ @@ -1088,13 +999,12 @@ namespace fileBackup { if (outFile){ TEST(true); // Backup range task wrote multiple versions - bool isFinished = wait(taskBucket->isFinished(cx, task)); - if (isFinished){ - Void _ = wait(truncateCloseFile(cx, task->params[FileBackupAgent::keyErrors], task->params[FileBackupAgent::keyBackupContainer].toString(), outFileName, outFile)); - return Void(); - } state Key nextKey = keyAfter(lastKey); - Void _ = wait(endKeyRangeFile(cx, task->params[FileBackupAgent::keyErrors], &rangeFile, task->params[FileBackupAgent::keyBackupContainer].toString(), &outFileName, nextKey, outVersion)); + Void _ = wait(saveAndExtendIncrementally(cx, taskBucket, task, + endKeyRangeFile(cx, backup, &rangeFile, backupContainer, &outFileName, nextKey, outVersion), + timeout // time at which to do the first saveAndExtend + ) + ); // outFileName has now been modified to be the file's final (non temporary) name. bool keepGoing = wait(recordRangeFile(backup, cx, task, taskBucket, KeyRangeRef(beginKey, nextKey), outFileName)); @@ -1107,13 +1017,13 @@ namespace fileBackup { if (now() >= timeout) { TEST(true); // Backup range task did not finish before timeout - task->params[BackupRangeTaskFunc::keyBackupRangeBeginKey] = beginKey; - task->params[BackupRangeTaskFunc::keyFileSize] = BinaryWriter::toValue(fileSize, Unversioned()); + Params.backupRangeBeginKey().set(task, beginKey); + Params.fileSize().set(task, fileSize); return Void(); } outFileName = FileBackupAgent::getTempFilename(); - Reference f = wait(openBackupFile(true, task->params[FileBackupAgent::keyBackupContainer].toString(), outFileName, task->params[FileBackupAgent::keyErrors], cx)); + Reference f = wait(openBackupFile(true, backupContainer, outFileName, backup, cx)); outFile = f; outVersion = values.second; @@ -1138,13 +1048,12 @@ namespace fileBackup { if (err.code() == error_code_end_of_stream) { if (outFile) { - bool isFinished = wait(taskBucket->isFinished(cx, task)); - if (isFinished){ - Void _ = wait(truncateCloseFile(cx, task->params[FileBackupAgent::keyErrors], task->params[FileBackupAgent::keyBackupContainer].toString(), outFileName, outFile)); - return Void(); - } try { - Void _ = wait(endKeyRangeFile(cx, task->params[FileBackupAgent::keyErrors], &rangeFile, task->params[FileBackupAgent::keyBackupContainer].toString(), &outFileName, endKey, outVersion)); + Void _ = wait(saveAndExtendIncrementally(cx, taskBucket, task, + endKeyRangeFile(cx, backup, &rangeFile, backupContainer, &outFileName, endKey, outVersion), + timeout // time at which to do the first saveAndExtend + ) + ); // outFileName has now been modified to be the file's final (non temporary) name. bool keepGoing = wait(recordRangeFile(backup, cx, task, taskBucket, KeyRangeRef(beginKey, endKey), outFileName)); @@ -1158,15 +1067,15 @@ namespace fileBackup { throw e2; } - Void _ = wait(logError(cx, task->params[FileBackupAgent::keyErrors], format("ERROR: Failed to write to file `%s' because of error %s", outFileName.c_str(), e2.what()))); + Void _ = wait(backup.logError(cx, e2, format("ERROR: Failed to write to file `%s' because of error: %s", outFileName.c_str(), e2.what()))); throw e2; } } - task->params[BackupRangeTaskFunc::keyFileSize] = BinaryWriter::toValue(fileSize, Unversioned()); + Params.fileSize().set(task, fileSize); return Void(); } - Void _ = wait(logError(cx, task->params[FileBackupAgent::keyErrors], format("ERROR: Failed to write to file `%s' because of error %s", outFileName.c_str(), err.what()))); + Void _ = wait(backup.logError(cx, err, format("ERROR: Failed to write to file `%s' because of error: %s", outFileName.c_str(), err.what()))); throw err; } @@ -1176,8 +1085,8 @@ namespace fileBackup { ACTOR static Future startBackupRangeInternal(Reference tr, Reference taskBucket, Reference futureBucket, Reference task, Reference onDone) { tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); tr->setOption(FDBTransactionOptions::LOCK_AWARE); - state Key nextKey = task->params[BackupAgentBase::keyBeginKey]; - state Standalone> keys = wait(getBlockOfShards(tr, nextKey, task->params[FileBackupAgent::keyEndKey], CLIENT_KNOBS->BACKUP_SHARD_TASK_LIMIT)); + state Key nextKey = Params.beginKey().get(task); + state Standalone> keys = wait(getBlockOfShards(tr, nextKey, Params.endKey().get(task), CLIENT_KNOBS->BACKUP_SHARD_TASK_LIMIT)); std::vector> addTaskVector; for (int idx = 0; idx < keys.size(); ++idx) { @@ -1189,9 +1098,9 @@ namespace fileBackup { Void _ = wait(waitForAll(addTaskVector)); - if (nextKey != task->params[BackupAgentBase::keyEndKey]) { + if (nextKey != Params.endKey().get(task)) { // Add task to cover nextKey to the end, using the priority of the current task - Key _ = wait(addTask(tr, taskBucket, task, nextKey, task->params[BackupAgentBase::keyEndKey], TaskCompletionKey::joinWith(onDone), Reference(), task->getPriority())); + Key _ = wait(addTask(tr, taskBucket, task, nextKey, Params.endKey().get(task), TaskCompletionKey::joinWith(onDone), Reference(), task->getPriority())); } return Void(); @@ -1200,17 +1109,16 @@ namespace fileBackup { ACTOR static Future _finish(Reference tr, Reference taskBucket, Reference futureBucket, Reference task) { state Reference taskFuture = futureBucket->unpack(task->params[Task::reservedTaskParamKeyDone]); - if(task->params.find(BackupRangeTaskFunc::keyFileSize) != task->params.end()) { - int64_t fileSize = BinaryReader::fromStringRef(task->params[BackupRangeTaskFunc::keyFileSize], Unversioned()); - BackupConfig(task).rangeBytesWritten().atomicOp(tr, fileSize, MutationRef::AddValue); + if(Params.fileSize().exists(task)) { + BackupConfig(task).rangeBytesWritten().atomicOp(tr, Params.fileSize().get(task), MutationRef::AddValue); } - if (task->params.find(BackupRangeTaskFunc::keyAddBackupRangeTasks) != task->params.end()) { + if (Params.addBackupRangeTasks().get(task)) { Void _ = wait(startBackupRangeInternal(tr, taskBucket, futureBucket, task, taskFuture)); } - else if (task->params.find(BackupRangeTaskFunc::keyBackupRangeBeginKey) != task->params.end() && task->params[BackupRangeTaskFunc::keyBackupRangeBeginKey] < task->params[BackupAgentBase::keyEndKey]) { + else if (Params.backupRangeBeginKey().exists(task) && Params.backupRangeBeginKey().get(task) < Params.endKey().get(task)) { ASSERT(taskFuture->key.size() > 0); - Key _ = wait(BackupRangeTaskFunc::addTask(tr, taskBucket, task, task->params[BackupRangeTaskFunc::keyBackupRangeBeginKey], task->params[BackupAgentBase::keyEndKey], TaskCompletionKey::signal(taskFuture->key))); + Key _ = wait(BackupRangeTaskFunc::addTask(tr, taskBucket, task, Params.backupRangeBeginKey().get(task), Params.endKey().get(task), TaskCompletionKey::signal(taskFuture->key))); } else { Void _ = wait(taskFuture->set(tr, taskBucket)); @@ -1223,9 +1131,6 @@ namespace fileBackup { }; StringRef BackupRangeTaskFunc::name = LiteralStringRef("file_backup_range"); const uint32_t BackupRangeTaskFunc::version = 1; - const Key BackupRangeTaskFunc::keyAddBackupRangeTasks = LiteralStringRef("addBackupRangeTasks"); - const Key BackupRangeTaskFunc::keyBackupRangeBeginKey = LiteralStringRef("backupRangeBeginKey"); - const Key BackupRangeTaskFunc::keyFileSize = LiteralStringRef("fileSize"); REGISTER_TASKFUNC(BackupRangeTaskFunc); struct FinishFullBackupTaskFunc : TaskFuncBase { @@ -1233,11 +1138,17 @@ namespace fileBackup { static const uint32_t version; ACTOR static Future _finish(Reference tr, Reference taskBucket, Reference futureBucket, Reference task) { - Void _ = wait(checkTaskVersion(tr, task, FinishFullBackupTaskFunc::name, FinishFullBackupTaskFunc::version)); + Void _ = wait(checkTaskVersion(tr->getDatabase(), task, FinishFullBackupTaskFunc::name, FinishFullBackupTaskFunc::version)); + + tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); + tr->setOption(FDBTransactionOptions::LOCK_AWARE); + + state BackupConfig config(task); // Enable the stop key state Version readVersion = wait(tr->getReadVersion()); - tr->set(task->params[FileBackupAgent::keyStateStop], BinaryWriter::toValue(readVersion, Unversioned())); + config.stopVersion().set(tr, readVersion); + TraceEvent(SevInfo, "FBA_setStopVersion").detail("stopVersion", readVersion); Void _ = wait(taskBucket->finish(tr, task)); @@ -1245,18 +1156,11 @@ namespace fileBackup { } ACTOR static Future addTask(Reference tr, Reference taskBucket, Reference parentTask, TaskCompletionKey completionKey, Reference waitFor = Reference()) { - // After the BackupRangeTask completes, set the stop key which will stop the BackupLogsTask - Key doneKey = wait(completionKey.get(tr, taskBucket)); - Reference task(new Task(FinishFullBackupTaskFunc::name, FinishFullBackupTaskFunc::version, doneKey)); - - copyDefaultParameters(parentTask, task); - - if (!waitFor) { - return taskBucket->addTask(tr, task, parentTask->params[Task::reservedTaskParamValidKey], task->params[BackupAgentBase::keyFolderId]); - } - - Void _ = wait(waitFor->onSetAddTask(tr, taskBucket, task, parentTask->params[Task::reservedTaskParamValidKey], task->params[BackupAgentBase::keyFolderId])); - return LiteralStringRef("OnSetAddTask"); + Key key = wait(addBackupTask(FinishFullBackupTaskFunc::name, + FinishFullBackupTaskFunc::version, + tr, taskBucket, completionKey, + BackupConfig(parentTask), waitFor)); + return key; } StringRef getName() const { return name; }; @@ -1273,16 +1177,30 @@ namespace fileBackup { static StringRef name; static const uint32_t version; - static const Key keyNextBeginVersion; - static const Key keyAddBackupLogRangeTasks; - static const Key keyFileSize; + static struct { + static TaskParam nextBeginVersion() { + return LiteralStringRef(__FUNCTION__); + } + static TaskParam addBackupLogRangeTasks() { + return LiteralStringRef(__FUNCTION__); + } + static TaskParam fileSize() { + return LiteralStringRef(__FUNCTION__); + } + static TaskParam beginVersion() { + return LiteralStringRef(__FUNCTION__); + } + static TaskParam endVersion() { + return LiteralStringRef(__FUNCTION__); + } + } Params; StringRef getName() const { return name; }; Future execute(Database cx, Reference tb, Reference fb, Reference task) { return _execute(cx, tb, fb, task); }; Future finish(Reference tr, Reference tb, Reference fb, Reference task) { return _finish(tr, tb, fb, task); }; - ACTOR static Future dumpData(Database cx, Reference task, PromiseStream results, LogFileWriter *outFile, + ACTOR static Future dumpData(Database cx, BackupConfig config, PromiseStream results, LogFileWriter *outFile, std::string fileName, FlowLock* lock, double timeout) { loop{ try{ @@ -1311,7 +1229,8 @@ namespace fileBackup { } state Error err = e; - Void _ = wait(logError(cx, task->params[FileBackupAgent::keyErrors], format("ERROR: Failed to write to file `%s' because of error %s", fileName.c_str(), err.what()))); + + Void _ = wait(config.logError(cx, err, format("ERROR: Failed to write to file `%s' because of error: %s", fileName.c_str(), err.what()))); throw err; } @@ -1324,15 +1243,19 @@ namespace fileBackup { Void _ = wait(checkTaskVersion(cx, task, BackupLogRangeTaskFunc::name, BackupLogRangeTaskFunc::version)); state double timeout = now() + CLIENT_KNOBS->BACKUP_RANGE_TIMEOUT; - state Version beginVersion = BinaryReader::fromStringRef(task->params[FileBackupAgent::keyBeginVersion], Unversioned()); - state Version endVersion = BinaryReader::fromStringRef(task->params[FileBackupAgent::keyEndVersion], Unversioned()); + state Version beginVersion = Params.beginVersion().get(task); + state Version endVersion = Params.endVersion().get(task); + state BackupConfig config(task); + state std::string backupContainer; loop{ state Reference tr(new ReadYourWritesTransaction(cx)); tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); tr->setOption(FDBTransactionOptions::LOCK_AWARE); // Wait for the read version to pass endVersion try { + std::string ret = wait(config.backupContainer().getOrThrow(tr)); + backupContainer = ret; Version currentVersion = wait(tr->getReadVersion()); if(endVersion < currentVersion) break; @@ -1345,19 +1268,18 @@ namespace fileBackup { } if (now() >= timeout) { - task->params[BackupLogRangeTaskFunc::keyNextBeginVersion] = task->params[FileBackupAgent::keyBeginVersion]; + Params.nextBeginVersion().set(task, beginVersion); return Void(); } - - state Standalone> ranges = getLogRanges(beginVersion, endVersion, task->params[FileBackupAgent::keyConfigLogUid]); + state Standalone> ranges = getLogRanges(beginVersion, endVersion, config.getUidAsKey()); if (ranges.size() > CLIENT_KNOBS->BACKUP_MAX_LOG_RANGES) { - task->params[BackupLogRangeTaskFunc::keyAddBackupLogRangeTasks] = StringRef(); + Params.addBackupLogRangeTasks().set(task, true); return Void(); } state std::string tempFileName = FileBackupAgent::getTempFilename(); - state Reference outFile = wait(openBackupFile(true, task->params[FileBackupAgent::keyBackupContainer].toString(), tempFileName, task->params[FileBackupAgent::keyErrors], cx)); + state Reference outFile = wait(openBackupFile(true, backupContainer, tempFileName, config, cx)); // Block size must be at least large enough for 1 max size key, 1 max size value, and overhead, so conservatively 125k. state LogFileWriter logFile(outFile, (BUGGIFY ? g_random->randomInt(125e3, 4e6) : CLIENT_KNOBS->BACKUP_LOGFILE_BLOCK_SIZE)); state size_t idx; @@ -1375,7 +1297,7 @@ namespace fileBackup { for (idx = 0; idx < ranges.size(); ++idx) { active[idx].send(Void()); - Version stopVersion = wait(dumpData(cx, task, results[idx], &logFile, tempFileName, lock.getPtr(), timeout)); + Version stopVersion = wait(dumpData(cx, config, results[idx], &logFile, tempFileName, lock.getPtr(), timeout)); if( stopVersion != invalidVersion || now() >= timeout) { if(stopVersion != invalidVersion) @@ -1383,33 +1305,35 @@ namespace fileBackup { else endVersion = std::min(endVersion, ((beginVersion / CLIENT_KNOBS->LOG_RANGE_BLOCK_SIZE) + idx + 1) * CLIENT_KNOBS->LOG_RANGE_BLOCK_SIZE); - task->params[BackupLogRangeTaskFunc::keyNextBeginVersion] = BinaryWriter::toValue(endVersion, Unversioned()); + Params.nextBeginVersion().set(task, endVersion); break; } } - task->params[BackupLogRangeTaskFunc::keyFileSize] = BinaryWriter::toValue(logFile.offset, Unversioned()); + Params.fileSize().set(task, logFile.offset); std::string logFileName = FileBackupAgent::getLogFilename(beginVersion, endVersion, logFile.offset, logFile.blockSize); - Void _ = wait(endLogFile(cx, taskBucket, futureBucket, task, outFile, tempFileName, logFileName, logFile.offset)); + + Void _ = wait(saveAndExtendIncrementally(cx, taskBucket, task, + endLogFile(cx, task, outFile, tempFileName, logFileName, logFile.offset, backupContainer), + timeout // time at which to do the first saveAndExtend + ) + ); return Void(); } ACTOR static Future addTask(Reference tr, Reference taskBucket, Reference parentTask, Version beginVersion, Version endVersion, TaskCompletionKey completionKey, Reference waitFor = Reference()) { - Key doneKey = wait(completionKey.get(tr, taskBucket)); - Reference task(new Task(BackupLogRangeTaskFunc::name, BackupLogRangeTaskFunc::version, doneKey, 1)); - - copyDefaultParameters(parentTask, task); - - task->params[FileBackupAgent::keyBeginVersion] = BinaryWriter::toValue(beginVersion, Unversioned()); - task->params[FileBackupAgent::keyEndVersion] = BinaryWriter::toValue(endVersion, Unversioned()); - - if (!waitFor) { - return taskBucket->addTask(tr, task, parentTask->params[Task::reservedTaskParamValidKey], task->params[BackupAgentBase::keyFolderId]); - } - - Void _ = wait(waitFor->onSetAddTask(tr, taskBucket, task, parentTask->params[Task::reservedTaskParamValidKey], task->params[BackupAgentBase::keyFolderId])); - return LiteralStringRef("OnSetAddTask"); + Key key = wait(addBackupTask(BackupLogRangeTaskFunc::name, + BackupLogRangeTaskFunc::version, + tr, taskBucket, completionKey, + BackupConfig(parentTask), + waitFor, + [=](Reference task) { + Params.beginVersion().set(task, beginVersion); + Params.endVersion().set(task, endVersion); + Params.addBackupLogRangeTasks().set(task, false); + })); + return key; } ACTOR static Future startBackupLogRangeInternal(Reference tr, Reference taskBucket, Reference futureBucket, Reference task, Reference taskFuture, Version beginVersion, Version endVersion ) { @@ -1437,21 +1361,20 @@ namespace fileBackup { } ACTOR static Future _finish(Reference tr, Reference taskBucket, Reference futureBucket, Reference task) { - state Version beginVersion = BinaryReader::fromStringRef(task->params[FileBackupAgent::keyBeginVersion], Unversioned()); - state Version endVersion = BinaryReader::fromStringRef(task->params[FileBackupAgent::keyEndVersion], Unversioned()); + state Version beginVersion = Params.beginVersion().get(task); + state Version endVersion = Params.endVersion().get(task); state Reference taskFuture = futureBucket->unpack(task->params[Task::reservedTaskParamKeyDone]); - if(task->params.find(BackupLogRangeTaskFunc::keyFileSize) != task->params.end()) { - int64_t fileSize = BinaryReader::fromStringRef(task->params[BackupLogRangeTaskFunc::keyFileSize], Unversioned()); - BackupConfig(task).logBytesWritten().atomicOp(tr, fileSize, MutationRef::AddValue); + if(Params.fileSize().exists(task)) { + BackupConfig(task).logBytesWritten().atomicOp(tr, Params.fileSize().get(task), MutationRef::AddValue); } - if (task->params.find(BackupLogRangeTaskFunc::keyAddBackupLogRangeTasks) != task->params.end()) { + if (Params.addBackupLogRangeTasks().get(task)) { Void _ = wait(startBackupLogRangeInternal(tr, taskBucket, futureBucket, task, taskFuture, beginVersion, endVersion)); endVersion = beginVersion; } - else if (task->params.find(BackupLogRangeTaskFunc::keyNextBeginVersion) != task->params.end()) { - state Version nextVersion = BinaryReader::fromStringRef(task->params[BackupLogRangeTaskFunc::keyNextBeginVersion], Unversioned()); + else if (Params.nextBeginVersion().exists(task)) { + state Version nextVersion = Params.nextBeginVersion().get(task); Key _ = wait(BackupLogRangeTaskFunc::addTask(tr, taskBucket, task, nextVersion, endVersion, TaskCompletionKey::joinWith(taskFuture))); endVersion = nextVersion; } else { @@ -1468,17 +1391,12 @@ namespace fileBackup { return Void(); } - ACTOR static Future endLogFile(Database cx, Reference taskBucket, Reference futureBucket, Reference task, Reference tempFile, std::string tempFileName, std::string logFileName, int64_t size) { - state std::string backupContainer = task->params[FileBackupAgent::keyBackupContainer].toString(); + ACTOR static Future endLogFile(Database cx, Reference task, Reference tempFile, std::string tempFileName, std::string logFileName, int64_t size, std::string backupContainer) { try { if (tempFile) { - Void _ = wait(truncateCloseFile(cx, task->params[FileBackupAgent::keyErrors], backupContainer, logFileName, tempFile, size)); + Void _ = wait(truncateCloseFile(cx, BackupConfig(task), backupContainer, logFileName, tempFile, size)); } - bool isFinished = wait(taskBucket->isFinished(cx, task)); - if (isFinished) - return Void(); - Void _ = wait(IBackupContainer::openContainer(backupContainer)->renameFile(tempFileName, logFileName)); } catch (Error &e) { @@ -1493,25 +1411,31 @@ namespace fileBackup { StringRef BackupLogRangeTaskFunc::name = LiteralStringRef("file_backup_log_range"); const uint32_t BackupLogRangeTaskFunc::version = 1; - const Key BackupLogRangeTaskFunc::keyNextBeginVersion = LiteralStringRef("nextBeginVersion"); - const Key BackupLogRangeTaskFunc::keyAddBackupLogRangeTasks = LiteralStringRef("addBackupLogRangeTasks"); - const Key BackupLogRangeTaskFunc::keyFileSize = LiteralStringRef("fileSize"); REGISTER_TASKFUNC(BackupLogRangeTaskFunc); struct BackupLogsTaskFunc : TaskFuncBase { static StringRef name; static const uint32_t version; + static struct { + static TaskParam beginVersion() { + return LiteralStringRef(__FUNCTION__); + } + } Params; + ACTOR static Future _finish(Reference tr, Reference taskBucket, Reference futureBucket, Reference task) { - Void _ = wait(checkTaskVersion(tr, task, BackupLogsTaskFunc::name, BackupLogsTaskFunc::version)); + Void _ = wait(checkTaskVersion(tr->getDatabase(), task, BackupLogsTaskFunc::name, BackupLogsTaskFunc::version)); state Reference onDone = futureBucket->unpack(task->params[Task::reservedTaskParamKeyDone]); state Reference allPartsDone; - state Optional stopValue = wait(tr->get(task->params[FileBackupAgent::keyStateStop])); - state Version stopVersionData = stopValue.present() ? BinaryReader::fromStringRef(stopValue.get(), Unversioned()) : -1; + tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); + tr->setOption(FDBTransactionOptions::LOCK_AWARE); - state Version beginVersion = BinaryReader::fromStringRef(task->params[FileBackupAgent::keyBeginVersion], Unversioned()); + state BackupConfig config(task); + state Version stopVersionData = wait(config.stopVersion().getD(tr, -1)); + + state Version beginVersion = Params.beginVersion().get(task); state Version endVersion = std::max( tr->getReadVersion().get() + 1, beginVersion + (CLIENT_KNOBS->BACKUP_MAX_LOG_RANGES-1)*CLIENT_KNOBS->LOG_RANGE_BLOCK_SIZE ); if(endVersion - beginVersion > g_random->randomInt64(0, CLIENT_KNOBS->BACKUP_VERSION_DELAY)) { @@ -1523,7 +1447,7 @@ namespace fileBackup { allPartsDone = onDone; // Updated the stop version - tr->set(task->params[FileBackupAgent::keyStateStop], BinaryWriter::toValue(endVersion, Unversioned())); + config.stopVersion().set(tr, endVersion); } else { allPartsDone = futureBucket->future(tr); @@ -1537,22 +1461,15 @@ namespace fileBackup { } ACTOR static Future addTask(Reference tr, Reference taskBucket, Reference parentTask, Version beginVersion, TaskCompletionKey completionKey, Reference waitFor = Reference()) { - Key doneKey = wait(completionKey.get(tr, taskBucket)); - Reference task(new Task(BackupLogsTaskFunc::name, BackupLogsTaskFunc::version, doneKey, 1)); - - copyDefaultParameters(parentTask, task); - copyParameter(parentTask, task, FileBackupAgent::keyStateStatus); - copyParameter(parentTask, task, FileBackupAgent::keyConfigStopWhenDoneKey); - copyParameter(parentTask, task, FileBackupAgent::keyConfigBackupRanges); - - task->params[BackupAgentBase::keyBeginVersion] = BinaryWriter::toValue(beginVersion, Unversioned()); - - if (!waitFor) { - return taskBucket->addTask(tr, task, parentTask->params[Task::reservedTaskParamValidKey], task->params[BackupAgentBase::keyFolderId]); - } - - Void _ = wait(waitFor->onSetAddTask(tr, taskBucket, task, parentTask->params[Task::reservedTaskParamValidKey], task->params[BackupAgentBase::keyFolderId])); - return LiteralStringRef("OnSetAddTask"); + Key key = wait(addBackupTask(BackupLogsTaskFunc::name, + BackupLogsTaskFunc::version, + tr, taskBucket, completionKey, + BackupConfig(parentTask), + waitFor, + [=](Reference task) { + Params.beginVersion().set(task, beginVersion); + })); + return key; } StringRef getName() const { return name; }; @@ -1571,38 +1488,28 @@ namespace fileBackup { StringRef getName() const { return name; }; ACTOR static Future _finish(Reference tr, Reference taskBucket, Reference futureBucket, Reference task) { - Void _ = wait(checkTaskVersion(tr, task, FinishedFullBackupTaskFunc::name, FinishedFullBackupTaskFunc::version)); - - state UID logUid = BinaryReader::fromStringRef(task->params[FileBackupAgent::keyConfigLogUid], Unversioned()); - - state Key configPath = uidPrefixKey(logRangesRange.begin, logUid); - state Key logsPath = uidPrefixKey(backupLogKeys.begin, logUid); + Void _ = wait(checkTaskVersion(tr->getDatabase(), task, FinishedFullBackupTaskFunc::name, FinishedFullBackupTaskFunc::version)); state BackupConfig backup(task); - backup.clear(tr); + state UID uid = backup.getUid(); + + state Key configPath = uidPrefixKey(logRangesRange.begin, uid); + state Key logsPath = uidPrefixKey(backupLogKeys.begin, uid); + tr->clear(KeyRangeRef(configPath, strinc(configPath))); tr->clear(KeyRangeRef(logsPath, strinc(logsPath))); - - tr->set(task->params[FileBackupAgent::keyStateStatus], StringRef(BackupAgentBase::getStateText(BackupAgentBase::STATE_COMPLETED))); + backup.stateEnum().set(tr, EBackupState::STATE_COMPLETED); Void _ = wait(taskBucket->finish(tr, task)); return Void(); } ACTOR static Future addTask(Reference tr, Reference taskBucket, Reference parentTask, TaskCompletionKey completionKey, Reference waitFor = Reference()) { - Key doneKey = wait(completionKey.get(tr, taskBucket)); - Reference task(new Task(FinishedFullBackupTaskFunc::name, FinishedFullBackupTaskFunc::version, doneKey)); - - copyDefaultParameters(parentTask, task); - copyParameter(parentTask, task, BackupAgentBase::keyStateStatus); - copyParameter(parentTask, task, BackupAgentBase::keyConfigBackupRanges); - - if (!waitFor) { - return taskBucket->addTask(tr, task, parentTask->params[Task::reservedTaskParamValidKey], task->params[BackupAgentBase::keyFolderId]); - } - - Void _ = wait(waitFor->onSetAddTask(tr, taskBucket, task, parentTask->params[Task::reservedTaskParamValidKey], task->params[BackupAgentBase::keyFolderId])); - return LiteralStringRef("OnSetAddTask"); + Key key = wait(addBackupTask(FinishedFullBackupTaskFunc::name, + FinishedFullBackupTaskFunc::version, + tr, taskBucket, completionKey, + BackupConfig(parentTask), waitFor)); + return key; } Future execute(Database cx, Reference tb, Reference fb, Reference task) { return Void(); }; @@ -1616,26 +1523,38 @@ namespace fileBackup { static StringRef name; static const uint32_t version; + static struct { + static TaskParam beginVersion() { + return LiteralStringRef(__FUNCTION__); + } + } Params; + ACTOR static Future _finish(Reference tr, Reference taskBucket, Reference futureBucket, Reference task) { - Void _ = wait(checkTaskVersion(tr, task, BackupDiffLogsTaskFunc::name, BackupDiffLogsTaskFunc::version)); + Void _ = wait(checkTaskVersion(tr->getDatabase(), task, BackupDiffLogsTaskFunc::name, BackupDiffLogsTaskFunc::version)); + + tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); + tr->setOption(FDBTransactionOptions::LOCK_AWARE); + + state BackupConfig config(task); + state std::string tagName = wait(config.tag().getOrThrow(tr)); state Reference onDone = futureBucket->unpack(task->params[Task::reservedTaskParamKeyDone]); state Reference allPartsDone; - state Optional stopWhenDone = wait(tr->get(task->params[FileBackupAgent::keyConfigStopWhenDoneKey])); + state bool stopWhenDone = wait(config.stopWhenDone().getOrThrow(tr)); - state Version beginVersion = BinaryReader::fromStringRef(task->params[FileBackupAgent::keyBeginVersion], Unversioned()); + state Version beginVersion = Params.beginVersion().get(task); state Version endVersion = std::max( tr->getReadVersion().get() + 1, beginVersion + (CLIENT_KNOBS->BACKUP_MAX_LOG_RANGES-1)*CLIENT_KNOBS->LOG_RANGE_BLOCK_SIZE ); - tr->set(FileBackupAgent().lastRestorable.get(task->params[FileBackupAgent::keyConfigBackupTag]).pack(), BinaryWriter::toValue(beginVersion, Unversioned())); + tr->set(FileBackupAgent().lastRestorable.get(StringRef(tagName)).pack(), BinaryWriter::toValue(beginVersion, Unversioned())); if(endVersion - beginVersion > g_random->randomInt64(0, CLIENT_KNOBS->BACKUP_VERSION_DELAY)) { - TraceEvent("FBA_DiffLogs").detail("beginVersion", beginVersion).detail("endVersion", endVersion).detail("stopWhenDone", stopWhenDone.present()); + TraceEvent("FBA_DiffLogs").detail("beginVersion", beginVersion).detail("endVersion", endVersion).detail("stopWhenDone", stopWhenDone); } - if (stopWhenDone.present()) { + if (stopWhenDone) { allPartsDone = onDone; - tr->set(task->params[FileBackupAgent::keyStateStop], BinaryWriter::toValue(endVersion, Unversioned())); + config.stopVersion().set(tr, endVersion); } else { allPartsDone = futureBucket->future(tr); @@ -1649,22 +1568,15 @@ namespace fileBackup { } ACTOR static Future addTask(Reference tr, Reference taskBucket, Reference parentTask, Version beginVersion, TaskCompletionKey completionKey, Reference waitFor = Reference()) { - Key doneKey = wait(completionKey.get(tr, taskBucket)); - Reference task(new Task(BackupDiffLogsTaskFunc::name, BackupDiffLogsTaskFunc::version, doneKey, 1)); - - copyDefaultParameters(parentTask, task); - copyParameter(parentTask, task, BackupAgentBase::keyStateStatus); - copyParameter(parentTask, task, BackupAgentBase::keyConfigBackupRanges); - copyParameter(parentTask, task, BackupAgentBase::keyConfigStopWhenDoneKey); - - task->params[FileBackupAgent::keyBeginVersion] = BinaryWriter::toValue(beginVersion, Unversioned()); - - if (!waitFor) { - return taskBucket->addTask(tr, task, parentTask->params[Task::reservedTaskParamValidKey], task->params[BackupAgentBase::keyFolderId]); - } - - Void _ = wait(waitFor->onSetAddTask(tr, taskBucket, task, parentTask->params[Task::reservedTaskParamValidKey], task->params[BackupAgentBase::keyFolderId])); - return LiteralStringRef("OnSetAddTask"); + Key key = wait(addBackupTask(BackupDiffLogsTaskFunc::name, + BackupDiffLogsTaskFunc::version, + tr, taskBucket, completionKey, + BackupConfig(parentTask), + waitFor, + [=](Reference task) { + Params.beginVersion().set(task, beginVersion); + })); + return key; } StringRef getName() const { return name; }; @@ -1770,12 +1682,15 @@ namespace fileBackup { state std::map> localmap; state Key startKey; state int batchSize = BUGGIFY ? 1 : 1000000; + state std::string backupContainer; loop { try { tr->reset(); tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); tr->setOption(FDBTransactionOptions::LOCK_AWARE); + std::string ret = wait(backup.backupContainer().getOrThrow(tr)); + backupContainer = ret; // Calling isFinished instead of keepRunning because if this backup was cancelled completely but we got // all the way to this part we may as well write out the kvmanifest. @@ -1837,44 +1752,45 @@ namespace fileBackup { array.push_back(f.toString()); state std::string docString = json_spirit::write_string(doc); - std::string url = task->params[FileBackupAgent::keyBackupContainer].toString(); - state Reference bc = IBackupContainer::openContainer(url); + state Reference bc = IBackupContainer::openContainer(backupContainer); state std::string tempFile = FileBackupAgent::getTempFilename(); state Reference mf = wait(bc->openFile(tempFile, IBackupContainer::WRITEONLY)); Void _ = wait(mf->write(docString.data(), docString.size(), 0)); Void _ = wait(mf->sync()); std::string fileName = format("kvmanifest,%lld,%lld,%lld,%s", minVer, maxVer, totalBytes, g_random->randomUniqueID().toString().c_str()); + + TraceEvent(SevInfo, "FBA_KVManifest").detail("fileName", fileName.c_str()); Void _ = wait(bc->renameFile(tempFile, fileName)); return Void(); } ACTOR static Future _finish(Reference tr, Reference taskBucket, Reference futureBucket, Reference task) { - Void _ = wait(checkTaskVersion(tr, task, BackupRestorableTaskFunc::name, BackupRestorableTaskFunc::version)); + Void _ = wait(checkTaskVersion(tr->getDatabase(), task, BackupRestorableTaskFunc::name, BackupRestorableTaskFunc::version)); + + state BackupConfig config(task); + tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); + tr->setOption(FDBTransactionOptions::LOCK_AWARE); state Reference onDone = futureBucket->unpack(task->params[Task::reservedTaskParamKeyDone]); - state Optional stopValue = wait(tr->get(task->params[FileBackupAgent::keyStateStop])); - state Version restoreVersion = stopValue.present() ? BinaryReader::fromStringRef(stopValue.get(), Unversioned()) : -1; + state Version restoreVersion = wait(config.stopVersion().getD(tr, -1)); - state Optional stopWhenDone = wait(tr->get(task->params[FileBackupAgent::keyConfigStopWhenDoneKey])); + state bool stopWhenDone = wait(config.stopWhenDone().getOrThrow(tr)); state Reference allPartsDone; - state UID logUid = BinaryReader::fromStringRef(task->params[FileBackupAgent::keyConfigLogUid], Unversioned()); + Void _ = wait(writeRestoreFile(tr, config, restoreVersion)); - Void _ = wait(writeRestoreFile(tr, task->params[FileBackupAgent::keyErrors], task->params[FileBackupAgent::keyBackupContainer].toString(), logUid, restoreVersion, - task->params[FileBackupAgent::keyConfigBackupTag], task->params[BackupAgentBase::keyConfigLogUid], task->params[BackupAgentBase::keyConfigBackupRanges])); - - TraceEvent("FBA_Complete").detail("restoreVersion", restoreVersion).detail("differential", stopWhenDone.present()); + TraceEvent("FBA_Complete").detail("restoreVersion", restoreVersion).detail("differential", stopWhenDone); // Start the complete task, if differential is not enabled - if (stopWhenDone.present()) { + if (stopWhenDone) { // After the Backup completes, clear the backup subspace and update the status Key _ = wait(FinishedFullBackupTaskFunc::addTask(tr, taskBucket, task, TaskCompletionKey::noSignal())); } else { // Start the writing of logs, if differential - tr->set(task->params[FileBackupAgent::keyStateStatus], StringRef(BackupAgentBase::getStateText(BackupAgentBase::STATE_DIFFERENTIAL))); + config.stateEnum().set(tr, EBackupState::STATE_DIFFERENTIAL); allPartsDone = futureBucket->future(tr); @@ -1889,20 +1805,11 @@ namespace fileBackup { } ACTOR static Future addTask(Reference tr, Reference taskBucket, Reference parentTask, TaskCompletionKey completionKey, Reference waitFor = Reference()) { - Key doneKey = wait(completionKey.get(tr, taskBucket)); - Reference task(new Task(BackupRestorableTaskFunc::name, BackupRestorableTaskFunc::version, doneKey)); - - copyDefaultParameters(parentTask, task); - copyParameter(parentTask, task, BackupAgentBase::keyStateStatus); - copyParameter(parentTask, task, BackupAgentBase::keyConfigBackupRanges); - copyParameter(parentTask, task, BackupAgentBase::keyConfigStopWhenDoneKey); - - if (!waitFor) { - return taskBucket->addTask(tr, task, parentTask->params[Task::reservedTaskParamValidKey], task->params[BackupAgentBase::keyFolderId]); - } - - Void _ = wait(waitFor->onSetAddTask(tr, taskBucket, task, parentTask->params[Task::reservedTaskParamValidKey], task->params[BackupAgentBase::keyFolderId])); - return LiteralStringRef("OnSetAddTask"); + Key key = wait(addBackupTask(BackupRestorableTaskFunc::name, + BackupRestorableTaskFunc::version, + tr, taskBucket, completionKey, + BackupConfig(parentTask), waitFor)); + return key; } StringRef getName() const { return name; }; @@ -1918,6 +1825,10 @@ namespace fileBackup { static StringRef name; static const uint32_t version; + static struct { + static TaskParam beginVersion() { return LiteralStringRef(__FUNCTION__); } + } Params; + ACTOR static Future _execute(Database cx, Reference taskBucket, Reference futureBucket, Reference task) { Void _ = wait(checkTaskVersion(cx, task, StartFullBackupTaskFunc::name, StartFullBackupTaskFunc::version)); @@ -1928,7 +1839,7 @@ namespace fileBackup { tr->setOption(FDBTransactionOptions::LOCK_AWARE); Version startVersion = wait(tr->getReadVersion()); - task->params[FileBackupAgent::keyBeginVersion] = BinaryWriter::toValue(startVersion, Unversioned()); + Params.beginVersion().set(task, startVersion); break; } catch (Error &e) { @@ -1940,20 +1851,17 @@ namespace fileBackup { } ACTOR static Future _finish(Reference tr, Reference taskBucket, Reference futureBucket, Reference task) { - state UID logUid = BinaryReader::fromStringRef(task->params[FileBackupAgent::keyConfigLogUid], Unversioned()); - state Key logUidDest = uidPrefixKey(backupLogKeys.begin, logUid); - state Version beginVersion = BinaryReader::fromStringRef(task->params[BackupAgentBase::keyBeginVersion], Unversioned()); + state BackupConfig config(task); + state Version beginVersion = Params.beginVersion().get(task); - state Standalone> backupRanges; - BinaryReader br(task->params[FileBackupAgent::keyConfigBackupRanges], IncludeVersion()); - br >> backupRanges; + state std::vector backupRanges = wait(config.backupRanges().getOrThrow(tr)); // Start logging the mutations for the specified ranges of the tag for (auto &backupRange : backupRanges) { - tr->set(logRangesEncodeKey(backupRange.begin, logUid), logRangesEncodeValue(backupRange.end, logUidDest)); + config.startMutationLogs(tr, backupRange); } - tr->set(task->params[FileBackupAgent::keyStateStatus], StringRef(BackupAgentBase::getStateText(BackupAgentBase::STATE_BACKUP))); + config.stateEnum().set(tr, EBackupState::STATE_BACKUP); state Reference kvBackupRangeComplete = futureBucket->future(tr); state Reference kvBackupComplete = futureBucket->future(tr); @@ -1977,28 +1885,13 @@ namespace fileBackup { return Void(); } - ACTOR static Future addTask(Reference tr, Reference taskBucket, Key keyConfigFolderIdKey, Key keyFolderId, Key keyStateStatus, Key keyStateStop, Key keyBackupContainer, - Key keyConfigLogUid, Key keyConfigBackupTag, Key keyConfigBackupRanges, Key keyConfigStopWhenDoneKey, Key keyErrors, TaskCompletionKey completionKey, Reference waitFor = Reference()) + ACTOR static Future addTask(Reference tr, Reference taskBucket, UID uid, TaskCompletionKey completionKey, Reference waitFor = Reference()) { - Key doneKey = wait(completionKey.get(tr, taskBucket)); - Reference task(new Task(StartFullBackupTaskFunc::name, StartFullBackupTaskFunc::version, doneKey)); - - task->params[BackupAgentBase::keyFolderId] = keyFolderId; - task->params[BackupAgentBase::keyStateStatus] = keyStateStatus; - task->params[BackupAgentBase::keyStateStop] = keyStateStop; - task->params[BackupAgentBase::keyConfigLogUid] = keyConfigLogUid; - task->params[BackupAgentBase::keyConfigBackupTag] = keyConfigBackupTag; - task->params[BackupAgentBase::keyConfigBackupRanges] = keyConfigBackupRanges; - task->params[BackupAgentBase::keyConfigStopWhenDoneKey] = keyConfigStopWhenDoneKey; - task->params[BackupAgentBase::keyErrors] = keyErrors; - task->params[FileBackupAgent::keyBackupContainer] = keyBackupContainer; - - if (!waitFor) { - return taskBucket->addTask(tr, task, keyConfigFolderIdKey, task->params[BackupAgentBase::keyFolderId]); - } - - Void _ = wait(waitFor->onSetAddTask(tr, taskBucket, task, keyConfigFolderIdKey, task->params[BackupAgentBase::keyFolderId])); - return LiteralStringRef("OnSetAddTask"); + Key key = wait(addBackupTask(StartFullBackupTaskFunc::name, + StartFullBackupTaskFunc::version, + tr, taskBucket, completionKey, + BackupConfig(uid), waitFor)); + return key; } StringRef getName() const { return name; }; @@ -2262,7 +2155,7 @@ namespace fileBackup { struct RestoreCompleteTaskFunc : TaskFuncBase { ACTOR static Future _finish(Reference tr, Reference taskBucket, Reference futureBucket, Reference task) { - Void _ = wait(checkTaskVersion(tr, task, name, version)); + Void _ = wait(checkTaskVersion(tr->getDatabase(), task, name, version)); state RestoreConfig restore(task); restore.stateEnum().set(tr, ERestoreState::COMPLETED); @@ -2366,7 +2259,7 @@ namespace fileBackup { state Future addPrefix = restore.addPrefix().getD(tr); state Future removePrefix = restore.removePrefix().getD(tr); - Void _ = wait(success(url) && success(restoreRange) && success(addPrefix) && success(removePrefix) && checkTaskVersion(tr, task, name, version)); + Void _ = wait(success(url) && success(restoreRange) && success(addPrefix) && success(removePrefix) && checkTaskVersion(tr->getDatabase(), task, name, version)); bool go = wait(taskBucket->keepRunning(tr, task)); if(!go) return Void(); @@ -2606,7 +2499,7 @@ namespace fileBackup { state Value url = wait(restore.sourceURL().getD(tr)); - Void _ = wait(checkTaskVersion(tr, task, name, version)); + Void _ = wait(checkTaskVersion(tr->getDatabase(), task, name, version)); bool go = wait(taskBucket->keepRunning(tr, task)); if(!go) return Void(); @@ -2770,7 +2663,7 @@ namespace fileBackup { state Version beginVersion = Params.beginVersion().get(task); state Reference onDone = futureBucket->unpack(task->params[Task::reservedTaskParamKeyDone]); - Void _ = wait(checkTaskVersion(tr, task, name, version)); + Void _ = wait(checkTaskVersion(tr->getDatabase(), task, name, version)); state int64_t remainingInBatch = Params.remainingInBatch().get(task); state bool addingToExistingBatch = remainingInBatch > 0; @@ -3068,13 +2961,13 @@ namespace fileBackup { tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); tr->setOption(FDBTransactionOptions::LOCK_AWARE); - state std::vector tags; + state std::vector tags; if(tagName.size() == 0) { - std::vector t = wait(RestoreTags().getAll(tr)); + std::vector t = wait(getAllRestoreTags(tr)); tags = t; } else - tags.push_back(tagName); + tags.push_back(makeRestoreTag(tagName.toString())); state std::string result; state int i = 0; @@ -3093,7 +2986,7 @@ namespace fileBackup { tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); tr->setOption(FDBTransactionOptions::LOCK_AWARE); - state RestoreTag tag(tagName); + state KeyBackedTag tag = makeRestoreTag(tagName.toString()); state Optional current = wait(tag.get(tr)); if(!current.present()) return ERestoreState::UNITIALIZED; @@ -3136,7 +3029,7 @@ namespace fileBackup { tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); tr->setOption(FDBTransactionOptions::LOCK_AWARE); - Void _ = wait(checkTaskVersion(tr, task, name, version)); + Void _ = wait(checkTaskVersion(tr->getDatabase(), task, name, version)); state Version restoreVersion = wait(restore.restoreVersion().getD(tr)); bool go = wait(taskBucket->keepRunning(tr, task)); if(!go) @@ -3241,8 +3134,8 @@ namespace fileBackup { state RestoreConfig restore(task); if(firstVersion == Version()) { Void _ = wait(restore.logError(tr->getDatabase(), restore_missing_data(), "StartFullRestore: The backup had no data.", this)); - Key tag = wait(restore.tag().getD(tr)); - ERestoreState _ = wait(abortRestore(tr, tag)); + std::string tag = wait(restore.tag().getD(tr)); + ERestoreState _ = wait(abortRestore(tr, StringRef(tag))); return Void(); } @@ -3304,10 +3197,9 @@ public: static const int MAX_RESTORABLE_FILE_METASECTION_BYTES = 1024 * 8; // This method will return the final status of the backup - ACTOR static Future waitBackup(FileBackupAgent* backupAgent, Database cx, Key tagName, bool stopWhenDone) { + ACTOR static Future waitBackup(FileBackupAgent* backupAgent, Database cx, std::string tagName, bool stopWhenDone) { state std::string backTrace; - state UID logUid = wait(backupAgent->getLogUid(cx, tagName)); - state Key statusKey = backupAgent->states.get(logUid.toString()).pack(FileBackupAgent::keyStateStatus); + state KeyBackedTag tag = makeBackupTag(tagName); loop { state Reference tr(new ReadYourWritesTransaction(cx)); @@ -3315,10 +3207,16 @@ public: tr->setOption(FDBTransactionOptions::LOCK_AWARE); try { - state int status = wait(backupAgent->getStateValue(tr, logUid)); + state Optional oldUidAndAborted = wait(tag.get(tr)); + if (!oldUidAndAborted.present()) { + return EBackupState::STATE_NEVERRAN; + } + + state BackupConfig config(oldUidAndAborted.get().first); + state EBackupState status = wait(config.stateEnum().getD(tr, EBackupState::STATE_NEVERRAN)); // Break, if no longer runnable - if (!FileBackupAgent::isRunnable((BackupAgentBase::enumState)status)) { + if (!FileBackupAgent::isRunnable(status)) { return status; } @@ -3327,7 +3225,7 @@ public: return status; } - state Future watchFuture = tr->watch( statusKey ); + state Future watchFuture = tr->watch( config.stateEnum().key ); Void _ = wait( tr->commit() ); Void _ = wait( watchFuture ); } @@ -3337,50 +3235,53 @@ public: } } - ACTOR static Future submitBackup(FileBackupAgent* backupAgent, Reference tr, Key outContainer, Key tagName, Standalone> backupRanges, bool stopWhenDone) { - state UID logUid = g_random->randomUniqueID(); - state Key logUidValue = BinaryWriter::toValue(logUid, Unversioned()); - state UID logUidCurrent = wait(backupAgent->getLogUid(tr, tagName)); - + ACTOR static Future submitBackup(FileBackupAgent* backupAgent, Reference tr, Key outContainer, std::string tagName, Standalone> backupRanges, bool stopWhenDone) { tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); tr->setOption(FDBTransactionOptions::LOCK_AWARE); - // We will use the global status for now to ensure that multiple backups do not start place with different tags - state int status = wait(backupAgent->getStateValue(tr, logUidCurrent)); + TraceEvent(SevInfo, "FBA_submitBackup") + .detail("tagName", tagName.c_str()) + .detail("stopWhenDone", stopWhenDone) + .detail("outContainer", outContainer.toString()); - if (FileBackupAgent::isRunnable((BackupAgentBase::enumState)status)) { - throw backup_duplicate(); + state KeyBackedTag tag = makeBackupTag(tagName); + Optional uidAndAbortedFlag = wait(tag.get(tr)); + if (uidAndAbortedFlag.present()) { + state BackupConfig prevConfig(uidAndAbortedFlag.get().first); + state EBackupState prevBackupStatus = wait(prevConfig.stateEnum().getD(tr, EBackupState::STATE_NEVERRAN)); + if (FileBackupAgent::isRunnable(prevBackupStatus)) { + throw backup_duplicate(); + } + + // Now is time to clear prev backup config space. We have no more use for it. + prevConfig.clear(tr); } - if (logUidCurrent.isValid()) { - logUid = logUidCurrent; - logUidValue = BinaryWriter::toValue(logUid, Unversioned()); - } + state BackupConfig config(g_random->randomUniqueID()); + state UID uid = config.getUid(); // This check will ensure that current backupUid is later than the last backup Uid - state Standalone backupUid = BackupAgentBase::getCurrentTime(); + state Standalone nowStr = BackupAgentBase::getCurrentTime(); state std::string backupContainer = outContainer.toString(); // To be consistent with directory handling behavior since FDB backup was first released, if the container string // describes a local directory then "/backup-UID" will be added to it. if(backupContainer.find("file://") == 0) { - if(backupContainer[backupContainer.size() - 1] != '/') - backupContainer += "/"; - backupContainer += std::string("backup-") + backupUid.toString(); + backupContainer = joinPath(backupContainer, std::string("backup-") + nowStr.toString()); } Reference bc = IBackupContainer::openContainer(backupContainer); try { Void _ = wait(timeoutError(bc->create(), 30)); } catch(Error &e) { - fprintf(stderr, "ERROR: Could not create backup container: %s\n", e.what()); + fprintf(stderr, "ERROR: Could not create backup container: %s\n", e.what()); throw backup_error(); } - Optional uidOld = wait(tr->get(backupAgent->config.pack(FileBackupAgent::keyLastUid))); + Optional lastBackupTimestamp = wait(backupAgent->lastBackupTimestamp().get(tr)); - if ((uidOld.present()) && (uidOld.get() >= backupUid)) { - fprintf(stderr, "ERROR: The last backup `%s' happened in the future.\n", printable(uidOld.get()).c_str()); + if ((lastBackupTimestamp.present()) && (lastBackupTimestamp.get() >= nowStr)) { + fprintf(stderr, "ERROR: The last backup `%s' happened in the future.\n", printable(lastBackupTimestamp.get()).c_str()); throw backup_error(); } @@ -3390,39 +3291,29 @@ public: } backupRangeSet.coalesce(allKeys); - backupRanges = Standalone>(); + state std::vector normalizedRanges; for (auto& backupRange : backupRangeSet.ranges()) { if (backupRange.value()) { - backupRanges.push_back_deep(backupRanges.arena(), backupRange.range()); + normalizedRanges.push_back(KeyRange(KeyRangeRef(backupRange.range().begin, backupRange.range().end))); } } - // Clear the backup ranges for the tag - tr->clear(backupAgent->config.get(logUid.toString()).range()); - tr->clear(backupAgent->states.get(logUid.toString()).range()); - tr->clear(backupAgent->errors.range()); - BackupConfig(logUid).clear(tr); + config.clear(tr); - tr->set(backupAgent->tagNames.pack(tagName), logUidValue); - tr->set(backupAgent->config.pack(FileBackupAgent::keyLastUid), backupUid); + // Point the tag to this new uid + tag.set(tr, {uid, false}); + + backupAgent->lastBackupTimestamp().set(tr, nowStr); // Set the backup keys - tr->set(backupAgent->config.get(logUid.toString()).pack(FileBackupAgent::keyBackupContainer), backupContainer); - tr->set(backupAgent->config.get(logUid.toString()).pack(FileBackupAgent::keyConfigBackupTag), tagName); - tr->set(backupAgent->config.get(logUid.toString()).pack(FileBackupAgent::keyConfigLogUid), logUidValue); - tr->set(backupAgent->config.get(logUid.toString()).pack(FileBackupAgent::keyFolderId), backupUid); - tr->set(backupAgent->config.get(logUid.toString()).pack(FileBackupAgent::keyConfigBackupRanges), BinaryWriter::toValue(backupRanges, IncludeVersion())); - tr->set(backupAgent->states.get(logUid.toString()).pack(FileBackupAgent::keyStateStatus), StringRef(BackupAgentBase::getStateText(BackupAgentBase::STATE_SUBMITTED))); - if (stopWhenDone) { - tr->set(backupAgent->config.get(logUid.toString()).pack(FileBackupAgent::keyConfigStopWhenDoneKey), StringRef()); - } + config.tag().set(tr, tagName); + config.stateEnum().set(tr, EBackupState::STATE_SUBMITTED); + config.backupContainer().set(tr, backupContainer); + config.stopWhenDone().set(tr, stopWhenDone); + config.backupRanges().set(tr, normalizedRanges); - Key taskKey = wait(fileBackup::StartFullBackupTaskFunc::addTask(tr, backupAgent->taskBucket, backupAgent->config.get(logUid.toString()).pack(FileBackupAgent::keyFolderId), - backupUid, backupAgent->states.get(logUid.toString()).pack(FileBackupAgent::keyStateStatus), - backupAgent->states.get(logUid.toString()).pack(FileBackupAgent::keyStateStop), - StringRef(backupContainer), logUidValue, tagName, BinaryWriter::toValue(backupRanges, IncludeVersion()), - backupAgent->config.get(logUid.toString()).pack(FileBackupAgent::keyConfigStopWhenDoneKey), backupAgent->errors.pack(logUid.toString()), TaskCompletionKey::noSignal())); + Key taskKey = wait(fileBackup::StartFullBackupTaskFunc::addTask(tr, backupAgent->taskBucket, uid, TaskCompletionKey::noSignal())); return Void(); } @@ -3434,7 +3325,7 @@ public: tr->setOption(FDBTransactionOptions::LOCK_AWARE); // Get old restore config for this tag - state RestoreTag tag(tagName); + state KeyBackedTag tag = makeRestoreTag(tagName.toString()); state Optional oldUidAndAborted = wait(tag.get(tr)); if(oldUidAndAborted.present()) { if (oldUidAndAborted.get().first == uid) { @@ -3472,7 +3363,7 @@ public: tag.set(tr, {uid, false}); // Configure the new restore - restore.tag().set(tr, tagName); + restore.tag().set(tr, tagName.toString()); restore.sourceURL().set(tr, backupURL); restore.stateEnum().set(tr, ERestoreState::QUEUED); restore.restoreVersion().set(tr, restoreVersion); @@ -3499,7 +3390,7 @@ public: tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); tr->setOption(FDBTransactionOptions::LOCK_AWARE); - state RestoreTag tag(tagName); + state KeyBackedTag tag = makeRestoreTag(tagName.toString()); Optional current = wait(tag.get(tr)); if(!current.present()) { if(verbose) @@ -3540,53 +3431,64 @@ public: ACTOR static Future discontinueBackup(FileBackupAgent* backupAgent, Reference tr, Key tagName) { tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); tr->setOption(FDBTransactionOptions::LOCK_AWARE); - state UID logUid = wait(backupAgent->getLogUid(tr, tagName)); - state int status = wait(backupAgent->getStateValue(tr, logUid)); - if (!FileBackupAgent::isRunnable((BackupAgentBase::enumState)status)) { - Optional status = wait(tr->get(backupAgent->states.get(logUid.toString()).pack(FileBackupAgent::keyStateStatus))); + state KeyBackedTag tag = makeBackupTag(tagName.toString()); + state UidAndAbortedFlagT current = wait(tag.getOrThrow(tr, false, backup_unneeded())); + state BackupConfig config(current.first); + state EBackupState status = wait(config.stateEnum().getD(tr, EBackupState::STATE_NEVERRAN)); + + if (!FileBackupAgent::isRunnable(status)) { throw backup_unneeded(); } - state Optional stopWhenDoneValue = wait(tr->get(backupAgent->config.get(logUid.toString()).pack(FileBackupAgent::keyConfigStopWhenDoneKey))); + TraceEvent(SevInfo, "FBA_discontinueBackup") + .detail("tagName", tag.tagName.c_str()) + .detail("status", BackupAgentBase::getStateText(status)); - if (stopWhenDoneValue.present()) { + state bool stopWhenDone = wait(config.stopWhenDone().getOrThrow(tr)); + + if (stopWhenDone) { throw backup_duplicate(); } - tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); - tr->set(backupAgent->config.get(logUid.toString()).pack(BackupAgentBase::keyConfigStopWhenDoneKey), StringRef()); + config.stopWhenDone().set(tr, true); return Void(); } - ACTOR static Future abortBackup(FileBackupAgent* backupAgent, Reference tr, Key tagName) { + ACTOR static Future abortBackup(FileBackupAgent* backupAgent, Reference tr, std::string tagName) { tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); tr->setOption(FDBTransactionOptions::LOCK_AWARE); - state UID logUid = wait(backupAgent->getLogUid(tr, tagName)); - int status = wait(backupAgent->getStateValue(tr, logUid)); + + state KeyBackedTag tag = makeBackupTag(tagName); + state UidAndAbortedFlagT current = wait(tag.getOrThrow(tr, false, backup_unneeded())); + + state BackupConfig config(current.first); + EBackupState status = wait(config.stateEnum().getD(tr, EBackupState::STATE_NEVERRAN)); if (!backupAgent->isRunnable((BackupAgentBase::enumState)status)) { throw backup_unneeded(); } - // Clear the folder id will prevent future tasks from executing - tr->clear(singleKeyRange(StringRef(backupAgent->config.get(logUid.toString()).pack(FileBackupAgent::keyFolderId)))); + TraceEvent(SevInfo, "FBA_abortBackup") + .detail("tagName", tagName.c_str()) + .detail("status", BackupAgentBase::getStateText(status)); - Key configPath = uidPrefixKey(logRangesRange.begin, logUid); - Key logsPath = uidPrefixKey(backupLogKeys.begin, logUid); + // Cancel backup task through tag + Void _ = wait(tag.cancel(tr)); + + Key configPath = uidPrefixKey(logRangesRange.begin, config.getUid()); + Key logsPath = uidPrefixKey(backupLogKeys.begin, config.getUid()); tr->clear(KeyRangeRef(configPath, strinc(configPath))); tr->clear(KeyRangeRef(logsPath, strinc(logsPath))); - BackupConfig(logUid).clear(tr); - Key statusKey = StringRef(backupAgent->states.get(logUid.toString()).pack(FileBackupAgent::keyStateStatus)); - tr->set(statusKey, StringRef(FileBackupAgent::getStateText(BackupAgentBase::STATE_ABORTED))); + config.stateEnum().set(tr, EBackupState::STATE_ABORTED); return Void(); } - ACTOR static Future getStatus(FileBackupAgent* backupAgent, Database cx, int errorLimit, Key tagName) { + ACTOR static Future getStatus(FileBackupAgent* backupAgent, Database cx, int errorLimit, std::string tagName) { state Reference tr(new ReadYourWritesTransaction(cx)); state std::string statusText; @@ -3595,79 +3497,60 @@ public: tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); tr->setOption(FDBTransactionOptions::LOCK_AWARE); - state BackupAgentBase::enumState backupState; + state KeyBackedTag tag; + state BackupConfig config; + state EBackupState backupState; + statusText = ""; - - state UID logUid = wait(backupAgent->getLogUid(tr, tagName)); - - state Optional status = wait(tr->get(backupAgent->states.get(logUid.toString()).pack(FileBackupAgent::keyStateStatus))); - - state std::string backupStatus = status.present() ? status.get().toString() : ""; - backupState = BackupAgentBase::getState(backupStatus); - - if (backupState == FileBackupAgent::STATE_NEVERRAN) { - statusText += "No previous backups found.\n"; + tag = makeBackupTag(tagName); + state Optional uidAndAbortedFlag = wait(tag.get(tr)); + state Future> fDisabled = tr->get(backupAgent->taskBucket->getDisableKey()); + if (uidAndAbortedFlag.present()) { + config = BackupConfig(uidAndAbortedFlag.get().first); + EBackupState status = wait(config.stateEnum().getD(tr, EBackupState::STATE_NEVERRAN)); + backupState = status; } - else { - state std::string outContainer = wait(backupAgent->getLastBackupContainer(tr, logUid)); - state std::string tagNameDisplay; - Optional tagName = wait(tr->get(backupAgent->config.get(logUid.toString()).pack(BackupAgentBase::keyConfigBackupTag))); - - // Define the display tag name - if (tagName.present()) { - tagNameDisplay = tagName.get().toString(); - } - - state Optional uid = wait(tr->get(backupAgent->config.get(logUid.toString()).pack(BackupAgentBase::keyFolderId))); - state Optional stopVersionKey = wait(tr->get(backupAgent->states.get(logUid.toString()).pack(BackupAgentBase::keyStateStop))); - - state Standalone> backupRanges; - Optional backupKeysPacked = wait(tr->get(backupAgent->config.get(logUid.toString()).pack(BackupAgentBase::keyConfigBackupRanges))); - - if (backupKeysPacked.present()) { - BinaryReader br(backupKeysPacked.get(), IncludeVersion()); - br >> backupRanges; - } + if (!uidAndAbortedFlag.present() || backupState == EBackupState::STATE_NEVERRAN) { + statusText += "No previous backups found.\n"; + } else { + state std::string backupStatus(BackupAgentBase::getStateText(backupState)); + state std::string outContainer = wait(config.backupContainer().getOrThrow(tr)); + state Version stopVersion = wait(config.stopVersion().getD(tr, -1)); switch (backupState) { case BackupAgentBase::STATE_SUBMITTED: - statusText += "The backup on tag `" + tagNameDisplay + "' is in progress (just started) to " + outContainer + ".\n"; + statusText += "The backup on tag `" + tagName + "' is in progress (just started) to " + outContainer + ".\n"; break; case BackupAgentBase::STATE_BACKUP: - statusText += "The backup on tag `" + tagNameDisplay + "' is in progress to " + outContainer + ".\n"; + statusText += "The backup on tag `" + tagName + "' is in progress to " + outContainer + ".\n"; break; case BackupAgentBase::STATE_DIFFERENTIAL: - statusText += "The backup on tag `" + tagNameDisplay + "' is restorable but continuing to " + outContainer + ".\n"; + statusText += "The backup on tag `" + tagName + "' is restorable but continuing to " + outContainer + ".\n"; break; case BackupAgentBase::STATE_COMPLETED: - { - Version stopVersion = stopVersionKey.present() ? BinaryReader::fromStringRef(stopVersionKey.get(), Unversioned()) : -1; - statusText += "The previous backup on tag `" + tagNameDisplay + "' at " + outContainer + " completed at version " + format("%lld", stopVersion) + ".\n"; - } + statusText += "The previous backup on tag `" + tagName + "' at " + outContainer + " completed at version " + format("%lld", stopVersion) + ".\n"; break; default: - statusText += "The previous backup on tag `" + tagNameDisplay + "' at " + outContainer + " " + backupStatus + ".\n"; + statusText += "The previous backup on tag `" + tagName + "' at " + outContainer + " " + backupStatus + ".\n"; break; } } // Append the errors, if requested - if (errorLimit > 0) { - Standalone values = wait(tr->getRange(backupAgent->errors.get(BinaryWriter::toValue(logUid, Unversioned())).range(), errorLimit, false, true)); - - // Display the errors, if any - if (values.size() > 0) { - // Inform the user that the list of errors is complete or partial - statusText += (values.size() < errorLimit) - ? "WARNING: Some backup agents have reported issues:\n" - : "WARNING: Some backup agents have reported issues (printing " + std::to_string(errorLimit) + "):\n"; - - for (auto &s : values) { - statusText += " " + printable(s.value) + "\n"; - } + if (errorLimit > 0 && config.getUid().isValid()) { + Optional> errMsg = wait(config.lastError().get(tr)); + if (errMsg.present()) { + statusText += "WARNING: Some backup agents have reported issues:\n"; + statusText += format("[%lld]: %s\n", errMsg.get().second, errMsg.get().first.c_str()); } } + + Optional disabled = wait(fDisabled); + if(disabled.present()) { + statusText += format("\nAll backup agents have been disabled.\n"); + } + break; } catch (Error &e) { @@ -3678,30 +3561,6 @@ public: return statusText; } - ACTOR static Future getStateValue(FileBackupAgent* backupAgent, Reference tr, UID logUid) { - tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); - tr->setOption(FDBTransactionOptions::LOCK_AWARE); - state Key statusKey = backupAgent->states.get(logUid.toString()).pack(FileBackupAgent::keyStateStatus); - Optional status = wait(tr->get(statusKey)); - - return (!status.present()) ? FileBackupAgent::STATE_NEVERRAN : BackupAgentBase::getState(status.get().toString()); - } - - ACTOR static Future getStateStopVersion(FileBackupAgent* backupAgent, Reference tr, UID logUid) { - tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); - tr->setOption(FDBTransactionOptions::LOCK_AWARE); - state Optional stopVersion = wait(tr->get(backupAgent->states.get(logUid.toString()).pack(BackupAgentBase::keyStateStop))); - return stopVersion.present() ? BinaryReader::fromStringRef(stopVersion.get(), Unversioned()) : -1; - } - - ACTOR static Future getLogUid(FileBackupAgent* backupAgent, Reference tr, Key tagName) { - tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); - tr->setOption(FDBTransactionOptions::LOCK_AWARE); - state Optional logUid = wait(tr->get(backupAgent->tagNames.pack(tagName))); - - return (logUid.present()) ? BinaryReader::fromStringRef(logUid.get(), Unversioned()) : UID(); - } - ACTOR static Future getLastRestorable(FileBackupAgent* backupAgent, Reference tr, Key tagName) { tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); tr->setOption(FDBTransactionOptions::LOCK_AWARE); @@ -3810,16 +3669,17 @@ public: //the tagname of the backup must be the same as the restore. ACTOR static Future atomicRestore(FileBackupAgent* backupAgent, Database cx, Key tagName, KeyRange range, Key addPrefix, Key removePrefix) { state Reference ryw_tr = Reference(new ReadYourWritesTransaction(cx)); - state UID logUid; + state BackupConfig backupConfig; loop { try { ryw_tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); ryw_tr->setOption(FDBTransactionOptions::LOCK_AWARE); - UID _logUid = wait(backupAgent->getLogUid(ryw_tr, tagName)); - logUid = _logUid; - state int status = wait(backupAgent->getStateValue(ryw_tr, logUid)); + state KeyBackedTag tag = makeBackupTag(tagName.toString()); + UidAndAbortedFlagT uidFlag = wait(tag.getOrThrow(ryw_tr)); + backupConfig = BackupConfig(uidFlag.first); + state EBackupState status = wait(backupConfig.stateEnum().getOrThrow(ryw_tr)); - if ( (BackupAgentBase::enumState)status != BackupAgentBase::STATE_DIFFERENTIAL ) { + if (status != BackupAgentBase::STATE_DIFFERENTIAL ) { throw backup_duplicate(); } @@ -3858,7 +3718,7 @@ public: } } - int _ = wait( waitBackup(backupAgent, cx, tagName, true) ); + int _ = wait( waitBackup(backupAgent, cx, tagName.toString(), true) ); ryw_tr->reset(); loop { @@ -3874,14 +3734,14 @@ public: } } - std::string lastBackupContainer = wait(backupAgent->getLastBackupContainer(cx, logUid)); - + std::string lastBackupContainer = wait(backupConfig.backupContainer().getOrThrow(cx)); + Version ver = wait( restore(backupAgent, cx, tagName, KeyRef(lastBackupContainer), true, -1, true, range, addPrefix, removePrefix, true, randomUid) ); return ver; } }; -const KeyRef BackupAgentBase::defaultTag = LiteralStringRef("default"); +const std::string BackupAgentBase::defaultTagName = "default"; const int BackupAgentBase::logHeaderSize = 12; const int FileBackupAgent::dataFooterSize = 20; @@ -3905,7 +3765,7 @@ Future FileBackupAgent::waitRestore(Database cx, Key tagName, boo return FileBackupAgentImpl::waitRestore(cx, tagName, verbose); }; -Future FileBackupAgent::submitBackup(Reference tr, Key outContainer, Key tagName, Standalone> backupRanges, bool stopWhenDone) { +Future FileBackupAgent::submitBackup(Reference tr, Key outContainer, std::string tagName, Standalone> backupRanges, bool stopWhenDone) { return FileBackupAgentImpl::submitBackup(this, tr, outContainer, tagName, backupRanges, stopWhenDone); } @@ -3913,39 +3773,19 @@ Future FileBackupAgent::discontinueBackup(Reference FileBackupAgent::abortBackup(Reference tr, Key tagName){ +Future FileBackupAgent::abortBackup(Reference tr, std::string tagName){ return FileBackupAgentImpl::abortBackup(this, tr, tagName); } -Future FileBackupAgent::getStatus(Database cx, int errorLimit, Key tagName) { +Future FileBackupAgent::getStatus(Database cx, int errorLimit, std::string tagName) { return FileBackupAgentImpl::getStatus(this, cx, errorLimit, tagName); } -Future FileBackupAgent::getStateValue(Reference tr, UID logUid) { - return FileBackupAgentImpl::getStateValue(this, tr, logUid); -} - -Future FileBackupAgent::getRangeBytesWritten(Reference tr, UID logUid) { - return BackupConfig(logUid).rangeBytesWritten().getD(tr); -} - -Future FileBackupAgent::getLogBytesWritten(Reference tr, UID logUid) { - return BackupConfig(logUid).logBytesWritten().getD(tr); -} - -Future FileBackupAgent::getStateStopVersion(Reference tr, UID logUid) { - return FileBackupAgentImpl::getStateStopVersion(this, tr, logUid); -} - -Future FileBackupAgent::getLogUid(Reference tr, Key tagName) { - return FileBackupAgentImpl::getLogUid(this, tr, tagName); -} - Future FileBackupAgent::getLastRestorable(Reference tr, Key tagName) { return FileBackupAgentImpl::getLastRestorable(this, tr, tagName); } -Future FileBackupAgent::waitBackup(Database cx, Key tagName, bool stopWhenDone) { +Future FileBackupAgent::waitBackup(Database cx, std::string tagName, bool stopWhenDone) { return FileBackupAgentImpl::waitBackup(this, cx, tagName, stopWhenDone); } @@ -3964,7 +3804,3 @@ std::string FileBackupAgent::getLogFilename(Version beginVer, Version endVer, in Future FileBackupAgent::getBackupInfo(std::string container, Version* defaultVersion) { return FileBackupAgentImpl::getBackupInfo(IBackupContainer::openContainer(container), defaultVersion); } - -Future FileBackupAgent::getLastBackupContainer(Reference tr, UID logUid) { - return fileBackup::getPath(tr, config.get(logUid.toString()).pack(FileBackupAgent::keyBackupContainer)); -} diff --git a/fdbclient/KeyBackedTypes.h b/fdbclient/KeyBackedTypes.h index 8b77753d87..b91b181c10 100644 --- a/fdbclient/KeyBackedTypes.h +++ b/fdbclient/KeyBackedTypes.h @@ -59,6 +59,10 @@ template<> inline Standalone Codec>::unpack(Tup template<> inline Tuple Codec::pack(UID const &val) { return Codec>::pack(BinaryWriter::toValue(val, Unversioned())); } template<> inline UID Codec::unpack(Tuple const &val) { return BinaryReader::fromStringRef(Codec>::unpack(val), Unversioned()); } +// This is backward compatible with Codec> +template<> inline Tuple Codec::pack(std::string const &val) { return Tuple().append(StringRef(val)); } +template<> inline std::string Codec::unpack(Tuple const &val) { return val.getString(0).toString(); } + // Partial specialization to cover all std::pairs as long as the component types are Codec compatible template struct Codec> { @@ -69,6 +73,30 @@ struct Codec> { } }; +template +struct Codec> { + static Tuple pack(typename std::vector const &val) { + Tuple t; + for (T item : val) { + Tuple itemTuple = Codec::pack(item); + // fdbclient doesn't support nested tuples yet. For now, flatten the tuple into StringRef + t.append(itemTuple.pack()); + } + return t; + } + + static std::vector unpack(Tuple const &t) { + std::vector v; + + for (int i = 0; i < t.size(); i++) { + Tuple itemTuple = Tuple::unpack(t.getString(i)); + v.push_back(Codec::unpack(itemTuple)); + } + + return v; + } +}; + template<> inline Tuple Codec::pack(KeyRange const &val) { return Tuple().append(val.begin).append(val.end); } template<> inline KeyRange Codec::unpack(Tuple const &val) { return KeyRangeRef(val.getString(0), val.getString(1)); } @@ -87,11 +115,61 @@ public: } // Get property's value or defaultValue if it doesn't exist Future getD(Reference tr, bool snapshot = false, T defaultValue = T()) const { - return map(get(tr, false), [=](Optional val) -> T { return val.present() ? val.get() : defaultValue; }); + return map(get(tr, snapshot), [=](Optional val) -> T { return val.present() ? val.get() : defaultValue; }); } + // Get property's value or throw error if it doesn't exist + Future getOrThrow(Reference tr, bool snapshot = false, Error err = key_not_found()) const { + auto keyCopy = key; + auto backtrace = platform::get_backtrace(); + return map(get(tr, snapshot), [=](Optional val) -> T { + if (!val.present()) { + TraceEvent(SevInfo, "KeyBackedProperty_keyNotFound") + .detail("key", printable(keyCopy)) + .detail("err", err.code()) + .detail("parentTrace", backtrace.c_str()); + throw err; + } + + return val.get(); + }); + } + + Future> get(Database cx, bool snapshot = false) const { + auto © = *this; + return runRYWTransaction(cx, [=](Reference tr) { + tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); + tr->setOption(FDBTransactionOptions::LOCK_AWARE); + + return copy.get(tr, snapshot); + }); + } + + Future getOrThrow(Database cx, bool snapshot = false, Error err = key_not_found()) const { + auto © = *this; + return runRYWTransaction(cx, [=](Reference tr) { + tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); + tr->setOption(FDBTransactionOptions::LOCK_AWARE); + + return copy.getOrThrow(tr, snapshot, err); + }); + } + void set(Reference tr, T const &val) { return tr->set(key, Codec::pack(val).pack()); } + + Future set(Database cx, T const &val) { + auto _key = key; + Value _val = Codec::pack(val).pack(); + return runRYWTransaction(cx, [_key, _val](Reference tr) { + tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); + tr->setOption(FDBTransactionOptions::LOCK_AWARE); + tr->set(_key, _val); + + return Future(Void()); + }); + } + void clear(Reference tr) { return tr->clear(key); } diff --git a/fdbclient/Knobs.cpp b/fdbclient/Knobs.cpp index 8318c4137a..fae9f328c9 100644 --- a/fdbclient/Knobs.cpp +++ b/fdbclient/Knobs.cpp @@ -111,7 +111,7 @@ ClientKnobs::ClientKnobs(bool randomize) { init( BACKUP_MAP_KEY_UPPER_LIMIT, 1e5 ); if( buggifyMapLimits ) BACKUP_MAP_KEY_UPPER_LIMIT = 30; init( BACKUP_COPY_TASKS, 90 ); init( BACKUP_BLOCK_SIZE, LOG_RANGE_BLOCK_SIZE/10 ); - init( BACKUP_TASKS_PER_AGENT, 80 ); + init( BACKUP_TASKS_PER_AGENT, 20 ); init( SIM_BACKUP_TASKS_PER_AGENT, 10 ); init( BACKUP_RANGEFILE_BLOCK_SIZE, 1024 * 1024); init( BACKUP_LOGFILE_BLOCK_SIZE, 1024 * 1024); @@ -137,13 +137,14 @@ ClientKnobs::ClientKnobs(bool randomize) { init( HTTP_READ_SIZE, 128*1024 ); init( HTTP_SEND_SIZE, 32*1024 ); init( HTTP_VERBOSE_LEVEL, 0 ); - init( BLOBSTORE_CONNECT_TRIES, 3 ); + init( BLOBSTORE_CONNECT_TRIES, 10 ); init( BLOBSTORE_CONNECT_TIMEOUT, 10 ); init( BLOBSTORE_REQUEST_TRIES, 10 ); - init( BLOBSTORE_REQUEST_TIMEOUT, 15 ); + init( BLOBSTORE_REQUEST_TIMEOUT, 30 ); - init( BLOBSTORE_CONCURRENT_UPLOADS, BACKUP_TASKS_PER_AGENT * 15 ); + init( BLOBSTORE_CONCURRENT_UPLOADS, BACKUP_TASKS_PER_AGENT*2 ); + init( BLOBSTORE_CONCURRENT_WRITES_PER_FILE, 5 ); init( BLOBSTORE_CONCURRENT_READS_PER_FILE, 3 ); init( BLOBSTORE_READ_BLOCK_SIZE, 1024 * 1024 ); init( BLOBSTORE_READ_AHEAD_BLOCKS, 0 ); @@ -153,8 +154,8 @@ ClientKnobs::ClientKnobs(bool randomize) { init( BLOBSTORE_BACKUP_BUCKETS, 100 ); // These are basically unlimited by default but can be used to reduce blob IO if needed - init( BLOBSTORE_REQUESTS_PER_SECOND, 20000); - init( BLOBSTORE_CONCURRENT_REQUESTS, 2000); + init( BLOBSTORE_REQUESTS_PER_SECOND, 200 ); + init( BLOBSTORE_CONCURRENT_REQUESTS, (BACKUP_TASKS_PER_AGENT*2)+5 ); init( BLOBSTORE_MAX_SEND_BYTES_PER_SECOND, 1e9 ); init( BLOBSTORE_MAX_RECV_BYTES_PER_SECOND, 1e9 ); diff --git a/fdbclient/Knobs.h b/fdbclient/Knobs.h index 5af4d4525b..71fcb34b34 100644 --- a/fdbclient/Knobs.h +++ b/fdbclient/Knobs.h @@ -150,6 +150,7 @@ public: int BLOBSTORE_MULTIPART_MAX_PART_SIZE; int BLOBSTORE_MULTIPART_MIN_PART_SIZE; int BLOBSTORE_CONCURRENT_UPLOADS; + int BLOBSTORE_CONCURRENT_WRITES_PER_FILE; int BLOBSTORE_CONCURRENT_READS_PER_FILE; int BLOBSTORE_READ_BLOCK_SIZE; int BLOBSTORE_READ_AHEAD_BLOCKS; diff --git a/fdbclient/ManagementAPI.actor.cpp b/fdbclient/ManagementAPI.actor.cpp index 892cac8368..73026bcfd1 100644 --- a/fdbclient/ManagementAPI.actor.cpp +++ b/fdbclient/ManagementAPI.actor.cpp @@ -250,7 +250,7 @@ ACTOR Future changeConfig( Database cx, std::map waitForExcludedServers( Database cx, vector } } +ACTOR Future timeKeeperSetDisable(Database cx) { + loop { + state Transaction tr(cx); + try { + tr.setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); + tr.setOption(FDBTransactionOptions::LOCK_AWARE); + tr.set(timeKeeperDisableKey, StringRef()); + Void _ = wait(tr.commit()); + return Void(); + } catch (Error &e) { + Void _ = wait(tr.onError(e)); + } + } +} + ACTOR Future lockDatabase( Transaction* tr, UID id ) { tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); tr->setOption(FDBTransactionOptions::LOCK_AWARE); diff --git a/fdbclient/ManagementAPI.h b/fdbclient/ManagementAPI.h index 590ddd8c1a..d529918c1b 100644 --- a/fdbclient/ManagementAPI.h +++ b/fdbclient/ManagementAPI.h @@ -142,6 +142,8 @@ Future waitForExcludedServers( Database const& cx, vector> getWorkers( Database const& cx ); Future> getWorkers( Transaction* const& tr ); +Future timeKeeperSetDisable(Database const& cx); + Future lockDatabase( Transaction* const& tr, UID const& id ); Future lockDatabase( Reference const& tr, UID const& id ); Future lockDatabase( Database const& cx, UID const& id ); diff --git a/fdbclient/MultiVersionTransaction.actor.cpp b/fdbclient/MultiVersionTransaction.actor.cpp index daad55dd77..6103e22003 100644 --- a/fdbclient/MultiVersionTransaction.actor.cpp +++ b/fdbclient/MultiVersionTransaction.actor.cpp @@ -1134,12 +1134,25 @@ void MultiVersionApi::setupNetwork() { THREAD_FUNC_RETURN runNetworkThread(void *param) { try { - ((IClientApi*)param)->runNetwork(); + ((ClientInfo*)param)->api->runNetwork(); } catch(Error &e) { TraceEvent(SevError, "RunNetworkError").error(e); } + std::vector> &hooks = ((ClientInfo*)param)->threadCompletionHooks; + for(auto &hook : hooks) { + try { + hook.first(hook.second); + } + catch(Error &e) { + TraceEvent(SevError, "NetworkShutdownHookError").error(e); + } + catch(...) { + TraceEvent(SevError, "NetworkShutdownHookError").error(unknown_error()); + } + } + THREAD_RETURN; } @@ -1156,12 +1169,34 @@ void MultiVersionApi::runNetwork() { if(!bypassMultiClientApi) { runOnExternalClients([&handles](Reference client) { if(client->external) { - handles.push_back(g_network->startThread(&runNetworkThread, client->api)); + handles.push_back(g_network->startThread(&runNetworkThread, client.getPtr())); } }); } - localClient->api->runNetwork(); + Error *runErr = NULL; + try { + localClient->api->runNetwork(); + } + catch(Error &e) { + runErr = &e; + } + + for(auto &hook : localClient->threadCompletionHooks) { + try { + hook.first(hook.second); + } + catch(Error &e) { + TraceEvent(SevError, "NetworkShutdownHookError").error(e); + } + catch(...) { + TraceEvent(SevError, "NetworkShutdownHookError").error(unknown_error()); + } + } + + if(runErr != NULL) { + throw *runErr; + } for(auto h : handles) { waitThread(h); @@ -1185,6 +1220,24 @@ void MultiVersionApi::stopNetwork() { } } +void MultiVersionApi::addNetworkThreadCompletionHook(void (*hook)(void*), void *hook_parameter) { + lock.enter(); + if(!networkSetup) { + lock.leave(); + throw network_not_setup(); + } + lock.leave(); + + auto hookPair = std::pair(hook, hook_parameter); + threadCompletionHooks.push_back(hookPair); + + if(!bypassMultiClientApi) { + for( auto it : externalClients ) { + it.second->threadCompletionHooks.push_back(hookPair); + } + } +} + ThreadFuture> MultiVersionApi::createCluster(const char *clusterFilePath) { lock.enter(); if(!networkSetup) { @@ -1470,7 +1523,7 @@ THREAD_FUNC setAbort(void *arg) { ((ThreadSingleAssignmentVar*)arg)->delref(); } catch(Error &e) { - printf("Caught error in setAbort: %s\n", e.what()); + printf("Caught error in setAbort: %s\n", e.name()); ASSERT(false); } THREAD_RETURN; @@ -1489,7 +1542,7 @@ THREAD_FUNC releaseMem(void *arg) { ((ThreadSingleAssignmentVar*)arg)->releaseMemory(); } catch(Error &e) { - printf("Caught error in releaseMem: %s\n", e.what()); + printf("Caught error in releaseMem: %s\n", e.name()); ASSERT(false); } THREAD_RETURN; @@ -1501,7 +1554,7 @@ THREAD_FUNC destroy(void *arg) { ((ThreadSingleAssignmentVar*)arg)->cancel(); } catch(Error &e) { - printf("Caught error in destroy: %s\n", e.what()); + printf("Caught error in destroy: %s\n", e.name()); ASSERT(false); } THREAD_RETURN; @@ -1514,7 +1567,7 @@ THREAD_FUNC cancel(void *arg) { destroy(arg); } catch(Error &e) { - printf("Caught error in cancel: %s\n", e.what()); + printf("Caught error in cancel: %s\n", e.name()); ASSERT(false); } THREAD_RETURN; @@ -1608,7 +1661,7 @@ THREAD_FUNC runSingleAssignmentVarTest(void *arg) { }, NULL); } catch(Error &e) { - printf("Caught error in test: %s\n", e.what()); + printf("Caught error in test: %s\n", e.name()); *done = true; ASSERT(false); } diff --git a/fdbclient/MultiVersionTransaction.h b/fdbclient/MultiVersionTransaction.h index 7ca1379189..a8ba31b387 100644 --- a/fdbclient/MultiVersionTransaction.h +++ b/fdbclient/MultiVersionTransaction.h @@ -320,6 +320,7 @@ struct ClientInfo : ThreadSafeReferenceCounted { std::string libPath; bool external; bool failed; + std::vector> threadCompletionHooks; ClientInfo() : protocolVersion(0), api(NULL), external(false), failed(true) {} ClientInfo(IClientApi *api) : protocolVersion(0), api(api), libPath("internal"), external(false), failed(false) {} @@ -402,6 +403,7 @@ public: void setupNetwork(); void runNetwork(); void stopNetwork(); + void addNetworkThreadCompletionHook(void (*hook)(void*), void *hook_parameter); ThreadFuture> createCluster(const char *clusterFilePath); static MultiVersionApi* api; @@ -441,7 +443,8 @@ private: std::vector>>> options; std::map>> setEnvOptions; volatile bool envOptionsLoaded; + std::vector> threadCompletionHooks; }; -#endif \ No newline at end of file +#endif diff --git a/fdbclient/NativeAPI.actor.cpp b/fdbclient/NativeAPI.actor.cpp index 15c121e2e0..03b0f960c3 100644 --- a/fdbclient/NativeAPI.actor.cpp +++ b/fdbclient/NativeAPI.actor.cpp @@ -1370,7 +1370,7 @@ ACTOR Future> getValue( Future version, Key key, Databa .detail("ReplySize", reply.value.present() ? reply.value.get().size() : -1);*/ } if (e.code() == error_code_wrong_shard_server || e.code() == error_code_all_alternatives_failed || - (e.code() == error_code_past_version && ver == latestVersion) ) { + (e.code() == error_code_transaction_too_old && ver == latestVersion) ) { cx->invalidateCache( key ); cx->invalidateCache( ssi.second ); Void _ = wait(delay(CLIENT_KNOBS->WRONG_SHARD_SERVER_DELAY, info.taskID)); @@ -1864,7 +1864,7 @@ ACTOR Future> getRange( Database cx, Future TraceEvent("TransactionDebugError", info.debugID.get()).error(e); } if (e.code() == error_code_wrong_shard_server || e.code() == error_code_all_alternatives_failed || - (e.code() == error_code_past_version && readVersion == latestVersion)) + (e.code() == error_code_transaction_too_old && readVersion == latestVersion)) { cx->invalidateCache( reverse ? end.getKey() : begin.getKey(), reverse ? (end-1).isBackward() : begin.isBackward() ); cx->invalidateCache( beginServer.second ); @@ -2207,6 +2207,12 @@ void Transaction::atomicOp(const KeyRef& key, const ValueRef& operand, MutationR if(operand.size() > CLIENT_KNOBS->VALUE_SIZE_LIMIT) throw value_too_large(); + if (apiVersionAtLeast(510)) { + if (operationType == MutationRef::Min) + operationType = MutationRef::MinV2; + else if (operationType == MutationRef::And) + operationType = MutationRef::AndV2; + } auto &req = tr; auto &t = req.transaction; auto r = singleKeyRange( key, req.arena ); @@ -2422,7 +2428,7 @@ ACTOR void checkWrites( Database cx, Future committed, Promise outCo } TraceEvent("CheckWritesSuccess").detail("Version", version).detail("MutationCount", mCount).detail("CheckedRanges", checkedRanges); } catch( Error& e ) { - bool ok = e.code() == error_code_past_version || e.code() == error_code_future_version; + bool ok = e.code() == error_code_transaction_too_old || e.code() == error_code_future_version; TraceEvent( ok ? SevWarn : SevError, "CheckWritesFailed" ).error(e); throw; } @@ -2555,7 +2561,7 @@ ACTOR static Future tryCommit( Database cx, Reference // The user needs to be informed that we aren't sure whether the commit happened. Standard retry loops retry it anyway (relying on transaction idempotence) but a client might do something else. throw commit_unknown_result(); } else { - if (e.code() != error_code_past_version && e.code() != error_code_not_committed && e.code() != error_code_database_locked) + if (e.code() != error_code_transaction_too_old && e.code() != error_code_not_committed && e.code() != error_code_database_locked) TraceEvent(SevError, "tryCommitError").error(e); if (e.code() != error_code_actor_cancelled && trLogInfo) trLogInfo->addLog(FdbClientLogEvents::EventCommitError(startTime, static_cast(e.code()), req)); @@ -2567,13 +2573,16 @@ ACTOR static Future tryCommit( Database cx, Reference Future Transaction::commitMutations() { cx->transactionsCommitStarted++; + if(options.readOnly) + return transaction_read_only(); + try { //if this is a read-only transaction return immediately if( !tr.transaction.write_conflict_ranges.size() && !tr.transaction.mutations.size() ) { numErrors = 0; committedVersion = invalidVersion; - versionstampPromise.sendError(transaction_read_only()); + versionstampPromise.sendError(no_commit_version()); return Void(); } @@ -2745,6 +2754,15 @@ void Transaction::setOption( FDBTransactionOptions::Option option, Optional Transaction::onError( Error const& e ) { reset(); return delay( backoff, info.taskID ); } - if (e.code() == error_code_past_version || + if (e.code() == error_code_transaction_too_old || e.code() == error_code_future_version) { - if( e.code() == error_code_past_version ) + if( e.code() == error_code_transaction_too_old ) cx->transactionsPastVersions++; else if( e.code() == error_code_future_version ) cx->transactionsFutureVersions++; diff --git a/fdbclient/NativeAPI.h b/fdbclient/NativeAPI.h index fe33950553..4377058dda 100644 --- a/fdbclient/NativeAPI.h +++ b/fdbclient/NativeAPI.h @@ -127,6 +127,9 @@ public: void checkDeferredError() { if (deferred_error.code() != invalid_error_code) throw deferred_error; } private: friend class ThreadSafeCluster; + friend class AtomicOpsApiCorrectnessWorkload; // This is just for testing purposes. It needs to change apiVersion + friend class AtomicOpsWorkload; // This is just for testing purposes. It needs to change apiVersion + Cluster( Reference connFile, int apiVersion = API_VERSION_LATEST ); Reference>> clusterInterface; @@ -145,6 +148,7 @@ struct TransactionOptions { bool causalWriteRisky : 1; bool debugDump : 1; bool lockAware : 1; + bool readOnly : 1; TransactionOptions() { reset(); } void reset() { diff --git a/fdbclient/RYWIterator.cpp b/fdbclient/RYWIterator.cpp index 2cb554fc09..21c7a96d53 100644 --- a/fdbclient/RYWIterator.cpp +++ b/fdbclient/RYWIterator.cpp @@ -55,9 +55,9 @@ KeyValueRef const& RYWIterator::kv( Arena& arena ) { if (writes.is_unmodified_range()) return cache.kv( arena ); else if (writes.is_independent() || cache.is_empty_range()) - return temp = KeyValueRef( writes.beginKey().assertRef(), WriteMap::coalesceUnder( writes.op(), Optional(), arena ).value ); + return temp = KeyValueRef( writes.beginKey().assertRef(), WriteMap::coalesceUnder( writes.op(), Optional(), arena ).value.get() ); else - return temp = KeyValueRef( writes.beginKey().assertRef(), WriteMap::coalesceUnder( writes.op(), cache.kv(arena).value, arena ).value ); + return temp = KeyValueRef( writes.beginKey().assertRef(), WriteMap::coalesceUnder( writes.op(), cache.kv(arena).value, arena ).value.get() ); } RYWIterator& RYWIterator::operator++() { @@ -651,11 +651,11 @@ TEST_CASE("fdbclient/WriteMap/random") { TraceEvent("RWMT_checkOperation") .detail("wm_key", printable(it.beginKey().toStandaloneStringRef())) .detail("wm_size", it.op().size()) - .detail("wm_value", it.op().top().value.size()) + .detail("wm_value", it.op().top().value.present() ? std::to_string(it.op().top().value.get().size()) : "Not Found") .detail("wm_type", (int)it.op().top().type) .detail("sm_key", printable(setIter->first)) .detail("sm_size", setIter->second.size()) - .detail("sm_value", setIter->second.top().value.size()) + .detail("sm_value", setIter->second.top().value.present() ? std::to_string(setIter->second.top().value.get().size()) : "Not Found") .detail("sm_type", (int)setIter->second.top().type); ASSERT(it.beginKey() == setIter->first && it.op() == setIter->second); ++setIter; diff --git a/fdbclient/ReadYourWrites.actor.cpp b/fdbclient/ReadYourWrites.actor.cpp index 9e55c79ce3..6793820e28 100644 --- a/fdbclient/ReadYourWrites.actor.cpp +++ b/fdbclient/ReadYourWrites.actor.cpp @@ -1406,7 +1406,7 @@ void ReadYourWritesTransaction::writeRangeToNativeTransaction( KeyRangeRef const for( int i = 0; i < op.size(); ++i) { switch(op[i].type) { case MutationRef::SetValue: - tr.set( it.beginKey().assertRef(), op[i].value, false ); + tr.set( it.beginKey().assertRef(), op[i].value.get(), false ); break; case MutationRef::AddValue: case MutationRef::AppendIfFits: @@ -1417,7 +1417,11 @@ void ReadYourWritesTransaction::writeRangeToNativeTransaction( KeyRangeRef const case MutationRef::Min: case MutationRef::SetVersionstampedKey: case MutationRef::SetVersionstampedValue: - tr.atomicOp( it.beginKey().assertRef(), op[i].value, op[i].type, false ); + case MutationRef::ByteMin: + case MutationRef::ByteMax: + case MutationRef::MinV2: + case MutationRef::AndV2: + tr.atomicOp( it.beginKey().assertRef(), op[i].value.get(), op[i].type, false ); break; default: break; @@ -1488,6 +1492,13 @@ void ReadYourWritesTransaction::atomicOp( const KeyRef& key, const ValueRef& ope if (operationType == MutationRef::SetVersionstampedValue && operand.size() < 10) throw client_invalid_operation(); + if (tr.apiVersionAtLeast(510)) { + if (operationType == MutationRef::Min) + operationType = MutationRef::MinV2; + else if (operationType == MutationRef::And) + operationType = MutationRef::AndV2; + } + if(options.readYourWritesDisabled) { return tr.atomicOp(key, operand, (MutationRef::Type) operationType, addWriteConflict); } diff --git a/fdbclient/RunTransaction.actor.h b/fdbclient/RunTransaction.actor.h index 0c1a90ba29..251bc91274 100644 --- a/fdbclient/RunTransaction.actor.h +++ b/fdbclient/RunTransaction.actor.h @@ -64,4 +64,12 @@ runRYWTransactionFailIfLocked(Database cx, Function func) { } } +ACTOR template < class Function > +Future()(Reference()).getValue())> +runRYWTransactionNoRetry(Database cx, Function func) { + state Reference tr(new ReadYourWritesTransaction(cx)); + state decltype(fake()(Reference()).getValue()) result = wait(func(tr)); + Void _ = wait(tr->commit()); + return result; +} #endif \ No newline at end of file diff --git a/fdbclient/SystemData.cpp b/fdbclient/SystemData.cpp index 35d25c6364..2f0a2d1275 100644 --- a/fdbclient/SystemData.cpp +++ b/fdbclient/SystemData.cpp @@ -290,6 +290,7 @@ ProcessData decodeWorkerListValue( ValueRef const& value ) { const KeyRef coordinatorsKey = LiteralStringRef("\xff/coordinators"); const KeyRef logsKey = LiteralStringRef("\xff/logs"); +const KeyRef minRequiredCommitVersionKey = LiteralStringRef("\xff/minRequiredCommitVersion"); const KeyRef globalKeysPrefix = LiteralStringRef("\xff/globals"); const KeyRef lastEpochEndKey = LiteralStringRef("\xff/globals/lastEpochEnd"); @@ -305,6 +306,13 @@ const UID dataDistributionModeLock = UID(6345,3425); // Client status info prefix const KeyRangeRef fdbClientInfoPrefixRange(LiteralStringRef("\xff\x02/fdbClientInfo/"), LiteralStringRef("\xff\x02/fdbClientInfo0")); +const KeyRef fdbClientInfoTxnSampleRate = LiteralStringRef("\xff\x02/fdbClientInfo/client_txn_sample_rate/"); +const KeyRef fdbClientInfoTxnSizeLimit = LiteralStringRef("\xff\x02/fdbClientInfo/client_txn_size_limit/"); + +// Keyspace to maintain wall clock to version map +const KeyRangeRef timeKeeperPrefixRange(LiteralStringRef("\xff\x02/timeKeeper/map/"), LiteralStringRef("\xff\x02/timeKeeper/map0")); +const KeyRef timeKeeperVersionKey = LiteralStringRef("\xff\x02/timeKeeper/version"); +const KeyRef timeKeeperDisableKey = LiteralStringRef("\xff\x02/timeKeeper/disable"); // Backup Log Mutation constant variables const KeyRef backupEnabledKey = LiteralStringRef("\xff/backupEnabled"); diff --git a/fdbclient/SystemData.h b/fdbclient/SystemData.h index 22f92fd55d..84d8a64cfd 100644 --- a/fdbclient/SystemData.h +++ b/fdbclient/SystemData.h @@ -117,6 +117,7 @@ ProcessData decodeWorkerListValue( ValueRef const& ); extern const KeyRef coordinatorsKey; extern const KeyRef logsKey; +extern const KeyRef minRequiredCommitVersionKey; const Value logsValue( const vector>& logs, const vector>& oldLogs ); std::pair>,vector>> decodeLogsValue( const ValueRef& value ); @@ -170,8 +171,15 @@ extern const KeyRangeRef applyMutationsRemovePrefixRange; extern const KeyRangeRef applyMutationsKeyVersionMapRange; extern const KeyRangeRef applyMutationsKeyVersionCountRange; -// FdbClient Info prefix +// FdbClient Info prefix extern const KeyRangeRef fdbClientInfoPrefixRange; +extern const KeyRef fdbClientInfoTxnSampleRate; +extern const KeyRef fdbClientInfoTxnSizeLimit; + +// Keyspace to maintain wall clock to version map +extern const KeyRangeRef timeKeeperPrefixRange; +extern const KeyRef timeKeeperVersionKey; +extern const KeyRef timeKeeperDisableKey; // Layer status metadata prefix extern const KeyRangeRef layerStatusMetaPrefixRange; diff --git a/fdbclient/TaskBucket.actor.cpp b/fdbclient/TaskBucket.actor.cpp index e5c6d8dbd0..d56cbe071e 100644 --- a/fdbclient/TaskBucket.actor.cpp +++ b/fdbclient/TaskBucket.actor.cpp @@ -304,7 +304,10 @@ public: } ACTOR static Future doTask(Database cx, Reference taskBucket, Reference futureBucket, Reference task) { - if (task && TaskFuncBase::isValidTask(task)) { + if (!task || !TaskFuncBase::isValidTask(task)) + return false; + + try { state Reference taskFunc = TaskFuncBase::create(task->params[Task::reservedTaskParamKeyType]); if (taskFunc) { state bool verifyTask = (task->params.find(Task::reservedTaskParamValidKey) != task->params.end()); @@ -358,10 +361,8 @@ public: state Reference tr3(new ReadYourWritesTransaction(cx)); taskBucket->setOptions(tr3); Version version = wait(tr3->getReadVersion()); - if(version >= task->timeout) { - TraceEvent(SevWarn, "TB_ExecuteTimedOut").detail("TaskType", printable(task->params[Task::reservedTaskParamKeyType])); - return true; - } + if(version >= task->timeout) + throw timed_out(); // Otherwise reset the timeout timeout = delay((BUGGIFY ? (2 * g_random->random01()) : 1.0) * (double)(task->timeout - (uint64_t)versionNow) / CLIENT_KNOBS->CORE_VERSIONSPERSECOND); } @@ -370,15 +371,22 @@ public: if (BUGGIFY) Void _ = wait(delay(10.0)); Void _ = wait(runRYWTransaction(cx, [=](Reference tr) { - return finishTaskRun(tr, taskBucket, futureBucket, task, taskFunc, verifyTask); })); - return true; + return finishTaskRun(tr, taskBucket, futureBucket, task, taskFunc, verifyTask); + })); } + } catch(Error &e) { + TraceEvent(SevWarn, "TB_ExecuteFailure") + .detail("TaskUID", task->key.printable()) + .detail("TaskType", task->params[Task::reservedTaskParamKeyType].printable()) + .detail("Priority", task->getPriority()) + .error(e); } - return false; + // Return true to indicate that we did work. + return true; } - ACTOR static Future run(Database cx, Reference taskBucket, Reference futureBucket, double *pollDelay, int maxConcurrentTasks) { + ACTOR static Future dispatch(Database cx, Reference taskBucket, Reference futureBucket, double *pollDelay, int maxConcurrentTasks) { state std::vector> tasks(maxConcurrentTasks); for(auto &f : tasks) f = Never(); @@ -441,6 +449,38 @@ public: } } + ACTOR static Future watchDisabled(Database cx, Reference taskBucket, Reference> disabled) { + loop { + state Reference tr(new ReadYourWritesTransaction(cx)); + loop { + try { + taskBucket->setOptions(tr); + Optional disabledVal = wait(tr->get(taskBucket->disableKey)); + disabled->set(disabledVal.present()); + state Future watchDisabledFuture = tr->watch(taskBucket->disableKey); + Void _ = wait(tr->commit()); + Void _ = wait(watchDisabledFuture); + } + catch (Error &e) { + Void _ = wait(tr->onError(e)); + } + } + } + } + + ACTOR static Future run(Database cx, Reference taskBucket, Reference futureBucket, double *pollDelay, int maxConcurrentTasks) { + state Reference> disabled = Reference>( new AsyncVar(true) ); + state Future watchDisabledFuture = watchDisabled(cx, taskBucket, disabled); + + loop { + while(disabled->get()) { + Void _ = wait(disabled->onChange() || watchDisabledFuture); + } + + Void _ = wait(dispatch(cx, taskBucket, futureBucket, pollDelay, maxConcurrentTasks) || disabled->onChange() || watchDisabledFuture); + } + } + static Future> addIdle(Reference tr, Reference taskBucket) { taskBucket->setOptions(tr); @@ -685,6 +725,7 @@ TaskBucket::TaskBucket(const Subspace& subspace, bool sysAccess, bool priorityBa , available(prefix.get(LiteralStringRef("av"))) , available_prioritized(prefix.get(LiteralStringRef("avp"))) , timeouts(prefix.get(LiteralStringRef("to"))) + , disableKey(prefix.pack(LiteralStringRef("disable"))) , timeout(CLIENT_KNOBS->TASKBUCKET_TIMEOUT_VERSIONS) , system_access(sysAccess) , priority_batch(priorityBatch) @@ -703,6 +744,18 @@ Future TaskBucket::clear(Reference tr){ return Void(); } +Future TaskBucket::changeDisable(Reference tr, bool disable){ + setOptions(tr); + + if(disable) { + tr->set(disableKey, StringRef()); + } else { + tr->clear(disableKey); + } + + return Void(); +} + Key TaskBucket::addTask(Reference tr, Reference task) { setOptions(tr); @@ -767,6 +820,10 @@ Future TaskBucket::run(Database cx, Reference futureBucket, return TaskBucketImpl::run(cx, Reference::addRef(this), futureBucket, pollDelay, maxConcurrentTasks); } +Future TaskBucket::watchDisabled(Database cx, Reference> disabled) { + return TaskBucketImpl::watchDisabled(cx, Reference::addRef(this), disabled); +} + Future TaskBucket::isEmpty(Reference tr){ return TaskBucketImpl::isEmpty(tr, Reference::addRef(this)); } diff --git a/fdbclient/TaskBucket.h b/fdbclient/TaskBucket.h index e4f6d7e334..735d6b2b94 100644 --- a/fdbclient/TaskBucket.h +++ b/fdbclient/TaskBucket.h @@ -69,6 +69,11 @@ public: tr->setOption(FDBTransactionOptions::LOCK_AWARE); } + Future changeDisable(Reference tr, bool disable); + Future changeDisable(Database cx, bool disable) { + return runRYWTransaction(cx, [=](Reference tr){ return changeDisable(tr, disable); }); + } + Future clear(Reference tr); Future clear(Database cx) { return runRYWTransaction(cx, [=](Reference tr){ return clear(tr); }); @@ -99,6 +104,7 @@ public: Future doOne(Database cx, Reference futureBucket); Future run(Database cx, Reference futureBucket, double *pollDelay, int maxConcurrentTasks); + Future watchDisabled(Database cx, Reference> disabled); Future isEmpty(Reference tr); Future isEmpty(Database cx){ @@ -148,6 +154,10 @@ public: return lock_aware; } + Key getDisableKey() const { + return disableKey; + } + Subspace getAvailableSpace(int priority = 0) { if(priority == 0) return available; @@ -157,11 +167,15 @@ public: Database src; Map>>> key_version; + double getTimeoutSeconds() const { + return (double)timeout / CLIENT_KNOBS->CORE_VERSIONSPERSECOND; + } private: friend class TaskBucketImpl; Subspace prefix; Subspace active; + Key disableKey; // Available task subspaces. Priority 0, the default, will be under available which is backward // compatible with pre-priority TaskBucket processes. Priority 1 and higher will be in diff --git a/fdbclient/WriteMap.h b/fdbclient/WriteMap.h index 82c1b778b5..b648c67cfa 100644 --- a/fdbclient/WriteMap.h +++ b/fdbclient/WriteMap.h @@ -28,11 +28,11 @@ #include "Atomic.h" struct RYWMutation { - ValueRef value; + Optional value; enum MutationRef::Type type; - RYWMutation( ValueRef const& entry, MutationRef::Type type ) : value(entry), type(type) {} - RYWMutation() : value(ValueRef()), type(MutationRef::NoOp) {} + RYWMutation(Optional const& entry, MutationRef::Type type ) : value(entry), type(type) {} + RYWMutation() : value(), type(MutationRef::NoOp) {} bool operator == (const RYWMutation& r) const { return value == r.value && type == r.type; @@ -148,7 +148,7 @@ public: if (it.entry().key != key) { if( it.is_cleared_range() && is_dependent ) { it.tree.clear(); - OperationStack op( RYWMutation( StringRef(), MutationRef::SetValue ) ); + OperationStack op( RYWMutation( Optional(), MutationRef::SetValue ) ); coalesceOver(op, RYWMutation(param, operation), *arena); PTreeImpl::insert( writes, ver, WriteMapEntry( key, std::move(op), true, following_conflict, is_conflict, following_unreadable, is_unreadable ) ); } else { @@ -165,7 +165,7 @@ public: e.is_conflict = is_conflict; e.is_unreadable = is_unreadable; if (e.stack.size() == 0 && it.is_cleared_range() && is_dependent) { - e.stack.push(RYWMutation(StringRef(), MutationRef::SetValue)); + e.stack.push(RYWMutation(Optional(), MutationRef::SetValue)); coalesceOver(e.stack, RYWMutation(param, operation), *arena); } else if( !is_unreadable && e.stack.size() > 0 ) coalesceOver( e.stack, RYWMutation( param, operation ), *arena ); @@ -381,14 +381,16 @@ public: bool empty() const { return writeMapEmpty; } static RYWMutation coalesce(RYWMutation existingEntry, RYWMutation newEntry, Arena& arena) { + ASSERT(newEntry.value.present()); + if (newEntry.type == MutationRef::SetValue) return newEntry; else if (newEntry.type == MutationRef::AddValue) { switch(existingEntry.type) { case MutationRef::SetValue: - return RYWMutation(doLittleEndianAdd(existingEntry.value, newEntry.value, arena), MutationRef::SetValue); + return RYWMutation(doLittleEndianAdd(existingEntry.value, newEntry.value.get(), arena), MutationRef::SetValue); case MutationRef::AddValue: - return RYWMutation(doLittleEndianAdd(existingEntry.value, newEntry.value, arena), MutationRef::AddValue); + return RYWMutation(doLittleEndianAdd(existingEntry.value, newEntry.value.get(), arena), MutationRef::AddValue); default: throw operation_failed(); } @@ -396,9 +398,9 @@ public: else if (newEntry.type == MutationRef::AppendIfFits) { switch(existingEntry.type) { case MutationRef::SetValue: - return RYWMutation(doAppendIfFits(existingEntry.value, newEntry.value, arena), MutationRef::SetValue); + return RYWMutation(doAppendIfFits(existingEntry.value, newEntry.value.get(), arena), MutationRef::SetValue); case MutationRef::AppendIfFits: - return RYWMutation(doAppendIfFits(existingEntry.value, newEntry.value, arena), MutationRef::AppendIfFits); + return RYWMutation(doAppendIfFits(existingEntry.value, newEntry.value.get(), arena), MutationRef::AppendIfFits); default: throw operation_failed(); } @@ -406,9 +408,9 @@ public: else if (newEntry.type == MutationRef::And) { switch(existingEntry.type) { case MutationRef::SetValue: - return RYWMutation(doAnd(existingEntry.value, newEntry.value, arena), MutationRef::SetValue); + return RYWMutation(doAnd(existingEntry.value, newEntry.value.get(), arena), MutationRef::SetValue); case MutationRef::And: - return RYWMutation(doAnd(existingEntry.value, newEntry.value, arena), MutationRef::And); + return RYWMutation(doAnd(existingEntry.value, newEntry.value.get(), arena), MutationRef::And); default: throw operation_failed(); } @@ -416,9 +418,9 @@ public: else if (newEntry.type == MutationRef::Or) { switch(existingEntry.type) { case MutationRef::SetValue: - return RYWMutation(doOr(existingEntry.value, newEntry.value, arena), MutationRef::SetValue); + return RYWMutation(doOr(existingEntry.value, newEntry.value.get(), arena), MutationRef::SetValue); case MutationRef::Or: - return RYWMutation(doOr(existingEntry.value, newEntry.value, arena), MutationRef::Or); + return RYWMutation(doOr(existingEntry.value, newEntry.value.get(), arena), MutationRef::Or); default: throw operation_failed(); } @@ -426,9 +428,9 @@ public: else if (newEntry.type == MutationRef::Xor) { switch(existingEntry.type) { case MutationRef::SetValue: - return RYWMutation(doXor(existingEntry.value, newEntry.value, arena), MutationRef::SetValue); + return RYWMutation(doXor(existingEntry.value, newEntry.value.get(), arena), MutationRef::SetValue); case MutationRef::Xor: - return RYWMutation(doXor(existingEntry.value, newEntry.value, arena), MutationRef::Xor); + return RYWMutation(doXor(existingEntry.value, newEntry.value.get(), arena), MutationRef::Xor); default: throw operation_failed(); } @@ -436,9 +438,9 @@ public: else if (newEntry.type == MutationRef::Max) { switch (existingEntry.type) { case MutationRef::SetValue: - return RYWMutation(doMax(existingEntry.value, newEntry.value, arena), MutationRef::SetValue); + return RYWMutation(doMax(existingEntry.value, newEntry.value.get(), arena), MutationRef::SetValue); case MutationRef::Max: - return RYWMutation(doMax(existingEntry.value, newEntry.value, arena), MutationRef::Max); + return RYWMutation(doMax(existingEntry.value, newEntry.value.get(), arena), MutationRef::Max); default: throw operation_failed(); } @@ -446,20 +448,60 @@ public: else if (newEntry.type == MutationRef::Min) { switch (existingEntry.type) { case MutationRef::SetValue: - return RYWMutation(doMin(existingEntry.value, newEntry.value, arena), MutationRef::SetValue); + return RYWMutation(doMin(existingEntry.value, newEntry.value.get(), arena), MutationRef::SetValue); case MutationRef::Min: - return RYWMutation(doMin(existingEntry.value, newEntry.value, arena), MutationRef::Min); + return RYWMutation(doMin(existingEntry.value, newEntry.value.get(), arena), MutationRef::Min); default: throw operation_failed(); } } + else if (newEntry.type == MutationRef::ByteMin) { + switch (existingEntry.type) { + case MutationRef::SetValue: + return RYWMutation(doByteMin(existingEntry.value, newEntry.value.get(), arena), MutationRef::SetValue); + case MutationRef::ByteMin: + return RYWMutation(doByteMin(existingEntry.value, newEntry.value.get(), arena), MutationRef::ByteMin); + default: + throw operation_failed(); + } + } + else if (newEntry.type == MutationRef::ByteMax) { + switch (existingEntry.type) { + case MutationRef::SetValue: + return RYWMutation(doByteMax(existingEntry.value, newEntry.value.get(), arena), MutationRef::SetValue); + case MutationRef::ByteMax: + return RYWMutation(doByteMax(existingEntry.value, newEntry.value.get(), arena), MutationRef::ByteMax); + default: + throw operation_failed(); + } + } + else if (newEntry.type == MutationRef::MinV2) { + switch (existingEntry.type) { + case MutationRef::SetValue: + return RYWMutation(doMinV2(existingEntry.value, newEntry.value.get(), arena), MutationRef::SetValue); + case MutationRef::MinV2: + return RYWMutation(doMinV2(existingEntry.value, newEntry.value.get(), arena), MutationRef::MinV2); + default: + throw operation_failed(); + } + } + else if (newEntry.type == MutationRef::AndV2) { + switch (existingEntry.type) { + case MutationRef::SetValue: + return RYWMutation(doAndV2(existingEntry.value, newEntry.value.get(), arena), MutationRef::SetValue); + case MutationRef::AndV2: + return RYWMutation(doAndV2(existingEntry.value, newEntry.value.get(), arena), MutationRef::AndV2); + default: + throw operation_failed(); + } + } else throw operation_failed(); } static void coalesceOver(OperationStack& stack, RYWMutation newEntry, Arena& arena) { RYWMutation existingEntry = stack.top(); if (existingEntry.type == newEntry.type) { - if (isNonAssociativeOp(existingEntry.type) && existingEntry.value.size() != newEntry.value.size()) { + if (isNonAssociativeOp(existingEntry.type) && existingEntry.value.present() && existingEntry.value.get().size() != newEntry.value.get().size()) { stack.push(newEntry); } else { @@ -480,7 +522,7 @@ public: if( !stack.isDependent() && stack.size() == 1 ) return stack.at(0); - RYWMutation currentEntry = RYWMutation( value.present() ? value.get() : StringRef(), MutationRef::SetValue); + RYWMutation currentEntry = RYWMutation( value, MutationRef::SetValue); for(int i = 0; i < stack.size(); ++i) { currentEntry = coalesce(currentEntry, stack.at(i), arena); } diff --git a/fdbclient/vexillographer/fdb.options b/fdbclient/vexillographer/fdb.options index c194784a52..c06d4a38ac 100644 --- a/fdbclient/vexillographer/fdb.options +++ b/fdbclient/vexillographer/fdb.options @@ -82,7 +82,7 @@ description is not currently required but encouraged.