1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
6 // This file implements the callback "bridge" between Java and C++ for
7 // rocksdb::TransactionNotifier.
9 #include "rocksjni/transaction_notifier_jnicallback.h"
10 #include "rocksjni/portal.h"
14 TransactionNotifierJniCallback::TransactionNotifierJniCallback(JNIEnv
* env
,
15 jobject jtransaction_notifier
) : JniCallback(env
, jtransaction_notifier
) {
16 // we cache the method id for the JNI callback
17 m_jsnapshot_created_methodID
=
18 AbstractTransactionNotifierJni::getSnapshotCreatedMethodId(env
);
21 void TransactionNotifierJniCallback::SnapshotCreated(
22 const Snapshot
* newSnapshot
) {
23 jboolean attached_thread
= JNI_FALSE
;
24 JNIEnv
* env
= getJniEnv(&attached_thread
);
25 assert(env
!= nullptr);
27 env
->CallVoidMethod(m_jcallback_obj
,
28 m_jsnapshot_created_methodID
, reinterpret_cast<jlong
>(newSnapshot
));
30 if(env
->ExceptionCheck()) {
31 // exception thrown from CallVoidMethod
32 env
->ExceptionDescribe(); // print out exception to stderr
33 releaseJniEnv(attached_thread
);
37 releaseJniEnv(attached_thread
);
39 } // namespace rocksdb