Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

A whole bunch of changes, mainly build-related.. ugh

  • Loading branch information...
commit 2aec41cf438be4689c45af0e264d8ec18d0a8c97 1 parent 5025f61
@mnunberg authored
View
218 Client.xs
@@ -1,6 +1,5 @@
#include "perl-couchbase.h"
#include "plcb-util.h"
-#include <libcouchbase/libevent_io_opts.h>
static inline void
wait_for_single_response(PLCB_t *object)
@@ -34,7 +33,7 @@ void plcb_errstack_push(PLCB_t *object, libcouchbase_error_t err,
{
libcouchbase_t instance;
SV *errsvs[2];
-
+
instance = object->instance;
if(!errinfo) {
errinfo = libcouchbase_strerror(instance, err);
@@ -53,44 +52,43 @@ SV *PLCB_construct(const char *pkg, AV *options)
struct libcouchbase_io_opt_st *io_ops;
SV *blessed_obj;
PLCB_t *object;
-
+
char *host = NULL, *username = NULL, *password = NULL, *bucket = NULL;
-
+
plcb_ctor_cbc_opts(options,
&host, &username, &password, &bucket);
-
-
+
+
io_ops = libcouchbase_create_io_ops(
LIBCOUCHBASE_IO_OPS_DEFAULT, NULL, &err);
-
+
if(io_ops == NULL && err != LIBCOUCHBASE_SUCCESS) {
die("Couldn't create new IO operations: %d", err);
}
-
- //io_ops = libcouchbase_create_libevent_io_opts(NULL);
- instance = libcouchbase_create(host, username, password, bucket, io_ops);
-
+
+ instance = libcouchbase_create(host, username, password, bucket, io_ops);
+
if(!instance) {
die("Failed to create instance");
}
-
+
Newxz(object, 1, PLCB_t);
-
+
object->io_ops = io_ops;
plcb_ctor_conversion_opts(object, options);
plcb_ctor_init_common(object, instance, options);
-
+
libcouchbase_set_cookie(instance, object);
-
+
plcb_callbacks_setup(object);
-
+
blessed_obj = newSV(0);
sv_setiv(newSVrv(blessed_obj, "Couchbase::Client"), PTR2IV(object));
-
+
if( (object->my_flags & PLCBf_NO_CONNECT) == 0) {
PLCB_connect(blessed_obj);
}
-
+
return blessed_obj;
}
@@ -112,11 +110,11 @@ PLCB_connect(SV *self)
libcouchbase_error_t err;
AV *retav;
PLCB_t *object;
-
+
mk_instance_vars(self, instance, object);
-
+
av_clear(object->errors);
-
+
if(object->connected) {
warn("Already connected");
return 1;
@@ -162,24 +160,24 @@ static SV *PLCB_set_common(SV *self,
PLCB_sync_t *syncp;
time_t exp;
uint32_t store_flags = 0;
-
+
mk_instance_vars(self, instance, object);
-
+
plcb_get_str_or_die(key, skey, klen, "Key");
- plcb_get_str_or_die(value, sval, vlen, "Value");
-
+ plcb_get_str_or_die(value, sval, vlen, "Value");
+
/*Clear existing error status first*/
av_clear(object->errors);
-
+
_sync_initialize_single(object, syncp);
-
+
exp = exp_offset ? time(NULL) + exp_offset : 0;
-
+
plcb_convert_storage(object, &value, &vlen, &store_flags);
err = libcouchbase_store(instance, syncp, storop,
skey, klen, SvPVX(value), vlen, store_flags, exp, cas);
plcb_convert_storage_free(object, value, store_flags);
-
+
_sync_return_single(object, err, syncp);
}
@@ -193,24 +191,24 @@ static SV *PLCB_arithmetic_common(SV *self,
char *skey;
STRLEN nkey;
-
+
PLCB_sync_t *syncp;
time_t exp;
libcouchbase_error_t err;
-
+
mk_instance_vars(self, instance, object);
exp = exp_offset ? time(NULL) + exp_offset : 0;
-
+
plcb_get_str_or_die(key, skey, nkey, "Key");
-
+
_sync_initialize_single(object, syncp);
-
+
err = libcouchbase_arithmetic(
instance, syncp, skey, nkey, delta,
exp, do_create, initial
);
-
- _sync_return_single(object, err, syncp);
+
+ _sync_return_single(object, err, syncp);
}
static SV *PLCB_get_common(SV *self, SV *key, int exp_offset)
@@ -218,25 +216,25 @@ static SV *PLCB_get_common(SV *self, SV *key, int exp_offset)
libcouchbase_t instance;
PLCB_t *object;
PLCB_sync_t *syncp;
- libcouchbase_error_t err;
+ libcouchbase_error_t err;
STRLEN klen;
char *skey;
-
+
time_t exp;
time_t *exp_arg;
-
+
mk_instance_vars(self, instance, object);
plcb_get_str_or_die(key, skey, klen, "Key");
_sync_initialize_single(object, syncp);
-
+
av_clear(object->errors);
exp_arg = (exp_offset && (exp = time(NULL) + exp_offset)) ? &exp : NULL;
-
+
err = libcouchbase_mget(instance, syncp, 1,
(const void * const*)&skey, &klen,
exp_arg);
-
- _sync_return_single(object, err, syncp);
+
+ _sync_return_single(object, err, syncp);
}
#define set_plst_get_offset(exp_idx, exp_var, diemsg) \
@@ -270,22 +268,22 @@ SV *PLCB_remove(SV *self, SV *key, uint64_t cas)
libcouchbase_t instance;
PLCB_t *object;
libcouchbase_error_t err;
-
+
char *skey;
AV *ret_av;
SV *ret_rv;
STRLEN key_len;
PLCB_sync_t *syncp;
-
+
mk_instance_vars(self, instance, object);
-
+
plcb_get_str_or_die(key, skey, key_len, "Key");
av_clear(object->errors);
-
+
_sync_initialize_single(object, syncp);
-
+
err = libcouchbase_remove(instance, syncp, skey, key_len, cas);
- _sync_return_single(object, err, syncp);
+ _sync_return_single(object, err, syncp);
}
SV *PLCB_stats(SV *self, AV *stats)
@@ -296,19 +294,19 @@ SV *PLCB_stats(SV *self, AV *stats)
STRLEN nkey;
int curidx;
libcouchbase_error_t err;
-
+
SV *ret_hvref;
SV **tmpsv;
-
+
mk_instance_vars(self, instance, object);
if(object->stats_hv) {
die("Hrrm.. stats_hv should be NULL");
}
-
+
av_clear(object->errors);
object->stats_hv = newHV();
ret_hvref = newRV_noinc((SV*)object->stats_hv);
-
+
if(stats == NULL || (curidx = av_len(stats)) == -1) {
skey = NULL;
nkey = 0;
@@ -318,9 +316,9 @@ SV *PLCB_stats(SV *self, AV *stats)
SvREFCNT_dec(ret_hvref);
ret_hvref = &PL_sv_undef;
}
-
+
wait_for_single_response(object);
-
+
} else {
for(; curidx >= 0; curidx--) {
tmpsv = av_fetch(stats, curidx, 0);
@@ -336,7 +334,7 @@ SV *PLCB_stats(SV *self, AV *stats)
}
}
}
-
+
object->stats_hv = NULL;
return ret_hvref;
}
@@ -347,7 +345,7 @@ return_empty(SV *self, int error, const char *errmsg)
libcouchbase_t instance;
PLCB_t *object;
AV *ret_av;
-
+
mk_instance_vars(self, instance, object);
ret_av = newAV();
av_store(ret_av, PLCB_RETIDX_ERRNUM, newSViv(error));
@@ -391,20 +389,20 @@ PLCB_construct(pkg, options)
void
PLCB_DESTROY(self)
SV *self
-
+
CODE:
PLCB_t *object;
libcouchbase_t instance;
-
+
mk_instance_vars(self, instance, object);
plcb_cleanup(object);
Safefree(object);
-
+
SV *
PLCB_get(self, key)
SV * self
SV * key
-
+
SV *
PLCB_touch(self, key, exp_offset)
@@ -417,41 +415,41 @@ PLCB_set(self, key, value, ...)
SV *self
SV *key
SV *value
-
+
ALIAS:
add = 1
replace = 2
append = 3
prepend = 4
-
+
PREINIT:
UV exp_offset;
-
+
CODE:
set_plst_get_offset(4, exp_offset, "USAGE: set(key, value [,expiry]");
-
+
if(ix >= 3 && SvROK(value)) {
die("Cannot append/prepend a reference");
}
-
+
RETVAL = PLCB_set_common(
self, key, value,
PLCB_XS_setmap[ix],
exp_offset, 0);
-
+
OUTPUT:
RETVAL
-
-
+
+
SV *
PLCB_arithmetic(self, key, ...)
SV *self
SV *key
-
+
ALIAS:
incr = 1
decr = 2
-
+
PREINIT:
int64_t delta;
UV exp_offset;
@@ -459,31 +457,31 @@ PLCB_arithmetic(self, key, ...)
SV *delta_sv;
int do_create;
uint64_t initial_i;
-
+
CODE:
do_create = 0;
exp_offset = 0;
initial_i = 0;
initial = NULL;
delta_sv = NULL;
-
-
+
+
if(items > 2) {
delta_sv = ST(2);
}
-
+
if(ix == 0) {
if(items < 4 || items > 5) {
die("arithmetic(key, delta, initial [,expiry])");
}
-
+
if(SvTYPE( (initial=ST(3)) ) == SVt_NULL) {
do_create = 0;
} else {
do_create = 1;
initial_i = plcb_sv_to_u64(initial);
}
-
+
if(items == 5 && (exp_offset = SvUV( ST(4) )) == 0 ) {
die("Expiry offset cannot be 0");
}
@@ -498,7 +496,7 @@ PLCB_arithmetic(self, key, ...)
RETVAL = PLCB_arithmetic_common(
self, key, delta, do_create, initial_i, exp_offset);
-
+
OUTPUT:
RETVAL
@@ -509,12 +507,12 @@ PLCB_cas(self, key, value, cas_sv, ...)
SV *key
SV *value
SV *cas_sv
-
+
PREINIT:
UV exp_offset;
uint64_t *cas_val;
STRLEN cas_len;
-
+
CODE:
if(SvTYPE(cas_sv) == SVt_NULL) {
/*don't bother the network if we know our CAS operation will fail*/
@@ -523,9 +521,9 @@ PLCB_cas(self, key, value, cas_sv, ...)
LIBCOUCHBASE_KEY_EEXISTS, "I was given an undef cas");
return;
}
-
+
plcb_cas_from_sv(cas_sv, cas_val, cas_len);
-
+
set_plst_get_offset(5, exp_offset, "USAGE: cas(key,value,cas[,expiry])");
RETVAL = PLCB_set_common(
self, key, value,
@@ -540,15 +538,15 @@ SV *
PLCB_remove(self, key, ...)
SV *self
SV *key
-
+
ALIAS:
delete = 1
-
+
PREINIT:
uint64_t *cas_ptr;
STRLEN cas_len;
SV *cas_sv;
-
+
CODE:
if(items == 2) {
RETVAL = PLCB_remove(self, key, 0);
@@ -557,7 +555,7 @@ PLCB_remove(self, key, ...)
plcb_cas_from_sv(cas_sv, cas_ptr, cas_len);
RETVAL = PLCB_remove(self, key, *cas_ptr);
}
-
+
OUTPUT:
RETVAL
@@ -565,16 +563,16 @@ PLCB_remove(self, key, ...)
SV *
PLCB_get_errors(self)
SV *self
-
+
PREINIT:
libcouchbase_t instance;
PLCB_t *object;
AV *errors;
-
+
CODE:
mk_instance_vars(self, instance, object);
RETVAL = newRV_inc((SV*)object->errors);
-
+
OUTPUT:
RETVAL
@@ -582,11 +580,11 @@ PLCB_get_errors(self)
SV *
PLCB_stats(self, ...)
SV *self
-
+
PREINIT:
SV *klist;
-
- CODE:
+
+ CODE:
if( items < 2 ) {
klist = NULL;
} else {
@@ -596,7 +594,7 @@ PLCB_stats(self, ...)
}
}
RETVAL = PLCB_stats(self, (klist) ? (AV*)SvRV(klist) : NULL);
-
+
OUTPUT:
RETVAL
@@ -604,7 +602,7 @@ PLCB_stats(self, ...)
IV
PLCB__settings(self, ...)
SV *self
-
+
ALIAS:
enable_compress = SETTINGS_ALIAS_COMPRESS_COMPAT
compression_settings = SETTINGS_ALIAS_COMPRESS
@@ -613,13 +611,13 @@ PLCB__settings(self, ...)
deconversion_settings = SETTINGS_ALIAS_DECONVERT
compress_threshold = SETTINGS_ALIAS_COMP_THRESHOLD
dereference_scalar_ref_settings = SETTINGS_ALIAS_DEREF_RVPV
-
+
PREINIT:
int flag;
int new_value;
libcouchbase_t instance;
PLCB_t *object;
-
+
CODE:
mk_instance_vars(self, instance, object);
switch(ix) {
@@ -656,13 +654,13 @@ PLCB__settings(self, ...)
} else {
die("%s(self, [value])", GvNAME(GvCV(cv)));
}
-
+
if(!SvROK(self)) {
die("%s: I was given a bad object", GvNAME(GvCV(cv)));
}
-
-
-
+
+
+
RETVAL = plcb_convert_settings(object, flag, new_value);
//warn("Report flag %d = %d", flag, RETVAL);
@@ -673,21 +671,21 @@ PLCB__settings(self, ...)
NV
PLCB_timeout(self, ...)
SV *self
-
+
PREINIT:
NV new_param;
uint32_t usecs;
NV ret;
-
+
libcouchbase_t instance;
PLCB_t *object;
-
+
CODE:
-
+
mk_instance_vars(self, instance, object);
-
+
ret = ((NV)(libcouchbase_get_timeout(instance))) / (1000*1000);
-
+
if(items == 2) {
new_param = SvNV(ST(1));
if(new_param <= 0) {
@@ -697,9 +695,9 @@ PLCB_timeout(self, ...)
usecs = new_param * (1000*1000);
libcouchbase_set_timeout(instance, usecs);
}
-
+
RETVAL = ret;
-
+
OUTPUT:
RETVAL
@@ -707,7 +705,7 @@ int
PLCB_connect(self)
SV *self
-
+
BOOT:
{
{
@@ -725,7 +723,7 @@ BOOT:
mXPUSHs(newSVpv(XS_VERSION, 0));
PUTBACK;
boot_Couchbase__Client_multi(aTHX_ cv);
- SPAGAIN;
+ SPAGAIN;
}
INCLUDE: Async.xs
View
8 MANIFEST
@@ -14,8 +14,6 @@ lib/Couchbase/Client/IDXConst.pm
lib/Couchbase/Client/README.pod
-lib/Couchbase/Client/Errors_const.pm
-lib/Couchbase/Client/IDXConst_const.pm
lib/Couchbase/Client/Compat.pm
lib/Couchbase/Client/Async.pm
@@ -54,8 +52,8 @@ print_constants.pl
t/00-load.t
t/01-main.t
+t/tmp/CouchbaseMock.jar
src/memcached-headers.tar.gz
-
-src/libcouchbase-1.0.0_45_g58818c5.tar.gz
-src/libvbucket-1.8.0.1_4_g677e403.tar.gz
+src/libcouchbase-1.0.0_50_g1a42d9e.tar.gz
+src/libvbucket-1.8.0.1_5_ga4397f3.tar.gz
View
2  MANIFEST.SKIP
@@ -3,3 +3,5 @@
^\.
^src/
^inst_dir/
+.+_const\.pm
+^author_utils
View
59 MANIFEST.in
@@ -0,0 +1,59 @@
+Changes
+MANIFEST
+MANIFEST.SKIP
+Makefile.PL
+README.pod
+
+PLCB_ConfUtil.pm
+PLCB_Config.pm
+
+lib/Couchbase/Client.pm
+lib/Couchbase/Client/Return.pm
+lib/Couchbase/Client/Errors.pm
+lib/Couchbase/Client/IDXConst.pm
+
+lib/Couchbase/Client/README.pod
+
+lib/Couchbase/Client/Compat.pm
+
+lib/Couchbase/Client/Async.pm
+lib/Couchbase/Client/Async/Event.pm
+lib/Couchbase/Client/Async/Request.pm
+
+lib/Couchbase/MockServer.pm
+lib/Couchbase/Test/ClientSync.pm
+lib/Couchbase/Test/Common.pm
+lib/Couchbase/Test/Async.pm
+lib/Couchbase/Test/Async/Loop.pm
+lib/Couchbase/Test/Settings.pm
+lib/Couchbase/Test/Interop.pm
+lib/Couchbase/Test/Netfail.pm
+
+Client.xs
+Client_multi.xs
+Async.xs
+
+perl-couchbase.h
+perl-couchbase-async.h
+plcb-util.h
+plcb-return.h
+
+callbacks.c
+convert.c
+ctor.c
+async.c
+async_callbacks.c
+async_events.c
+
+build_libraries.pl
+idx_constants.pl
+error_constants.pl
+print_constants.pl
+
+t/00-load.t
+t/01-main.t
+t/tmp/CouchbaseMock.jar
+
+src/memcached-headers.tar.gz
+src/libcouchbase-__LIBCOUCHBASE_RELEASE__.tar.gz
+src/libvbucket-__LIBVBUCKET_RELEASE__.tar.gz
View
39 Makefile.PL
@@ -9,6 +9,8 @@ use File::Spec;
use Config;
use lib __DIR__;
+use PLCB_ConfUtil;
+
GetOptions(
'dynamic' => \my $UseDynamic,
@@ -24,18 +26,21 @@ my $myextlib;
my $inc;
my $libs;
+my $buildscript_options = "";
+
if(!$UseDynamic) {
- my $inst_dir = File::Spec->catfile('src', 'inst');
+ my $inst_dir = PLCB_ConfUtil::get_inst_dir();
+ $inc = '-I' . File::Spec->catfile($inst_dir, 'include');
+
my $lib_dir = File::Spec->catfile($inst_dir, 'lib');
+ $libs = "-L$lib_dir -lsasl2 -levent -ldl -lresolv";
+
#Set path for linker and friends
$myextlib = join(' ',
map(File::Spec->catfile($lib_dir, $_.'$(LIB_EXT)'),
qw(libcouchbase libvbucket)));
- #set include path
- $inc = '-I' . File::Spec->catfile($inst_dir, 'include');
- $libs = '-lsasl2 -levent -ldl -lresolv';
{
no warnings 'once';
*MY::postamble = \&_static_my_postamble;
@@ -48,10 +53,14 @@ if(!$UseDynamic) {
foreach ([\$inc, \$ExtraInclude], [\$libs, \$ExtraLDPath]) {
my ($defl,$extra) = @$_;
if($$extra) {
+ $$defl ||= "";
$$defl = "$$extra $$defl";
}
}
+#Write our temporary parameters
+PLCB_ConfUtil::write_tmpflags($inc, $libs);
+
# .c files
my @source_modules = qw(
callbacks
@@ -82,8 +91,9 @@ WriteMakefile(
: ()),
PL_FILES => {
- "error_constants.pl" => "lib/Couchbase/Client/Errors_const.pm",
- "idx_constants.pl" => "lib/Couchbase/Client/IDXConst_const.pm"
+ #Force them to build into blib
+ "error_constants.pl" => '$(INST_LIB)/Couchbase/Client/Errors_const.pm',
+ "idx_constants.pl" => '$(INST_LIB)/Couchbase/Client/IDXConst_const.pm'
},
CONFIGURE_REQUIRES => {
@@ -96,12 +106,14 @@ WriteMakefile(
'Class::XSAccessor' => 1.11,
'Test::More' => 0,
+ #We need libevent for whatever we're doing
+ 'Alien::Libevent' => 0.001004,
+
#These modules are needed for tests, but not strictly required for
#functionality
'Log::Fu' => 0.25,
'Test::Class' => 0.36,
- 'LWP::UserAgent' => 0,
#these are needed for asynchronous tests and modules
'POE::Sugar::Attributes' => 0.02,
@@ -116,16 +128,25 @@ WriteMakefile(
LIBS => $libs,
INC => $inc,
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
- clean => { FILES => 'Couchbase-Client-*' },
+ clean => { FILES => 'Couchbase-Client-* COMPILER_FLAGS' },
);
+sub MY::libscan {
+ my ($self,$path) = @_;
+ if($path =~ /\.pl$/i) {
+ return "";
+ } else {
+ return $path;
+ }
+}
sub _static_my_postamble {
my $make_text = <<'EOM';
$(MYEXTLIB):
- $(PERLRUN) build_libraries.pl
+ $(PERLRUN) build_libraries.pl __BUILD_LIBRARIES_OPTIONS__
EOM
+ $make_text =~ s/__BUILD_LIBRARIES_OPTIONS__/$buildscript_options/g;
$make_text =~ s/^\s+/\t/msg;
$make_text;
}
View
56 PLCB_ConfUtil.pm
@@ -2,6 +2,11 @@ package PLCB_ConfUtil;
use strict;
use warnings;
use Dir::Self;
+use File::Spec;
+use File::Path qw(rmtree);
+use Data::Dumper;
+use Config;
+
use lib __DIR__;
my $config = do 'PLCB_Config.pm';
@@ -11,14 +16,7 @@ if(!$config) {
}
sub set_gcc_env {
- my $existing_env = $ENV{C_INCLUDE_PATH};
- $existing_env ||= "";
- my $new_env = $config->{COUCHBASE_INCLUDE_PATH};
- if(!$new_env) {
- return;
- } else {
- $ENV{C_INCLUDE_PATH} = "$new_env:$existing_env";
- }
+
}
sub get_gcc_linker_flags {
@@ -41,4 +39,46 @@ sub get_include_dir {
}
}
+sub clean_cbc_sources {
+ my $dir_base = $config->{SRC_DIR};
+
+ foreach my $lib (qw(couchbase vbucket)) {
+ my $dir = sprintf("lib%s-%s", $lib,
+ $config->{ "LIB" . uc($lib) . "_RELEASE" });
+ $dir = File::Spec->catfile($dir_base, $dir);
+ rmtree($dir);
+ }
+ rmtree($config->{SRC_INST});
+}
+
+sub get_toplevel_dir {
+ $config->{SRC_DIR};
+}
+
+sub get_inst_dir {
+ $config->{SRC_INST};
+}
+
+my $TEMPFILE = File::Spec->catfile(__DIR__, "COMPILER_FLAGS");
+
+sub write_tmpflags {
+ my ($cflags,$ldflags) = @_;
+ open my $fh, ">", $TEMPFILE or die "$TEMPFILE: $@";
+ my $h = {
+ CFLAGS => $cflags,
+ LDFLAGS => $ldflags
+ };
+ print $fh Dumper($h);
+}
+
+sub env_from_tmpflags {
+ my $confhash = do "$TEMPFILE";
+ $ENV{CFLAGS} .= ' ' . $confhash->{CFLAGS} . ' ' . $Config{ccflags};
+ $ENV{CFLAGS} .= ' -I' . __DIR__;
+ $ENV{LDFLAGS}= "";
+# $ENV{LDFLAGS} .= ' ' . $confhash->{LDFLAGS};
+
+# printf("CFLAGS: %s\nLDFLAGS=%s\n", $ENV{CFLAGS}, $ENV{LDFLAGS});
+}
+
1;
View
21 PLCB_Config.pm
@@ -1,6 +1,9 @@
package PLCB_Config;
use strict;
use warnings;
+use Dir::Self;
+use File::Spec;
+use Hash::Util qw(lock_keys);
#this perl 'hash' contains configuration information necessary
#to bootstrap and/or configure the perl couchbase client and run
@@ -8,13 +11,19 @@ use warnings;
my $params = {
#URL from which to download the mock JAR file for tests
- #COUCHBASE_MOCK_JARURL =>
- # "http://files.couchbase.com/maven2/org/couchbase/mock/".
- # "CouchbaseMock/0.5-SNAPSHOT/CouchbaseMock-0.5-20120202.071818-12.jar",
- COUCHBASE_MOCK_JARURL => 'http://files.avsej.net/CouchbaseMock.jar',
- LIBVBUCKET_RELEASE => '1.8.0.1_4_g677e403',
- LIBCOUCHBASE_RELEASE => '1.0.0_45_g58818c5'
+ COUCHBASE_MOCK_JARURL => 'https://github.com/downloads/mnunberg/' .
+ 'perl-Couchbase-Client/CouchbaseMock-0.5-SNAPSHOT.jar',
+
+ #version numbers for libcouchbase and libvbucket
+ LIBVBUCKET_RELEASE => '1.8.0.1_5_ga4397f3',
+ LIBCOUCHBASE_RELEASE => '1.0.0_50_g1a42d9e'
};
+#don't change these, or there may be bad consequences
+$params->{SRC_DIR} = File::Spec->catfile(__DIR__, 'src');
+$params->{SRC_INST} = File::Spec->catfile($params->{SRC_DIR}, 'inst');
+
+lock_keys(%$params);
+
return $params; #return value
View
0  gen_manifest.pl → author_utils/gen_manifest.pl
File renamed without changes
View
8 author_utils/reset_sources.pl
@@ -0,0 +1,8 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Dir::Self;
+use lib __DIR__ . "../";
+use PLCB_ConfUtil;
+
+PLCB_ConfUtil::clean_cbc_sources();
View
50 build_libraries.pl
@@ -4,13 +4,13 @@
use Cwd qw(getcwd);
use File::Basename qw(fileparse);
use Log::Fu;
-use File::Slurp qw(read_file write_file);
use File::Spec;
use Dir::Self;
use Config;
-use Getopt::Long;
+use File::Path qw(mkpath);
use lib __DIR__;
+use PLCB_ConfUtil;
require 'PLCB_Config.pm';
@@ -18,7 +18,7 @@
sub runcmd {
my $cmd = join(" ", @_);
- system($cmd) == 0 or die "$cmd failed";
+ system($cmd . " > /dev/null") == 0 or die "$cmd failed";
}
#Figure out various ways to get a tarball
@@ -44,19 +44,23 @@ sub tarball_2_dir {
return $filename;
}
-chdir 'src';
-my $TOPLEVEL = getcwd();
-my $INST_DIR = File::Spec->catfile($TOPLEVEL, 'inst');
+my $TOPLEVEL = PLCB_ConfUtil::get_toplevel_dir();
+my $INST_DIR = PLCB_ConfUtil::get_inst_dir();
+
+chdir $TOPLEVEL;
+mkpath($INST_DIR);
+
log_info("We're in $TOPLEVEL now");
my @COMMON_OPTIONS = (
"--prefix=$INST_DIR",
qw(
+--silent
--disable-shared
--enable-static
--without-docs)
);
-runcmd("tar xf $MEMCACHED_H_TARBALL");
+runcmd("tar xf $MEMCACHED_H_TARBALL -C $INST_DIR");
$ENV{CPPFLAGS} .= ' -fPIC ';
#build libvbucket first:
@@ -64,23 +68,45 @@ sub tarball_2_dir {
chdir tarball_2_dir($LIBVBUCKET_TARBALL);
if(!-e 'Makefile') {
runcmd("./configure", @COMMON_OPTIONS);
+ log_info("Configured libvbucket");
}
- runcmd("make install check -sj20");
+
+ runcmd("make");
+ log_info("build libvbucket");
+ runcmd("make install");
+ log_info("installed libvbucket");
+ runcmd("make check");
+ log_info("tested libvbucket");
}
{
chdir $TOPLEVEL;
chdir tarball_2_dir($LIBCOUCHBASE_TARBALL);
- $ENV{CPPFLAGS} .= "-I".File::Spec->catfile($TOPLEVEL, "include");
$ENV{CPPFLAGS} .= " -I".File::Spec->catfile($INST_DIR, "include");
$ENV{LDFLAGS} .= " -lm -L".File::Spec->catfile($INST_DIR, "lib");
log_info("CPPFLAGS:", $ENV{CPPFLAGS});
log_info("LDFLAS:", $ENV{LDFLAGS});
+
+ my @libcouchbase_options = (
+ @COMMON_OPTIONS,
+ "--disable-tools",
+ "--enable-embed-libevent-plugin",
+ );
+
+ my $have_java = eval { runcmd("java", "-version"); 1; };
+ my $mockpath = File::Spec->catfile(
+ __DIR__, 't', 'tmp', 'CouchbaseMock.jar');
+
+ if($have_java && -e $mockpath) {
+ push @libcouchbase_options, '--with-couchbase-mock='.$mockpath;
+ } else {
+ push @libcouchbase_options, '--disable-couchbasemock';
+ }
+
if(!-e 'Makefile') {
- runcmd("./configure", @COMMON_OPTIONS, "--disable-tools",
- "--enable-embed-libevent-plugin");
+ runcmd("./configure", @libcouchbase_options);
}
- runcmd("make install check -sj20");
+ runcmd("make install check -s");
}
#Write a little file about where our stuff is located:
View
7 error_constants.pl
@@ -1,7 +1,10 @@
-use ExtUtils::H2PM;
+#!/usr/bin/perl
use PLCB_ConfUtil;
-PLCB_ConfUtil::set_gcc_env();
+BEGIN {
+ PLCB_ConfUtil::env_from_tmpflags();
+}
+use ExtUtils::H2PM;
module "Couchbase::Client::Errors";
use_export;
View
16 idx_constants.pl
@@ -1,6 +1,10 @@
-use ExtUtils::H2PM;
use PLCB_ConfUtil;
+BEGIN {
+ PLCB_ConfUtil::env_from_tmpflags();
+}
+
+use ExtUtils::H2PM;
module "Couchbase::Client::IDXConst";
use_export;
@@ -9,8 +13,6 @@
include "perl-couchbase.h";
include "perl-couchbase-async.h";
-PLCB_ConfUtil::set_gcc_env();
-
my @const_bases = qw(
CTORIDX_SERVERS
CTORIDX_USERNAME
@@ -18,15 +20,15 @@
CTORIDX_BUCKET
CTORIDX_STOREFLAGS
CTORIDX_MYFLAGS
-
+
CTORIDX_COMP_THRESHOLD
CTORIDX_COMP_METHODS
-
+
CTORIDX_SERIALIZE_METHODS
-
+
CTORIDX_TIMEOUT
CTORIDX_NO_CONNECT
-
+
RETIDX_VALUE
RETIDX_ERRSTR
RETIDX_CAS
View
3  lib/Couchbase/Client.pm
@@ -119,7 +119,8 @@ sub _MkCtorIDX {
my %RETRY_ERRORS = (
COUCHBASE_NETWORK_ERROR, 1,
COUCHBASE_CONNECT_ERROR, 1,
- COUCHBASE_ETIMEDOUT, 1
+ COUCHBASE_ETIMEDOUT, 1,
+ COUCHBASE_UNKNOWN_HOST, 1
);
sub new {
View
31 lib/Couchbase/Client/Errors_const.pm
@@ -1,31 +0,0 @@
-package Couchbase::Client::Errors;
-# This module was generated automatically by ExtUtils::H2PM from error_constants.pl
-
-push @EXPORT, 'COUCHBASE_SUCCESS', 'COUCHBASE_AUTH_CONTINUE', 'COUCHBASE_AUTH_ERROR', 'COUCHBASE_DELTA_BADVAL', 'COUCHBASE_E2BIG', 'COUCHBASE_EBUSY', 'COUCHBASE_EINTERNAL', 'COUCHBASE_EINVAL', 'COUCHBASE_ENOMEM', 'COUCHBASE_ERANGE', 'COUCHBASE_ERROR', 'COUCHBASE_ETMPFAIL', 'COUCHBASE_KEY_EEXISTS', 'COUCHBASE_KEY_ENOENT', 'COUCHBASE_LIBEVENT_ERROR', 'COUCHBASE_NETWORK_ERROR', 'COUCHBASE_NOT_MY_VBUCKET', 'COUCHBASE_NOT_STORED', 'COUCHBASE_NOT_SUPPORTED', 'COUCHBASE_UNKNOWN_COMMAND', 'COUCHBASE_UNKNOWN_HOST', 'COUCHBASE_PROTOCOL_ERROR', 'COUCHBASE_ETIMEDOUT', 'COUCHBASE_CONNECT_ERROR', 'COUCHBASE_BUCKET_ENOENT';
-use constant COUCHBASE_SUCCESS => 0;
-use constant COUCHBASE_AUTH_CONTINUE => 1;
-use constant COUCHBASE_AUTH_ERROR => 2;
-use constant COUCHBASE_DELTA_BADVAL => 3;
-use constant COUCHBASE_E2BIG => 4;
-use constant COUCHBASE_EBUSY => 5;
-use constant COUCHBASE_EINTERNAL => 6;
-use constant COUCHBASE_EINVAL => 7;
-use constant COUCHBASE_ENOMEM => 8;
-use constant COUCHBASE_ERANGE => 9;
-use constant COUCHBASE_ERROR => 10;
-use constant COUCHBASE_ETMPFAIL => 11;
-use constant COUCHBASE_KEY_EEXISTS => 12;
-use constant COUCHBASE_KEY_ENOENT => 13;
-use constant COUCHBASE_LIBEVENT_ERROR => 14;
-use constant COUCHBASE_NETWORK_ERROR => 15;
-use constant COUCHBASE_NOT_MY_VBUCKET => 16;
-use constant COUCHBASE_NOT_STORED => 17;
-use constant COUCHBASE_NOT_SUPPORTED => 18;
-use constant COUCHBASE_UNKNOWN_COMMAND => 19;
-use constant COUCHBASE_UNKNOWN_HOST => 20;
-use constant COUCHBASE_PROTOCOL_ERROR => 21;
-use constant COUCHBASE_ETIMEDOUT => 22;
-use constant COUCHBASE_CONNECT_ERROR => 23;
-use constant COUCHBASE_BUCKET_ENOENT => 24;
-
-1;
View
70 lib/Couchbase/Client/IDXConst_const.pm
@@ -1,70 +0,0 @@
-package Couchbase::Client::IDXConst;
-# This module was generated automatically by ExtUtils::H2PM from idx_constants.pl
-
-push @EXPORT, 'CTORIDX_SERVERS', 'CTORIDX_USERNAME', 'CTORIDX_PASSWORD', 'CTORIDX_BUCKET', 'CTORIDX_STOREFLAGS', 'CTORIDX_MYFLAGS', 'CTORIDX_COMP_THRESHOLD', 'CTORIDX_COMP_METHODS', 'CTORIDX_SERIALIZE_METHODS', 'CTORIDX_TIMEOUT', 'CTORIDX_NO_CONNECT', 'RETIDX_VALUE', 'RETIDX_ERRSTR', 'RETIDX_CAS', 'RETIDX_ERRNUM', 'fUSE_COMPAT_FLAGS', 'fUSE_COMPRESSION', 'fUSE_STORABLE', 'fUSE_CONVERT_UTF8', 'fNO_CONNECT', 'fDECONVERT', 'fDEREF_RVPV', 'CTORIDX_CBEVMOD', 'CTORIDX_CBERR', 'CTORIDX_CBTIMERMOD', 'CTORIDX_CBWAITDONE', 'CTORIDX_BLESS_EVENT', 'COUCHBASE_READ_EVENT', 'COUCHBASE_WRITE_EVENT', 'REQIDX_KEY', 'REQIDX_VALUE', 'REQIDX_EXP', 'REQIDX_CAS', 'REQIDX_ARITH_DELTA', 'REQIDX_ARITH_INITIAL', 'REQIDX_STAT_ARGS', 'PLCBA_CMD_SET', 'PLCBA_CMD_GET', 'PLCBA_CMD_ADD', 'PLCBA_CMD_REPLACE', 'PLCBA_CMD_APPEND', 'PLCBA_CMD_PREPEND', 'PLCBA_CMD_REMOVE', 'PLCBA_CMD_TOUCH', 'PLCBA_CMD_ARITHMETIC', 'PLCBA_CMD_STATS', 'PLCBA_CMD_FLUSH', 'REQTYPE_SINGLE', 'REQTYPE_MULTI', 'CBTYPE_COMPLETION', 'CBTYPE_INCREMENTAL', 'EVIDX_FD', 'EVIDX_DUPFH', 'EVIDX_WATCHFLAGS', 'EVIDX_STATEFLAGS', 'EVIDX_OPAQUE', 'EVIDX_PLDATA', 'EVACTION_WATCH', 'EVACTION_UNWATCH', 'EVACTION_SUSPEND', 'EVACTION_RESUME', 'EVSTATE_INITIALIZED', 'EVSTATE_ACTIVE', 'EVSTATE_SUSPENDED';
-use constant CTORIDX_SERVERS => 0;
-use constant CTORIDX_USERNAME => 1;
-use constant CTORIDX_PASSWORD => 2;
-use constant CTORIDX_BUCKET => 3;
-use constant CTORIDX_STOREFLAGS => 5;
-use constant CTORIDX_MYFLAGS => 4;
-use constant CTORIDX_COMP_THRESHOLD => 6;
-use constant CTORIDX_COMP_METHODS => 7;
-use constant CTORIDX_SERIALIZE_METHODS => 8;
-use constant CTORIDX_TIMEOUT => 10;
-use constant CTORIDX_NO_CONNECT => 11;
-use constant RETIDX_VALUE => 0;
-use constant RETIDX_ERRSTR => 2;
-use constant RETIDX_CAS => 3;
-use constant RETIDX_ERRNUM => 1;
-use constant fUSE_COMPAT_FLAGS => 2;
-use constant fUSE_COMPRESSION => 4;
-use constant fUSE_STORABLE => 8;
-use constant fUSE_CONVERT_UTF8 => 16;
-use constant fNO_CONNECT => 32;
-use constant fDECONVERT => 64;
-use constant fDEREF_RVPV => 512;
-use constant CTORIDX_CBEVMOD => 10;
-use constant CTORIDX_CBERR => 12;
-use constant CTORIDX_CBTIMERMOD => 11;
-use constant CTORIDX_CBWAITDONE => 13;
-use constant CTORIDX_BLESS_EVENT => 14;
-use constant COUCHBASE_READ_EVENT => 2;
-use constant COUCHBASE_WRITE_EVENT => 4;
-use constant REQIDX_KEY => 0;
-use constant REQIDX_VALUE => 1;
-use constant REQIDX_EXP => 2;
-use constant REQIDX_CAS => 3;
-use constant REQIDX_ARITH_DELTA => 4;
-use constant REQIDX_ARITH_INITIAL => 5;
-use constant REQIDX_STAT_ARGS => 6;
-use constant PLCBA_CMD_SET => 2;
-use constant PLCBA_CMD_GET => 1;
-use constant PLCBA_CMD_ADD => 4;
-use constant PLCBA_CMD_REPLACE => 8;
-use constant PLCBA_CMD_APPEND => 16;
-use constant PLCBA_CMD_PREPEND => 18;
-use constant PLCBA_CMD_REMOVE => 32;
-use constant PLCBA_CMD_TOUCH => 48;
-use constant PLCBA_CMD_ARITHMETIC => 256;
-use constant PLCBA_CMD_STATS => 258;
-use constant PLCBA_CMD_FLUSH => 259;
-use constant REQTYPE_SINGLE => 0;
-use constant REQTYPE_MULTI => 1;
-use constant CBTYPE_COMPLETION => 0;
-use constant CBTYPE_INCREMENTAL => 1;
-use constant EVIDX_FD => 0;
-use constant EVIDX_DUPFH => 1;
-use constant EVIDX_WATCHFLAGS => 2;
-use constant EVIDX_STATEFLAGS => 3;
-use constant EVIDX_OPAQUE => 4;
-use constant EVIDX_PLDATA => 5;
-use constant EVACTION_WATCH => 0;
-use constant EVACTION_UNWATCH => 1;
-use constant EVACTION_SUSPEND => 2;
-use constant EVACTION_RESUME => 3;
-use constant EVSTATE_INITIALIZED => 0;
-use constant EVSTATE_ACTIVE => 1;
-use constant EVSTATE_SUSPENDED => 2;
-
-1;
View
121 lib/Couchbase/MockServer.pm
@@ -1,7 +1,6 @@
package Couchbase::MockServer;
use strict;
use warnings;
-use LWP::UserAgent;
use File::Basename;
use URI;
use File::Path qw(mkpath);
@@ -19,24 +18,54 @@ our $INSTANCE;
use Class::XSAccessor {
constructor => '_real_new',
accessors => [qw(
- harakiri_addr
- port
pid
- dir
- url
+ jarfile
nodes
buckets
vbuckets
harakiri_socket
+ port
)]
};
# This is the couchbase mock server, it will attempt to download, spawn, and
# otherwise control the java-based CouchbaseMock server.
+
+sub _accept_harakiri {
+ my $self = shift;
+ $self->harakiri_socket->blocking(0);
+ my $begin_time = time();
+ my $max_wait = 5;
+ my $got_accept = 0;
+ while(time - $begin_time < $max_wait) {
+ my $sock = $self->harakiri_socket->accept();
+ if($sock) {
+ $self->harakiri_socket($sock);
+ $got_accept = 1;
+ log_info("Got harakiri connection");
+ my $buf = "";
+ $self->harakiri_socket->recv($buf, 100, 0);
+ if($buf) {
+ my ($port) = ($buf =~ /(\d+)/);
+ $self->port($port);
+ } else {
+ die("Couldn't get port");
+ }
+ last;
+ } else {
+ sleep(0.1);
+ }
+ }
+ if(!$got_accept) {
+ die("Could not establish harakiri control connection");
+ }
+ $self->harakiri_socket->blocking(1);
+}
+
sub _do_run {
my $self = shift;
my @command;
- push @command, "java", "-jar", $self->dir . "/$SYMLINK";
+ push @command, "java", "-jar", $self->jarfile;
my $buckets_arg = "--buckets=";
@@ -56,21 +85,17 @@ sub _do_run {
push @command, $buckets_arg;
- push @command, "--port=" . $self->port;
+ push @command, "--port=0";
if($self->nodes) {
push @command, "--nodes=" . $self->nodes;
}
- if($self->harakiri_addr) {
- push @command, "--harakiri-monitor=" . $self->harakiri_addr
- } else {
- my $sock = IO::Socket::INET->new(Listen => 5);
- $self->harakiri_socket($sock);
- my $port = $self->harakiri_socket->sockport;
- log_infof("Listening on %d for harakiri", $port);
- push @command, "--harakiri-monitor=localhost:$port";
- }
+ my $sock = IO::Socket::INET->new(Listen => 5);
+ $self->harakiri_socket($sock);
+ my $port = $self->harakiri_socket->sockport;
+ log_infof("Listening on %d for harakiri", $port);
+ push @command, "--harakiri-monitor=localhost:$port";
my $pid = fork();
@@ -82,29 +107,7 @@ sub _do_run {
die("Child process died prematurely");
}
log_info("Launched CouchbaseMock PID=$pid");
- if($self->harakiri_socket) {
- $self->harakiri_socket->blocking(0);
- my $begin_time = time();
- my $max_wait = 5;
- my $got_accept = 0;
- while(time - $begin_time < $max_wait) {
- my $sock = $self->harakiri_socket->accept();
- if($sock) {
- $self->harakiri_socket($sock);
- $got_accept = 1;
- log_info("Got harakiri connection");
- my $buf;
- $self->harakiri_socket->recv($buf, 100, 0);
- last;
- } else {
- sleep(0.1);
- }
- }
- if(!$got_accept) {
- die("Could not establish harakiri control connection");
- }
- $self->harakiri_socket->blocking(1);
- }
+ $self->_accept_harakiri();
} else {
log_warnf("Executing %s", join(" ", @command));
exec(@command);
@@ -119,42 +122,16 @@ sub new {
log_warn("Returning cached instance");
return $INSTANCE;
}
- unless(exists $opts{url} and exists $opts{dir}) {
- die("Must have directory and URL");
- }
- my $o = $cls->_real_new(%opts);
- my $dir = $o->dir;
- my $url = URI->new($o->url);
- my $basepath = basename($url->path);
- my $fqpath = "$dir/$basepath";
-
- if(!-d $dir) {
- mkpath($dir);
- }
- if(!-e $fqpath) {
- log_warn("$fqpath does not exist. Downloading..");
- my $ua = LWP::UserAgent->new();
- $ua->get($url, ':content_file' => $fqpath);
+ unless(exists $opts{jarfile}) {
+ die("Must have path to JAR");
}
-
- unlink("$dir/$SYMLINK");
- symlink($fqpath, "$dir/$SYMLINK");
- #
- #Initialize buckets to their defaults
- if(!$o->buckets) {
- $o->buckets([{
- name => "default",
- #does mock not support SASL?
- #password => "secret"
- }]);
- }
-
- #initialize port to the default, if not there already
- if(!$o->port) {
- $o->port(8091);
+ my $o = $cls->_real_new(%opts);
+ my $file = $o->jarfile;
+ if(!-e $file) {
+ die("Cannot find $file");
}
-
+
$o->_do_run();
$INSTANCE = $o;
return $o;
View
2  lib/Couchbase/Test/Common.pm
@@ -143,7 +143,7 @@ sub Initialize {
eval {
$Mock = Couchbase::MockServer->new(%opts);
}; if( ($@ || (!$Mock)) && $$ == $init_pid) {
- $cls->SKIP_ALL("Cannot run tests without mock server");
+ $cls->SKIP_ALL("Cannot run tests without mock server ($@)");
}
return $Mock;
}
View
2  lib/Couchbase/Test/Netfail.pm
@@ -20,7 +20,7 @@ my $have_vbucket = eval {
};
if($Couchbase::Test::Common::RealServer) {
- __PACKAGE__->SKIP_CLASS("Can't perform network tests on real server");
+ __PACKAGE__->SKIP_CLASS("Can't perform network failure tests on real cluster");
}
sub startup_tests :Test(startup)
View
4 t/01-main.t
@@ -10,9 +10,7 @@ use Couchbase::Test::Common;
my $TEST_PORT;
Couchbase::Test::Common->Initialize(
- url => $config->{COUCHBASE_MOCK_JARURL},
- dir => __DIR__ . "/tmp",
- port => 8092,
+ jarfile => __DIR__ . "/tmp/CouchbaseMock.jar",
nodes => 5,
buckets => [{name => "default", type => "memcache"}],
);
Please sign in to comment.
Something went wrong with that request. Please try again.