mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-18 20:12:13 +08:00
Add Java API for network busyness
This commit is contained in:
parent
cc083ea1c7
commit
b5412b355e
@ -580,6 +580,17 @@ JNIEXPORT void JNICALL Java_com_apple_foundationdb_FDBDatabase_Database_1setOpti
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jdouble JNICALL Java_com_apple_foundationdb_FDBDatabase_Database_1getMainThreadBusyness(JNIEnv* jenv,
|
||||||
|
jobject,
|
||||||
|
jlong dbPtr) {
|
||||||
|
if (!dbPtr) {
|
||||||
|
throwParamNotNull(jenv);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
FDBDatabase* database = (FDBDatabase*)dbPtr;
|
||||||
|
return (jdouble) fdb_database_get_main_thread_busyness(database);
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL Java_com_apple_foundationdb_FDB_Error_1predicate(JNIEnv* jenv,
|
JNIEXPORT jboolean JNICALL Java_com_apple_foundationdb_FDB_Error_1predicate(JNIEnv* jenv,
|
||||||
jobject,
|
jobject,
|
||||||
jint predicate,
|
jint predicate,
|
||||||
|
@ -80,6 +80,15 @@ public interface Database extends AutoCloseable, TransactionContext {
|
|||||||
*/
|
*/
|
||||||
DatabaseOptions options();
|
DatabaseOptions options();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a value which indicates the saturation of the client
|
||||||
|
* <br>
|
||||||
|
* <b>Note:</b> By default, this value is updated every second
|
||||||
|
*
|
||||||
|
* @return a value where 0 indicates that the client is idle and 1 (or larger) indicates that the client is saturated.
|
||||||
|
*/
|
||||||
|
double getMainThreadBusyness();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs a read-only transactional function against this {@code Database} with retry logic.
|
* Runs a read-only transactional function against this {@code Database} with retry logic.
|
||||||
* {@link Function#apply(Object) apply(ReadTransaction)} will be called on the
|
* {@link Function#apply(Object) apply(ReadTransaction)} will be called on the
|
||||||
|
@ -150,6 +150,16 @@ class FDBDatabase extends NativeObjectWrapper implements Database, OptionConsume
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getMainThreadBusyness() {
|
||||||
|
pointerReadLock.lock();
|
||||||
|
try {
|
||||||
|
return Database_getMainThreadBusyness(getPtr());
|
||||||
|
} finally {
|
||||||
|
pointerReadLock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Executor getExecutor() {
|
public Executor getExecutor() {
|
||||||
return executor;
|
return executor;
|
||||||
@ -163,4 +173,5 @@ class FDBDatabase extends NativeObjectWrapper implements Database, OptionConsume
|
|||||||
private native long Database_createTransaction(long cPtr);
|
private native long Database_createTransaction(long cPtr);
|
||||||
private native void Database_dispose(long cPtr);
|
private native void Database_dispose(long cPtr);
|
||||||
private native void Database_setOption(long cPtr, int code, byte[] value) throws FDBException;
|
private native void Database_setOption(long cPtr, int code, byte[] value) throws FDBException;
|
||||||
|
private native double Database_getMainThreadBusyness(long cPtr);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user