[infinispan-commits] Infinispan SVN: r1491 - in trunk/server/memcached/src/main: resources and 1 other directory.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Wed Feb 10 12:23:32 EST 2010


Author: galder.zamarreno at jboss.com
Date: 2010-02-10 12:23:32 -0500 (Wed, 10 Feb 2010)
New Revision: 1491

Modified:
   trunk/server/memcached/src/main/java/org/infinispan/server/memcached/Main.java
   trunk/server/memcached/src/main/resources/memcached.bat
   trunk/server/memcached/src/main/resources/memcached.sh
   trunk/server/memcached/src/main/resources/sample_python_memcached_client.py
   trunk/server/memcached/src/main/resources/sample_python_memcached_reader.py
   trunk/server/memcached/src/main/resources/sample_python_memcached_writer.py
Log:
[ISPN-300] (Demo memcached being accessed from a non-Java client) Done.

Modified: trunk/server/memcached/src/main/java/org/infinispan/server/memcached/Main.java
===================================================================
--- trunk/server/memcached/src/main/java/org/infinispan/server/memcached/Main.java	2010-02-10 14:56:45 UTC (rev 1490)
+++ trunk/server/memcached/src/main/java/org/infinispan/server/memcached/Main.java	2010-02-10 17:23:32 UTC (rev 1491)
@@ -109,7 +109,10 @@
    private void processCommandLine(String[] args) throws Exception {
       // set this from a system property or default to jboss
       String programName = System.getProperty("program.name", "memcached");
-      String sopts = "-:hD:Vp:l:m:t:c";
+      // TODO: Since this memcached implementation stores stuff as byte[], these could be implemented in the future:
+      // -m <num>      max memory to use for items in megabytes (default: 64 MB)
+      // -M            return error on memory exhausted (rather than removing items)
+      String sopts = "-:hD:Vp:l:m:t:c:";
       LongOpt[] lopts =
       {new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'),
             new LongOpt("version", LongOpt.NO_ARGUMENT, null, 'V'),

Modified: trunk/server/memcached/src/main/resources/memcached.bat
===================================================================
--- trunk/server/memcached/src/main/resources/memcached.bat	2010-02-10 14:56:45 UTC (rev 1490)
+++ trunk/server/memcached/src/main/resources/memcached.bat	2010-02-10 17:23:32 UTC (rev 1491)
@@ -9,6 +9,6 @@
 
 set CP=%LIB%;..\infinispan-core.jar;..\modules\memcached\infinispan-server-memcached.jar;%CP%
 
-java -classpath "%CP%" org.infinispan.server.memcached.Main %*
+java -classpath "%CP%" -Dbind.address=127.0.0.1 -Djava.net.preferIPv4Stack=true -Dlog4j.configuration=..\etc\log4j.xml org.infinispan.server.memcached.Main %*
 
 :fileEnd
\ No newline at end of file

Modified: trunk/server/memcached/src/main/resources/memcached.sh
===================================================================
--- trunk/server/memcached/src/main/resources/memcached.sh	2010-02-10 14:56:45 UTC (rev 1490)
+++ trunk/server/memcached/src/main/resources/memcached.sh	2010-02-10 17:23:32 UTC (rev 1491)
@@ -29,7 +29,7 @@
    done
 fi
 
-JVM_PARAMS="${JVM_PARAMS} -Dlog4j.configuration=file:${ISPN_HOME}/etc/log4j.xml"
+JVM_PARAMS="${JVM_PARAMS} -Dbind.address=127.0.0.1 -Djava.net.preferIPv4Stack=true  -Dlog4j.configuration=file:${ISPN_HOME}/etc/log4j.xml"
 
 # Sample JPDA settings for remote socket debuging
 #JVM_PARAMS="$JVM_PARAMS -Xrunjdwp:transport=dt_socket,address=8686,server=y,suspend=n"

Modified: trunk/server/memcached/src/main/resources/sample_python_memcached_client.py
===================================================================
--- trunk/server/memcached/src/main/resources/sample_python_memcached_client.py	2010-02-10 14:56:45 UTC (rev 1490)
+++ trunk/server/memcached/src/main/resources/sample_python_memcached_client.py	2010-02-10 17:23:32 UTC (rev 1491)
@@ -8,8 +8,13 @@
 import memcache
 import time
 
-mc = memcache.Client(['127.0.0.1:11211'], debug=0)
+ip = "127.0.0.1"
+port = "12211"
+ipaddress = ip + ':' + port
+mc = memcache.Client([ipaddress], debug=1)
 
+print "Connecting to {0}".format(ipaddress)
+
 def setAndGet(mc, k, v):
    mc.set(k, v)
    get(mc, k, v)

Modified: trunk/server/memcached/src/main/resources/sample_python_memcached_reader.py
===================================================================
--- trunk/server/memcached/src/main/resources/sample_python_memcached_reader.py	2010-02-10 14:56:45 UTC (rev 1490)
+++ trunk/server/memcached/src/main/resources/sample_python_memcached_reader.py	2010-02-10 17:23:32 UTC (rev 1491)
@@ -3,73 +3,56 @@
 #
 # Sample python code using the standard memcached library to talk to Infinispan memcached server
 # To use it, make sure you install Python memcached client library
+# This particular script tests that it's reading from one of the clustered servers correctly
 #
 
 import memcache
 import time
-from ftplib import print_line
 
-mc = memcache.Client(['127.0.0.1:11211'], debug=0)
+ip = "127.0.0.1"
+port = "13211"
+ipaddress = ip + ':' + port
+mc = memcache.Client([ipaddress], debug=1)
 
-print "Testing set ['{0}': {1}] ...".format("Simple_Key", "Simple value"),
-#mc.set("Simple_Key", "Simple value")
-value = mc.get("Simple_Key")
-if value == "Simple value":
-   print "OK"
-else:
-   print "FAIL"
+print "Connecting to {0}".format(ipaddress)
 
-#print "Testing delete ['{0}'] ...".format("Simple_Key"),
-#value = mc.delete("Simple_Key")
-#if value != 0:
-#   print "OK"
-#else:
-#   print "FAIL"
+def get(mc, key, expected) :
+   value = mc.get(key)
+   if value == expected:
+      print "OK"
+   else:
+      print "FAIL"
 
-print "Testing set ['{0}' : {1} : {2}] ...".format("Expiring_Key", 999, 3),
-mc.set("Expiring_Key", 999, 3)
-#time.sleep(5)
-#value = mc.get("Expiring_Key")
-#if value == None:
-#   print "OK"
-#else:
-#   print "FAIL"
+def getNone(mc, key):
+   value = mc.get(key)
+   if value == None:
+      print "OK"
+   else:
+      print "FAIL"
 
-print "Testing increment 3 times ['{0}' : starting at {1} ] ...".format("Incr_Key", "1"),
-mc.set("Incr_Key", "1")   # note that the key used for incr/decr must be a string.
-mc.incr("Incr_Key")
-mc.incr("Incr_Key")
-mc.incr("Incr_Key")
-#value = mc.get("Incr_Decr_Key")
-#if value == "4":
-#   print "OK"
-#else:
-#   print "FAIL"
+key = "Simple_Key"
+expected = "Simple value"
+print "Testing get ['{0}'] should return {1} ...".format(key, expected),
+get(mc, key, expected)
 
-print "Testing decrement 1 time ['{0}' : starting at {1} ] ...".format("Decr_Key", "4"),
-mc.set("Decr_Key", "4")
-mc.decr("Decr_Key")
-#value = mc.get("Incr_Decr_Key")
-#if value == "3":
-#   print "OK"
-#else:
-#   print "FAIL"
+key = "Expiring_Key"
+print "Testing get ['{0}'] should return nothing...".format(key),
+time.sleep(5)
+getNone(mc, key)
 
-print "Testing decrement 2 times in one call ['{0}' : {1} ] ...".format("Multi_Decr_Key", "3"),
-mc.set("Multi_Decr_Key", "3")
-mc.decr("Multi_Decr_Key", 2)
-#value = mc.get("Incr_Decr_Key")
-#if value == "1":
-#   print "OK"
-#else:
-#   print "FAIL"
+key = "Incr_Key"
+expected = "4"
+print "Testing get ['{0}'] should return {1} ...".format(key, expected),
+get(mc, key, expected)
 
-#print "Finally, delete ['{0}'] ...".format("Incr_Decr_Key"),
-#value = mc.delete("Incr_Decr_Key")
-#if value != 0:
-#   print "OK"
-#else:
-#   print "FAIL"
+key = "Decr_Key"
+expected = "3"
+print "Testing get ['{0}'] should return {1} ...".format(key, expected),
+get(mc, key, expected)
 
+key = "Multi_Decr_Key"
+expected = "1"
+print "Testing get ['{0}'] should return {1} ...".format(key, expected),
+get(mc, key, expected)
 
 ## For more information see http://community.jboss.org/wiki/UsingInfinispanMemcachedServer
\ No newline at end of file

Modified: trunk/server/memcached/src/main/resources/sample_python_memcached_writer.py
===================================================================
--- trunk/server/memcached/src/main/resources/sample_python_memcached_writer.py	2010-02-10 14:56:45 UTC (rev 1490)
+++ trunk/server/memcached/src/main/resources/sample_python_memcached_writer.py	2010-02-10 17:23:32 UTC (rev 1491)
@@ -3,14 +3,19 @@
 #
 # Sample python code using the standard memcached library to talk to Infinispan memcached server
 # To use it, make sure you install Python memcached client library
-# This particular script tests that it's writing to the server correctly 
+# This particular script tests that it's writing to the one of the clustered servers correctly 
 #
 
 import memcache
 import time
 
-mc = memcache.Client(['127.0.0.1:11211'], debug=1)
+ip = "127.0.0.1"
+port = "12211"
+ipaddress = ip + ':' + port
+mc = memcache.Client([ipaddress], debug=1)
 
+print "Connecting to {0}".format(ipaddress)
+
 def set(mc, key, val, time = 0):
     ret = mc.set(key, val, time)
     if ret != 0:
@@ -32,31 +37,42 @@
    else:
       print "FAIL: returned {0}".format(ret)
 
-print "Testing set ['{0}': {1}] ...".format("Simple_Key", "Simple value"),
-set(mc, "Simple_Key", "Simple value")
+key = "Simple_Key"
+value = "Simple value"
+print "Testing set ['{0}': {1}] ...".format(key, value),
+set(mc, key, value)
 
-print "Testing set ['{0}' : {1} : {2}] ...".format("Expiring_Key", 999, 3),
-set(mc, "Expiring_Key", 999, 3)
+key = "Expiring_Key"
+value = 999
+expiry = 3
+print "Testing set ['{0}' : {1} : {2}] ...".format(key, value, expiry),
+set(mc, key, value, expiry)
 
-print "Testing increment 3 times ['{0}' : starting at {1} ]".format("Incr_Key", "1")
-print "Initialise at {0} ...".format("1"),
-set(mc, "Incr_Key", "1")   # note that the key used for incr/decr must be a string.
+key = "Incr_Key"
+value = "1"
+print "Testing increment 3 times ['{0}' : starting at {1} ]".format(key, value)
+print "Initialise at {0} ...".format(value),
+set(mc, key, value)   # note that the key used for incr/decr must be a string.
 print "Increment by one ...",
-incr(mc, 2, "Incr_Key")
+incr(mc, 2, key)
 print "Increment again ...",
-incr(mc, 3, "Incr_Key")
+incr(mc, 3, key)
 print "Increment yet again ...",
-incr(mc, 4, "Incr_Key")
+incr(mc, 4, key)
 
-print "Testing decrement 1 time ['{0}' : starting at {1} ]".format("Decr_Key", "4")
-print "Initialise at {0} ...".format("4"),
-set(mc, "Decr_Key", "4")
+key = "Decr_Key"
+value = "4"
+print "Testing decrement 1 time ['{0}' : starting at {1} ]".format(key, value)
+print "Initialise at {0} ...".format(value),
+set(mc, key, value)
 print "Decrement by one ...",
-decr(mc, 3, "Decr_Key")
+decr(mc, 3, key)
 
-print "Testing decrement 2 times in one call ['{0}' : {1} ]".format("Multi_Decr_Key", "3")
-print "Initialise at {0} ...".format("3"),
-set(mc, "Multi_Decr_Key", "3")
+key = "Multi_Decr_Key"
+value = "3"
+print "Testing decrement 2 times in one call ['{0}' : {1} ]".format(key, value)
+print "Initialise at {0} ...".format(value),
+set(mc, key, value)
 print "Decrement by 2 ...",
 decr(mc, 1, "Multi_Decr_Key", 2)
 



More information about the infinispan-commits mailing list