summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/samples
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sca-cpp/trunk/samples/store-cluster/Makefile.am2
-rw-r--r--sca-cpp/trunk/samples/store-cluster/domains/jane/store.composite37
-rw-r--r--sca-cpp/trunk/samples/store-cluster/domains/joe/store.composite37
-rwxr-xr-xsca-cpp/trunk/samples/store-cluster/sqldb-master-conf35
-rwxr-xr-xsca-cpp/trunk/samples/store-cluster/sqldb-standby-conf28
-rwxr-xr-xsca-cpp/trunk/samples/store-cluster/ssl-stop3
-rwxr-xr-xsca-cpp/trunk/samples/store-cluster/start12
-rwxr-xr-xsca-cpp/trunk/samples/store-cluster/stop7
-rw-r--r--sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp20
-rwxr-xr-xsca-cpp/trunk/samples/store-sql/ssl-start3
-rwxr-xr-xsca-cpp/trunk/samples/store-sql/start2
-rwxr-xr-xsca-cpp/trunk/samples/store-sql/stop1
-rw-r--r--sca-cpp/trunk/samples/store-sql/store.composite23
13 files changed, 184 insertions, 26 deletions
diff --git a/sca-cpp/trunk/samples/store-cluster/Makefile.am b/sca-cpp/trunk/samples/store-cluster/Makefile.am
index 0f933b34f3..2f18d95983 100644
--- a/sca-cpp/trunk/samples/store-cluster/Makefile.am
+++ b/sca-cpp/trunk/samples/store-cluster/Makefile.am
@@ -21,7 +21,7 @@ if WANT_OPENID
if WANT_LOG
if WANT_QUEUE
-dist_sample_SCRIPTS = start stop ssl-start ssl-stop proxy-conf proxy-ssl-conf server-conf server-ssl-conf tunnel-ssl-conf
+dist_sample_SCRIPTS = start stop ssl-start ssl-stop proxy-conf proxy-ssl-conf server-conf server-ssl-conf tunnel-ssl-conf sqldb-master-conf sqldb-standby-conf
sampledir = $(prefix)/samples/store-cluster
nobase_dist_sample_DATA = htdocs/*.html htdocs/domains/*/*.html domains/*/*.py domains/*/*.composite
diff --git a/sca-cpp/trunk/samples/store-cluster/domains/jane/store.composite b/sca-cpp/trunk/samples/store-cluster/domains/jane/store.composite
index 396970a6e6..85d6aa3a9b 100644
--- a/sca-cpp/trunk/samples/store-cluster/domains/jane/store.composite
+++ b/sca-cpp/trunk/samples/store-cluster/domains/jane/store.composite
@@ -58,15 +58,44 @@
<t:implementation.python script="currency-converter.py"/>
<service name="CurrencyConverter">
<t:binding.jsonrpc uri="currencyConverter"/>
- </service>
- </component>
+ </service>
+ </component>
<component name="Cache">
- <implementation.cpp path="../../../../components/cache" library="libmemcache"/>
+ <implementation.cpp path="../../../../components/cache" library="libfrontcache"/>
<service name="Cache">
<t:binding.atom uri="cache"/>
</service>
+ <reference name="l1reader" target="Memcache"/>
+ <reference name="l1writer" target="Memcache"/>
+ <reference name="l2reader" target="Standbydb"/>
+ <reference name="l2writer" target="Masterdb"/>
+ </component>
+
+ <component name="Memcache">
+ <implementation.cpp path="../../../../components/cache" library="libmemcache"/>
+ <service name="Memcache">
+ <t:binding.atom uri="memcache"/>
+ </service>
<property name="servers">localhost:11211,localhost:11212,localhost:11213</property>
- </component>
+ </component>
+
+ <component name="Masterdb">
+ <implementation.cpp path="../../../../components/sqldb" library="libsqldb"/>
+ <property name="conninfo">host=localhost port=5432 dbname=db</property>
+ <property name="table">store</property>
+ <service name="Masterdb">
+ <t:binding.atom uri="masterdb"/>
+ </service>
+ </component>
+
+ <component name="Standbydb">
+ <implementation.cpp path="../../../../components/sqldb" library="libsqldb"/>
+ <property name="conninfo">host=localhost port=5433 dbname=db</property>
+ <property name="table">store</property>
+ <service name="Standbydb">
+ <t:binding.atom uri="standbydb"/>
+ </service>
+ </component>
</composite>
diff --git a/sca-cpp/trunk/samples/store-cluster/domains/joe/store.composite b/sca-cpp/trunk/samples/store-cluster/domains/joe/store.composite
index 396970a6e6..ca7815d573 100644
--- a/sca-cpp/trunk/samples/store-cluster/domains/joe/store.composite
+++ b/sca-cpp/trunk/samples/store-cluster/domains/joe/store.composite
@@ -58,15 +58,44 @@
<t:implementation.python script="currency-converter.py"/>
<service name="CurrencyConverter">
<t:binding.jsonrpc uri="currencyConverter"/>
- </service>
- </component>
+ </service>
+ </component>
<component name="Cache">
- <implementation.cpp path="../../../../components/cache" library="libmemcache"/>
+ <implementation.cpp path="../../../../components/cache" library="libfrontcache"/>
<service name="Cache">
<t:binding.atom uri="cache"/>
</service>
+ <reference name="l1reader" target="Memcache"/>
+ <reference name="l1writer" target="Memcache"/>
+ <reference name="l2reader" target="Standbydb"/>
+ <reference name="l2writer" target="Masterdb"/>
+ </component>
+
+ <component name="Memcache">
+ <implementation.cpp path="../../../../components/cache" library="libmemcache"/>
+ <service name="Memcache">
+ <t:binding.atom uri="memcache"/>
+ </service>
<property name="servers">localhost:11211,localhost:11212,localhost:11213</property>
- </component>
+ </component>
+
+ <component name="Masterdb">
+ <implementation.cpp path="../../../../components/sqldb" library="libsqldb"/>
+ <property name="conninfo">host=localhost port=5432 dbname=db</property>
+ <property name="table">store</property>
+ <service name="Masterdb">
+ <t:binding.atom uri="masterdb"/>
+ </service>
+ </component>
+
+ <component name="Standbydb">
+ <implementation.cpp path="../../../../components/sqldb" library="libsqldb"/>
+ <property name="conninfo">host=localhost port=5434 dbname=db</property>
+ <property name="table">store</property>
+ <service name="Standbydb">
+ <t:binding.atom uri="standbydb"/>
+ </service>
+ </component>
</composite>
diff --git a/sca-cpp/trunk/samples/store-cluster/sqldb-master-conf b/sca-cpp/trunk/samples/store-cluster/sqldb-master-conf
new file mode 100755
index 0000000000..cd85f1e328
--- /dev/null
+++ b/sca-cpp/trunk/samples/store-cluster/sqldb-master-conf
@@ -0,0 +1,35 @@
+#!/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.
+
+root=$1
+port=$2
+
+# Configure a database server
+if [ ! -f $root/sqldb/data/postgresql.conf ]; then
+ create="true"
+else
+ create="false"
+fi
+../../components/sqldb/pgsql-conf $root $port
+if [ "$create" = "true" ]; then
+ ../../components/sqldb/pgsql-start $root
+ ../../components/sqldb/pgsql localhost $port "create table store(key text, value text);" 1>/dev/null 2>&1
+ ../../components/sqldb/pgsql-stop $root
+fi
+
diff --git a/sca-cpp/trunk/samples/store-cluster/sqldb-standby-conf b/sca-cpp/trunk/samples/store-cluster/sqldb-standby-conf
new file mode 100755
index 0000000000..d1dec9930b
--- /dev/null
+++ b/sca-cpp/trunk/samples/store-cluster/sqldb-standby-conf
@@ -0,0 +1,28 @@
+#!/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.
+
+root=$1
+mhost=$2
+mport=$3
+mhttpport=$4
+port=$5
+
+# Configure a standby database server
+../../components/sqldb/pgsql-standby-conf $root $mhost $mport $mhttpport $port
+
diff --git a/sca-cpp/trunk/samples/store-cluster/ssl-stop b/sca-cpp/trunk/samples/store-cluster/ssl-stop
index 97af3d7faa..3c52c60399 100755
--- a/sca-cpp/trunk/samples/store-cluster/ssl-stop
+++ b/sca-cpp/trunk/samples/store-cluster/ssl-stop
@@ -20,9 +20,12 @@
../../modules/http/httpd-stop tmp/server1
../../modules/http/httpd-stop tmp/server2
../../modules/http/httpd-stop tmp/server3
+
../../modules/http/httpd-stop tmp/proxy1
../../modules/http/httpd-stop tmp/proxy2
+
../../components/cache/memcached-stop 127.0.0.1:11411
../../components/cache/memcached-stop 127.0.0.1:11412
../../components/cache/memcached-stop 127.0.0.1:11413
+
../../modules/http/httpd-stop tmp/tunnel1
diff --git a/sca-cpp/trunk/samples/store-cluster/start b/sca-cpp/trunk/samples/store-cluster/start
index 4612ca2770..2b3afc320c 100755
--- a/sca-cpp/trunk/samples/store-cluster/start
+++ b/sca-cpp/trunk/samples/store-cluster/start
@@ -22,15 +22,25 @@
../../components/cache/memcached-start 11212
../../components/cache/memcached-start 11213
-# Start three app servers
+# Start three app servers, with a master database and
+# two hot standby databases
./server-conf tmp/server1 8101
+./sqldb-master-conf tmp/server1 5432
+../../components/sqldb/pgsql-start tmp/server1
../../modules/http/httpd-start tmp/server1
+sleep 1
./server-conf tmp/server2 8102
+./sqldb-standby-conf tmp/server2 localhost 5432 8101 5433
+../../components/sqldb/pgsql-start tmp/server2
../../modules/http/httpd-start tmp/server2
+sleep 1
./server-conf tmp/server3 8103
+./sqldb-standby-conf tmp/server3 localhost 5432 8101 5434
+../../components/sqldb/pgsql-start tmp/server3
../../modules/http/httpd-start tmp/server3
+sleep 1
# Start two proxy balancers
./proxy-conf tmp/proxy1 8091
diff --git a/sca-cpp/trunk/samples/store-cluster/stop b/sca-cpp/trunk/samples/store-cluster/stop
index 9df37dc948..d3d29f9cb2 100755
--- a/sca-cpp/trunk/samples/store-cluster/stop
+++ b/sca-cpp/trunk/samples/store-cluster/stop
@@ -17,11 +17,18 @@
# specific language governing permissions and limitations
# under the License.
+../../components/sqldb/pgsql-stop tmp/server2
+../../components/sqldb/pgsql-stop tmp/server3
+../../components/sqldb/pgsql-stop tmp/server1
+
../../modules/http/httpd-stop tmp/server1
../../modules/http/httpd-stop tmp/server2
../../modules/http/httpd-stop tmp/server3
+
../../modules/http/httpd-stop tmp/proxy1
../../modules/http/httpd-stop tmp/proxy2
+
../../components/cache/memcached-stop 11211
../../components/cache/memcached-stop 11212
../../components/cache/memcached-stop 11213
+
diff --git a/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp b/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp
index 5cbbb2feff..3a1df44490 100644
--- a/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp
+++ b/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp
@@ -23,8 +23,6 @@
* Shopping cart component implementation.
*/
-#include <apr_general.h>
-#include <apr_uuid.h>
#include "string.hpp"
#include "function.hpp"
#include "list.hpp"
@@ -42,27 +40,21 @@ const string cartId("1234");
*/
const list<value> getcart(const value& id, const lambda<value(const list<value>&)> cache) {
const value cart = cache(mklist<value>("get", mklist<value>(id)));
+ cerr << "cart value: " << cart << "\n";
+ const failable<value> fcart = cart;
+ cerr << "cart fvalue: " << fcart << "\n";
+ cerr << "cart content: " << content(fcart) << "\n";
+ cerr << "cart reason: " << reason(fcart) << "\n";
if (isNil(cart))
return value(list<value>());
return (list<value>)cart;
}
/**
- * Returns a UUID.
- */
-const value uuid() {
- apr_uuid_t uuid;
- apr_uuid_get(&uuid);
- char buf[APR_UUID_FORMATTED_LENGTH];
- apr_uuid_format(buf, &uuid);
- return string(buf, APR_UUID_FORMATTED_LENGTH);
-}
-
-/**
* Post a new item to the cart. Create a new cart if necessary.
*/
const failable<value> post(unused const list<value>& collection, const value& item, const lambda<value(const list<value>&)> cache) {
- const value id(uuid());
+ const value id(mkuuid());
const list<value> newItem(mklist<value>(car<value>(item), id, caddr<value>(item)));
const list<value> cart(cons<value>(newItem, getcart(cartId, cache)));
cache(mklist<value>("put", mklist<value>(cartId), cart));
diff --git a/sca-cpp/trunk/samples/store-sql/ssl-start b/sca-cpp/trunk/samples/store-sql/ssl-start
index 46e46dd32c..9263e16dfb 100755
--- a/sca-cpp/trunk/samples/store-sql/ssl-start
+++ b/sca-cpp/trunk/samples/store-sql/ssl-start
@@ -21,6 +21,7 @@
../../modules/http/ssl-cert-conf tmp localhost
../../modules/http/httpd-conf tmp localhost 8090 htdocs
../../modules/http/httpd-ssl-conf tmp 8453
+../../modules/http/httpd-auth-conf tmp
../../modules/server/server-conf tmp
../../modules/server/scheme-conf tmp
cat >>tmp/conf/httpd.conf <<EOF
@@ -30,6 +31,8 @@ SCAComposite store.composite
EOF
+../../components/cache/memcached-start
+../../components/sqldb/pgsql-conf tmp
../../components/sqldb/pgsql-start tmp
../../components/sqldb/pgsql "create table store(key text, value text);" 1>/dev/null 2>&1
../../modules/http/httpd-start tmp
diff --git a/sca-cpp/trunk/samples/store-sql/start b/sca-cpp/trunk/samples/store-sql/start
index 60f5a2d702..95881294d1 100755
--- a/sca-cpp/trunk/samples/store-sql/start
+++ b/sca-cpp/trunk/samples/store-sql/start
@@ -27,6 +27,8 @@ SCAComposite store.composite
EOF
+../../components/cache/memcached-start
+../../components/sqldb/pgsql-conf tmp
../../components/sqldb/pgsql-start tmp
../../components/sqldb/pgsql "create table store(key text, value text);" 1>/dev/null 2>&1
../../modules/http/httpd-start tmp
diff --git a/sca-cpp/trunk/samples/store-sql/stop b/sca-cpp/trunk/samples/store-sql/stop
index 603165ef46..2226018a3f 100755
--- a/sca-cpp/trunk/samples/store-sql/stop
+++ b/sca-cpp/trunk/samples/store-sql/stop
@@ -19,3 +19,4 @@
../../modules/http/httpd-stop tmp
../../components/sqldb/pgsql-stop tmp
+../../components/cache/memcached-stop
diff --git a/sca-cpp/trunk/samples/store-sql/store.composite b/sca-cpp/trunk/samples/store-sql/store.composite
index 501d465b03..18a77c2802 100644
--- a/sca-cpp/trunk/samples/store-sql/store.composite
+++ b/sca-cpp/trunk/samples/store-sql/store.composite
@@ -49,7 +49,7 @@
<service name="Total">
<t:binding.jsonrpc uri="total"/>
</service>
- <reference name="cache" target="Sqldb"/>
+ <reference name="cache" target="Cache"/>
</component>
<component name="CurrencyConverter">
@@ -59,9 +59,28 @@
</service>
</component>
+ <component name="Cache">
+ <implementation.cpp path="../../components/cache" library="libfrontcache"/>
+ <service name="Cache">
+ <t:binding.atom uri="cache"/>
+ </service>
+ <reference name="l1reader" target="Memcache"/>
+ <reference name="l1writer" target="Memcache"/>
+ <reference name="l2reader" target="Sqldb"/>
+ <reference name="l2writer" target="Sqldb"/>
+ </component>
+
+ <component name="Memcache">
+ <implementation.cpp path="../../components/cache" library="libmemcache"/>
+ <service name="Memcache">
+ <t:binding.atom uri="memcache"/>
+ </service>
+ <property name="servers">localhost:11211</property>
+ </component>
+
<component name="Sqldb">
<implementation.cpp path="../../components/sqldb" library="libsqldb"/>
- <property name="conninfo">dbname=db</property>
+ <property name="conninfo">host=localhost port=5432 dbname=db</property>
<property name="table">store</property>
<service name="Sqldb">
<t:binding.atom uri="sqldb"/>