summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/components
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-08-14 18:46:26 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-08-14 18:46:26 +0000
commitd6451b81703c809abcd0f51e74abdba7c732b513 (patch)
treefab2013702ae33a07e5bb43abad606e0201b485b /sca-cpp/trunk/components
parentd090bd129574458379aa9997345e7ca5b2c24886 (diff)
Some refactoring of the HTTP support, tunnel Memcached requests over HTTPS and add HTTPS config to store-cluster sample.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@985561 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/components')
-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
-rw-r--r--sca-cpp/trunk/components/chat/client-test.cpp2
-rw-r--r--sca-cpp/trunk/components/log/client-test.cpp2
-rw-r--r--sca-cpp/trunk/components/nosqldb/client-test.cpp2
-rw-r--r--sca-cpp/trunk/components/queue/client-test.cpp2
-rw-r--r--sca-cpp/trunk/components/sqldb/client-test.cpp2
-rw-r--r--sca-cpp/trunk/components/webservice/client-test.cpp2
13 files changed, 89 insertions, 27 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 }'`
diff --git a/sca-cpp/trunk/components/chat/client-test.cpp b/sca-cpp/trunk/components/chat/client-test.cpp
index f9ca2cabd6..702d3ae041 100644
--- a/sca-cpp/trunk/components/chat/client-test.cpp
+++ b/sca-cpp/trunk/components/chat/client-test.cpp
@@ -32,7 +32,7 @@
#include "monad.hpp"
#include "perf.hpp"
#include "parallel.hpp"
-#include "../../modules/http/curl.hpp"
+#include "../../modules/http/http.hpp"
#include "xmpp.hpp"
namespace tuscany {
diff --git a/sca-cpp/trunk/components/log/client-test.cpp b/sca-cpp/trunk/components/log/client-test.cpp
index d35a892f8a..e972ed59bf 100644
--- a/sca-cpp/trunk/components/log/client-test.cpp
+++ b/sca-cpp/trunk/components/log/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 log {
diff --git a/sca-cpp/trunk/components/nosqldb/client-test.cpp b/sca-cpp/trunk/components/nosqldb/client-test.cpp
index 4d3cc1ec29..f28f084487 100644
--- a/sca-cpp/trunk/components/nosqldb/client-test.cpp
+++ b/sca-cpp/trunk/components/nosqldb/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 nosqldb {
diff --git a/sca-cpp/trunk/components/queue/client-test.cpp b/sca-cpp/trunk/components/queue/client-test.cpp
index a448d1fccd..c80b2d2a31 100644
--- a/sca-cpp/trunk/components/queue/client-test.cpp
+++ b/sca-cpp/trunk/components/queue/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"
#include "qpid.hpp"
// Ignore conversion issues and redundant declarations in Qpid headers
diff --git a/sca-cpp/trunk/components/sqldb/client-test.cpp b/sca-cpp/trunk/components/sqldb/client-test.cpp
index 7712d6427c..303afe3c10 100644
--- a/sca-cpp/trunk/components/sqldb/client-test.cpp
+++ b/sca-cpp/trunk/components/sqldb/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 sqldb {
diff --git a/sca-cpp/trunk/components/webservice/client-test.cpp b/sca-cpp/trunk/components/webservice/client-test.cpp
index 9030a77676..e666895717 100644
--- a/sca-cpp/trunk/components/webservice/client-test.cpp
+++ b/sca-cpp/trunk/components/webservice/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"
#include "axis2.hpp"
namespace tuscany {