MCPcopy Create free account
hub / github.com/apple/foundationdb / init

Method init

bindings/java/JavaWorkload.cpp:353–386  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351 }
352
353 void init() {
354 if (abstractWorkloadClass != nullptr) {
355 return;
356 }
357 abstractWorkloadClass = getClass("com/apple/foundationdb/testing/AbstractWorkload");
358 setNativeMethods(abstractWorkloadClass,
359 { { "log", "(JILjava/lang/String;Ljava/util/Map;)V", reinterpret_cast<void*>(&printTrace) } });
360 auto loggerField = env->GetStaticFieldID(abstractWorkloadClass, "logger", "J");
361 checkException();
362 env->SetStaticLongField(abstractWorkloadClass, loggerField, reinterpret_cast<jlong>(log));
363 log->trace(info, "SetLogger", { { "Logger", std::to_string(reinterpret_cast<jlong>(log)) } });
364 setNativeMethods(getClass("com/apple/foundationdb/testing/WorkloadContext"),
365 { { "getProcessID", "(J)J", reinterpret_cast<void*>(&getProcessID) },
366 { "setProcessID", "(JJ)V", reinterpret_cast<void*>(&setProcessID) },
367 { "getOption", "(JLjava/lang/String;Z)Z", reinterpret_cast<void*>(&getOptionBool) },
368 { "getOption", "(JLjava/lang/String;J)J", reinterpret_cast<void*>(&getOptionLong) },
369 { "getOption", "(JLjava/lang/String;D)D", reinterpret_cast<void*>(&getOptionDouble) },
370 { "getOption",
371 "(JLjava/lang/String;Ljava/lang/String;)Ljava/lang/String;",
372 reinterpret_cast<void*>(&getOptionString) },
373 { "getClientID", "(J)I", reinterpret_cast<void*>(&getClientID) },
374 { "getClientCount", "(J)I", reinterpret_cast<void*>(&getClientCount) },
375 { "getSharedRandomNumber", "(J)J", reinterpret_cast<void*>(&getSharedRandomNumber) } });
376 setNativeMethods(getClass("com/apple/foundationdb/testing/Promise"),
377 { { "send", "(JZ)V", reinterpret_cast<void*>(&promiseSend) } });
378 auto fdbClass = getClass("com/apple/foundationdb/FDB");
379 jmethodID selectMethod =
380 env->GetStaticMethodID(fdbClass, "selectAPIVersion", "(I)Lcom/apple/foundationdb/FDB;");
381 checkException();
382 auto fdbInstance = env->CallStaticObjectMethod(fdbClass, selectMethod, jint(FDB_API_VERSION));
383 checkException();
384 env->CallObjectMethod(fdbInstance, getMethod(fdbClass, "disableShutdownHook", "()V"));
385 checkException();
386 }
387
388 jobject createWorkloadContext(FDBWorkloadContext* context) {
389 auto clazz = getClass("com/apple/foundationdb/testing/WorkloadContext");

Callers 1

initMethod · 0.45

Calls 3

getMethodFunction · 0.85
to_stringFunction · 0.50
traceMethod · 0.45

Tested by

no test coverage detected