summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/components/cache
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sca-cpp/trunk/components/cache/Makefile.am4
-rw-r--r--sca-cpp/trunk/components/cache/client-test.cpp2
-rw-r--r--sca-cpp/trunk/components/cache/memcache-test.cpp6
-rw-r--r--sca-cpp/trunk/components/cache/memcache.hpp10
-rwxr-xr-xsca-cpp/trunk/components/cache/memcached-ssl-test52
-rwxr-xr-xsca-cpp/trunk/components/cache/memcached-start15
-rwxr-xr-xsca-cpp/trunk/components/cache/memcached-stop15
7 files changed, 83 insertions, 21 deletions
diff --git a/sca-cpp/trunk/components/cache/Makefile.am b/sca-cpp/trunk/components/cache/Makefile.am
index 4af8acd6bf..580a5e4d84 100644
--- a/sca-cpp/trunk/components/cache/Makefile.am
+++ b/sca-cpp/trunk/components/cache/Makefile.am
@@ -39,6 +39,6 @@ memcache_test_LDFLAGS = -lxml2
client_test_SOURCES = client-test.cpp
client_test_LDFLAGS = -lxml2 -lcurl -lmozjs
-dist_noinst_SCRIPTS = memcached-test server-test
+dist_noinst_SCRIPTS = memcached-test memcached-ssl-test server-test
noinst_PROGRAMS = memcache-test client-test
-TESTS = memcached-test server-test
+TESTS = memcached-test memcached-ssl-test server-test
diff --git a/sca-cpp/trunk/components/cache/client-test.cpp b/sca-cpp/trunk/components/cache/client-test.cpp
index e3ec449e69..25bdb722f3 100644
--- a/sca-cpp/trunk/components/cache/client-test.cpp
+++ b/sca-cpp/trunk/components/cache/client-test.cpp
@@ -31,7 +31,7 @@
#include "value.hpp"
#include "monad.hpp"
#include "perf.hpp"
-#include "../../modules/http/curl.hpp"
+#include "../../modules/http/http.hpp"
namespace tuscany {
namespace cache {
diff --git a/sca-cpp/trunk/components/cache/memcache-test.cpp b/sca-cpp/trunk/components/cache/memcache-test.cpp
index 289037a179..49848dd2a7 100644
--- a/sca-cpp/trunk/components/cache/memcache-test.cpp
+++ b/sca-cpp/trunk/components/cache/memcache-test.cpp
@@ -37,9 +37,9 @@ bool testMemCached() {
const value k = mklist<value>("a");
assert(hasContent(post(k, string("AAA"), ch)));
- assert((get(k, ch)) == value(string("AAA")));
+ assert(get(k, ch) == value(string("AAA")));
assert(hasContent(put(k, string("aaa"), ch)));
- assert((get(k, ch)) == value(string("aaa")));
+ assert(get(k, ch) == value(string("aaa")));
assert(hasContent(del(k, ch)));
assert(!hasContent(get(k, ch)));
@@ -52,7 +52,7 @@ struct getLoop {
getLoop(const value& k, MemCached& ch) : k(k), ch(ch) {
}
const bool operator()() const {
- assert((get(k, ch)) == value(string("CCC")));
+ assert(get(k, ch) == value(string("CCC")));
return true;
}
};
diff --git a/sca-cpp/trunk/components/cache/memcache.hpp b/sca-cpp/trunk/components/cache/memcache.hpp
index 213120891f..8749f845bf 100644
--- a/sca-cpp/trunk/components/cache/memcache.hpp
+++ b/sca-cpp/trunk/components/cache/memcache.hpp
@@ -89,7 +89,7 @@ private:
*/
const failable<bool> addServer(const string& host, const int port) {
apr_memcache_server_t *server;
- const apr_status_t sc = apr_memcache_server_create(pool, c_str(host), (apr_port_t)port, 0, 1, 1, 60, &server);
+ const apr_status_t sc = apr_memcache_server_create(pool, c_str(host), (apr_port_t)port, 1, 1, 1, 600, &server);
if (sc != APR_SUCCESS)
return mkfailure<bool>("Could not create server");
const apr_status_t as = apr_memcache_add_server(mc, server);
@@ -161,21 +161,13 @@ const failable<value> get(const value& key, const MemCached& cache) {
debug(key, "memcache::get::key");
const string ks(scheme::writeValue(key));
- apr_pool_t* vpool;
- const apr_status_t pc = apr_pool_create(&vpool, cache.pool);
- if (pc != APR_SUCCESS)
- return mkfailure<value>("Could not allocate memory");
-
char *data;
apr_size_t size;
const apr_status_t rc = apr_memcache_getp(cache.mc, cache.pool, nospaces(c_str(ks)), &data, &size, NULL);
if (rc != APR_SUCCESS) {
- apr_pool_destroy(vpool);
return mkfailure<value>("Could not get entry");
}
-
const value val(scheme::readValue(string(data, size)));
- apr_pool_destroy(vpool);
debug(val, "memcache::get::result");
return val;
diff --git a/sca-cpp/trunk/components/cache/memcached-ssl-test b/sca-cpp/trunk/components/cache/memcached-ssl-test
new file mode 100755
index 0000000000..7e55cfdee6
--- /dev/null
+++ b/sca-cpp/trunk/components/cache/memcached-ssl-test
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Setup
+../../modules/http/ssl-ca-conf tmp/ssl localhost
+../../modules/http/ssl-cert-conf tmp/ssl localhost server
+../../modules/http/ssl-cert-conf tmp/ssl localhost tunnel
+
+./memcached-start 11411
+./memcached-start 11412
+./memcached-start 11413
+
+../../modules/http/httpd-conf tmp/tunnel localhost 8089 htdocs
+tar -C tmp/ssl -c `../../modules/http/ssl-cert-find tmp/ssl` | tar -C tmp/tunnel -x
+../../modules/http/tunnel-ssl-conf tmp/tunnel 11211 localhost 8453 11411
+../../modules/http/tunnel-ssl-conf tmp/tunnel 11212 localhost 8453 11412
+../../modules/http/tunnel-ssl-conf tmp/tunnel 11213 localhost 8453 11413
+../../modules/http/httpd-start tmp/tunnel
+
+../../modules/http/httpd-conf tmp/server localhost 8090 htdocs
+tar -C tmp/ssl -c `../../modules/http/ssl-cert-find tmp/ssl` | tar -C tmp/server -x
+../../modules/http/httpd-ssl-conf tmp/server 8453
+../../modules/http/httpd-start tmp/server
+sleep 1
+
+# Test
+./memcache-test 2>/dev/null
+rc=$?
+
+# Cleanup
+../../modules/http/httpd-stop tmp/tunnel
+../../modules/http/httpd-stop tmp/server
+./memcached-stop 11411
+./memcached-stop 11412
+./memcached-stop 11413
+return $rc
diff --git a/sca-cpp/trunk/components/cache/memcached-start b/sca-cpp/trunk/components/cache/memcached-start
index a3cecc29bf..75524d0dec 100755
--- a/sca-cpp/trunk/components/cache/memcached-start
+++ b/sca-cpp/trunk/components/cache/memcached-start
@@ -19,11 +19,20 @@
# Start memcached
here=`readlink -f $0`; here=`dirname $here`
-port=$1
-if [ "$port" = "" ]; then
+
+addr=$1
+if [ "$addr" = "" ]; then
+ ip=""
port="11211"
+else
+ ip=`$here/../../modules/http/httpd-addr ip $addr`
+ port=`$here/../../modules/http/httpd-addr port $addr`
fi
memcached_prefix=`cat $here/memcached.prefix`
-$memcached_prefix/bin/memcached -d -l 127.0.0.1 -m 4 -p $port
+if [ "$ip" = "" ]; then
+ $memcached_prefix/bin/memcached -d -m 4 -p $port
+else
+ $memcached_prefix/bin/memcached -d -l $ip -m 4 -p $port
+fi
diff --git a/sca-cpp/trunk/components/cache/memcached-stop b/sca-cpp/trunk/components/cache/memcached-stop
index 6522e1d36e..c414616752 100755
--- a/sca-cpp/trunk/components/cache/memcached-stop
+++ b/sca-cpp/trunk/components/cache/memcached-stop
@@ -19,12 +19,21 @@
# Stop memcached
here=`readlink -f $0`; here=`dirname $here`
-port=$1
-if [ "$port" = "" ]; then
+
+addr=$1
+if [ "$addr" = "" ]; then
+ ip=""
port="11211"
+else
+ ip=`$here/../../modules/http/httpd-addr ip $addr`
+ port=`$here/../../modules/http/httpd-addr port $addr`
fi
memcached_prefix=`cat $here/memcached.prefix`
-mc="$memcached_prefix/bin/memcached -d -l 127.0.0.1 -m 4 -p $port"
+if [ "$ip" = "" ]; then
+ mc="$memcached_prefix/bin/memcached -d -m 4 -p $port"
+else
+ mc="$memcached_prefix/bin/memcached -d -l $ip -m 4 -p $port"
+fi
kill `ps -ef | grep -v grep | grep "${mc}" | awk '{ print $2 }'`