Merge branch 'master' of git://github.com/kpy3/bdberl into merge-changes-from-kpy3
Conflicts: Makefile c_src/buildlib.sh include/bdberl.hrl int_test/DB_CONFIG rebar rebar.config test/bdberl_SUITE.erl
This commit is contained in:
commit
db1eb122c6
17 changed files with 283 additions and 165 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -4,6 +4,7 @@
|
|||
*.o
|
||||
*.so
|
||||
*.beam
|
||||
*.orig
|
||||
logs
|
||||
doc
|
||||
test/test.cover
|
||||
|
@ -14,3 +15,4 @@ priv/mibs
|
|||
c_src/system
|
||||
c_src/db-*
|
||||
c_src/db-*.tar.gz
|
||||
.eunit
|
||||
|
|
24
Makefile
24
Makefile
|
@ -1,13 +1,25 @@
|
|||
all: compile
|
||||
|
||||
compile:
|
||||
@ $(REBAR) compile
|
||||
ERL ?=erl
|
||||
ERL_FLAGS ?=+A10
|
||||
REBAR_FLAGS :=
|
||||
|
||||
all: $(BDB_LOCAL_LIB)
|
||||
ERL_FLAGS=$(ERL_FLAGS) $(REBAR) $(REBAR_FLAGS) compile
|
||||
|
||||
test: tests
|
||||
|
||||
tests:
|
||||
@ $(REBAR) ct
|
||||
@ $(REBAR) $(REBAR_FLAGS) eunit ct
|
||||
|
||||
clean:
|
||||
@ $(REBAR) clean
|
||||
@ rm -rf ./logs
|
||||
$(REBAR) $(REBAR_FLAGS) clean
|
||||
-rm test/*.beam
|
||||
|
||||
distclean: clean
|
||||
-rm -rf $(BDB_LOCAL_DIST)
|
||||
-rm -rf c_src/sources
|
||||
-rm -rf priv
|
||||
-rm -rf logs
|
||||
|
||||
include rebar.mk
|
||||
|
||||
|
|
1
README
1
README
|
@ -4,3 +4,4 @@ Authors:
|
|||
Dave "dizzyd" Smith <dizzyd@dizzyd.com>
|
||||
Phil Toland <phil.toland@gmail.com>
|
||||
Jon Meredith <jon@jonmeredith.com>
|
||||
Sergey Yelin <elinsn@gmail.com>
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
# This Makefile builds the dependency (libdb) needed by bdberl_drv.so
|
||||
|
||||
ERL ?=erl
|
||||
ERL_FLAGS ?=+A10
|
||||
TAR ?= tar
|
||||
GUNZIP ?= gunzip
|
||||
BDB_VER := 5.2.28
|
||||
BDB_VER := 5.2.36
|
||||
BDB_DIR := $(CURDIR)/db-$(BDB_VER)
|
||||
BDB_DIST := db-$(BDB_VER).tar.gz
|
||||
BDB_DIST_URL := http://download.oracle.com/berkeley-db/$(BDB_DIST)
|
||||
|
||||
SYSTEM_DIR := $(CURDIR)/system
|
||||
LIB_DIR := $(SYSTEM_DIR)/lib
|
||||
|
@ -12,7 +16,7 @@ INC_DIR := $(SYSTEM_DIR)/include
|
|||
|
||||
db: $(LIB_DIR)/libdb.a
|
||||
|
||||
$(LIB_DIR)/libdb.a:
|
||||
$(LIB_DIR)/libdb.a: $(BDB_DIST)
|
||||
$(GUNZIP) -c db-$(BDB_VER).tar.gz | $(TAR) xf -
|
||||
@for I in patches/*.patch; do \
|
||||
(patch -p0 < $${I} || echo "Skipping patch"); \
|
||||
|
@ -21,6 +25,9 @@ $(LIB_DIR)/libdb.a:
|
|||
@$(MAKE) -C $(BDB_DIR)/build_unix install
|
||||
|
||||
clean:
|
||||
@rm -rf $(SYSTEM_DIR) $(BDB_DIR)
|
||||
@rm -rf ./*.o $(SYSTEM_DIR) $(BDB_DIR)
|
||||
|
||||
$(BDB_DIST):
|
||||
$(REBAR_FETCH) $(BDB_DIST_URL)
|
||||
|
||||
.EXPORT_ALL_VARIABLES:
|
||||
|
|
|
@ -88,6 +88,8 @@
|
|||
*/
|
||||
#define DB_TYPE_BTREE DB_BTREE /* 1 */
|
||||
#define DB_TYPE_HASH DB_HASH /* 2 */
|
||||
#define DB_TYPE_RECNO DB_RECNO /* 3 */
|
||||
#define DB_TYPE_QUEUE DB_QUEUE /* 4 */
|
||||
|
||||
/**
|
||||
* Error codes -- chosen so that we do not conflict with other packages, particularly
|
||||
|
|
30
c_src/buildlib.sh
Executable file
30
c_src/buildlib.sh
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ `basename $PWD` != "c_src" ]; then
|
||||
pushd c_src
|
||||
fi
|
||||
|
||||
BASEDIR="$PWD"
|
||||
|
||||
WORKDIR=$BASEDIR/system
|
||||
TARGETDIR=$BASEDIR/../priv
|
||||
|
||||
## Check for necessary tarball
|
||||
if [ ! -f "db-${BDB_VERSION}.tar.gz" ]; then
|
||||
echo "Could not find db tarball. Aborting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## Make sure target directory exists
|
||||
mkdir -p $TARGETDIR
|
||||
|
||||
## Remove existing directories
|
||||
rm -rf system db-${BDB_VERSION}
|
||||
|
||||
## Untar and build everything
|
||||
tar -xzf db-${BDB_VERSION}.tar.gz && \
|
||||
##(cd db-${BDB_VERSION} && patch -p0 < ../bdb-align.patch ) && \
|
||||
(cd db-${BDB_VERSION}/build_unix && \
|
||||
../dist/configure --prefix=$WORKDIR --disable-shared && make && ranlib libdb-*.a && make install) && \
|
||||
rm -rf db-${BDB_VERSION}
|
||||
|
Binary file not shown.
|
@ -1,6 +1,24 @@
|
|||
--- db-5.2.28/dist/Makefile.in.orig 2011-08-08 11:12:17.000000000 -0400
|
||||
+++ db-5.2.28/dist/Makefile.in 2011-08-08 11:13:04.000000000 -0400
|
||||
@@ -1066,9 +1066,9 @@
|
||||
--- db-5.2.36/dist/Makefile.in 2011-09-14 10:30:11.000000000 -0400
|
||||
+++ db-5.2.36/dist/Makefile.in.patched 2011-11-28 12:15:04.000000000 -0500
|
||||
@@ -239,7 +239,7 @@
|
||||
|
||||
LOG_VRFY_OBJS=\
|
||||
log_verify@o@ log_verify_util@o@ log_verify_int@o@ \
|
||||
- log_verify_auto@o@
|
||||
+ log_verify_auto@o@
|
||||
|
||||
MUTEX_OBJS=\
|
||||
mut_alloc@o@ mut_failchk@o@ mut_method@o@ mut_region@o@ mut_stat@o@
|
||||
@@ -762,7 +762,7 @@
|
||||
$(JAVA_EXDIR)/persist/gettingStarted/SimpleStorePut.java \
|
||||
$(JAVA_EXDIR)/persist/txn/PayloadDataEntity.java \
|
||||
$(JAVA_EXDIR)/persist/txn/StoreWriter.java \
|
||||
- $(JAVA_EXDIR)/persist/txn/TxnGuideDPL.java
|
||||
+ $(JAVA_EXDIR)/persist/txn/TxnGuideDPL.java
|
||||
|
||||
SQL_OBJS=\
|
||||
sqlite3@o@ $(C_OBJS)
|
||||
@@ -1067,9 +1067,9 @@
|
||||
# Library and standard utilities install.
|
||||
##################################################
|
||||
library_install: install_setup
|
||||
|
@ -12,7 +30,7 @@
|
|||
|
||||
install_setup:
|
||||
@test -d $(DESTDIR)$(prefix) || \
|
||||
@@ -1144,22 +1144,6 @@
|
||||
@@ -1145,22 +1145,6 @@
|
||||
$(RM) $$i; \
|
||||
done)
|
||||
|
||||
|
@ -35,3 +53,21 @@
|
|||
|
||||
##################################################
|
||||
# Remaining standard Makefile targets.
|
||||
@@ -1335,7 +1319,7 @@
|
||||
db_repsite: $(DBREPSITE_OBJS) $(DEF_LIB_CXX)
|
||||
$(CXXLINK) -o $@ \
|
||||
$(LDFLAGS) $(DBREPSITE_OBJS) $(DEF_LIB_CXX) $(TEST_LIBS) $(LIBS)
|
||||
- $(POSTLINK) $@
|
||||
+ $(POSTLINK) $@
|
||||
|
||||
db_reptest@o@: $(testdir)/repmgr/db_reptest.c
|
||||
$(CC) $(CFLAGS) $?
|
||||
@@ -1349,7 +1333,7 @@
|
||||
$(CC) $(CFLAGS) $?
|
||||
DBREPTEST_OBJS=\
|
||||
db_reptest@o@ reptest_am@o@ reptest_handles@o@ \
|
||||
- reptest_spawn@o@ reptest_util@o@
|
||||
+ reptest_spawn@o@ reptest_util@o@
|
||||
|
||||
db_reptest: $(DBREPTEST_OBJS) $(DEF_LIB)
|
||||
$(CCLINK) -o $@ \
|
||||
|
|
|
@ -72,7 +72,9 @@
|
|||
|
||||
-define(DB_TYPE_BTREE, 1).
|
||||
-define(DB_TYPE_HASH, 2).
|
||||
-define(DB_TYPE_UNKNOWN, 6).
|
||||
-define(DB_TYPE_RECNO, 3).
|
||||
-define(DB_TYPE_QUEUE, 4).
|
||||
-define(DB_TYPE_UNKNOWN, 5).
|
||||
|
||||
-define(SYSP_CACHESIZE_GET, 1).
|
||||
-define(SYSP_TXN_TIMEOUT_GET, 2).
|
||||
|
@ -93,6 +95,7 @@
|
|||
-define(ERROR_DB_ACTIVE, -29007). % Database is currently active; operation requires otherwise
|
||||
-define(ERROR_INVALID_CMD, -29008). % Invalid command
|
||||
-define(ERROR_INVALID_DB_TYPE,-29009). % Invalid database type
|
||||
-define(ERROR_INVALID_VALUE, -29010). % Invalid CRC-32 on value
|
||||
|
||||
%% DB (public, user visible) error return codes.
|
||||
-define(DB_BUFFER_SMALL, -30999). % User memory too small for return.
|
||||
|
|
|
@ -3,3 +3,4 @@ set_cachesize 0 536870912 1
|
|||
set_lg_max 104857600
|
||||
set_lg_bsize 536870912
|
||||
log_set_config DB_LOG_IN_MEMORY
|
||||
set_flags DB_LOG_AUTOREMOVE
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
%% -------------------------------------------------------------------
|
||||
-module(stress_SUITE).
|
||||
-compile(export_all).
|
||||
-include_lib("ct.hrl").
|
||||
-include_lib("common_test/include/ct.hrl").
|
||||
|
||||
%% NOTE: all of the tests are set for a low number of iterations to guarantee
|
||||
%% that they all pass and run in a reasonable amount of time. That kinda defeats
|
||||
|
@ -36,11 +36,21 @@ all() ->
|
|||
write_array_test,
|
||||
write_bytes_test].
|
||||
|
||||
dbconfig(Config) ->
|
||||
Cfg = [
|
||||
{set_data_dir, ?config(priv_dir, Config)},
|
||||
{set_flags, 'DB_TXN_WRITE_NOSYNC'},
|
||||
{set_cachesize, '0 536870912 1'},
|
||||
{set_lg_max, '1048576000'},
|
||||
{set_lg_bsize, '5368709120'},
|
||||
{set_log_config, 'DB_LOG_IN_MEMORY'}
|
||||
],
|
||||
list_to_binary(lists:flatten([io_lib:format("~s ~s\n", [K,V]) || {K, V} <- Cfg])).
|
||||
|
||||
init_per_suite(Config) ->
|
||||
{ok, Cwd} = file:get_cwd(),
|
||||
{ok, _} = file:copy(lists:append([Cwd, "/../../int_test/DB_CONFIG"]),
|
||||
lists:append([Cwd, "/DB_CONFIG"])),
|
||||
crypto:start(),
|
||||
DbHome = ?config(priv_dir, Config),
|
||||
os:putenv("DB_HOME", DbHome),
|
||||
ok = file:write_file(DbHome ++ "DB_CONFIG", dbconfig(Config)),
|
||||
Config.
|
||||
|
||||
end_per_suite(_Config) ->
|
||||
|
|
BIN
rebar
vendored
BIN
rebar
vendored
Binary file not shown.
|
@ -38,3 +38,7 @@
|
|||
|
||||
{pre_hooks, [{compile, "make -C c_src"}]}.
|
||||
{post_hooks, [{clean, "make -C c_src clean"}]}.
|
||||
|
||||
{cover_enabled, true}.
|
||||
|
||||
{ct_extra_params, "-boot start_sasl -s snmp"}.
|
||||
|
|
|
@ -188,6 +188,8 @@ open(Name, Type, Opts) ->
|
|||
case Type of
|
||||
btree -> TypeCode = ?DB_TYPE_BTREE;
|
||||
hash -> TypeCode = ?DB_TYPE_HASH;
|
||||
recno -> TypeCode = ?DB_TYPE_RECNO;
|
||||
queue -> TypeCode = ?DB_TYPE_QUEUE;
|
||||
unknown -> TypeCode = ?DB_TYPE_UNKNOWN %% BDB automatically determines if file exists
|
||||
end,
|
||||
Flags = process_flags(lists:umerge(Opts, [auto_commit, threaded])),
|
||||
|
@ -2276,7 +2278,7 @@ stop() ->
|
|||
%% ====================================================================
|
||||
|
||||
init() ->
|
||||
case erl_ddll:load_driver(code:priv_dir(bdberl), bdberl_drv) of
|
||||
case erl_ddll:load_driver(priv_dir(), bdberl_drv) of
|
||||
ok -> ok;
|
||||
{error, permanent} -> ok % Means that the driver is already active
|
||||
end,
|
||||
|
@ -2295,6 +2297,15 @@ init() ->
|
|||
erlang:put(bdb_port, Port),
|
||||
Port.
|
||||
|
||||
priv_dir() ->
|
||||
case code:priv_dir(?MODULE) of
|
||||
Name when is_list(Name) ->
|
||||
Name;
|
||||
{error, bad_name} ->
|
||||
{ok, Cwd} = file:get_cwd(),
|
||||
filename:absname(filename:join(Cwd, "../priv"))
|
||||
end.
|
||||
|
||||
get_port() ->
|
||||
case erlang:get(bdb_port) of
|
||||
undefined -> init();
|
||||
|
|
|
@ -75,9 +75,11 @@ all() ->
|
|||
|
||||
|
||||
dbconfig(Config) ->
|
||||
Cfg = [{set_data_dir, ?config(priv_dir, Config)},
|
||||
Cfg = [
|
||||
{set_data_dir, ?config(priv_dir, Config)},
|
||||
{set_flags, 'DB_TXN_NOSYNC'},
|
||||
{log_set_config, 'DB_LOG_IN_MEMORY'}],
|
||||
{log_set_config, 'DB_LOG_IN_MEMORY'}
|
||||
],
|
||||
list_to_binary(lists:flatten([io_lib:format("~s ~s\n", [K,V]) || {K, V} <- Cfg])).
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
{export, ["test/test.cover"]}.
|
||||
{level, details}.
|
||||
{incl_dirs_r, ["ebin"]}.
|
Loading…
Reference in a new issue