summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/samples
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sca-cpp/trunk/samples/store-cluster/domains/jane/shopping-cart.py27
-rw-r--r--sca-cpp/trunk/samples/store-cluster/domains/jane/store.composite3
-rw-r--r--sca-cpp/trunk/samples/store-cluster/domains/joe/shopping-cart.py27
-rw-r--r--sca-cpp/trunk/samples/store-cluster/domains/joe/store.composite3
-rwxr-xr-xsca-cpp/trunk/samples/store-cluster/ssl-start7
-rwxr-xr-xsca-cpp/trunk/samples/store-cluster/start7
-rwxr-xr-xsca-cpp/trunk/samples/store-cluster/stop4
-rw-r--r--sca-cpp/trunk/samples/store-cpp/store.composite1
-rw-r--r--sca-cpp/trunk/samples/store-java/store.composite1
-rw-r--r--sca-cpp/trunk/samples/store-python/store.composite1
-rw-r--r--sca-cpp/trunk/samples/store-scheme/store.composite1
-rw-r--r--sca-cpp/trunk/samples/store-vhost/domains/jane/store.composite1
-rw-r--r--sca-cpp/trunk/samples/store-vhost/domains/joe/store.composite1
13 files changed, 51 insertions, 33 deletions
diff --git a/sca-cpp/trunk/samples/store-cluster/domains/jane/shopping-cart.py b/sca-cpp/trunk/samples/store-cluster/domains/jane/shopping-cart.py
index 405adb85bf..e315b2f1ca 100644
--- a/sca-cpp/trunk/samples/store-cluster/domains/jane/shopping-cart.py
+++ b/sca-cpp/trunk/samples/store-cluster/domains/jane/shopping-cart.py
@@ -19,21 +19,23 @@
import uuid
import sys
-cartId = "1234"
+# Convert a particular host and user email to a cart id
+def cartid(host, email):
+ return ("cart", host(), email())
# Get the shopping cart from the cache
# Return an empty cart if not found
def getcart(id, cache):
- cart = cache("get", (id,))
+ cart = cache("get", id)
if cart is None:
return ()
return cart
# Post a new item to the cart, create a new cart if necessary
-def post(collection, item, cache):
+def post(collection, item, cache, host, email):
id = str(uuid.uuid1())
- cart = ((item[0], id, item[2]),) + getcart(cartId, cache)
- cache("put", (cartId,), cart)
+ cart = ((item[0], id, item[2]),) + getcart(cartid(host, email), cache)
+ cache("put", cartid(host, email), cart)
return (id,)
@@ -47,15 +49,15 @@ def find(id, cart):
return find(id, cart[1:])
# Get items from the cart
-def get(id, cache):
+def get(id, cache, host, email):
if id == ():
- return ("Your Cart", cartId) + getcart(cartId, cache)
- return find(id[0], getcart(cartId, cache))
+ return ("Your Cart", email()) + getcart(cartid(host, email), cache)
+ return find(id[0], getcart(cartid(host, email), cache))
# Delete items from the cart
-def delete(id, cache):
+def delete(id, cache, host, email):
if id == ():
- return cache("delete", (cartId,))
+ return cache("delete", cartid(host, email))
return True
# Return the price of an item
@@ -69,7 +71,6 @@ def sum(items):
return price(items[0]) + sum(items[1:])
# Return the total price of the items in the cart
-def gettotal(cache):
- cart = getcart(cartId, cache)
- return sum(cart)
+def gettotal(cache, host, email):
+ return sum(getcart(cartid(host, email), cache))
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 893b4f0ed4..396970a6e6 100644
--- a/sca-cpp/trunk/samples/store-cluster/domains/jane/store.composite
+++ b/sca-cpp/trunk/samples/store-cluster/domains/jane/store.composite
@@ -43,6 +43,8 @@
<component name="ShoppingCart">
<t:implementation.python script="shopping-cart.py"/>
+ <property name="host">localhost</property>
+ <property name="email">anonymous@localhost</property>
<service name="ShoppingCart">
<t:binding.atom uri="shoppingCart"/>
</service>
@@ -64,6 +66,7 @@
<service name="Cache">
<t:binding.atom uri="cache"/>
</service>
+ <property name="servers">localhost:11211,localhost:11212,localhost:11213</property>
</component>
</composite>
diff --git a/sca-cpp/trunk/samples/store-cluster/domains/joe/shopping-cart.py b/sca-cpp/trunk/samples/store-cluster/domains/joe/shopping-cart.py
index 405adb85bf..e315b2f1ca 100644
--- a/sca-cpp/trunk/samples/store-cluster/domains/joe/shopping-cart.py
+++ b/sca-cpp/trunk/samples/store-cluster/domains/joe/shopping-cart.py
@@ -19,21 +19,23 @@
import uuid
import sys
-cartId = "1234"
+# Convert a particular host and user email to a cart id
+def cartid(host, email):
+ return ("cart", host(), email())
# Get the shopping cart from the cache
# Return an empty cart if not found
def getcart(id, cache):
- cart = cache("get", (id,))
+ cart = cache("get", id)
if cart is None:
return ()
return cart
# Post a new item to the cart, create a new cart if necessary
-def post(collection, item, cache):
+def post(collection, item, cache, host, email):
id = str(uuid.uuid1())
- cart = ((item[0], id, item[2]),) + getcart(cartId, cache)
- cache("put", (cartId,), cart)
+ cart = ((item[0], id, item[2]),) + getcart(cartid(host, email), cache)
+ cache("put", cartid(host, email), cart)
return (id,)
@@ -47,15 +49,15 @@ def find(id, cart):
return find(id, cart[1:])
# Get items from the cart
-def get(id, cache):
+def get(id, cache, host, email):
if id == ():
- return ("Your Cart", cartId) + getcart(cartId, cache)
- return find(id[0], getcart(cartId, cache))
+ return ("Your Cart", email()) + getcart(cartid(host, email), cache)
+ return find(id[0], getcart(cartid(host, email), cache))
# Delete items from the cart
-def delete(id, cache):
+def delete(id, cache, host, email):
if id == ():
- return cache("delete", (cartId,))
+ return cache("delete", cartid(host, email))
return True
# Return the price of an item
@@ -69,7 +71,6 @@ def sum(items):
return price(items[0]) + sum(items[1:])
# Return the total price of the items in the cart
-def gettotal(cache):
- cart = getcart(cartId, cache)
- return sum(cart)
+def gettotal(cache, host, email):
+ return sum(getcart(cartid(host, email), cache))
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 893b4f0ed4..396970a6e6 100644
--- a/sca-cpp/trunk/samples/store-cluster/domains/joe/store.composite
+++ b/sca-cpp/trunk/samples/store-cluster/domains/joe/store.composite
@@ -43,6 +43,8 @@
<component name="ShoppingCart">
<t:implementation.python script="shopping-cart.py"/>
+ <property name="host">localhost</property>
+ <property name="email">anonymous@localhost</property>
<service name="ShoppingCart">
<t:binding.atom uri="shoppingCart"/>
</service>
@@ -64,6 +66,7 @@
<service name="Cache">
<t:binding.atom uri="cache"/>
</service>
+ <property name="servers">localhost:11211,localhost:11212,localhost:11213</property>
</component>
</composite>
diff --git a/sca-cpp/trunk/samples/store-cluster/ssl-start b/sca-cpp/trunk/samples/store-cluster/ssl-start
index 4acd41bc2d..d9d0fec67d 100755
--- a/sca-cpp/trunk/samples/store-cluster/ssl-start
+++ b/sca-cpp/trunk/samples/store-cluster/ssl-start
@@ -99,9 +99,10 @@ cp `../../modules/http/ssl-ls tmp/ssl` tmp/proxy2/conf
../../modules/http/proxy-ssl-member-conf tmp/proxy2 localhost 8443
../../modules/http/httpd-start tmp/proxy2
-# Start a shared memcached
-# Todo change to one per server
-../../components/cache/memcached-start
+# Start three memcached servers
+../../components/cache/memcached-start 11211
+../../components/cache/memcached-start 11212
+../../components/cache/memcached-start 11213
# Redirect traffic from port 80 to 8091 and use proxy1
#../../ubuntu/ip-redirect-all 80 8091
diff --git a/sca-cpp/trunk/samples/store-cluster/start b/sca-cpp/trunk/samples/store-cluster/start
index 809e9edad9..1cd5825471 100755
--- a/sca-cpp/trunk/samples/store-cluster/start
+++ b/sca-cpp/trunk/samples/store-cluster/start
@@ -71,9 +71,10 @@ EOF
../../modules/http/proxy-member-conf tmp/proxy2 localhost 8103
../../modules/http/httpd-start tmp/proxy2
-# Start a shared memcached
-# Todo change to one per server
-../../components/cache/memcached-start
+# Start three memcached servers
+../../components/cache/memcached-start 11211
+../../components/cache/memcached-start 11212
+../../components/cache/memcached-start 11213
# Redirect traffic from port 80 to 8091 and use proxy1
#../../ubuntu/ip-redirect-all 80 8091
diff --git a/sca-cpp/trunk/samples/store-cluster/stop b/sca-cpp/trunk/samples/store-cluster/stop
index 375e5de698..9df37dc948 100755
--- a/sca-cpp/trunk/samples/store-cluster/stop
+++ b/sca-cpp/trunk/samples/store-cluster/stop
@@ -22,4 +22,6 @@
../../modules/http/httpd-stop tmp/server3
../../modules/http/httpd-stop tmp/proxy1
../../modules/http/httpd-stop tmp/proxy2
-../../components/cache/memcached-stop
+../../components/cache/memcached-stop 11211
+../../components/cache/memcached-stop 11212
+../../components/cache/memcached-stop 11213
diff --git a/sca-cpp/trunk/samples/store-cpp/store.composite b/sca-cpp/trunk/samples/store-cpp/store.composite
index c9039a1d58..8b5edede99 100644
--- a/sca-cpp/trunk/samples/store-cpp/store.composite
+++ b/sca-cpp/trunk/samples/store-cpp/store.composite
@@ -64,6 +64,7 @@
<service name="Cache">
<t:binding.atom uri="cache"/>
</service>
+ <property name="servers">localhost:11211</property>
</component>
</composite>
diff --git a/sca-cpp/trunk/samples/store-java/store.composite b/sca-cpp/trunk/samples/store-java/store.composite
index b93e2dbfbf..4b0db9d05c 100644
--- a/sca-cpp/trunk/samples/store-java/store.composite
+++ b/sca-cpp/trunk/samples/store-java/store.composite
@@ -64,6 +64,7 @@
<service name="Cache">
<t:binding.atom uri="cache"/>
</service>
+ <property name="servers">localhost:11211</property>
</component>
</composite>
diff --git a/sca-cpp/trunk/samples/store-python/store.composite b/sca-cpp/trunk/samples/store-python/store.composite
index 045ebe6ec5..912898123b 100644
--- a/sca-cpp/trunk/samples/store-python/store.composite
+++ b/sca-cpp/trunk/samples/store-python/store.composite
@@ -64,6 +64,7 @@
<service name="Cache">
<t:binding.atom uri="cache"/>
</service>
+ <property name="servers">localhost:11211</property>
</component>
</composite>
diff --git a/sca-cpp/trunk/samples/store-scheme/store.composite b/sca-cpp/trunk/samples/store-scheme/store.composite
index e461637b2b..fd58ae6c9d 100644
--- a/sca-cpp/trunk/samples/store-scheme/store.composite
+++ b/sca-cpp/trunk/samples/store-scheme/store.composite
@@ -64,6 +64,7 @@
<service name="Cache">
<t:binding.atom uri="cache"/>
</service>
+ <property name="servers">localhost:11211</property>
</component>
</composite>
diff --git a/sca-cpp/trunk/samples/store-vhost/domains/jane/store.composite b/sca-cpp/trunk/samples/store-vhost/domains/jane/store.composite
index 893b4f0ed4..0c94bd81d2 100644
--- a/sca-cpp/trunk/samples/store-vhost/domains/jane/store.composite
+++ b/sca-cpp/trunk/samples/store-vhost/domains/jane/store.composite
@@ -64,6 +64,7 @@
<service name="Cache">
<t:binding.atom uri="cache"/>
</service>
+ <property name="servers">localhost:11211</property>
</component>
</composite>
diff --git a/sca-cpp/trunk/samples/store-vhost/domains/joe/store.composite b/sca-cpp/trunk/samples/store-vhost/domains/joe/store.composite
index 893b4f0ed4..0c94bd81d2 100644
--- a/sca-cpp/trunk/samples/store-vhost/domains/joe/store.composite
+++ b/sca-cpp/trunk/samples/store-vhost/domains/joe/store.composite
@@ -64,6 +64,7 @@
<service name="Cache">
<t:binding.atom uri="cache"/>
</service>
+ <property name="servers">localhost:11211</property>
</component>
</composite>