Rename tune_system to get_info and remove set calls.
This commit is contained in:
parent
fe3606b881
commit
ab1e627089
5 changed files with 21 additions and 43 deletions
|
@ -27,7 +27,7 @@ static int open_database(const char* name, DBTYPE type, unsigned int flags, Port
|
|||
static int close_database(int dbref, unsigned flags, PortData* data);
|
||||
static int delete_database(const char* name);
|
||||
|
||||
static void tune_system(int target, void* values, BinHelper* bh);
|
||||
static void get_info(int target, void* values, BinHelper* bh);
|
||||
|
||||
static void do_async_put(void* arg);
|
||||
static void do_async_get(void* arg);
|
||||
|
@ -539,7 +539,7 @@ static int bdberl_drv_control(ErlDrvData handle, unsigned int cmd,
|
|||
RETURN_INT(ERROR_INVALID_DBREF, outbuf);
|
||||
}
|
||||
}
|
||||
case CMD_TUNE:
|
||||
case CMD_GETINFO:
|
||||
{
|
||||
// Inbuf is: << Target:32, Values/binary >>
|
||||
int target = UNPACK_INT(inbuf, 0);
|
||||
|
@ -548,7 +548,7 @@ static int bdberl_drv_control(ErlDrvData handle, unsigned int cmd,
|
|||
// Execute the tuning -- the result to send back to the caller is wrapped
|
||||
// up in the provided binhelper
|
||||
BinHelper bh;
|
||||
tune_system(target, values, &bh);
|
||||
get_info(target, values, &bh);
|
||||
RETURN_BH(bh, outbuf);
|
||||
}
|
||||
case CMD_CURSOR_OPEN:
|
||||
|
@ -851,9 +851,9 @@ static int delete_database(const char* name)
|
|||
}
|
||||
|
||||
/**
|
||||
* Given a target system parameter/action adjust/return the requested value
|
||||
* Given a target system parameter, return the requested value
|
||||
*/
|
||||
static void tune_system(int target, void* values, BinHelper* bh)
|
||||
static void get_info(int target, void* values, BinHelper* bh)
|
||||
{
|
||||
switch(target)
|
||||
{
|
||||
|
@ -870,14 +870,6 @@ static void tune_system(int target, void* values, BinHelper* bh)
|
|||
bin_helper_push_int32(bh, caches);
|
||||
break;
|
||||
}
|
||||
case SYSP_TXN_TIMEOUT_SET:
|
||||
{
|
||||
unsigned int timeout = UNPACK_INT(values, 0);
|
||||
int rc = G_DB_ENV->set_timeout(G_DB_ENV, timeout, DB_SET_TXN_TIMEOUT);
|
||||
bin_helper_init(bh);
|
||||
bin_helper_push_int32(bh, rc);
|
||||
break;
|
||||
}
|
||||
case SYSP_TXN_TIMEOUT_GET:
|
||||
{
|
||||
unsigned int timeout = 0;
|
||||
|
|
|
@ -36,7 +36,7 @@ static int bdberl_drv_control(ErlDrvData handle, unsigned int cmd,
|
|||
#define CMD_TXN_ABORT 5
|
||||
#define CMD_GET 6
|
||||
#define CMD_PUT 7
|
||||
#define CMD_TUNE 8
|
||||
#define CMD_GETINFO 8
|
||||
#define CMD_CURSOR_OPEN 9
|
||||
#define CMD_CURSOR_CURR 10
|
||||
#define CMD_CURSOR_NEXT 11
|
||||
|
@ -77,12 +77,11 @@ static int bdberl_drv_control(ErlDrvData handle, unsigned int cmd,
|
|||
|
||||
|
||||
/**
|
||||
* Tunable system parameters/actions
|
||||
* System information ids
|
||||
*/
|
||||
#define SYSP_CACHESIZE_GET 1
|
||||
#define SYSP_TXN_TIMEOUT_SET 2
|
||||
#define SYSP_TXN_TIMEOUT_GET 3
|
||||
#define SYSP_DATA_DIR_GET 4
|
||||
#define SYSP_TXN_TIMEOUT_GET 2
|
||||
#define SYSP_DATA_DIR_GET 3
|
||||
|
||||
/**
|
||||
* Driver Entry
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
-define(CMD_TXN_ABORT, 5).
|
||||
-define(CMD_GET, 6).
|
||||
-define(CMD_PUT, 7).
|
||||
-define(CMD_TUNE, 8).
|
||||
-define(CMD_GETINFO, 8).
|
||||
-define(CMD_CURSOR_OPEN, 9).
|
||||
-define(CMD_CURSOR_CURR, 10).
|
||||
-define(CMD_CURSOR_NEXT, 11).
|
||||
|
@ -27,9 +27,8 @@
|
|||
-define(DB_TYPE_HASH, 2).
|
||||
|
||||
-define(SYSP_CACHESIZE_GET, 1).
|
||||
-define(SYSP_TXN_TIMEOUT_SET, 2).
|
||||
-define(SYSP_TXN_TIMEOUT_GET, 3).
|
||||
-define(SYSP_DATA_DIR_GET, 4).
|
||||
-define(SYSP_TXN_TIMEOUT_GET, 2).
|
||||
-define(SYSP_DATA_DIR_GET, 3).
|
||||
|
||||
-define(STATUS_OK, 0).
|
||||
-define(STATUS_ERROR, 1).
|
||||
|
|
|
@ -10,8 +10,9 @@
|
|||
close/1, close/2,
|
||||
txn_begin/0, txn_begin/1,
|
||||
txn_commit/0, txn_commit/1, txn_abort/0,
|
||||
get_cache_size/0, get_data_dirs/0,
|
||||
get_txn_timeout/0, set_txn_timeout/1,
|
||||
get_cache_size/0,
|
||||
get_data_dirs/0,
|
||||
get_txn_timeout/0,
|
||||
transaction/1, transaction/2,
|
||||
put/3, put/4,
|
||||
put_r/3, put_r/4,
|
||||
|
@ -277,7 +278,7 @@ delete_database(Filename) ->
|
|||
get_data_dirs() ->
|
||||
%% Call into the BDB library and get a list of configured data directories
|
||||
Cmd = <<?SYSP_DATA_DIR_GET:32/signed-native>>,
|
||||
<<Result:32/signed-native, Rest/bytes>> = erlang:port_control(get_port(), ?CMD_TUNE, Cmd),
|
||||
<<Result:32/signed-native, Rest/bytes>> = erlang:port_control(get_port(), ?CMD_GETINFO, Cmd),
|
||||
case decode_rc(Result) of
|
||||
ok ->
|
||||
Dirs = [binary_to_list(D) || D <- split_bin(0, Rest, <<>>, [])],
|
||||
|
@ -295,7 +296,7 @@ get_data_dirs() ->
|
|||
get_cache_size() ->
|
||||
Cmd = <<?SYSP_CACHESIZE_GET:32/signed-native>>,
|
||||
<<Result:32/signed-native, Gbytes:32/native, Bytes:32/native, Ncaches:32/native>> =
|
||||
erlang:port_control(get_port(), ?CMD_TUNE, Cmd),
|
||||
erlang:port_control(get_port(), ?CMD_GETINFO, Cmd),
|
||||
case Result of
|
||||
0 ->
|
||||
{ok, Gbytes, Bytes, Ncaches};
|
||||
|
@ -305,7 +306,7 @@ get_cache_size() ->
|
|||
|
||||
get_txn_timeout() ->
|
||||
Cmd = <<?SYSP_TXN_TIMEOUT_GET:32/signed-native>>,
|
||||
<<Result:32/signed-native, Timeout:32/native>> = erlang:port_control(get_port(), ?CMD_TUNE, Cmd),
|
||||
<<Result:32/signed-native, Timeout:32/native>> = erlang:port_control(get_port(), ?CMD_GETINFO, Cmd),
|
||||
case Result of
|
||||
0 ->
|
||||
{ok, Timeout};
|
||||
|
@ -313,17 +314,6 @@ get_txn_timeout() ->
|
|||
{error, Result}
|
||||
end.
|
||||
|
||||
set_txn_timeout(Timeout) ->
|
||||
Cmd = <<?SYSP_TXN_TIMEOUT_SET:32/signed-native, Timeout:32/native>>,
|
||||
<<Result:32/signed-native>> = erlang:port_control(get_port(), ?CMD_TUNE, Cmd),
|
||||
case Result of
|
||||
0 ->
|
||||
ok;
|
||||
_ ->
|
||||
{error, Result}
|
||||
end.
|
||||
|
||||
|
||||
|
||||
%% ====================================================================
|
||||
%% Internal functions
|
||||
|
|
|
@ -24,7 +24,7 @@ all() ->
|
|||
transaction_error_should_return_error,
|
||||
update_should_save_value_if_successful,
|
||||
update_should_accept_args_for_fun,
|
||||
port_should_tune_transaction_timeouts,
|
||||
port_should_return_transaction_timeouts,
|
||||
cursor_should_iterate, cursor_should_fail_if_not_open,
|
||||
put_commit_should_end_txn,
|
||||
data_dir_should_be_priv_dir,
|
||||
|
@ -157,11 +157,9 @@ update_should_accept_args_for_fun(Config) ->
|
|||
|
||||
{ok, newvalue} = bdberl:update(Db, mykey, F, look_at_me).
|
||||
|
||||
port_should_tune_transaction_timeouts(_Config) ->
|
||||
port_should_return_transaction_timeouts(_Config) ->
|
||||
%% Test transaction timeouts
|
||||
{ok, 500000} = bdberl:get_txn_timeout(),
|
||||
ok = bdberl:set_txn_timeout(250000),
|
||||
{ok, 250000} = bdberl:get_txn_timeout().
|
||||
{ok, 500000} = bdberl:get_txn_timeout().
|
||||
|
||||
cursor_should_iterate(Config) ->
|
||||
Db = ?config(db, Config),
|
||||
|
|
Loading…
Reference in a new issue