mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
155e78f014
BitKeeper/deleted/.del-ex_access.wpj~3df6ae8c99bf7c5f: Delete: bdb/build_vxworks/ex_access/ex_access.wpj BitKeeper/deleted/.del-ex_btrec.wpj~a7622f1c6f432dc6: Delete: bdb/build_vxworks/ex_btrec/ex_btrec.wpj BitKeeper/deleted/.del-ex_dbclient.wpj~7345440f3b204cdd: Delete: bdb/build_vxworks/ex_dbclient/ex_dbclient.wpj BitKeeper/deleted/.del-ex_env.wpj~fbe1ab10b04e8b74: Delete: bdb/build_vxworks/ex_env/ex_env.wpj BitKeeper/deleted/.del-ex_mpool.wpj~4479cfd5c45f327d: Delete: bdb/build_vxworks/ex_mpool/ex_mpool.wpj BitKeeper/deleted/.del-ex_tpcb.wpj~f78093006e14bf41: Delete: bdb/build_vxworks/ex_tpcb/ex_tpcb.wpj BitKeeper/deleted/.del-db_buildall.dsp~bd749ff6da11682: Delete: bdb/build_win32/db_buildall.dsp BitKeeper/deleted/.del-cxx_app.cpp~ad8df8e0791011ed: Delete: bdb/cxx/cxx_app.cpp BitKeeper/deleted/.del-cxx_log.cpp~a50ff3118fe06952: Delete: bdb/cxx/cxx_log.cpp BitKeeper/deleted/.del-cxx_table.cpp~ecd751e79b055556: Delete: bdb/cxx/cxx_table.cpp BitKeeper/deleted/.del-namemap.txt~796a3acd3885d8fd: Delete: bdb/cxx/namemap.txt BitKeeper/deleted/.del-Design.fileop~3ca4da68f1727373: Delete: bdb/db/Design.fileop BitKeeper/deleted/.del-db185_int.h~61bee3736e7959ef: Delete: bdb/db185/db185_int.h BitKeeper/deleted/.del-acconfig.h~411e8854d67ad8b5: Delete: bdb/dist/acconfig.h BitKeeper/deleted/.del-mutex.m4~a13383cde18a64e1: Delete: bdb/dist/aclocal/mutex.m4 BitKeeper/deleted/.del-options.m4~b9d0ca637213750a: Delete: bdb/dist/aclocal/options.m4 BitKeeper/deleted/.del-programs.m4~3ce7890b47732b30: Delete: bdb/dist/aclocal/programs.m4 BitKeeper/deleted/.del-tcl.m4~f944e2db93c3b6db: Delete: bdb/dist/aclocal/tcl.m4 BitKeeper/deleted/.del-types.m4~59cae158c9a32cff: Delete: bdb/dist/aclocal/types.m4 BitKeeper/deleted/.del-script~d38f6d3a4f159cb4: Delete: bdb/dist/build/script BitKeeper/deleted/.del-configure.in~ac795a92c8fe049c: Delete: bdb/dist/configure.in BitKeeper/deleted/.del-ltconfig~66bbd007d8024af: Delete: bdb/dist/ltconfig BitKeeper/deleted/.del-rec_ctemp~a28554362534f00a: Delete: bdb/dist/rec_ctemp BitKeeper/deleted/.del-s_tcl~2ffe4326459fcd9f: Delete: bdb/dist/s_tcl BitKeeper/deleted/.del-.IGNORE_ME~d8148b08fa7d5d15: Delete: bdb/dist/template/.IGNORE_ME BitKeeper/deleted/.del-btree.h~179f2aefec1753d: Delete: bdb/include/btree.h BitKeeper/deleted/.del-cxx_int.h~6b649c04766508f8: Delete: bdb/include/cxx_int.h BitKeeper/deleted/.del-db.src~6b433ae615b16a8d: Delete: bdb/include/db.src BitKeeper/deleted/.del-db_185.h~ad8b373d9391d35c: Delete: bdb/include/db_185.h BitKeeper/deleted/.del-db_am.h~a714912b6b75932f: Delete: bdb/include/db_am.h BitKeeper/deleted/.del-db_cxx.h~fcafadf45f5d19e9: Delete: bdb/include/db_cxx.h BitKeeper/deleted/.del-db_dispatch.h~6844f20f7eb46904: Delete: bdb/include/db_dispatch.h BitKeeper/deleted/.del-db_int.src~419a3f48b6a01da7: Delete: bdb/include/db_int.src BitKeeper/deleted/.del-db_join.h~76f9747a42c3399a: Delete: bdb/include/db_join.h BitKeeper/deleted/.del-db_page.h~e302ca3a4db3abdc: Delete: bdb/include/db_page.h BitKeeper/deleted/.del-db_server_int.h~e1d20b6ba3bca1ab: Delete: bdb/include/db_server_int.h BitKeeper/deleted/.del-db_shash.h~5fbf2d696fac90f3: Delete: bdb/include/db_shash.h BitKeeper/deleted/.del-db_swap.h~1e60887550864a59: Delete: bdb/include/db_swap.h BitKeeper/deleted/.del-db_upgrade.h~c644eee73701fc8d: Delete: bdb/include/db_upgrade.h BitKeeper/deleted/.del-db_verify.h~b8d6c297c61f342e: Delete: bdb/include/db_verify.h BitKeeper/deleted/.del-debug.h~dc2b4f2cf27ccebc: Delete: bdb/include/debug.h BitKeeper/deleted/.del-hash.h~2aaa548b28882dfb: Delete: bdb/include/hash.h BitKeeper/deleted/.del-lock.h~a761c1b7de57b77f: Delete: bdb/include/lock.h BitKeeper/deleted/.del-log.h~ff20184238e35e4d: Delete: bdb/include/log.h BitKeeper/deleted/.del-mp.h~7e317597622f3411: Delete: bdb/include/mp.h BitKeeper/deleted/.del-mutex.h~d3ae7a2977a68137: Delete: bdb/include/mutex.h BitKeeper/deleted/.del-os.h~91867cc8757cd0e3: Delete: bdb/include/os.h BitKeeper/deleted/.del-os_jump.h~e1b939fa5151d4be: Delete: bdb/include/os_jump.h BitKeeper/deleted/.del-qam.h~6fad0c1b5723d597: Delete: bdb/include/qam.h BitKeeper/deleted/.del-queue.h~4c72c0826c123d5: Delete: bdb/include/queue.h BitKeeper/deleted/.del-region.h~513fe04d977ca0fc: Delete: bdb/include/region.h BitKeeper/deleted/.del-shqueue.h~525fc3e6c2025c36: Delete: bdb/include/shqueue.h BitKeeper/deleted/.del-tcl_db.h~c536fd61a844f23f: Delete: bdb/include/tcl_db.h BitKeeper/deleted/.del-txn.h~c8d94b221ec147e4: Delete: bdb/include/txn.h BitKeeper/deleted/.del-xa.h~ecc466493aae9d9a: Delete: bdb/include/xa.h BitKeeper/deleted/.del-DbRecoveryInit.java~756b52601a0b9023: Delete: bdb/java/src/com/sleepycat/db/DbRecoveryInit.java BitKeeper/deleted/.del-DbTxnRecover.java~74607cba7ab89d6d: Delete: bdb/java/src/com/sleepycat/db/DbTxnRecover.java BitKeeper/deleted/.del-lock_conflict.c~fc5e0f14cf597a2b: Delete: bdb/lock/lock_conflict.c BitKeeper/deleted/.del-log.src~53ac9e7b5cb023f2: Delete: bdb/log/log.src BitKeeper/deleted/.del-log_findckp.c~24287f008916e81f: Delete: bdb/log/log_findckp.c BitKeeper/deleted/.del-log_rec.c~d51711f2cac09297: Delete: bdb/log/log_rec.c BitKeeper/deleted/.del-log_register.c~b40bb4efac75ca15: Delete: bdb/log/log_register.c BitKeeper/deleted/.del-Design~b3d0f179f2767b: Delete: bdb/mp/Design BitKeeper/deleted/.del-os_finit.c~95dbefc6fe79b26c: Delete: bdb/os/os_finit.c BitKeeper/deleted/.del-os_abs.c~df95d1e7db81924: Delete: bdb/os_vxworks/os_abs.c BitKeeper/deleted/.del-os_finit.c~803b484bdb9d0122: Delete: bdb/os_vxworks/os_finit.c BitKeeper/deleted/.del-os_map.c~3a6d7926398b76d3: Delete: bdb/os_vxworks/os_map.c BitKeeper/deleted/.del-os_finit.c~19a227c6d3c78ad: Delete: bdb/os_win32/os_finit.c BitKeeper/deleted/.del-log-corruption.patch~1cf2ecc7c6408d5d: Delete: bdb/patches/log-corruption.patch BitKeeper/deleted/.del-Btree.pm~af6d0c5eaed4a98e: Delete: bdb/perl.BerkeleyDB/BerkeleyDB/Btree.pm BitKeeper/deleted/.del-BerkeleyDB.pm~7244036d4482643: Delete: bdb/perl.BerkeleyDB/BerkeleyDB.pm BitKeeper/deleted/.del-BerkeleyDB.pod~e7b18fd6132448e3: Delete: bdb/perl.BerkeleyDB/BerkeleyDB.pod BitKeeper/deleted/.del-Hash.pm~10292a26c06a5c95: Delete: bdb/perl.BerkeleyDB/BerkeleyDB/Hash.pm BitKeeper/deleted/.del-BerkeleyDB.pod.P~79f76a1495eda203: Delete: bdb/perl.BerkeleyDB/BerkeleyDB.pod.P BitKeeper/deleted/.del-BerkeleyDB.xs~80c99afbd98e392c: Delete: bdb/perl.BerkeleyDB/BerkeleyDB.xs BitKeeper/deleted/.del-Changes~729c1891efa60de9: Delete: bdb/perl.BerkeleyDB/Changes BitKeeper/deleted/.del-MANIFEST~63a1e34aecf157a0: Delete: bdb/perl.BerkeleyDB/MANIFEST BitKeeper/deleted/.del-Makefile.PL~c68797707d8df87a: Delete: bdb/perl.BerkeleyDB/Makefile.PL BitKeeper/deleted/.del-README~5f2f579b1a241407: Delete: bdb/perl.BerkeleyDB/README BitKeeper/deleted/.del-Todo~dca3c66c193adda9: Delete: bdb/perl.BerkeleyDB/Todo BitKeeper/deleted/.del-config.in~ae81681e450e0999: Delete: bdb/perl.BerkeleyDB/config.in BitKeeper/deleted/.del-dbinfo~28ad67d83be4f68e: Delete: bdb/perl.BerkeleyDB/dbinfo BitKeeper/deleted/.del-mkconsts~543ab60669c7a04e: Delete: bdb/perl.BerkeleyDB/mkconsts BitKeeper/deleted/.del-mkpod~182c0ca54e439afb: Delete: bdb/perl.BerkeleyDB/mkpod BitKeeper/deleted/.del-5.004~e008cb5a48805543: Delete: bdb/perl.BerkeleyDB/patches/5.004 BitKeeper/deleted/.del-irix_6_5.pl~61662bb08afcdec8: Delete: bdb/perl.BerkeleyDB/hints/irix_6_5.pl BitKeeper/deleted/.del-solaris.pl~6771e7182394e152: Delete: bdb/perl.BerkeleyDB/hints/solaris.pl BitKeeper/deleted/.del-typemap~783b8f5295b05f3d: Delete: bdb/perl.BerkeleyDB/typemap BitKeeper/deleted/.del-5.004_01~6081ce2fff7b0bc: Delete: bdb/perl.BerkeleyDB/patches/5.004_01 BitKeeper/deleted/.del-5.004_02~87214eac35ad9e6: Delete: bdb/perl.BerkeleyDB/patches/5.004_02 BitKeeper/deleted/.del-5.004_03~9a672becec7cb40f: Delete: bdb/perl.BerkeleyDB/patches/5.004_03 BitKeeper/deleted/.del-5.004_04~e326cb51af09d154: Delete: bdb/perl.BerkeleyDB/patches/5.004_04 BitKeeper/deleted/.del-5.004_05~7ab457a1e41a92fe: Delete: bdb/perl.BerkeleyDB/patches/5.004_05 BitKeeper/deleted/.del-5.005~f9e2d59b5964cd4b: Delete: bdb/perl.BerkeleyDB/patches/5.005 BitKeeper/deleted/.del-5.005_01~3eb9fb7b5842ea8e: Delete: bdb/perl.BerkeleyDB/patches/5.005_01 BitKeeper/deleted/.del-5.005_02~67477ce0bef717cb: Delete: bdb/perl.BerkeleyDB/patches/5.005_02 BitKeeper/deleted/.del-5.005_03~c4c29a1fb21e290a: Delete: bdb/perl.BerkeleyDB/patches/5.005_03 BitKeeper/deleted/.del-5.6.0~e1fb9897d124ee22: Delete: bdb/perl.BerkeleyDB/patches/5.6.0 BitKeeper/deleted/.del-btree.t~e4a1a3c675ddc406: Delete: bdb/perl.BerkeleyDB/t/btree.t BitKeeper/deleted/.del-db-3.0.t~d2c60991d84558f2: Delete: bdb/perl.BerkeleyDB/t/db-3.0.t BitKeeper/deleted/.del-db-3.1.t~6ee88cd13f55e018: Delete: bdb/perl.BerkeleyDB/t/db-3.1.t BitKeeper/deleted/.del-db-3.2.t~f73b6461f98fd1cf: Delete: bdb/perl.BerkeleyDB/t/db-3.2.t BitKeeper/deleted/.del-destroy.t~cc6a2ae1980a2ecd: Delete: bdb/perl.BerkeleyDB/t/destroy.t BitKeeper/deleted/.del-env.t~a8604a4499c4bd07: Delete: bdb/perl.BerkeleyDB/t/env.t BitKeeper/deleted/.del-examples.t~2571b77c3cc75574: Delete: bdb/perl.BerkeleyDB/t/examples.t BitKeeper/deleted/.del-examples.t.T~8228bdd75ac78b88: Delete: bdb/perl.BerkeleyDB/t/examples.t.T BitKeeper/deleted/.del-examples3.t.T~66a186897a87026d: Delete: bdb/perl.BerkeleyDB/t/examples3.t.T BitKeeper/deleted/.del-examples3.t~fe3822ba2f2d7f83: Delete: bdb/perl.BerkeleyDB/t/examples3.t BitKeeper/deleted/.del-filter.t~f87b045c1b708637: Delete: bdb/perl.BerkeleyDB/t/filter.t BitKeeper/deleted/.del-hash.t~616bfb4d644de3a3: Delete: bdb/perl.BerkeleyDB/t/hash.t BitKeeper/deleted/.del-join.t~29fc39f74a83ca22: Delete: bdb/perl.BerkeleyDB/t/join.t BitKeeper/deleted/.del-mldbm.t~31f5015341eea040: Delete: bdb/perl.BerkeleyDB/t/mldbm.t BitKeeper/deleted/.del-queue.t~8f338034ce44a641: Delete: bdb/perl.BerkeleyDB/t/queue.t BitKeeper/deleted/.del-recno.t~d4ddbd3743add63e: Delete: bdb/perl.BerkeleyDB/t/recno.t BitKeeper/deleted/.del-strict.t~6885cdd2ea71ca2d: Delete: bdb/perl.BerkeleyDB/t/strict.t BitKeeper/deleted/.del-subdb.t~aab62a5d5864c603: Delete: bdb/perl.BerkeleyDB/t/subdb.t BitKeeper/deleted/.del-txn.t~65033b8558ae1216: Delete: bdb/perl.BerkeleyDB/t/txn.t BitKeeper/deleted/.del-unknown.t~f3710458682665e1: Delete: bdb/perl.BerkeleyDB/t/unknown.t BitKeeper/deleted/.del-Changes~436f74a5c414c65b: Delete: bdb/perl.DB_File/Changes BitKeeper/deleted/.del-DB_File.pm~ae0951c6c7665a82: Delete: bdb/perl.DB_File/DB_File.pm BitKeeper/deleted/.del-DB_File.xs~89e49a0b5556f1d8: Delete: bdb/perl.DB_File/DB_File.xs BitKeeper/deleted/.del-DB_File_BS~290fad5dbbb87069: Delete: bdb/perl.DB_File/DB_File_BS BitKeeper/deleted/.del-MANIFEST~90ee581572bdd4ac: Delete: bdb/perl.DB_File/MANIFEST BitKeeper/deleted/.del-Makefile.PL~ac0567bb5a377e38: Delete: bdb/perl.DB_File/Makefile.PL BitKeeper/deleted/.del-README~77e924a5a9bae6b3: Delete: bdb/perl.DB_File/README BitKeeper/deleted/.del-config.in~ab4c2792b86a810b: Delete: bdb/perl.DB_File/config.in BitKeeper/deleted/.del-dbinfo~461c43b30fab2cb: Delete: bdb/perl.DB_File/dbinfo BitKeeper/deleted/.del-dynixptx.pl~50dcddfae25d17e9: Delete: bdb/perl.DB_File/hints/dynixptx.pl BitKeeper/deleted/.del-typemap~55cffb3288a9e587: Delete: bdb/perl.DB_File/typemap BitKeeper/deleted/.del-version.c~a4df0e646f8b3975: Delete: bdb/perl.DB_File/version.c BitKeeper/deleted/.del-5.004_01~d6830d0082702af7: Delete: bdb/perl.DB_File/patches/5.004_01 BitKeeper/deleted/.del-5.004_02~78b082dc80c91031: Delete: bdb/perl.DB_File/patches/5.004_02 BitKeeper/deleted/.del-5.004~4411ec2e3c9e008b: Delete: bdb/perl.DB_File/patches/5.004 BitKeeper/deleted/.del-sco.pl~1e795fe14fe4dcfe: Delete: bdb/perl.DB_File/hints/sco.pl BitKeeper/deleted/.del-5.004_03~33f274648b160d95: Delete: bdb/perl.DB_File/patches/5.004_03 BitKeeper/deleted/.del-5.004_04~8f3d1b3cf18bb20a: Delete: bdb/perl.DB_File/patches/5.004_04 BitKeeper/deleted/.del-5.004_05~9c0f02e7331e142: Delete: bdb/perl.DB_File/patches/5.004_05 BitKeeper/deleted/.del-5.005~c2108cb2e3c8d951: Delete: bdb/perl.DB_File/patches/5.005 BitKeeper/deleted/.del-5.005_01~3b45e9673afc4cfa: Delete: bdb/perl.DB_File/patches/5.005_01 BitKeeper/deleted/.del-5.005_02~9fe5766bb02a4522: Delete: bdb/perl.DB_File/patches/5.005_02 BitKeeper/deleted/.del-5.005_03~ffa1c38c19ae72ea: Delete: bdb/perl.DB_File/patches/5.005_03 BitKeeper/deleted/.del-5.6.0~373be3a5ce47be85: Delete: bdb/perl.DB_File/patches/5.6.0 BitKeeper/deleted/.del-db-btree.t~3231595a1c241eb3: Delete: bdb/perl.DB_File/t/db-btree.t BitKeeper/deleted/.del-db-hash.t~7c4ad0c795c7fad2: Delete: bdb/perl.DB_File/t/db-hash.t BitKeeper/deleted/.del-db-recno.t~6c2d3d80b9ba4a50: Delete: bdb/perl.DB_File/t/db-recno.t BitKeeper/deleted/.del-db_server.sed~cdb00ebcd48a64e2: Delete: bdb/rpc_server/db_server.sed BitKeeper/deleted/.del-db_server_proc.c~d46c8f409c3747f4: Delete: bdb/rpc_server/db_server_proc.c BitKeeper/deleted/.del-db_server_svc.sed~3f5e59f334fa4607: Delete: bdb/rpc_server/db_server_svc.sed BitKeeper/deleted/.del-db_server_util.c~a809f3a4629acda: Delete: bdb/rpc_server/db_server_util.c BitKeeper/deleted/.del-log.tcl~ff1b41f1355b97d7: Delete: bdb/test/log.tcl BitKeeper/deleted/.del-mpool.tcl~b0df4dc1b04db26c: Delete: bdb/test/mpool.tcl BitKeeper/deleted/.del-mutex.tcl~52fd5c73a150565: Delete: bdb/test/mutex.tcl BitKeeper/deleted/.del-txn.tcl~c4ff071550b5446e: Delete: bdb/test/txn.tcl BitKeeper/deleted/.del-README~e800a12a5392010a: Delete: bdb/test/upgrade/README BitKeeper/deleted/.del-pack-2.6.6.pl~89d5076d758d3e98: Delete: bdb/test/upgrade/generate-2.X/pack-2.6.6.pl BitKeeper/deleted/.del-test-2.6.patch~4a52dc83d447547b: Delete: bdb/test/upgrade/generate-2.X/test-2.6.patch
1450 lines
38 KiB
C
1450 lines
38 KiB
C
/*-
|
|
* See the file LICENSE for redistribution information.
|
|
*
|
|
* Copyright (c) 1997-2002
|
|
* Sleepycat Software. All rights reserved.
|
|
*/
|
|
#include "db_config.h"
|
|
|
|
#ifndef lint
|
|
static const char revid[] = "$Id: java_DbEnv.c,v 11.105 2002/08/29 14:22:23 margo Exp $";
|
|
#endif /* not lint */
|
|
|
|
#include <jni.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include "db_int.h"
|
|
#include "java_util.h"
|
|
#include "java_stat_auto.h"
|
|
#include "com_sleepycat_db_DbEnv.h"
|
|
|
|
/* We keep these lined up, and alphabetical by field name,
|
|
* for comparison with C++'s list.
|
|
*/
|
|
JAVADB_SET_METH_STR(DbEnv, data_1dir, DB_ENV, data_dir)
|
|
JAVADB_SET_METH(DbEnv, jint, lg_1bsize, DB_ENV, lg_bsize)
|
|
JAVADB_SET_METH_STR(DbEnv, lg_1dir, DB_ENV, lg_dir)
|
|
JAVADB_SET_METH(DbEnv, jint, lg_1max, DB_ENV, lg_max)
|
|
JAVADB_SET_METH(DbEnv, jint, lg_1regionmax, DB_ENV, lg_regionmax)
|
|
JAVADB_SET_METH(DbEnv, jint, lk_1detect, DB_ENV, lk_detect)
|
|
JAVADB_SET_METH(DbEnv, jint, lk_1max, DB_ENV, lk_max)
|
|
JAVADB_SET_METH(DbEnv, jint, lk_1max_1locks, DB_ENV, lk_max_locks)
|
|
JAVADB_SET_METH(DbEnv, jint, lk_1max_1lockers, DB_ENV, lk_max_lockers)
|
|
JAVADB_SET_METH(DbEnv, jint, lk_1max_1objects, DB_ENV, lk_max_objects)
|
|
/* mp_mmapsize is declared below, it needs an extra cast */
|
|
JAVADB_SET_METH_STR(DbEnv, tmp_1dir, DB_ENV, tmp_dir)
|
|
JAVADB_SET_METH(DbEnv, jint, tx_1max, DB_ENV, tx_max)
|
|
|
|
static void DbEnv_errcall_callback(const char *prefix, char *message)
|
|
{
|
|
JNIEnv *jnienv;
|
|
DB_ENV_JAVAINFO *envinfo = (DB_ENV_JAVAINFO *)prefix;
|
|
jstring pre;
|
|
|
|
/*
|
|
* Note: these error cases are "impossible", and would
|
|
* normally warrant an exception. However, without
|
|
* a jnienv, we cannot throw an exception...
|
|
* We don't want to trap or exit, since the point of
|
|
* this facility is for the user to completely control
|
|
* error situations.
|
|
*/
|
|
if (envinfo == NULL) {
|
|
/*
|
|
* Something is *really* wrong here, the
|
|
* prefix is set in every environment created.
|
|
*/
|
|
fprintf(stderr, "Error callback failed!\n");
|
|
fprintf(stderr, "error: %s\n", message);
|
|
return;
|
|
}
|
|
|
|
/* Should always succeed... */
|
|
jnienv = dbjie_get_jnienv(envinfo);
|
|
|
|
if (jnienv == NULL) {
|
|
|
|
/* But just in case... */
|
|
fprintf(stderr, "Cannot attach to current thread!\n");
|
|
fprintf(stderr, "error: %s\n", message);
|
|
return;
|
|
}
|
|
|
|
pre = dbjie_get_errpfx(envinfo, jnienv);
|
|
report_errcall(jnienv, dbjie_get_errcall(envinfo), pre, message);
|
|
}
|
|
|
|
static void DbEnv_initialize(JNIEnv *jnienv, DB_ENV *dbenv,
|
|
/*DbEnv*/ jobject jenv,
|
|
/*DbErrcall*/ jobject jerrcall,
|
|
int is_dbopen)
|
|
{
|
|
DB_ENV_JAVAINFO *envinfo;
|
|
|
|
envinfo = get_DB_ENV_JAVAINFO(jnienv, jenv);
|
|
DB_ASSERT(envinfo == NULL);
|
|
envinfo = dbjie_construct(jnienv, jenv, jerrcall, is_dbopen);
|
|
set_private_info(jnienv, name_DB_ENV, jenv, envinfo);
|
|
dbenv->set_errpfx(dbenv, (const char*)envinfo);
|
|
dbenv->set_errcall(dbenv, DbEnv_errcall_callback);
|
|
dbenv->api2_internal = envinfo;
|
|
set_private_dbobj(jnienv, name_DB_ENV, jenv, dbenv);
|
|
}
|
|
|
|
/*
|
|
* This is called when this DbEnv was made on behalf of a Db
|
|
* created directly (without a parent DbEnv), and the Db is
|
|
* being closed. We'll zero out the pointer to the DB_ENV,
|
|
* since it is no longer valid, to prevent mistakes.
|
|
*/
|
|
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv__1notify_1db_1close
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis)
|
|
{
|
|
DB_ENV_JAVAINFO *dbenvinfo;
|
|
|
|
set_private_dbobj(jnienv, name_DB_ENV, jthis, 0);
|
|
dbenvinfo = get_DB_ENV_JAVAINFO(jnienv, jthis);
|
|
if (dbenvinfo != NULL)
|
|
dbjie_dealloc(dbenvinfo, jnienv);
|
|
}
|
|
|
|
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_feedback_1changed
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis,
|
|
/*DbEnvFeedback*/ jobject jfeedback)
|
|
{
|
|
DB_ENV *dbenv;
|
|
DB_ENV_JAVAINFO *dbenvinfo;
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
dbenvinfo = get_DB_ENV_JAVAINFO(jnienv, jthis);
|
|
if (!verify_non_null(jnienv, dbenv) ||
|
|
!verify_non_null(jnienv, dbenvinfo))
|
|
return;
|
|
|
|
dbjie_set_feedback_object(dbenvinfo, jnienv, dbenv, jfeedback);
|
|
}
|
|
|
|
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv__1init
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jobject /*DbErrcall*/ jerrcall,
|
|
jint flags)
|
|
{
|
|
int err;
|
|
DB_ENV *dbenv;
|
|
|
|
err = db_env_create(&dbenv, flags);
|
|
if (verify_return(jnienv, err, 0))
|
|
DbEnv_initialize(jnienv, dbenv, jthis, jerrcall, 0);
|
|
}
|
|
|
|
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv__1init_1using_1db
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jobject /*DbErrcall*/ jerrcall,
|
|
/*Db*/ jobject jdb)
|
|
{
|
|
DB_ENV *dbenv;
|
|
DB *db;
|
|
|
|
db = get_DB(jnienv, jdb);
|
|
dbenv = db->dbenv;
|
|
DbEnv_initialize(jnienv, dbenv, jthis, jerrcall, 0);
|
|
}
|
|
|
|
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_open
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jstring db_home,
|
|
jint flags, jint mode)
|
|
{
|
|
int err;
|
|
DB_ENV *dbenv;
|
|
LOCKED_STRING ls_home;
|
|
DB_ENV_JAVAINFO *dbenvinfo;
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
dbenvinfo = get_DB_ENV_JAVAINFO(jnienv, jthis);
|
|
if (!verify_non_null(jnienv, dbenv) ||
|
|
!verify_non_null(jnienv, dbenvinfo))
|
|
return;
|
|
if (locked_string_get(&ls_home, jnienv, db_home) != 0)
|
|
goto out;
|
|
|
|
/* Java is assumed to be threaded. */
|
|
flags |= DB_THREAD;
|
|
|
|
err = dbenv->open(dbenv, ls_home.string, flags, mode);
|
|
verify_return(jnienv, err, EXCEPTION_FILE_NOT_FOUND);
|
|
out:
|
|
locked_string_put(&ls_home, jnienv);
|
|
}
|
|
|
|
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_remove
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jstring db_home, jint flags)
|
|
{
|
|
DB_ENV *dbenv;
|
|
DB_ENV_JAVAINFO *dbenvinfo;
|
|
LOCKED_STRING ls_home;
|
|
int err = 0;
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
dbenvinfo = get_DB_ENV_JAVAINFO(jnienv, jthis);
|
|
if (!verify_non_null(jnienv, dbenv))
|
|
return;
|
|
if (locked_string_get(&ls_home, jnienv, db_home) != 0)
|
|
goto out;
|
|
|
|
err = dbenv->remove(dbenv, ls_home.string, flags);
|
|
set_private_dbobj(jnienv, name_DB_ENV, jthis, 0);
|
|
|
|
verify_return(jnienv, err, 0);
|
|
out:
|
|
locked_string_put(&ls_home, jnienv);
|
|
|
|
if (dbenvinfo != NULL)
|
|
dbjie_dealloc(dbenvinfo, jnienv);
|
|
}
|
|
|
|
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv__1close
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint flags)
|
|
{
|
|
int err;
|
|
DB_ENV *dbenv;
|
|
DB_ENV_JAVAINFO *dbenvinfo;
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
dbenvinfo = get_DB_ENV_JAVAINFO(jnienv, jthis);
|
|
if (!verify_non_null(jnienv, dbenv))
|
|
return;
|
|
|
|
err = dbenv->close(dbenv, flags);
|
|
set_private_dbobj(jnienv, name_DB_ENV, jthis, 0);
|
|
|
|
if (dbenvinfo != NULL)
|
|
dbjie_dealloc(dbenvinfo, jnienv);
|
|
|
|
/* Throw an exception if the close failed. */
|
|
verify_return(jnienv, err, 0);
|
|
}
|
|
|
|
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_dbremove
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, /*DbTxn*/ jobject jtxn,
|
|
jstring name, jstring subdb, jint flags)
|
|
{
|
|
LOCKED_STRING ls_name, ls_subdb;
|
|
DB_ENV *dbenv;
|
|
DB_TXN *txn;
|
|
int err;
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
if (!verify_non_null(jnienv, dbenv))
|
|
return;
|
|
txn = get_DB_TXN(jnienv, jtxn);
|
|
if (locked_string_get(&ls_name, jnienv, name) != 0)
|
|
return;
|
|
if (locked_string_get(&ls_subdb, jnienv, subdb) != 0)
|
|
goto err1;
|
|
|
|
err = dbenv->dbremove(dbenv, txn, ls_name.string, ls_subdb.string,
|
|
flags);
|
|
|
|
/* Throw an exception if the dbremove failed. */
|
|
verify_return(jnienv, err, 0);
|
|
|
|
locked_string_put(&ls_subdb, jnienv);
|
|
err1: locked_string_put(&ls_name, jnienv);
|
|
}
|
|
|
|
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_dbrename
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, /*DbTxn*/ jobject jtxn,
|
|
jstring name, jstring subdb, jstring newname, jint flags)
|
|
{
|
|
LOCKED_STRING ls_name, ls_subdb, ls_newname;
|
|
DB_ENV *dbenv;
|
|
DB_TXN *txn;
|
|
int err;
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
if (!verify_non_null(jnienv, dbenv))
|
|
return;
|
|
txn = get_DB_TXN(jnienv, jtxn);
|
|
if (locked_string_get(&ls_name, jnienv, name) != 0)
|
|
return;
|
|
if (locked_string_get(&ls_subdb, jnienv, subdb) != 0)
|
|
goto err2;
|
|
if (locked_string_get(&ls_newname, jnienv, newname) != 0)
|
|
goto err1;
|
|
|
|
err = dbenv->dbrename(dbenv, txn, ls_name.string, ls_subdb.string,
|
|
ls_newname.string, flags);
|
|
|
|
/* Throw an exception if the dbrename failed. */
|
|
verify_return(jnienv, err, 0);
|
|
|
|
locked_string_put(&ls_newname, jnienv);
|
|
err1: locked_string_put(&ls_subdb, jnienv);
|
|
err2: locked_string_put(&ls_name, jnienv);
|
|
}
|
|
|
|
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_err
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint ecode, jstring msg)
|
|
{
|
|
LOCKED_STRING ls_msg;
|
|
DB_ENV *dbenv;
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
if (!verify_non_null(jnienv, dbenv))
|
|
return;
|
|
|
|
if (locked_string_get(&ls_msg, jnienv, msg) != 0)
|
|
goto out;
|
|
|
|
dbenv->err(dbenv, ecode, "%s", ls_msg.string);
|
|
out:
|
|
locked_string_put(&ls_msg, jnienv);
|
|
}
|
|
|
|
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_errx
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jstring msg)
|
|
{
|
|
LOCKED_STRING ls_msg;
|
|
DB_ENV *dbenv;
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
if (!verify_non_null(jnienv, dbenv))
|
|
return;
|
|
|
|
if (locked_string_get(&ls_msg, jnienv, msg) != 0)
|
|
goto out;
|
|
|
|
dbenv->errx(dbenv, "%s", ls_msg.string);
|
|
out:
|
|
locked_string_put(&ls_msg, jnienv);
|
|
}
|
|
|
|
/*static*/
|
|
JNIEXPORT jstring JNICALL Java_com_sleepycat_db_DbEnv_strerror
|
|
(JNIEnv *jnienv, jclass jthis_class, jint ecode)
|
|
{
|
|
const char *message;
|
|
|
|
COMPQUIET(jthis_class, NULL);
|
|
message = db_strerror(ecode);
|
|
return (get_java_string(jnienv, message));
|
|
}
|
|
|
|
JAVADB_METHOD(DbEnv_set_1cachesize,
|
|
(JAVADB_ARGS, jint gbytes, jint bytes, jint ncaches), DB_ENV,
|
|
set_cachesize, (c_this, gbytes, bytes, ncaches))
|
|
|
|
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_set_1encrypt
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jstring jpasswd, jint flags)
|
|
{
|
|
int err;
|
|
DB_ENV *dbenv;
|
|
LOCKED_STRING ls_passwd;
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
if (!verify_non_null(jnienv, dbenv))
|
|
return;
|
|
if (locked_string_get(&ls_passwd, jnienv, jpasswd) != 0)
|
|
goto out;
|
|
|
|
err = dbenv->set_encrypt(dbenv, ls_passwd.string, flags);
|
|
verify_return(jnienv, err, 0);
|
|
|
|
out: locked_string_put(&ls_passwd, jnienv);
|
|
}
|
|
|
|
JAVADB_METHOD(DbEnv_set_1flags,
|
|
(JAVADB_ARGS, jint flags, jboolean onoff), DB_ENV,
|
|
set_flags, (c_this, flags, onoff ? 1 : 0))
|
|
|
|
JAVADB_METHOD(DbEnv_set_1mp_1mmapsize, (JAVADB_ARGS, jlong value), DB_ENV,
|
|
set_mp_mmapsize, (c_this, (size_t)value))
|
|
|
|
JAVADB_METHOD(DbEnv_set_1tas_1spins, (JAVADB_ARGS, jint spins), DB_ENV,
|
|
set_tas_spins, (c_this, (u_int32_t)spins))
|
|
|
|
JAVADB_METHOD(DbEnv_set_1timeout,
|
|
(JAVADB_ARGS, jlong timeout, jint flags), DB_ENV,
|
|
set_timeout, (c_this, (u_int32_t)timeout, flags))
|
|
|
|
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_set_1lk_1conflicts
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jobjectArray array)
|
|
{
|
|
DB_ENV *dbenv;
|
|
DB_ENV_JAVAINFO *dbenvinfo;
|
|
int err;
|
|
jsize i, len;
|
|
u_char *newarr;
|
|
int bytesize;
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
dbenvinfo = get_DB_ENV_JAVAINFO(jnienv, jthis);
|
|
if (!verify_non_null(jnienv, dbenv) ||
|
|
!verify_non_null(jnienv, dbenvinfo))
|
|
return;
|
|
|
|
len = (*jnienv)->GetArrayLength(jnienv, array);
|
|
bytesize = sizeof(u_char) * len * len;
|
|
|
|
if ((err = __os_malloc(dbenv, bytesize, &newarr)) != 0) {
|
|
if (!verify_return(jnienv, err, 0))
|
|
return;
|
|
}
|
|
|
|
for (i=0; i<len; i++) {
|
|
jobject subArray =
|
|
(*jnienv)->GetObjectArrayElement(jnienv, array, i);
|
|
(*jnienv)->GetByteArrayRegion(jnienv, (jbyteArray)subArray,
|
|
0, len,
|
|
(jbyte *)&newarr[i*len]);
|
|
}
|
|
dbjie_set_conflict(dbenvinfo, newarr, bytesize);
|
|
err = dbenv->set_lk_conflicts(dbenv, newarr, len);
|
|
verify_return(jnienv, err, 0);
|
|
}
|
|
|
|
JNIEXPORT jint JNICALL
|
|
Java_com_sleepycat_db_DbEnv_rep_1elect
|
|
(JNIEnv *jnienv, /* DbEnv */ jobject jthis, jint nsites, jint pri,
|
|
jint timeout)
|
|
{
|
|
DB_ENV *dbenv;
|
|
int err, id;
|
|
|
|
if (!verify_non_null(jnienv, jthis))
|
|
return (DB_EID_INVALID);
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
|
|
err = dbenv->rep_elect(dbenv, (int)nsites,
|
|
(int)pri, (u_int32_t)timeout, &id);
|
|
verify_return(jnienv, err, 0);
|
|
|
|
return ((jint)id);
|
|
}
|
|
|
|
JNIEXPORT jint JNICALL
|
|
Java_com_sleepycat_db_DbEnv_rep_1process_1message
|
|
(JNIEnv *jnienv, /* DbEnv */ jobject jthis, /* Dbt */ jobject control,
|
|
/* Dbt */ jobject rec, /* RepProcessMessage */ jobject result)
|
|
{
|
|
DB_ENV *dbenv;
|
|
LOCKED_DBT cdbt, rdbt;
|
|
int err, envid;
|
|
|
|
if (!verify_non_null(jnienv, jthis) || !verify_non_null(jnienv, result))
|
|
return (-1);
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
err = 0;
|
|
|
|
/* The DBTs are always inputs. */
|
|
if (locked_dbt_get(&cdbt, jnienv, dbenv, control, inOp) != 0)
|
|
goto out2;
|
|
if (locked_dbt_get(&rdbt, jnienv, dbenv, rec, inOp) != 0)
|
|
goto out1;
|
|
|
|
envid = (*jnienv)->GetIntField(jnienv,
|
|
result, fid_RepProcessMessage_envid);
|
|
|
|
err = dbenv->rep_process_message(dbenv, &cdbt.javainfo->dbt,
|
|
&rdbt.javainfo->dbt, &envid);
|
|
|
|
if (err == DB_REP_NEWMASTER)
|
|
(*jnienv)->SetIntField(jnienv,
|
|
result, fid_RepProcessMessage_envid, envid);
|
|
else if (!DB_RETOK_REPPMSG(err))
|
|
verify_return(jnienv, err, 0);
|
|
|
|
out1: locked_dbt_put(&rdbt, jnienv, dbenv);
|
|
out2: locked_dbt_put(&cdbt, jnienv, dbenv);
|
|
|
|
return (err);
|
|
}
|
|
|
|
JNIEXPORT void JNICALL
|
|
Java_com_sleepycat_db_DbEnv_rep_1start
|
|
(JNIEnv *jnienv, /* DbEnv */ jobject jthis, /* Dbt */ jobject cookie,
|
|
jint flags)
|
|
{
|
|
DB_ENV *dbenv;
|
|
DBT *dbtp;
|
|
LOCKED_DBT ldbt;
|
|
int err;
|
|
|
|
if (!verify_non_null(jnienv, jthis))
|
|
return;
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
|
|
/* The Dbt cookie may be null; if so, pass in a NULL DBT. */
|
|
if (cookie != NULL) {
|
|
if (locked_dbt_get(&ldbt, jnienv, dbenv, cookie, inOp) != 0)
|
|
goto out;
|
|
dbtp = &ldbt.javainfo->dbt;
|
|
} else
|
|
dbtp = NULL;
|
|
|
|
err = dbenv->rep_start(dbenv, dbtp, flags);
|
|
verify_return(jnienv, err, 0);
|
|
|
|
out: if (cookie != NULL)
|
|
locked_dbt_put(&ldbt, jnienv, dbenv);
|
|
}
|
|
|
|
JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_rep_1stat
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint flags)
|
|
{
|
|
int err;
|
|
DB_ENV *dbenv = get_DB_ENV(jnienv, jthis);
|
|
DB_REP_STAT *statp = NULL;
|
|
jobject retval = NULL;
|
|
jclass dbclass;
|
|
|
|
if (!verify_non_null(jnienv, dbenv))
|
|
return (NULL);
|
|
|
|
err = dbenv->rep_stat(dbenv, &statp, (u_int32_t)flags);
|
|
if (verify_return(jnienv, err, 0)) {
|
|
if ((dbclass = get_class(jnienv, name_DB_REP_STAT)) == NULL ||
|
|
(retval =
|
|
create_default_object(jnienv, name_DB_REP_STAT)) == NULL)
|
|
goto err; /* An exception has been posted. */
|
|
|
|
__jv_fill_rep_stat(jnienv, dbclass, retval, statp);
|
|
|
|
err: __os_ufree(dbenv, statp);
|
|
}
|
|
return (retval);
|
|
}
|
|
|
|
JNIEXPORT void JNICALL
|
|
Java_com_sleepycat_db_DbEnv_set_1rep_1limit
|
|
(JNIEnv *jnienv, /* DbEnv */ jobject jthis, jint gbytes, jint bytes)
|
|
{
|
|
DB_ENV *dbenv;
|
|
int err;
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
|
|
if (verify_non_null(jnienv, dbenv)) {
|
|
err = dbenv->set_rep_limit(dbenv,
|
|
(u_int32_t)gbytes, (u_int32_t)bytes);
|
|
verify_return(jnienv, err, 0);
|
|
}
|
|
}
|
|
|
|
JNIEXPORT void JNICALL
|
|
Java_com_sleepycat_db_DbEnv_rep_1transport_1changed
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint envid,
|
|
/* DbRepTransport */ jobject jreptransport)
|
|
{
|
|
DB_ENV *dbenv;
|
|
DB_ENV_JAVAINFO *dbenvinfo;
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
dbenvinfo = get_DB_ENV_JAVAINFO(jnienv, jthis);
|
|
if (!verify_non_null(jnienv, dbenv) ||
|
|
!verify_non_null(jnienv, dbenvinfo) ||
|
|
!verify_non_null(jnienv, jreptransport))
|
|
return;
|
|
|
|
dbjie_set_rep_transport_object(dbenvinfo,
|
|
jnienv, dbenv, envid, jreptransport);
|
|
}
|
|
|
|
JNIEXPORT void JNICALL
|
|
Java_com_sleepycat_db_DbEnv_set_1rpc_1server
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, /*DbClient*/ jobject jclient,
|
|
jstring jhost, jlong tsec, jlong ssec, jint flags)
|
|
{
|
|
int err;
|
|
DB_ENV *dbenv = get_DB_ENV(jnienv, jthis);
|
|
const char *host = (*jnienv)->GetStringUTFChars(jnienv, jhost, NULL);
|
|
|
|
if (jclient != NULL) {
|
|
report_exception(jnienv, "DbEnv.set_rpc_server client arg "
|
|
"must be null; reserved for future use",
|
|
EINVAL, 0);
|
|
return;
|
|
}
|
|
if (verify_non_null(jnienv, dbenv)) {
|
|
err = dbenv->set_rpc_server(dbenv, NULL, host,
|
|
(long)tsec, (long)ssec, flags);
|
|
|
|
/* Throw an exception if the call failed. */
|
|
verify_return(jnienv, err, 0);
|
|
}
|
|
}
|
|
|
|
JAVADB_METHOD(DbEnv_set_1shm_1key, (JAVADB_ARGS, jlong shm_key), DB_ENV,
|
|
set_shm_key, (c_this, (long)shm_key))
|
|
|
|
JNIEXPORT void JNICALL
|
|
Java_com_sleepycat_db_DbEnv__1set_1tx_1timestamp
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jlong seconds)
|
|
{
|
|
int err;
|
|
DB_ENV *dbenv = get_DB_ENV(jnienv, jthis);
|
|
time_t time = seconds;
|
|
|
|
if (verify_non_null(jnienv, dbenv)) {
|
|
err = dbenv->set_tx_timestamp(dbenv, &time);
|
|
|
|
/* Throw an exception if the call failed. */
|
|
verify_return(jnienv, err, 0);
|
|
}
|
|
}
|
|
|
|
JAVADB_METHOD(DbEnv_set_1verbose,
|
|
(JAVADB_ARGS, jint which, jboolean onoff), DB_ENV,
|
|
set_verbose, (c_this, which, onoff ? 1 : 0))
|
|
|
|
/*static*/
|
|
JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbEnv_get_1version_1major
|
|
(JNIEnv * jnienv, jclass this_class)
|
|
{
|
|
COMPQUIET(jnienv, NULL);
|
|
COMPQUIET(this_class, NULL);
|
|
|
|
return (DB_VERSION_MAJOR);
|
|
}
|
|
|
|
/*static*/
|
|
JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbEnv_get_1version_1minor
|
|
(JNIEnv * jnienv, jclass this_class)
|
|
{
|
|
COMPQUIET(jnienv, NULL);
|
|
COMPQUIET(this_class, NULL);
|
|
|
|
return (DB_VERSION_MINOR);
|
|
}
|
|
|
|
/*static*/
|
|
JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbEnv_get_1version_1patch
|
|
(JNIEnv * jnienv, jclass this_class)
|
|
{
|
|
COMPQUIET(jnienv, NULL);
|
|
COMPQUIET(this_class, NULL);
|
|
|
|
return (DB_VERSION_PATCH);
|
|
}
|
|
|
|
/*static*/
|
|
JNIEXPORT jstring JNICALL Java_com_sleepycat_db_DbEnv_get_1version_1string
|
|
(JNIEnv *jnienv, jclass this_class)
|
|
{
|
|
COMPQUIET(this_class, NULL);
|
|
|
|
return ((*jnienv)->NewStringUTF(jnienv, DB_VERSION_STRING));
|
|
}
|
|
|
|
JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbEnv_lock_1id
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis)
|
|
{
|
|
int err;
|
|
u_int32_t id;
|
|
DB_ENV *dbenv = get_DB_ENV(jnienv, jthis);
|
|
|
|
if (!verify_non_null(jnienv, dbenv))
|
|
return (-1);
|
|
err = dbenv->lock_id(dbenv, &id);
|
|
verify_return(jnienv, err, 0);
|
|
return (id);
|
|
}
|
|
|
|
JAVADB_METHOD(DbEnv_lock_1id_1free, (JAVADB_ARGS, jint id), DB_ENV,
|
|
lock_id_free, (c_this, id))
|
|
|
|
JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_lock_1stat
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint flags)
|
|
{
|
|
int err;
|
|
DB_ENV *dbenv = get_DB_ENV(jnienv, jthis);
|
|
DB_LOCK_STAT *statp = NULL;
|
|
jobject retval = NULL;
|
|
jclass dbclass;
|
|
|
|
if (!verify_non_null(jnienv, dbenv))
|
|
return (NULL);
|
|
|
|
err = dbenv->lock_stat(dbenv, &statp, (u_int32_t)flags);
|
|
if (verify_return(jnienv, err, 0)) {
|
|
if ((dbclass = get_class(jnienv, name_DB_LOCK_STAT)) == NULL ||
|
|
(retval =
|
|
create_default_object(jnienv, name_DB_LOCK_STAT)) == NULL)
|
|
goto err; /* An exception has been posted. */
|
|
|
|
__jv_fill_lock_stat(jnienv, dbclass, retval, statp);
|
|
|
|
err: __os_ufree(dbenv, statp);
|
|
}
|
|
return (retval);
|
|
}
|
|
|
|
JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbEnv_lock_1detect
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint atype, jint flags)
|
|
{
|
|
int err;
|
|
DB_ENV *dbenv = get_DB_ENV(jnienv, jthis);
|
|
int aborted;
|
|
|
|
if (!verify_non_null(jnienv, dbenv))
|
|
return (0);
|
|
err = dbenv->lock_detect(dbenv, atype, flags, &aborted);
|
|
verify_return(jnienv, err, 0);
|
|
return (aborted);
|
|
}
|
|
|
|
JNIEXPORT /*DbLock*/ jobject JNICALL Java_com_sleepycat_db_DbEnv_lock_1get
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, /*u_int32_t*/ jint locker,
|
|
jint flags, /*const Dbt*/ jobject obj, /*db_lockmode_t*/ jint lock_mode)
|
|
{
|
|
int err;
|
|
DB_ENV *dbenv;
|
|
DB_LOCK *dblock;
|
|
LOCKED_DBT lobj;
|
|
/*DbLock*/ jobject retval;
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
if (!verify_non_null(jnienv, dbenv))
|
|
return (NULL);
|
|
|
|
if ((err = __os_malloc(dbenv, sizeof(DB_LOCK), &dblock)) != 0)
|
|
if (!verify_return(jnienv, err, 0))
|
|
return (NULL);
|
|
|
|
memset(dblock, 0, sizeof(DB_LOCK));
|
|
err = 0;
|
|
retval = NULL;
|
|
if (locked_dbt_get(&lobj, jnienv, dbenv, obj, inOp) != 0)
|
|
goto out;
|
|
|
|
err = dbenv->lock_get(dbenv, locker, flags, &lobj.javainfo->dbt,
|
|
(db_lockmode_t)lock_mode, dblock);
|
|
|
|
if (err == DB_LOCK_NOTGRANTED)
|
|
report_notgranted_exception(jnienv,
|
|
"DbEnv.lock_get not granted",
|
|
DB_LOCK_GET, lock_mode, obj,
|
|
NULL, -1);
|
|
else if (verify_return(jnienv, err, 0)) {
|
|
retval = create_default_object(jnienv, name_DB_LOCK);
|
|
set_private_dbobj(jnienv, name_DB_LOCK, retval, dblock);
|
|
}
|
|
|
|
out:
|
|
locked_dbt_put(&lobj, jnienv, dbenv);
|
|
return (retval);
|
|
}
|
|
|
|
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_lock_1vec
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, /*u_int32_t*/ jint locker,
|
|
jint flags, /*const Dbt*/ jobjectArray list, jint offset, jint count)
|
|
{
|
|
DB_ENV *dbenv;
|
|
DB_LOCKREQ *lockreq;
|
|
DB_LOCKREQ *prereq; /* preprocessed requests */
|
|
DB_LOCKREQ *failedreq;
|
|
DB_LOCK *lockp;
|
|
LOCKED_DBT *locked_dbts;
|
|
int err;
|
|
int alloc_err;
|
|
int i;
|
|
size_t bytesize;
|
|
size_t ldbtsize;
|
|
jobject jlockreq;
|
|
db_lockop_t op;
|
|
jobject jobj;
|
|
jobject jlock;
|
|
int completed;
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
if (!verify_non_null(jnienv, dbenv))
|
|
goto out0;
|
|
|
|
if ((*jnienv)->GetArrayLength(jnienv, list) < offset + count) {
|
|
report_exception(jnienv,
|
|
"DbEnv.lock_vec array not large enough",
|
|
0, 0);
|
|
goto out0;
|
|
}
|
|
|
|
bytesize = sizeof(DB_LOCKREQ) * count;
|
|
if ((err = __os_malloc(dbenv, bytesize, &lockreq)) != 0) {
|
|
verify_return(jnienv, err, 0);
|
|
goto out0;
|
|
}
|
|
memset(lockreq, 0, bytesize);
|
|
|
|
ldbtsize = sizeof(LOCKED_DBT) * count;
|
|
if ((err = __os_malloc(dbenv, ldbtsize, &locked_dbts)) != 0) {
|
|
verify_return(jnienv, err, 0);
|
|
goto out1;
|
|
}
|
|
memset(lockreq, 0, ldbtsize);
|
|
prereq = &lockreq[0];
|
|
|
|
/* fill in the lockreq array */
|
|
for (i = 0, prereq = &lockreq[0]; i < count; i++, prereq++) {
|
|
jlockreq = (*jnienv)->GetObjectArrayElement(jnienv, list,
|
|
offset + i);
|
|
if (jlockreq == NULL) {
|
|
report_exception(jnienv,
|
|
"DbEnv.lock_vec list entry is null",
|
|
0, 0);
|
|
goto out2;
|
|
}
|
|
op = (*jnienv)->GetIntField(jnienv, jlockreq,
|
|
fid_DbLockRequest_op);
|
|
prereq->op = op;
|
|
|
|
switch (op) {
|
|
case DB_LOCK_GET_TIMEOUT:
|
|
/* Needed: mode, timeout, obj. Returned: lock. */
|
|
prereq->op = (*jnienv)->GetIntField(jnienv, jlockreq,
|
|
fid_DbLockRequest_timeout);
|
|
/* FALLTHROUGH */
|
|
case DB_LOCK_GET:
|
|
/* Needed: mode, obj. Returned: lock. */
|
|
prereq->mode = (*jnienv)->GetIntField(jnienv, jlockreq,
|
|
fid_DbLockRequest_mode);
|
|
jobj = (*jnienv)->GetObjectField(jnienv, jlockreq,
|
|
fid_DbLockRequest_obj);
|
|
if ((err = locked_dbt_get(&locked_dbts[i], jnienv,
|
|
dbenv, jobj, inOp)) != 0)
|
|
goto out2;
|
|
prereq->obj = &locked_dbts[i].javainfo->dbt;
|
|
break;
|
|
case DB_LOCK_PUT:
|
|
/* Needed: lock. Ignored: mode, obj. */
|
|
jlock = (*jnienv)->GetObjectField(jnienv, jlockreq,
|
|
fid_DbLockRequest_lock);
|
|
if (!verify_non_null(jnienv, jlock))
|
|
goto out2;
|
|
lockp = get_DB_LOCK(jnienv, jlock);
|
|
if (!verify_non_null(jnienv, lockp))
|
|
goto out2;
|
|
|
|
prereq->lock = *lockp;
|
|
break;
|
|
case DB_LOCK_PUT_ALL:
|
|
case DB_LOCK_TIMEOUT:
|
|
/* Needed: (none). Ignored: lock, mode, obj. */
|
|
break;
|
|
case DB_LOCK_PUT_OBJ:
|
|
/* Needed: obj. Ignored: lock, mode. */
|
|
jobj = (*jnienv)->GetObjectField(jnienv, jlockreq,
|
|
fid_DbLockRequest_obj);
|
|
if ((err = locked_dbt_get(&locked_dbts[i], jnienv,
|
|
dbenv, jobj, inOp)) != 0)
|
|
goto out2;
|
|
prereq->obj = &locked_dbts[i].javainfo->dbt;
|
|
break;
|
|
default:
|
|
report_exception(jnienv,
|
|
"DbEnv.lock_vec bad op value",
|
|
0, 0);
|
|
goto out2;
|
|
}
|
|
}
|
|
|
|
err = dbenv->lock_vec(dbenv, locker, flags, lockreq, count, &failedreq);
|
|
if (err == 0)
|
|
completed = count;
|
|
else
|
|
completed = failedreq - lockreq;
|
|
|
|
/* do post processing for any and all requests that completed */
|
|
for (i = 0; i < completed; i++) {
|
|
op = lockreq[i].op;
|
|
if (op == DB_LOCK_PUT) {
|
|
/*
|
|
* After a successful put, the DbLock can no longer
|
|
* be used, so we release the storage related to it.
|
|
*/
|
|
jlockreq = (*jnienv)->GetObjectArrayElement(jnienv,
|
|
list, i + offset);
|
|
jlock = (*jnienv)->GetObjectField(jnienv, jlockreq,
|
|
fid_DbLockRequest_lock);
|
|
lockp = get_DB_LOCK(jnienv, jlock);
|
|
__os_free(NULL, lockp);
|
|
set_private_dbobj(jnienv, name_DB_LOCK, jlock, 0);
|
|
}
|
|
else if (op == DB_LOCK_GET) {
|
|
/*
|
|
* Store the lock that was obtained.
|
|
* We need to create storage for it since
|
|
* the lockreq array only exists during this
|
|
* method call.
|
|
*/
|
|
alloc_err = __os_malloc(dbenv, sizeof(DB_LOCK), &lockp);
|
|
if (!verify_return(jnienv, alloc_err, 0))
|
|
goto out2;
|
|
|
|
*lockp = lockreq[i].lock;
|
|
|
|
jlockreq = (*jnienv)->GetObjectArrayElement(jnienv,
|
|
list, i + offset);
|
|
jlock = create_default_object(jnienv, name_DB_LOCK);
|
|
set_private_dbobj(jnienv, name_DB_LOCK, jlock, lockp);
|
|
(*jnienv)->SetObjectField(jnienv, jlockreq,
|
|
fid_DbLockRequest_lock,
|
|
jlock);
|
|
}
|
|
}
|
|
|
|
/* If one of the locks was not granted, build the exception now. */
|
|
if (err == DB_LOCK_NOTGRANTED && i < count) {
|
|
jlockreq = (*jnienv)->GetObjectArrayElement(jnienv,
|
|
list, i + offset);
|
|
jobj = (*jnienv)->GetObjectField(jnienv, jlockreq,
|
|
fid_DbLockRequest_obj);
|
|
jlock = (*jnienv)->GetObjectField(jnienv, jlockreq,
|
|
fid_DbLockRequest_lock);
|
|
report_notgranted_exception(jnienv,
|
|
"DbEnv.lock_vec incomplete",
|
|
lockreq[i].op,
|
|
lockreq[i].mode,
|
|
jobj,
|
|
jlock,
|
|
i);
|
|
}
|
|
else
|
|
verify_return(jnienv, err, 0);
|
|
|
|
out2:
|
|
/* Free the dbts that we have locked */
|
|
for (i = 0 ; i < (prereq - lockreq); i++) {
|
|
if ((op = lockreq[i].op) == DB_LOCK_GET ||
|
|
op == DB_LOCK_PUT_OBJ)
|
|
locked_dbt_put(&locked_dbts[i], jnienv, dbenv);
|
|
}
|
|
__os_free(dbenv, locked_dbts);
|
|
|
|
out1:
|
|
__os_free(dbenv, lockreq);
|
|
|
|
out0:
|
|
return;
|
|
}
|
|
|
|
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_lock_1put
|
|
(JNIEnv *jnienv, jobject jthis, /*DbLock*/ jobject jlock)
|
|
{
|
|
int err;
|
|
DB_ENV *dbenv;
|
|
DB_LOCK *dblock;
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
if (!verify_non_null(jnienv, dbenv))
|
|
return;
|
|
|
|
dblock = get_DB_LOCK(jnienv, jlock);
|
|
if (!verify_non_null(jnienv, dblock))
|
|
return;
|
|
|
|
err = dbenv->lock_put(dbenv, dblock);
|
|
if (verify_return(jnienv, err, 0)) {
|
|
/*
|
|
* After a successful put, the DbLock can no longer
|
|
* be used, so we release the storage related to it
|
|
* (allocated in DbEnv.lock_get()).
|
|
*/
|
|
__os_free(NULL, dblock);
|
|
|
|
set_private_dbobj(jnienv, name_DB_LOCK, jlock, 0);
|
|
}
|
|
}
|
|
|
|
JNIEXPORT jobjectArray JNICALL Java_com_sleepycat_db_DbEnv_log_1archive
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint flags)
|
|
{
|
|
int err, len, i;
|
|
char** ret;
|
|
jclass stringClass;
|
|
jobjectArray strarray;
|
|
DB_ENV *dbenv;
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
strarray = NULL;
|
|
if (!verify_non_null(jnienv, dbenv))
|
|
return (0);
|
|
err = dbenv->log_archive(dbenv, &ret, flags);
|
|
if (!verify_return(jnienv, err, 0))
|
|
return (0);
|
|
|
|
if (ret != NULL) {
|
|
len = 0;
|
|
while (ret[len] != NULL)
|
|
len++;
|
|
stringClass = (*jnienv)->FindClass(jnienv, "java/lang/String");
|
|
if ((strarray = (*jnienv)->NewObjectArray(jnienv,
|
|
len, stringClass, 0)) == NULL)
|
|
goto out;
|
|
for (i=0; i<len; i++) {
|
|
jstring str = (*jnienv)->NewStringUTF(jnienv, ret[i]);
|
|
(*jnienv)->SetObjectArrayElement(jnienv, strarray,
|
|
i, str);
|
|
}
|
|
}
|
|
out: return (strarray);
|
|
}
|
|
|
|
JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbEnv_log_1compare
|
|
(JNIEnv *jnienv, jclass jthis_class,
|
|
/*DbLsn*/ jobject lsn0, /*DbLsn*/ jobject lsn1)
|
|
{
|
|
DB_LSN *dblsn0;
|
|
DB_LSN *dblsn1;
|
|
|
|
COMPQUIET(jthis_class, NULL);
|
|
dblsn0 = get_DB_LSN(jnienv, lsn0);
|
|
dblsn1 = get_DB_LSN(jnienv, lsn1);
|
|
|
|
return (log_compare(dblsn0, dblsn1));
|
|
}
|
|
|
|
JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_log_1cursor
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint flags)
|
|
{
|
|
int err;
|
|
DB_LOGC *dblogc;
|
|
DB_ENV *dbenv = get_DB_ENV(jnienv, jthis);
|
|
|
|
if (!verify_non_null(jnienv, dbenv))
|
|
return (NULL);
|
|
err = dbenv->log_cursor(dbenv, &dblogc, flags);
|
|
verify_return(jnienv, err, 0);
|
|
return (get_DbLogc(jnienv, dblogc));
|
|
}
|
|
|
|
JNIEXPORT jstring JNICALL Java_com_sleepycat_db_DbEnv_log_1file
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, /*DbLsn*/ jobject lsn)
|
|
{
|
|
int err;
|
|
DB_ENV *dbenv = get_DB_ENV(jnienv, jthis);
|
|
DB_LSN *dblsn = get_DB_LSN(jnienv, lsn);
|
|
char filename[FILENAME_MAX+1] = "";
|
|
|
|
if (!verify_non_null(jnienv, dbenv))
|
|
return (NULL);
|
|
|
|
err = dbenv->log_file(dbenv, dblsn, filename, FILENAME_MAX);
|
|
verify_return(jnienv, err, 0);
|
|
filename[FILENAME_MAX] = '\0'; /* just to be sure */
|
|
return (get_java_string(jnienv, filename));
|
|
}
|
|
|
|
JAVADB_METHOD(DbEnv_log_1flush,
|
|
(JAVADB_ARGS, /*DbLsn*/ jobject lsn), DB_ENV,
|
|
log_flush, (c_this, get_DB_LSN(jnienv, lsn)))
|
|
|
|
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_log_1put
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, /*DbLsn*/ jobject lsn,
|
|
/*DbDbt*/ jobject data, jint flags)
|
|
{
|
|
int err;
|
|
DB_ENV *dbenv;
|
|
DB_LSN *dblsn;
|
|
LOCKED_DBT ldata;
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
dblsn = get_DB_LSN(jnienv, lsn);
|
|
if (!verify_non_null(jnienv, dbenv))
|
|
return;
|
|
|
|
/* log_put's DB_LSN argument may not be NULL. */
|
|
if (!verify_non_null(jnienv, dblsn))
|
|
return;
|
|
|
|
if (locked_dbt_get(&ldata, jnienv, dbenv, data, inOp) != 0)
|
|
goto out;
|
|
|
|
err = dbenv->log_put(dbenv, dblsn, &ldata.javainfo->dbt, flags);
|
|
verify_return(jnienv, err, 0);
|
|
out:
|
|
locked_dbt_put(&ldata, jnienv, dbenv);
|
|
}
|
|
|
|
JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_log_1stat
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint flags)
|
|
{
|
|
int err;
|
|
DB_ENV *dbenv;
|
|
DB_LOG_STAT *statp;
|
|
jobject retval;
|
|
jclass dbclass;
|
|
|
|
retval = NULL;
|
|
statp = NULL;
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
if (!verify_non_null(jnienv, dbenv))
|
|
return (NULL);
|
|
|
|
err = dbenv->log_stat(dbenv, &statp, (u_int32_t)flags);
|
|
if (verify_return(jnienv, err, 0)) {
|
|
if ((dbclass = get_class(jnienv, name_DB_LOG_STAT)) == NULL ||
|
|
(retval =
|
|
create_default_object(jnienv, name_DB_LOG_STAT)) == NULL)
|
|
goto err; /* An exception has been posted. */
|
|
|
|
__jv_fill_log_stat(jnienv, dbclass, retval, statp);
|
|
|
|
err: __os_ufree(dbenv, statp);
|
|
}
|
|
return (retval);
|
|
}
|
|
|
|
JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_memp_1stat
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint flags)
|
|
{
|
|
int err;
|
|
jclass dbclass;
|
|
DB_ENV *dbenv;
|
|
DB_MPOOL_STAT *statp;
|
|
jobject retval;
|
|
|
|
retval = NULL;
|
|
statp = NULL;
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
if (!verify_non_null(jnienv, dbenv))
|
|
return (NULL);
|
|
|
|
err = dbenv->memp_stat(dbenv, &statp, 0, (u_int32_t)flags);
|
|
if (verify_return(jnienv, err, 0)) {
|
|
if ((dbclass = get_class(jnienv, name_DB_MPOOL_STAT)) == NULL ||
|
|
(retval =
|
|
create_default_object(jnienv, name_DB_MPOOL_STAT)) == NULL)
|
|
goto err; /* An exception has been posted. */
|
|
|
|
__jv_fill_mpool_stat(jnienv, dbclass, retval, statp);
|
|
|
|
err: __os_ufree(dbenv, statp);
|
|
}
|
|
return (retval);
|
|
}
|
|
|
|
JNIEXPORT jobjectArray JNICALL Java_com_sleepycat_db_DbEnv_memp_1fstat
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint flags)
|
|
{
|
|
int err, i, len;
|
|
jclass fstat_class;
|
|
DB_ENV *dbenv;
|
|
DB_MPOOL_FSTAT **fstatp;
|
|
jobjectArray retval;
|
|
jfieldID filename_id;
|
|
jstring jfilename;
|
|
|
|
fstatp = NULL;
|
|
retval = NULL;
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
if (!verify_non_null(jnienv, dbenv))
|
|
return (NULL);
|
|
|
|
err = dbenv->memp_stat(dbenv, 0, &fstatp, (u_int32_t)flags);
|
|
if (verify_return(jnienv, err, 0)) {
|
|
len = 0;
|
|
while (fstatp[len] != NULL)
|
|
len++;
|
|
if ((fstat_class =
|
|
get_class(jnienv, name_DB_MPOOL_FSTAT)) == NULL ||
|
|
(retval = (*jnienv)->NewObjectArray(jnienv, len,
|
|
fstat_class, 0)) == NULL)
|
|
goto err;
|
|
for (i=0; i<len; i++) {
|
|
jobject obj;
|
|
if ((obj = create_default_object(jnienv,
|
|
name_DB_MPOOL_FSTAT)) == NULL)
|
|
goto err;
|
|
(*jnienv)->SetObjectArrayElement(jnienv, retval,
|
|
i, obj);
|
|
|
|
/* Set the string field. */
|
|
filename_id = (*jnienv)->GetFieldID(jnienv,
|
|
fstat_class, "file_name", string_signature);
|
|
jfilename = get_java_string(jnienv,
|
|
fstatp[i]->file_name);
|
|
(*jnienv)->SetObjectField(jnienv, obj,
|
|
filename_id, jfilename);
|
|
set_int_field(jnienv, fstat_class, obj,
|
|
"st_pagesize", fstatp[i]->st_pagesize);
|
|
set_int_field(jnienv, fstat_class, obj,
|
|
"st_cache_hit", fstatp[i]->st_cache_hit);
|
|
set_int_field(jnienv, fstat_class, obj,
|
|
"st_cache_miss", fstatp[i]->st_cache_miss);
|
|
set_int_field(jnienv, fstat_class, obj,
|
|
"st_map", fstatp[i]->st_map);
|
|
set_int_field(jnienv, fstat_class, obj,
|
|
"st_page_create", fstatp[i]->st_page_create);
|
|
set_int_field(jnienv, fstat_class, obj,
|
|
"st_page_in", fstatp[i]->st_page_in);
|
|
set_int_field(jnienv, fstat_class, obj,
|
|
"st_page_out", fstatp[i]->st_page_out);
|
|
__os_ufree(dbenv, fstatp[i]);
|
|
}
|
|
err: __os_ufree(dbenv, fstatp);
|
|
}
|
|
return (retval);
|
|
}
|
|
|
|
JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbEnv_memp_1trickle
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint pct)
|
|
{
|
|
int err;
|
|
DB_ENV *dbenv = get_DB_ENV(jnienv, jthis);
|
|
int result = 0;
|
|
|
|
if (verify_non_null(jnienv, dbenv)) {
|
|
err = dbenv->memp_trickle(dbenv, pct, &result);
|
|
verify_return(jnienv, err, 0);
|
|
}
|
|
return (result);
|
|
}
|
|
|
|
JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_txn_1begin
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, /*DbTxn*/ jobject pid, jint flags)
|
|
{
|
|
int err;
|
|
DB_TXN *dbpid, *result;
|
|
DB_ENV *dbenv;
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
if (!verify_non_null(jnienv, dbenv))
|
|
return (0);
|
|
|
|
dbpid = get_DB_TXN(jnienv, pid);
|
|
result = 0;
|
|
|
|
err = dbenv->txn_begin(dbenv, dbpid, &result, flags);
|
|
if (!verify_return(jnienv, err, 0))
|
|
return (0);
|
|
return (get_DbTxn(jnienv, result));
|
|
}
|
|
|
|
JAVADB_METHOD(DbEnv_txn_1checkpoint,
|
|
(JAVADB_ARGS, jint kbyte, jint min, jint flags), DB_ENV,
|
|
txn_checkpoint, (c_this, kbyte, min, flags))
|
|
|
|
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv_app_1dispatch_1changed
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, /*DbFeedback*/ jobject jappdispatch)
|
|
{
|
|
DB_ENV *dbenv;
|
|
DB_ENV_JAVAINFO *dbenvinfo;
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
dbenvinfo = get_DB_ENV_JAVAINFO(jnienv, jthis);
|
|
if (!verify_non_null(jnienv, dbenv) ||
|
|
!verify_non_null(jnienv, dbenvinfo))
|
|
return;
|
|
|
|
dbjie_set_app_dispatch_object(dbenvinfo, jnienv, dbenv, jappdispatch);
|
|
}
|
|
|
|
JNIEXPORT jobjectArray JNICALL Java_com_sleepycat_db_DbEnv_txn_1recover
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint count, jint flags)
|
|
{
|
|
int err;
|
|
DB_ENV *dbenv;
|
|
DB_PREPLIST *preps;
|
|
long retcount;
|
|
int i;
|
|
char signature[128];
|
|
size_t bytesize;
|
|
jobject retval;
|
|
jobject obj;
|
|
jobject txnobj;
|
|
jbyteArray bytearr;
|
|
jclass preplist_class;
|
|
jfieldID txn_fieldid;
|
|
jfieldID gid_fieldid;
|
|
|
|
retval = NULL;
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
if (!verify_non_null(jnienv, dbenv))
|
|
return (NULL);
|
|
|
|
/*
|
|
* We need to allocate some local storage for the
|
|
* returned preplist, and that requires us to do
|
|
* our own argument validation.
|
|
*/
|
|
if (count <= 0) {
|
|
verify_return(jnienv, EINVAL, 0);
|
|
goto out;
|
|
}
|
|
|
|
bytesize = sizeof(DB_PREPLIST) * count;
|
|
if ((err = __os_malloc(dbenv, bytesize, &preps)) != 0) {
|
|
verify_return(jnienv, err, 0);
|
|
goto out;
|
|
}
|
|
|
|
err = dbenv->txn_recover(dbenv, preps, count, &retcount, flags);
|
|
|
|
if (verify_return(jnienv, err, 0)) {
|
|
if ((preplist_class =
|
|
get_class(jnienv, name_DB_PREPLIST)) == NULL ||
|
|
(retval = (*jnienv)->NewObjectArray(jnienv, retcount,
|
|
preplist_class, 0)) == NULL)
|
|
goto err;
|
|
|
|
(void)snprintf(signature, sizeof(signature),
|
|
"L%s%s;", DB_PACKAGE_NAME, name_DB_TXN);
|
|
txn_fieldid = (*jnienv)->GetFieldID(jnienv, preplist_class,
|
|
"txn", signature);
|
|
gid_fieldid = (*jnienv)->GetFieldID(jnienv, preplist_class,
|
|
"gid", "[B");
|
|
|
|
for (i=0; i<retcount; i++) {
|
|
/*
|
|
* First, make a blank DbPreplist object
|
|
* and set the array entry.
|
|
*/
|
|
if ((obj = create_default_object(jnienv,
|
|
name_DB_PREPLIST)) == NULL)
|
|
goto err;
|
|
(*jnienv)->SetObjectArrayElement(jnienv,
|
|
retval, i, obj);
|
|
|
|
/* Set the txn field. */
|
|
txnobj = get_DbTxn(jnienv, preps[i].txn);
|
|
(*jnienv)->SetObjectField(jnienv,
|
|
obj, txn_fieldid, txnobj);
|
|
|
|
/* Build the gid array and set the field. */
|
|
if ((bytearr = (*jnienv)->NewByteArray(jnienv,
|
|
sizeof(preps[i].gid))) == NULL)
|
|
goto err;
|
|
(*jnienv)->SetByteArrayRegion(jnienv, bytearr, 0,
|
|
sizeof(preps[i].gid), (jbyte *)&preps[i].gid[0]);
|
|
(*jnienv)->SetObjectField(jnienv, obj,
|
|
gid_fieldid, bytearr);
|
|
}
|
|
}
|
|
err: __os_free(dbenv, preps);
|
|
out: return (retval);
|
|
}
|
|
|
|
JNIEXPORT jobject JNICALL Java_com_sleepycat_db_DbEnv_txn_1stat
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jint flags)
|
|
{
|
|
int err;
|
|
DB_ENV *dbenv;
|
|
DB_TXN_STAT *statp;
|
|
jobject retval, obj;
|
|
jclass dbclass, active_class;
|
|
char active_signature[512];
|
|
jfieldID arrid;
|
|
jobjectArray actives;
|
|
unsigned int i;
|
|
|
|
retval = NULL;
|
|
statp = NULL;
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
if (!verify_non_null(jnienv, dbenv))
|
|
return (NULL);
|
|
|
|
err = dbenv->txn_stat(dbenv, &statp, (u_int32_t)flags);
|
|
if (verify_return(jnienv, err, 0)) {
|
|
if ((dbclass = get_class(jnienv, name_DB_TXN_STAT)) == NULL ||
|
|
(retval =
|
|
create_default_object(jnienv, name_DB_TXN_STAT)) == NULL)
|
|
goto err;
|
|
|
|
/* Set the individual fields */
|
|
__jv_fill_txn_stat(jnienv, dbclass, retval, statp);
|
|
|
|
if ((active_class =
|
|
get_class(jnienv, name_DB_TXN_STAT_ACTIVE)) == NULL ||
|
|
(actives = (*jnienv)->NewObjectArray(jnienv,
|
|
statp->st_nactive, active_class, 0)) == NULL)
|
|
goto err;
|
|
|
|
/*
|
|
* Set the st_txnarray field. This is a little more involved
|
|
* than other fields, since the type is an array, so none
|
|
* of our utility functions help.
|
|
*/
|
|
(void)snprintf(active_signature, sizeof(active_signature),
|
|
"[L%s%s;", DB_PACKAGE_NAME, name_DB_TXN_STAT_ACTIVE);
|
|
|
|
arrid = (*jnienv)->GetFieldID(jnienv, dbclass, "st_txnarray",
|
|
active_signature);
|
|
(*jnienv)->SetObjectField(jnienv, retval, arrid, actives);
|
|
|
|
/* Now fill the in the elements of st_txnarray. */
|
|
for (i=0; i<statp->st_nactive; i++) {
|
|
obj = create_default_object(jnienv,
|
|
name_DB_TXN_STAT_ACTIVE);
|
|
(*jnienv)->SetObjectArrayElement(jnienv,
|
|
actives, i, obj);
|
|
|
|
set_int_field(jnienv, active_class, obj,
|
|
"txnid", statp->st_txnarray[i].txnid);
|
|
set_int_field(jnienv, active_class, obj, "parentid",
|
|
statp->st_txnarray[i].parentid);
|
|
set_lsn_field(jnienv, active_class, obj,
|
|
"lsn", statp->st_txnarray[i].lsn);
|
|
}
|
|
|
|
err: __os_ufree(dbenv, statp);
|
|
}
|
|
return (retval);
|
|
}
|
|
|
|
/* See discussion on errpfx, errcall in DB_ENV_JAVAINFO */
|
|
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv__1set_1errcall
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jobject errcall)
|
|
{
|
|
DB_ENV *dbenv;
|
|
DB_ENV_JAVAINFO *dbenvinfo;
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
dbenvinfo = get_DB_ENV_JAVAINFO(jnienv, jthis);
|
|
|
|
if (verify_non_null(jnienv, dbenv) &&
|
|
verify_non_null(jnienv, dbenvinfo)) {
|
|
dbjie_set_errcall(dbenvinfo, jnienv, errcall);
|
|
}
|
|
}
|
|
|
|
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv__1set_1errpfx
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis, jstring str)
|
|
{
|
|
DB_ENV *dbenv;
|
|
DB_ENV_JAVAINFO *dbenvinfo;
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
dbenvinfo = get_DB_ENV_JAVAINFO(jnienv, jthis);
|
|
|
|
if (verify_non_null(jnienv, dbenv) &&
|
|
verify_non_null(jnienv, dbenvinfo)) {
|
|
dbjie_set_errpfx(dbenvinfo, jnienv, str);
|
|
}
|
|
}
|
|
|
|
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbEnv__1finalize
|
|
(JNIEnv *jnienv, /*DbEnv*/ jobject jthis,
|
|
jobject /*DbErrcall*/ errcall, jstring errpfx)
|
|
{
|
|
DB_ENV *dbenv;
|
|
DB_ENV_JAVAINFO *envinfo;
|
|
|
|
dbenv = get_DB_ENV(jnienv, jthis);
|
|
envinfo = get_DB_ENV_JAVAINFO(jnienv, jthis);
|
|
DB_ASSERT(envinfo != NULL);
|
|
|
|
/* Note: We detect and report unclosed DbEnvs. */
|
|
if (dbenv != NULL && envinfo != NULL && !dbjie_is_dbopen(envinfo)) {
|
|
|
|
/* If this error occurs, this object was never closed. */
|
|
report_errcall(jnienv, errcall, errpfx,
|
|
"DbEnv.finalize: open DbEnv object destroyed");
|
|
}
|
|
|
|
/* Shouldn't see this object again, but just in case */
|
|
set_private_dbobj(jnienv, name_DB_ENV, jthis, 0);
|
|
set_private_info(jnienv, name_DB_ENV, jthis, 0);
|
|
|
|
dbjie_destroy(envinfo, jnienv);
|
|
}
|