Class: Bdb::Env
Overview
Encapsulated DB environment. Create by simple new (with flags as neede), then open. Database handles created with env.db -> Bdb::Db object.
Class Method Summary collapse
-
.new(vflags) ⇒ Object
new(flags) -> object.
Instance Method Summary collapse
-
#cachesize ⇒ Object
env.cachesize -> Fixnum|Bignum.
-
#cachesize=(size) ⇒ Object
env.cachesize=Fixnum|Bignum.
-
#close ⇒ Object
env.close -> self.
-
#data_dir=(vdata_dir) ⇒ Object
env.set_data_dir(data_dir) -> data_dir.
-
#data_dirs ⇒ Object
env.get_data_dir -> [data_dir_1, data_dir_2, …].
-
#db ⇒ Object
env.db -> Bdb::Db instance.
-
#flags ⇒ Object
env.flags -> flags.
-
#flags_off=(vflags) ⇒ Object
env.flags_off=flags.
-
#flags_on=(vflags) ⇒ Object
env.flags_on=flags.
-
#home ⇒ Object
env.get_home -> home.
- #lg_bsize ⇒ Object
- #lg_bsize=(size) ⇒ Object
-
#lg_dir ⇒ Object
env.get_lg_dir -> lg_dir.
-
#lg_dir=(vlg_dir) ⇒ Object
env.set_lg_dir(lg_dir) -> lg_dir.
- #lg_max ⇒ Object
- #lg_max=(size) ⇒ Object
- #lg_regionmax ⇒ Object
- #lg_regionmax=(size) ⇒ Object
-
#list_dbs ⇒ Object
env.list_dbs -> [Bdb::Db array].
-
#lk_detect ⇒ Object
env.get_lk_detect() -> detect.
-
#lk_detect=(vdetect) ⇒ Object
env.set_lk_detect(detect) -> detect.
-
#lk_max_locks ⇒ Object
env.get_lk_max_locks -> max.
-
#lk_max_locks=(vmax) ⇒ Object
env.set_lk_max_locks(max) -> max.
-
#lk_max_objects ⇒ Object
env.get_lk_max_objects -> max.
-
#lk_max_objects=(vmax) ⇒ Object
env.set_lk_max_objects(max) -> max.
- #log_config(flags, onoff) ⇒ Object
-
#mutex_get_max ⇒ Object
call-seq env.mutex_get_max -> Fixnum.
-
#mutex_set_max(vmax) ⇒ Object
env.mutex_set_max(max) -> max.
-
#open(vhome, vflags, vmode) ⇒ Object
env.open(homedir,flags,mode) -> self.
-
#rep_nsites ⇒ Object
env.rep_nsites -> int.
-
#rep_nsites=(nsites) ⇒ Object
env.rep_nsites = int.
-
#rep_priority ⇒ Object
env.rep_priority -> int.
-
#rep_priority=(priority) ⇒ Object
env.rep_priority = int.
-
#repmgr_ack_policy ⇒ Object
env.repmgr_ack_policy -> int.
-
#repmgr_ack_policy=(policy) ⇒ Object
env.repmgr_ack_policy = int.
-
#repmgr_add_remote_site(host, port) ⇒ Object
env.repmgr_add_remote_site(host, port).
-
#repmgr_set_local_site(host, port) ⇒ Object
env.repmgr_set_local_site(host, port).
-
#repmgr_start(num_threads, flags) ⇒ Object
env.repmgr_start(num_threads, flags).
-
#repmgr_stat_print(flags) ⇒ Object
env.repmgr_stat_print.
- #report_stderr ⇒ Object
-
#set_verbose(which, onoff) ⇒ Object
env.set_verbose(which, onoff).
-
#shm_key ⇒ Object
call-seq env.get_shm_key -> Fixnum.
-
#shm_key=(vkey) ⇒ Object
env.set_shm_key(key) -> max.
-
#timeout(vflags) ⇒ Object
env.get_timeout(flags) -> Fixnum.
-
#tmp_dir ⇒ Object
env.get_tmp_dir -> tmp_dir.
-
#tmp_dir=(vtmp_dir) ⇒ Object
env.set_tmp_dir(tmp_dir) -> tmp_dir.
-
#tx_max ⇒ Object
call-seq env.get_tx_max -> Fixnum.
-
#tx_max=(vmax) ⇒ Object
env.set_tx_max(max) -> max.
-
#txn_begin(vtxn_parent, vflags) ⇒ Object
env.txn_begin(txn_parent,flags) -> Bdb::Txn.
-
#txn_checkpoint(vkbyte, vmin, vflags) ⇒ Object
env.txn_checkpoint -> true.
-
#txn_stat(vflags) ⇒ Object
env.txn_stat -> Bdb::TxnStat.
Class Method Details
.new(vflags) ⇒ Object
new(flags) -> object
1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 |
# File 'ext/bdb.c', line 1654
VALUE env_new(VALUE class, VALUE vflags)
{
t_envh *eh;
int rv;
u_int32_t flags=0;
VALUE obj;
if ( ! NIL_P(vflags) )
flags=NUM2UINT(vflags);
obj=Data_Make_Struct(class,t_envh,env_mark,env_free,eh);
rv=db_env_create(&(eh->env),flags);
if ( rv != 0 ) {
raise_error(rv,"env_new: %s",db_strerror(rv));
return Qnil;
}
eh->self=obj;
eh->adb = rb_ary_new();
eh->atxn = rb_ary_new();
rb_obj_call_init(obj,0,NULL);
return obj;
}
|
Instance Method Details
#cachesize ⇒ Object
env.cachesize -> Fixnum|Bignum
return the environment cache size. If it is a Bignum then it will populate the bytes and gbytes part of the DB struct. Fixnums will only populate bytes (which is still pretty big).
1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 |
# File 'ext/bdb.c', line 1834
VALUE env_get_cachesize(VALUE obj)
{
t_envh *eh;
//unsigned long long ln;
u_int32_t bytes=0,gbytes=0;
int ncache;
int rv;
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
rv=eh->env->get_cachesize(eh->env,&gbytes,&bytes,&ncache);
if ( rv != 0 ) {
raise_error(rv, "get_cachesize failure: %s",db_strerror(rv));
return Qnil;
}
if (gbytes != 0)
return ULL2NUM(gbytes*1024*1024*1024+bytes);
else
return UINT2NUM(bytes);
return Qtrue;
}
|
#cachesize=(size) ⇒ Object
env.cachesize=Fixnum|Bignum
set the environment cache size. If it is a Bignum then it will populate the bytes and gbytes part of the DB struct. Fixnums will only populate bytes (which is still pretty big).
1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 |
# File 'ext/bdb.c', line 1796
VALUE env_set_cachesize(VALUE obj, VALUE size)
{
t_envh *eh;
unsigned long long ln;
u_int32_t bytes=0,gbytes=0;
int rv;
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
if ( TYPE(size) == T_BIGNUM ) {
ln = rb_big2ull(size);
gbytes = ln / (1024*1024*1024);
bytes = ln - (gbytes*1024*1024*1024);
} else if (FIXNUM_P(size) ) {
bytes=NUM2UINT(size);
} else {
raise_error(0,"set_cachesize requires number");
return Qnil;
}
rv=eh->env->set_cachesize(eh->env,gbytes,bytes,1);
if ( rv != 0 ) {
raise_error(rv, "set_cachesize failure: %s",db_strerror(rv));
return Qnil;
}
return Qtrue;
}
|
#close ⇒ Object
env.close -> self
close an environment. Do not use it after you close it. The close process will automatically abort any open transactions and close open databases (which also closes open cursors). But this is just an effort to keep your dbs and envs from becoming corrupted due to ruby errors that exit unintentionally. However, to make this at all worth anything use ObjectSpace.define_finalizer which calls env.close to approach some assurance of it happening.
1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 |
# File 'ext/bdb.c', line 1725
VALUE env_close(VALUE obj)
{
t_envh *eh;
VALUE db;
int rv;
Data_Get_Struct(obj,t_envh,eh);
if ( eh->env==NULL )
return Qnil;
if (RARRAY_LEN(eh->adb) > 0) {
rb_warning("%s/%d %s %li",__FILE__,__LINE__,
"database handles still open",RARRAY_LEN(eh->adb));
while (RARRAY_LEN(eh->adb) > 0)
if ((db=rb_ary_pop(eh->adb)) != Qnil ) {
rb_warning("%s/%d %s 0x%p",__FILE__,__LINE__,
"closing",(void*)db);
/* this could raise! needs rb_protect */
db_close(db,INT2FIX(0));
}
}
if (RARRAY_LEN(eh->atxn) > 0) {
rb_warning("%s/%d %s",__FILE__,__LINE__,
"database transactions still open");
while ( (db=rb_ary_pop(eh->atxn)) != Qnil ) {
/* this could raise! needs rb_protect */
txn_abort(db);
}
}
if ( RTEST(ruby_debug) )
rb_warning("%s/%d %s 0x%p",__FILE__,__LINE__,"env_close!",(void*)eh);
rv = eh->env->close(eh->env,NOFLAGS);
eh->env=NULL;
eh->adb=Qnil;
eh->atxn=Qnil;
if ( rv != 0 ) {
raise_error(rv, "env_close failure: %s",db_strerror(rv));
return Qnil;
}
return obj;
}
|
#data_dir=(vdata_dir) ⇒ Object
env.set_data_dir(data_dir) -> data_dir
set data_dir
2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 |
# File 'ext/bdb.c', line 2688
VALUE env_set_data_dir(VALUE obj, VALUE vdata_dir)
{
t_envh *eh;
const char *data_dir;
int rv;
data_dir=StringValueCStr(vdata_dir);
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
rv=eh->env->set_data_dir(eh->env,data_dir);
if ( rv != 0 ) {
raise_error(rv, "env_set_data_dir: %s",db_strerror(rv));
}
return vdata_dir;
}
|
#data_dirs ⇒ Object
env.get_data_dir -> [data_dir_1, data_dir_2, …]
get data_dir
2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 |
# File 'ext/bdb.c', line 2713
VALUE env_get_data_dirs(VALUE obj)
{
t_envh *eh;
const char **data_dirs;
int rv;
int ln;
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
rv=eh->env->get_data_dirs(eh->env,&data_dirs);
if ( rv != 0 ) {
raise_error(rv, "env_get_data_dir: %s",db_strerror(rv));
}
ln = (sizeof (data_dirs))/sizeof(data_dirs[0]);
VALUE rb_data_dirs = rb_ary_new2(ln);
int i;
for (i=0; i<ln; i++) {
rb_ary_push(rb_data_dirs, rb_str_new2(data_dirs[i]));
}
return rb_data_dirs;
}
|
#db ⇒ Object
env.db -> Bdb::Db instance
create a db associated with an environment
1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 |
# File 'ext/bdb.c', line 1775
VALUE env_db(VALUE obj)
{
t_envh *eh;
VALUE dbo;
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
dbo = Data_Wrap_Struct(cDb,db_mark,db_free,0);
return db_init_aux(dbo,eh);
}
|
#flags ⇒ Object
env.flags -> flags
get what flags are on.
1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 |
# File 'ext/bdb.c', line 1887
VALUE env_get_flags(VALUE obj)
{
t_envh *eh;
int rv;
u_int32_t flags;
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
rv=eh->env->get_flags(eh->env,&flags);
if ( rv != 0 ) {
raise_error(rv, "set_flags failure: %s",db_strerror(rv));
return Qnil;
}
return UINT2NUM(flags);
}
|
#flags_off=(vflags) ⇒ Object
env.flags_off=flags
set the ‘flags’ off. An or’ed set of flags will be set off. Only included flags will be affected. Serialized calls will only affect flags indicated (leaving others, default or set as they were).
1930 1931 1932 1933 |
# File 'ext/bdb.c', line 1930
VALUE env_set_flags_off(VALUE obj, VALUE vflags)
{
return env_set_flags(obj,vflags,0);
}
|
#flags_on=(vflags) ⇒ Object
env.flags_on=flags
set the ‘flags’ on. An or’ed set of flags will be set on. Only included flags will be affected. Serialized calls will only affect flags indicated (leaving others, default or set as they were).
1916 1917 1918 1919 |
# File 'ext/bdb.c', line 1916
VALUE env_set_flags_on(VALUE obj, VALUE vflags)
{
return env_set_flags(obj,vflags,1);
}
|
#home ⇒ Object
env.get_home -> home
get home
2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 |
# File 'ext/bdb.c', line 2840
VALUE env_get_home(VALUE obj)
{
t_envh *eh;
const char *home;
int rv;
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
rv=eh->env->get_home(eh->env,&home);
if ( rv != 0 ) {
raise_error(rv, "env_get_home: %s",db_strerror(rv));
}
return rb_str_new2(home);
}
|
#lg_bsize ⇒ Object
3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 |
# File 'ext/bdb.c', line 3065
VALUE env_get_lg_bsize( VALUE obj) {
t_envh *eh;
int rv;
u_int32_t size;
Data_Get_Struct( obj, t_envh, eh);
rv = eh->env->get_lg_bsize( eh->env, &size);
if ( rv != 0 )
raise_error(rv, "env_get_lg_bsize: %s", db_strerror(rv));
return UINT2FIX(size);
}
|
#lg_bsize=(size) ⇒ Object
3055 3056 3057 3058 3059 3060 3061 3062 3063 |
# File 'ext/bdb.c', line 3055
VALUE env_set_lg_bsize( VALUE obj, VALUE size) {
t_envh *eh;
int rv;
Data_Get_Struct(obj, t_envh, eh);
rv = eh->env->set_lg_bsize( eh->env, NUM2UINT( size));
if ( rv != 0 )
raise_error(rv, "env_set_lg_bsize: %s", db_strerror(rv));
return size;
}
|
#lg_dir ⇒ Object
env.get_lg_dir -> lg_dir
get lg_dir
2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 |
# File 'ext/bdb.c', line 2769
VALUE env_get_lg_dir(VALUE obj)
{
t_envh *eh;
const char *lg_dir;
int rv;
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
rv=eh->env->get_lg_dir(eh->env,&lg_dir);
if ( rv != 0 ) {
raise_error(rv, "env_get_lg_dir: %s",db_strerror(rv));
}
return rb_str_new2(lg_dir);
}
|
#lg_dir=(vlg_dir) ⇒ Object
env.set_lg_dir(lg_dir) -> lg_dir
set lg_dir
2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 |
# File 'ext/bdb.c', line 2744
VALUE env_set_lg_dir(VALUE obj, VALUE vlg_dir)
{
t_envh *eh;
const char *lg_dir;
int rv;
lg_dir=StringValueCStr(vlg_dir);
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
rv=eh->env->set_lg_dir(eh->env,lg_dir);
if ( rv != 0 ) {
raise_error(rv, "env_set_lg_dir: %s",db_strerror(rv));
}
return vlg_dir;
}
|
#lg_max ⇒ Object
3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 |
# File 'ext/bdb.c', line 3086
VALUE env_get_lg_max( VALUE obj) {
t_envh *eh;
int rv;
u_int32_t size;
Data_Get_Struct( obj, t_envh, eh);
rv = eh->env->get_lg_max( eh->env, &size);
if ( rv != 0 )
raise_error(rv, "env_get_lg_max: %s", db_strerror(rv));
return UINT2FIX(size);
}
|
#lg_max=(size) ⇒ Object
3076 3077 3078 3079 3080 3081 3082 3083 3084 |
# File 'ext/bdb.c', line 3076
VALUE env_set_lg_max( VALUE obj, VALUE size) {
t_envh *eh;
int rv;
Data_Get_Struct(obj, t_envh, eh);
rv = eh->env->set_lg_max( eh->env, NUM2UINT( size));
if ( rv != 0 )
raise_error(rv, "env_set_lg_max: %s", db_strerror(rv));
return size;
}
|
#lg_regionmax ⇒ Object
3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 |
# File 'ext/bdb.c', line 3107
VALUE env_get_lg_regionmax( VALUE obj) {
t_envh *eh;
int rv;
u_int32_t size;
Data_Get_Struct( obj, t_envh, eh);
rv = eh->env->get_lg_regionmax( eh->env, &size);
if ( rv != 0 )
raise_error(rv, "env_get_lg_regionmax: %s", db_strerror(rv));
return UINT2FIX(size);
}
|
#lg_regionmax=(size) ⇒ Object
3097 3098 3099 3100 3101 3102 3103 3104 3105 |
# File 'ext/bdb.c', line 3097
VALUE env_set_lg_regionmax( VALUE obj, VALUE size) {
t_envh *eh;
int rv;
Data_Get_Struct(obj, t_envh, eh);
rv = eh->env->set_lg_regionmax( eh->env, NUM2UINT( size));
if ( rv != 0 )
raise_error(rv, "env_set_lg_regionmax: %s", db_strerror(rv));
return size;
}
|
#list_dbs ⇒ Object
env.list_dbs -> [Bdb::Db array]
return 0 or more open databases within the receiver environment. If 0, will return [], not nil.
1942 1943 1944 1945 1946 1947 1948 1949 |
# File 'ext/bdb.c', line 1942
VALUE env_list_dbs(VALUE obj)
{
t_envh *eh;
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
return eh->adb;
}
|
#lk_detect ⇒ Object
env.get_lk_detect() -> detect
Get when lock detector should be run
2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 |
# File 'ext/bdb.c', line 2555
VALUE env_get_lk_detect(VALUE obj)
{
t_envh *eh;
u_int32_t detect;
int rv;
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
rv=eh->env->get_lk_detect(eh->env,&detect);
if ( rv != 0 ) {
raise_error(rv, "env_set_lk_detect: %s",db_strerror(rv));
}
return UINT2NUM(detect);
}
|
#lk_detect=(vdetect) ⇒ Object
env.set_lk_detect(detect) -> detect
Set when lock detector should be run
2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 |
# File 'ext/bdb.c', line 2530
VALUE env_set_lk_detect(VALUE obj, VALUE vdetect)
{
t_envh *eh;
u_int32_t detect;
int rv;
detect=NUM2UINT(vdetect);
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
rv=eh->env->set_lk_detect(eh->env,detect);
if ( rv != 0 ) {
raise_error(rv, "env_set_lk_detect: %s",db_strerror(rv));
}
return vdetect;
}
|
#lk_max_locks ⇒ Object
env.get_lk_max_locks -> max
Get the maximum number of locks in the environment
2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 |
# File 'ext/bdb.c', line 2603
VALUE env_get_lk_max_locks(VALUE obj)
{
t_envh *eh;
u_int32_t max;
int rv;
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
rv=eh->env->get_lk_max_locks(eh->env,&max);
if ( rv != 0 ) {
raise_error(rv, "env_get_lk_max_locks: %s",db_strerror(rv));
}
return UINT2NUM(max);
}
|
#lk_max_locks=(vmax) ⇒ Object
env.set_lk_max_locks(max) -> max
Set the maximum number of locks in the environment
2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 |
# File 'ext/bdb.c', line 2578
VALUE env_set_lk_max_locks(VALUE obj, VALUE vmax)
{
t_envh *eh;
u_int32_t max;
int rv;
max=FIX2UINT(vmax);
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
rv=eh->env->set_lk_max_locks(eh->env,max);
if ( rv != 0 ) {
raise_error(rv, "env_set_lk_max_locks: %s",db_strerror(rv));
}
return vmax;
}
|
#lk_max_objects ⇒ Object
env.get_lk_max_objects -> max
Get the maximum number of locks in the environment
2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 |
# File 'ext/bdb.c', line 2651
VALUE env_get_lk_max_objects(VALUE obj)
{
t_envh *eh;
u_int32_t max;
int rv;
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
rv=eh->env->get_lk_max_objects(eh->env,&max);
if ( rv != 0 ) {
raise_error(rv, "env_get_lk_max_objects: %s",db_strerror(rv));
}
return UINT2NUM(max);
}
|
#lk_max_objects=(vmax) ⇒ Object
env.set_lk_max_objects(max) -> max
Set the maximum number of locks in the environment
2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 |
# File 'ext/bdb.c', line 2626
VALUE env_set_lk_max_objects(VALUE obj, VALUE vmax)
{
t_envh *eh;
u_int32_t max;
int rv;
max=FIX2UINT(vmax);
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
rv=eh->env->set_lk_max_objects(eh->env,max);
if ( rv != 0 ) {
raise_error(rv, "env_set_lk_max_objects: %s",db_strerror(rv));
}
return vmax;
}
|
#log_config(flags, onoff) ⇒ Object
2518 2519 2520 2521 2522 |
# File 'ext/bdb.c', line 2518
ENV_LOG_CONFIG_FUNCS
VALUE env_log_set_config( VALUE obj, VALUE flags, VALUE onoff) {
return env_log_set_config_h( obj, NUM2UINT(flags), onoff);
}
|
#mutex_get_max ⇒ Object
call-seq env.mutex_get_max -> Fixnum
Get current maximum number of mutexes.
2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 |
# File 'ext/bdb.c', line 2419
VALUE env_mutex_get_max(VALUE obj)
{
t_envh *eh;
u_int32_t max;
int rv;
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
rv=eh->env->mutex_get_max(eh->env,&max);
if ( rv != 0 ) {
raise_error(rv, "env_mutex_get_max: %s",db_strerror(rv));
}
return INT2FIX(max);
}
|
#mutex_set_max(vmax) ⇒ Object
env.mutex_set_max(max) -> max
Set the maximum number of mutexes with the environment
2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 |
# File 'ext/bdb.c', line 2394
VALUE env_mutex_set_max(VALUE obj, VALUE vmax)
{
t_envh *eh;
u_int32_t max;
int rv;
max=FIX2UINT(vmax);
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
rv=eh->env->mutex_set_max(eh->env,max);
if ( rv != 0 ) {
raise_error(rv, "env_mutex_set_max: %s",db_strerror(rv));
}
return vmax;
}
|
#open(vhome, vflags, vmode) ⇒ Object
env.open(homedir,flags,mode) -> self
open an environment
1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 |
# File 'ext/bdb.c', line 1683
VALUE env_open(VALUE obj, VALUE vhome, VALUE vflags, VALUE vmode)
{
t_envh *eh;
int rv;
u_int32_t flags=0;
int mode=0;
if ( ! NIL_P(vflags) )
flags=NUM2UINT(vflags);
if ( ! NIL_P(vmode) )
mode=NUM2INT(vmode);
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
if ( NIL_P(eh->adb) )
raise_error(0,"env handle already used and closed");
rv = eh->env->open(eh->env,StringValueCStr(vhome),flags,mode);
eh->env->app_private=eh;
if (rv != 0) {
raise_error(rv, "env_open failure: %s",db_strerror(rv));
}
return obj;
}
|
#rep_nsites ⇒ Object
env.rep_nsites -> int
returns the replication manager’s acknowledgement policy
2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 |
# File 'ext/bdb.c', line 2935
VALUE env_rep_get_nsites(VALUE obj)
{
t_envh *eh;
u_int32_t nsites;
Data_Get_Struct(obj,t_envh,eh);
eh->env->rep_get_nsites(eh->env, &nsites);
return INT2NUM(nsites);
}
|
#rep_nsites=(nsites) ⇒ Object
env.rep_nsites = int
specify how the replication manager will handle acknowledgement of replication messages
2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 |
# File 'ext/bdb.c', line 2917
VALUE env_rep_set_nsites(VALUE obj, VALUE nsites)
{
t_envh *eh;
int rv;
Data_Get_Struct(obj,t_envh,eh);
rv = eh->env->rep_set_nsites(eh->env, NUM2UINT(nsites));
if ( rv != 0 ) raise_error(rv, "env_rep_set_nsites: %s", db_strerror(rv));
return nsites;
}
|
#rep_priority ⇒ Object
env.rep_priority -> int
returns the replication manager’s acknowledgement policy
2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 |
# File 'ext/bdb.c', line 2900
VALUE env_rep_get_priority(VALUE obj)
{
t_envh *eh;
u_int32_t priority;
Data_Get_Struct(obj,t_envh,eh);
eh->env->rep_get_priority(eh->env, &priority);
return INT2NUM(priority);
}
|
#rep_priority=(priority) ⇒ Object
env.rep_priority = int
specify how the replication manager will handle acknowledgement of replication messages
2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 |
# File 'ext/bdb.c', line 2882
VALUE env_rep_set_priority(VALUE obj, VALUE priority)
{
t_envh *eh;
int rv;
Data_Get_Struct(obj,t_envh,eh);
rv = eh->env->rep_set_priority(eh->env, NUM2UINT(priority));
if ( rv != 0 ) raise_error(rv, "env_rep_set_priority: %s", db_strerror(rv));
return priority;
}
|
#repmgr_ack_policy ⇒ Object
env.repmgr_ack_policy -> int
returns the replication manager’s acknowledgement policy
3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 |
# File 'ext/bdb.c', line 3008
VALUE env_repmgr_get_ack_policy(VALUE obj)
{
t_envh *eh;
int policy;
Data_Get_Struct(obj,t_envh,eh);
eh->env->repmgr_get_ack_policy(eh->env, &policy);
return INT2NUM(policy);
}
|
#repmgr_ack_policy=(policy) ⇒ Object
env.repmgr_ack_policy = int
specify how the replication manager will handle acknowledgement of replication messages
2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 |
# File 'ext/bdb.c', line 2990
VALUE env_repmgr_set_ack_policy(VALUE obj, VALUE policy)
{
t_envh *eh;
int rv;
Data_Get_Struct(obj,t_envh,eh);
rv = eh->env->repmgr_set_ack_policy(eh->env, NUM2INT(policy));
if ( rv != 0 ) raise_error(rv, "env_repmgr_set_ack_policy: %s", db_strerror(rv));
return policy;
}
|
#repmgr_add_remote_site(host, port) ⇒ Object
env.repmgr_add_remote_site(host, port)
add a remote for the replication manager
2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 |
# File 'ext/bdb.c', line 2971
VALUE env_repmgr_add_remote_site(VALUE obj, VALUE host, VALUE port)
{
t_envh *eh;
int rv;
int eidp;
Data_Get_Struct(obj,t_envh,eh);
rv = eh->env->repmgr_add_remote_site(eh->env, StringValuePtr(host), NUM2UINT(port), &eidp, 0);
if ( rv != 0 ) raise_error(rv, "env_repmgr_add_remote_site: %s", db_strerror(rv));
return INT2NUM(eidp);
}
|
#repmgr_set_local_site(host, port) ⇒ Object
env.repmgr_set_local_site(host, port)
specify the local site for the replication manager
2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 |
# File 'ext/bdb.c', line 2953
VALUE env_repmgr_set_local_site(VALUE obj, VALUE host, VALUE port)
{
t_envh *eh;
int rv;
Data_Get_Struct(obj,t_envh,eh);
rv = eh->env->repmgr_set_local_site(eh->env, StringValuePtr(host), NUM2UINT(port), 0);
if ( rv != 0 ) raise_error(rv, "env_repmgr_set_local_site: %s", db_strerror(rv));
return Qtrue;
}
|
#repmgr_start(num_threads, flags) ⇒ Object
env.repmgr_start(num_threads, flags)
start the replication manager
3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 |
# File 'ext/bdb.c', line 3025
VALUE env_repmgr_start(VALUE obj, VALUE num_threads, VALUE flags)
{
t_envh *eh;
int rv;
Data_Get_Struct(obj,t_envh,eh);
rv = eh->env->repmgr_start(eh->env, NUM2INT(num_threads), NUM2UINT(flags));
if ( rv != 0 ) raise_error(rv, "env_repmgr_start: %s", db_strerror(rv));
return Qtrue;
}
|
#repmgr_stat_print(flags) ⇒ Object
env.repmgr_stat_print
prints replication manager stats
3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 |
# File 'ext/bdb.c', line 3043
VALUE env_repmgr_stat_print(VALUE obj, VALUE flags)
{
t_envh *eh;
int rv;
Data_Get_Struct(obj,t_envh,eh);
rv = eh->env->repmgr_stat_print(eh->env, NUM2UINT(flags));
if ( rv != 0 ) raise_error(rv, "env_repmgr_stat_print: %s", db_strerror(rv));
return Qtrue;
}
|
#report_stderr ⇒ Object
2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 |
# File 'ext/bdb.c', line 2668
VALUE env_report_stderr(VALUE obj)
{
t_envh *eh;
//u_int32_t max;
//int rv;
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
eh->env->set_errfile(eh->env,stderr);
return Qtrue;
}
|
#set_verbose(which, onoff) ⇒ Object
env.set_verbose(which, onoff)
set verbose messages on or off
2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 |
# File 'ext/bdb.c', line 2863
VALUE env_set_verbose(VALUE obj, VALUE which, VALUE onoff)
{
t_envh *eh;
int rv;
Data_Get_Struct(obj,t_envh,eh);
rv = eh->env->set_verbose(eh->env, NUM2UINT(which), RTEST(onoff));
if ( rv != 0 ) raise_error(rv, "env_set_verbose: %s",db_strerror(rv));
return Qtrue;
}
|
#shm_key ⇒ Object
call-seq env.get_shm_key -> Fixnum
Get the current shm key base
2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 |
# File 'ext/bdb.c', line 2467
VALUE env_get_shm_key(VALUE obj)
{
t_envh *eh;
long key;
int rv;
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
rv=eh->env->get_shm_key(eh->env,&key);
if ( rv != 0 ) {
raise_error(rv, "env_get_shm_key: %s",db_strerror(rv));
}
return INT2FIX(key);
}
|
#shm_key=(vkey) ⇒ Object
env.set_shm_key(key) -> max
Set the shared memory key base
2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 |
# File 'ext/bdb.c', line 2442
VALUE env_set_shm_key(VALUE obj, VALUE vkey)
{
t_envh *eh;
long key;
int rv;
key=FIX2UINT(vkey);
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
rv=eh->env->set_shm_key(eh->env,key);
if ( rv != 0 ) {
raise_error(rv, "env_set_shm_key: %s",db_strerror(rv));
}
return vkey;
}
|
#timeout(vflags) ⇒ Object
env.get_timeout(flags) -> Fixnum
Get current transaction and lock timeout value
2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 |
# File 'ext/bdb.c', line 2291
VALUE env_set_timeout(VALUE obj, VALUE vtimeout, VALUE vflags)
{
t_envh *eh;
u_int32_t flags=0;
db_timeout_t timeout;
int rv;
if ( ! NIL_P(vflags))
flags=NUM2UINT(vflags);
timeout=FIX2UINT(vtimeout);
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
rv=eh->env->set_timeout(eh->env,timeout,flags);
if ( rv != 0 ) {
raise_error(rv, "env_set_timeout: %s",db_strerror(rv));
}
return vtimeout;
}
|
#tmp_dir ⇒ Object
env.get_tmp_dir -> tmp_dir
get tmp_dir
2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 |
# File 'ext/bdb.c', line 2817
VALUE env_get_tmp_dir(VALUE obj)
{
t_envh *eh;
const char *tmp_dir;
int rv;
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
rv=eh->env->get_tmp_dir(eh->env,&tmp_dir);
if ( rv != 0 ) {
raise_error(rv, "env_get_tmp_dir: %s",db_strerror(rv));
}
return rb_str_new2(tmp_dir);
}
|
#tmp_dir=(vtmp_dir) ⇒ Object
env.set_tmp_dir(tmp_dir) -> tmp_dir
set tmp_dir
2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 |
# File 'ext/bdb.c', line 2792
VALUE env_set_tmp_dir(VALUE obj, VALUE vtmp_dir)
{
t_envh *eh;
const char *tmp_dir;
int rv;
tmp_dir=StringValueCStr(vtmp_dir);
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
rv=eh->env->set_tmp_dir(eh->env,tmp_dir);
if ( rv != 0 ) {
raise_error(rv, "env_set_tmp_dir: %s",db_strerror(rv));
}
return vtmp_dir;
}
|
#tx_max ⇒ Object
call-seq env.get_tx_max -> Fixnum
Get current maximum number of transactions
2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 |
# File 'ext/bdb.c', line 2371
VALUE env_get_tx_max(VALUE obj)
{
t_envh *eh;
u_int32_t max;
int rv;
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
rv=eh->env->get_tx_max(eh->env,&max);
if ( rv != 0 ) {
raise_error(rv, "env_get_tx_max: %s",db_strerror(rv));
}
return INT2FIX(max);
}
|
#tx_max=(vmax) ⇒ Object
env.set_tx_max(max) -> max
Set the maximum number of transactions with the environment
2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 |
# File 'ext/bdb.c', line 2346
VALUE env_set_tx_max(VALUE obj, VALUE vmax)
{
t_envh *eh;
u_int32_t max;
int rv;
max=FIX2UINT(vmax);
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
rv=eh->env->set_tx_max(eh->env,max);
if ( rv != 0 ) {
raise_error(rv, "env_set_tx_max: %s",db_strerror(rv));
}
return vmax;
}
|
#txn_begin(vtxn_parent, vflags) ⇒ Object
env.txn_begin(txn_parent,flags) -> Bdb::Txn
start a root transaction or embedded (via txn_parent).
1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 |
# File 'ext/bdb.c', line 1981
VALUE env_txn_begin(VALUE obj, VALUE vtxn_parent, VALUE vflags)
{
t_txnh *parent=NULL, *txn=NULL;
u_int32_t flags=0;
int rv;
t_envh *eh;
VALUE t_obj;
if ( ! NIL_P(vflags))
flags=NUM2UINT(vflags);
if ( ! NIL_P(vtxn_parent) ) {
Data_Get_Struct(vtxn_parent,t_txnh,parent);
if (!parent->txn)
raise(0, "parent txn is closed");
}
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
t_obj=Data_Make_Struct(cTxn,t_txnh,txn_mark,txn_free,txn);
rv=eh->env->txn_begin(eh->env,parent?parent->txn:NULL,
&(txn->txn),flags);
if ( rv != 0 ) {
raise_error(rv, "env_txn_begin: %s",db_strerror(rv));
return Qnil;
}
txn->env=eh;
txn->self=t_obj;
rb_ary_push(eh->atxn,t_obj);
/* Once we get this working, we'll have to track transactions */
rb_obj_call_init(t_obj,0,NULL);
return t_obj;
}
|
#txn_checkpoint(vkbyte, vmin, vflags) ⇒ Object
env.txn_checkpoint -> true
Cause env transaction state to be checkpointed.
2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 |
# File 'ext/bdb.c', line 2024
VALUE env_txn_checkpoint(VALUE obj, VALUE vkbyte, VALUE vmin,
VALUE vflags)
{
u_int32_t flags=0;
int rv;
t_envh *eh;
u_int32_t kbyte=0, min=0;
if ( ! NIL_P(vflags))
flags=NUM2UINT(vflags);
if ( FIXNUM_P(vkbyte) )
kbyte=FIX2UINT(vkbyte);
if ( FIXNUM_P(vmin) )
min=FIX2UINT(vmin);
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
rv=eh->env->txn_checkpoint(eh->env,kbyte,min,flags);
if ( rv != 0 ) {
raise_error(rv, "env_txn_checkpoint: %s",db_strerror(rv));
return Qnil;
}
return Qtrue;
}
|
#txn_stat(vflags) ⇒ Object
env.txn_stat -> Bdb::TxnStat
get the environment transaction status. Each active transaction will be contained within a Bdb::TxnStat::Active class.
2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 |
# File 'ext/bdb.c', line 2222
VALUE env_txn_stat(VALUE obj, VALUE vflags)
{
u_int32_t flags=0;
int rv;
t_envh *eh;
DB_TXN_STAT *statp;
VALUE s_obj;
VALUE active;
int i;
if ( ! NIL_P(vflags))
flags=NUM2UINT(vflags);
Data_Get_Struct(obj,t_envh,eh);
if (!eh->env)
raise(0, "env is closed");
/* statp will need free() */
rv=eh->env->txn_stat(eh->env,&statp,flags);
if ( rv != 0 ) {
raise_error(rv, "txn_stat: %s",db_strerror(rv));
}
s_obj=rb_class_new_instance(0,NULL,cTxnStat);
rb_iv_set(s_obj,"@st_last_ckp",
rb_ary_new3(2,
INT2FIX(statp->st_last_ckp.file),
INT2FIX(statp->st_last_ckp.offset)) );
rb_iv_set(s_obj,"@st_time_ckp",
rb_time_new(statp->st_time_ckp,0));
rb_iv_set(s_obj,"@st_last_txnid",
INT2FIX(statp->st_last_txnid));
rb_iv_set(s_obj,"@st_maxtxns",
INT2FIX(statp->st_maxtxns));
rb_iv_set(s_obj,"@st_nactive",
INT2FIX(statp->st_nactive));
rb_iv_set(s_obj,"@st_maxnactive",
INT2FIX(statp->st_maxnactive));
rb_iv_set(s_obj,"@st_nbegins",
INT2FIX(statp->st_nbegins));
rb_iv_set(s_obj,"@st_naborts",
INT2FIX(statp->st_naborts));
rb_iv_set(s_obj,"@st_ncommits",
INT2FIX(statp->st_ncommits));
rb_iv_set(s_obj,"@st_nrestores",
INT2FIX(statp->st_nrestores));
rb_iv_set(s_obj,"@st_regsize",
INT2FIX(statp->st_regsize));
rb_iv_set(s_obj,"@st_region_wait",
INT2FIX(statp->st_region_wait));
rb_iv_set(s_obj,"@st_region_nowait",
INT2FIX(statp->st_region_nowait));
rb_iv_set(s_obj,"@st_txnarray",
active=rb_ary_new2(statp->st_nactive));
for (i=0; i<statp->st_nactive; i++) {
rb_ary_push(active,env_txn_stat_active(&(statp->st_txnarray[i])));
}
free(statp);
return s_obj;
}
|