summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2005-11-17 18:26:29 +0000
committerDwayne Boone <dwayne@zeroc.com>2005-11-17 18:26:29 +0000
commit05d60f523e830ba7849827100ccec7659f73e23e (patch)
tree4f6d47ed248e26245b219fa81131dc014b247314 /py
parentFix (diff)
downloadice-05d60f523e830ba7849827100ccec7659f73e23e.tar.bz2
ice-05d60f523e830ba7849827100ccec7659f73e23e.tar.xz
ice-05d60f523e830ba7849827100ccec7659f73e23e.zip
Added IceGrid, IceStorm and Glacier2 demos
Diffstat (limited to 'py')
-rw-r--r--py/CHANGES6
-rw-r--r--py/demo/Glacier2/README6
-rw-r--r--py/demo/Glacier2/callback/Callback.ice29
-rw-r--r--py/demo/Glacier2/callback/Client.py144
-rw-r--r--py/demo/Glacier2/callback/README26
-rw-r--r--py/demo/Glacier2/callback/Server.py37
-rw-r--r--py/demo/Glacier2/callback/SessionServer.py42
-rw-r--r--py/demo/Glacier2/callback/config61
-rw-r--r--py/demo/Glacier2/callback/config.glacier2121
-rw-r--r--py/demo/Glacier2/callback/config.server15
-rw-r--r--py/demo/Glacier2/callback/config.sessionserver15
-rw-r--r--py/demo/IceGrid/simple/Client.py63
-rw-r--r--py/demo/IceGrid/simple/Hello.ice24
-rw-r--r--py/demo/IceGrid/simple/README38
-rw-r--r--py/demo/IceGrid/simple/Server.py38
-rw-r--r--py/demo/IceGrid/simple/application.xml28
-rw-r--r--py/demo/IceGrid/simple/application_with_replication.xml38
-rw-r--r--py/demo/IceGrid/simple/application_with_template.xml35
-rw-r--r--py/demo/IceGrid/simple/config33
-rw-r--r--py/demo/IceGrid/simple/db/node/.dummy0
-rw-r--r--py/demo/IceGrid/simple/db/registry/.dummy0
-rw-r--r--py/demo/IceStorm/README5
-rw-r--r--py/demo/IceStorm/clock/Clock.ice23
-rw-r--r--py/demo/IceStorm/clock/Publisher.py58
-rw-r--r--py/demo/IceStorm/clock/README20
-rw-r--r--py/demo/IceStorm/clock/Subscriber.py97
-rw-r--r--py/demo/IceStorm/clock/config72
-rw-r--r--py/demo/IceStorm/clock/config_service44
-rw-r--r--py/demo/IceStorm/clock/db/.dummy0
29 files changed, 1118 insertions, 0 deletions
diff --git a/py/CHANGES b/py/CHANGES
index 88c8f682c1f..9de95cc201a 100644
--- a/py/CHANGES
+++ b/py/CHANGES
@@ -1,3 +1,9 @@
+Changes since version 3.0.0
+---------------------------
+
+- Added IceGrid, IceStorm and Glacier2 demos.
+
+
Changes since version 2.1.2
---------------------------
diff --git a/py/demo/Glacier2/README b/py/demo/Glacier2/README
new file mode 100644
index 00000000000..42d9df9a956
--- /dev/null
+++ b/py/demo/Glacier2/README
@@ -0,0 +1,6 @@
+Demos in this directory:
+
+- callback
+
+ Illustrates how to allow a server to call back into a client via a
+ Glacier2 connection.
diff --git a/py/demo/Glacier2/callback/Callback.ice b/py/demo/Glacier2/callback/Callback.ice
new file mode 100644
index 00000000000..ecfbc6ea581
--- /dev/null
+++ b/py/demo/Glacier2/callback/Callback.ice
@@ -0,0 +1,29 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#ifndef CALLBACK_ICE
+#define CALLBACK_ICE
+
+module Demo
+{
+
+interface CallbackReceiver
+{
+ void callback();
+};
+
+interface Callback
+{
+ void initiateCallback(CallbackReceiver* proxy);
+ void shutdown();
+};
+
+};
+
+#endif
diff --git a/py/demo/Glacier2/callback/Client.py b/py/demo/Glacier2/callback/Client.py
new file mode 100644
index 00000000000..6e5c15924fb
--- /dev/null
+++ b/py/demo/Glacier2/callback/Client.py
@@ -0,0 +1,144 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+import sys, Ice, Glacier2
+
+Ice.loadSlice('Callback.ice')
+import Demo
+
+def menu():
+ print """
+usage:
+t: send callback as twoway
+o: send callback as oneway
+O: send callback as batch oneway
+f: flush all batch requests
+v: set/reset override context field
+F: set/reset fake category
+s: shutdown server
+x: exit
+?: help
+"""
+
+class CallbackReceiverI(Demo.CallbackReceiver):
+ def callback(self, current=None):
+ print "received callback"
+
+class Client(Ice.Application):
+ def run(self, args):
+ defaultRouter = self.communicator().getDefaultRouter()
+ if not defaultRouter:
+ print self.appName() + ": no default router set"
+ return 1
+
+ router = Glacier2.RouterPrx.checkedCast(defaultRouter)
+ if not router:
+ print self.appName() + ": configured router is not a Glacier2 router"
+ return 1
+
+ while True:
+ print "This demo accepts any user-id / password combination."
+ id = raw_input("user id: ")
+ pw = raw_input("password: ")
+ try:
+ router.createSession(id, pw)
+ break
+ except Glacier2.PermissionDeniedException, ex:
+ print "permission denied:\n" + ex.reason
+
+ category = router.getServerProxy().ice_getIdentity().category
+ callbackReceiverIdent = Ice.Identity()
+ callbackReceiverIdent.name = "callbackReceiver"
+ callbackReceiverIdent.category = category
+ callbackReceiverFakeIdent = Ice.Identity()
+ callbackReceiverFakeIdent.name = "callbackReceiver"
+ callbackReceiverFakeIdent.category = "fake"
+
+ properties = self.communicator().getProperties()
+ proxyProperty = 'Callback.Proxy'
+ proxy = properties.getProperty(proxyProperty)
+ if len(proxy) == 0:
+ print self.appName() + ": property `" + proxyProperty + "' not set"
+ return 1
+
+ base = self.communicator().stringToProxy(proxy)
+ twoway = Demo.CallbackPrx.checkedCast(base)
+ oneway = Demo.CallbackPrx.uncheckedCast(twoway.ice_oneway())
+ batchOneway = Demo.CallbackPrx.uncheckedCast(twoway.ice_batchOneway())
+
+ adapter = self.communicator().createObjectAdapter("Callback.Client")
+ adapter.add(CallbackReceiverI(), callbackReceiverIdent)
+ adapter.add(CallbackReceiverI(), callbackReceiverFakeIdent)
+ adapter.activate()
+
+ twowayR = Demo.CallbackReceiverPrx.uncheckedCast(adapter.createProxy(callbackReceiverIdent))
+ onewayR = Demo.CallbackReceiverPrx.uncheckedCast(twowayR.ice_oneway())
+
+ override = ''
+ fake = False
+
+ menu()
+
+ c = None
+ while c != 'x':
+ try:
+ c = raw_input("==> ")
+ if c == 't':
+ context = {}
+ context["_fwd"] = "t"
+ if not len(override) == 0:
+ context["_ovrd"] = override
+ twoway.initiateCallback(twowayR, context)
+ elif c == 'o':
+ context = {}
+ context["_fwd"] = "o"
+ if not len(override) == 0:
+ context["_ovrd"] = override
+ oneway.initiateCallback(onewayR, context)
+ elif c == 'O':
+ context = {}
+ context["_fwd"] = "O"
+ if not len(override) == 0:
+ context["_ovrd"] = override
+ batchOneway.initiateCallback(onewayR, context)
+ elif c == 'f':
+ self.communicator().flushBatchRequests()
+ elif c == 'v':
+ if len(override) == 0:
+ override = "some_value"
+ print "override context field is now `" + override + "'"
+ else:
+ override = ''
+ print "override context field is empty"
+ elif c == 'F':
+ fake = not fake
+
+ if fake:
+ twowayR = Demo.CallbackReceiverPrx.uncheckedCast(twowayR.ice_newIdentity(callbackReceiverFakeIdent))
+ onewayR = Demo.CallbackReceiverPrx.uncheckedCast(onewayR.ice_newIdentity(callbackReceiverFakeIdent))
+ else:
+ twowayR = Demo.CallbackReceiverPrx.uncheckedCast(twowayR.ice_newIdentity(callbackReceiverIdent))
+ onewayR = Demo.CallbackReceiverPrx.uncheckedCast(twowayR.ice_newIdentity(callbackReceiverIdent))
+ elif c == 's':
+ twoway.shutdown()
+ elif c == 'x':
+ pass # Nothing to do
+ elif c == '?':
+ menu()
+ else:
+ print "unknown command `" + c + "'"
+ menu()
+ except EOFError:
+ break
+
+ return 0
+
+app = Client()
+sys.exit(app.main(sys.argv, "config"))
diff --git a/py/demo/Glacier2/callback/README b/py/demo/Glacier2/callback/README
new file mode 100644
index 00000000000..8669b396edf
--- /dev/null
+++ b/py/demo/Glacier2/callback/README
@@ -0,0 +1,26 @@
+This example demonstrates the use of a Glacier2 router and the
+implementation of a Glacier2 session server.
+
+To run the demo, first start the server:
+
+$ python Server.py
+
+In a separate window, start the session server:
+
+$ python SessionServer.py
+
+In a separate window, start the Glacier2 router:
+
+$ glacier2router --Ice.Config=config.glacier2
+
+In a separate window, start the client:
+
+$ python Client.py
+
+If you plan to run this demo using clients running on different
+hosts than the glacier2router, it is necessary to first modify the
+configuration. You need to change the Glacier2.Client.Endpoints
+property in config.glacier2 and the Ice.Default.Router and
+Callback.Client.Router properties in config. In all cases you must
+replace the "-h 127.0.0.1" parameter with the actual external address
+of the machine on which glacier2router is running.
diff --git a/py/demo/Glacier2/callback/Server.py b/py/demo/Glacier2/callback/Server.py
new file mode 100644
index 00000000000..9e313fe6918
--- /dev/null
+++ b/py/demo/Glacier2/callback/Server.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+import sys, traceback, Ice
+
+Ice.loadSlice('Callback.ice')
+import Demo
+
+class CallbackI(Demo.Callback):
+ def initiateCallback(self, proxy, current=None):
+ print "initiating callback to: " + current.adapter.getCommunicator().proxyToString(proxy)
+ try:
+ proxy.callback(current.ctx)
+ except:
+ traceback.print_exc()
+
+ def shutdown(self, current=None):
+ print "shutting down..."
+ current.adapter.getCommunicator().shutdown()
+
+class Server(Ice.Application):
+ def run(self, args):
+ adapter = self.communicator().createObjectAdapter("Callback.Server")
+ adapter.add(CallbackI(), Ice.stringToIdentity("callback"))
+ adapter.activate()
+ self.communicator().waitForShutdown()
+ return True
+
+app = Server()
+sys.exit(app.main(sys.argv, "config.server"))
diff --git a/py/demo/Glacier2/callback/SessionServer.py b/py/demo/Glacier2/callback/SessionServer.py
new file mode 100644
index 00000000000..aa4b3666c77
--- /dev/null
+++ b/py/demo/Glacier2/callback/SessionServer.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+import sys, traceback, Ice, Glacier2
+
+class DummyPermissionsVerifierI(Glacier2.PermissionsVerifier):
+ def checkPermissions(self, userId, password, current=None):
+ print "verified user `" + userId + "' with password `" + password + "'"
+ return (True, "")
+
+class SessionI(Glacier2.Session):
+ def __init__(self, userId):
+ self.userId = userId
+
+ def destroy(self, current=None):
+ print "destroying session for user `" + self.userId + "'"
+ current.adapter.remove(current.id)
+
+class SessionManagerI(Glacier2.SessionManager):
+ def create(self, userId, current=None):
+ print "creating session for user `" + userId + "'"
+ session = SessionI(userId)
+ return Glacier2.SessionPrx.uncheckedCast(current.adapter.addWithUUID(session))
+
+class SessionServer(Ice.Application):
+ def run(self, args):
+ adapter = self.communicator().createObjectAdapter("SessionServer")
+ adapter.add(DummyPermissionsVerifierI(), Ice.stringToIdentity("verifier"))
+ adapter.add(SessionManagerI(), Ice.stringToIdentity("sessionmanager"))
+ adapter.activate()
+ self.communicator().waitForShutdown()
+ return True
+
+app = SessionServer()
+sys.exit(app.main(sys.argv, "config.sessionserver"))
diff --git a/py/demo/Glacier2/callback/config b/py/demo/Glacier2/callback/config
new file mode 100644
index 00000000000..4a63941d84d
--- /dev/null
+++ b/py/demo/Glacier2/callback/config
@@ -0,0 +1,61 @@
+#
+# The proxy to the Glacier2 router for all outgoing connections. This
+# must match the value of Glacier2.Client.Endpoints in config.glacier2.
+#
+Ice.Default.Router=DemoGlacier2/router:ssl -p 10005 -h 127.0.0.1
+
+#
+# The proxy for the Glacier2 router, installed in the client's
+# object adapter named Callback.Client. This router proxy must
+# match the value of Glacier2.Client.Endpoints.
+#
+Callback.Client.Router=DemoGlacier2/router:ssl -p 10005 -h 127.0.0.1
+
+#
+# We don't need any endpoints for the client if we use a
+# router. Incoming requests are received through connections
+# established from the client to the router.
+#
+Callback.Client.Endpoints=
+
+#
+# This must match the value of Callback.Server.Endpoints in
+# config.server.
+#
+Callback.Proxy=callback:tcp -h 127.0.0.1 -p 10000
+
+#
+# No active connection management is permitted with Glacier2.
+# Connections must remain established.
+#
+Ice.ACM.Client=0
+Ice.ACM.Server=0
+
+#
+# Ice.MonitorConnections defaults to the smaller of Ice.ACM.Client or
+# Ice.ACM.Server, which we set to 0 above. However we still want the
+# connection monitor thread for AMI timeouts (for completeness, even
+# if this demo doesn't use AMI).
+#
+Ice.MonitorConnections=60
+
+#
+# Connection retry is not possible with Glacier2. Connections must
+# remain established.
+#
+Ice.RetryIntervals=-1
+
+#
+# Other settings.
+#
+
+#Ice.Trace.Network=1
+#Ice.Trace.Protocol=1
+Ice.Warn.Connections=1
+
+Ice.Plugin.IceSSL=IceSSL:create
+IceSSL.Client.CertPath=../../../certs
+IceSSL.Client.Config=sslconfig.xml
+IceSSL.Server.CertPath=../../../certs
+IceSSL.Server.Config=sslconfig.xml
+#IceSSL.Trace.Security=1
diff --git a/py/demo/Glacier2/callback/config.glacier2 b/py/demo/Glacier2/callback/config.glacier2
new file mode 100644
index 00000000000..a034872d433
--- /dev/null
+++ b/py/demo/Glacier2/callback/config.glacier2
@@ -0,0 +1,121 @@
+#
+# Set the instance name
+#
+Glacier2.InstanceName=DemoGlacier2
+
+#
+# We must set the stack size of new threads created by Glacier2. The
+# default on Linux is typically in the 10MB range, which is way too
+# high.
+#
+# Since Glacier2 always uses thread-per-connection mode, we must use
+# the property below to set the thread stack size. Internal Glacier2
+# threads also use this property value.
+#
+Ice.ThreadPerConnection.StackSize=262144
+
+#
+# The client-visible endpoint of Glacier2. This should be an endpoint
+# visible from the public Internet, and it should be secure.
+#
+Glacier2.Client.Endpoints=ssl -p 10005 -h 127.0.0.1
+
+#
+# The server-visible endpoint of Glacier2. This endpoint is only
+# required if callbacks are needed (leave empty otherwise). This
+# should be an endpoint on an internal network (like 192.168.x.x), or
+# on the loopback, so that the server is not directly accessible from
+# the Internet.
+#
+Glacier2.Server.Endpoints=tcp -h 127.0.0.1
+
+#
+# The configures the session manager. If no external session manager
+# is used, sessions are only handled Glacier2 internally.
+#
+Glacier2.SessionManager=sessionmanager:tcp -h 127.0.0.1 -p 10001
+
+#
+# For this demo, we use a dummy permissions verifier that is
+# collocated with the session server process. This dummy permissions
+# verifier allows any user-id / password combination.
+#
+Glacier2.PermissionsVerifier=verifier:tcp -h 127.0.0.1 -p 10001
+
+#
+# The timeout for inactive sessions. If any client session is inactive
+# for longer than this value, the session expires and is removed. The
+# unit is seconds.
+#
+Glacier2.SessionTimeout=30
+
+#
+# Glacier can forward requests buffered or unbuffered. Unbuffered
+# means a lower resource consumption, as buffering requires one
+# additional thread per connected client or server. However, without
+# buffering, messages cannot be batched and message overriding doesn't
+# work either. Also, with unbuffered request forwarding, the caller
+# thread blocks for twoway requests.
+#
+Glacier2.Client.Buffered=1
+Glacier2.Server.Buffered=1
+
+#
+# These two lines instruct Glacier2 to forward contexts both for
+# regular routing, as well as for callbacks (reverse routing).
+#
+Glacier2.Client.ForwardContext=1
+Glacier2.Server.ForwardContext=1
+
+#
+# To prevent Glacier2 from being flooded with requests from or to one
+# particular client, Glacier2 can be configured to sleep for a certain
+# period after all current requests for this client have been
+# forwarded. During this sleep period, new requests for the client are
+# queued. These requests are then all sent once the sleep period is
+# over. The unit is milliseconds.
+#
+Glacier2.Client.SleepTime=500
+Glacier2.Server.SleepTime=500
+
+#
+# With the two settings below, Glacier2 can be instructed to always
+# batch oneways, even if they are sent with a _fwd/o instead of a
+# _fwd/O context.
+#
+Glacier2.Client.AlwaysBatch=0
+Glacier2.Server.AlwaysBatch=0
+
+#
+# Glacier2 always disables active connection management so there is no
+# need to configure this manually. Connection retry does not need to
+# be disabled, as it's safe for Glacier2 to retry outgoing connections
+# to servers. Retry for incoming connections from clients must be
+# disabled in the clients.
+#
+
+#
+# Various settings to trace requests, overrides, etc.
+#
+Glacier2.Client.Trace.Request=1
+Glacier2.Server.Trace.Request=1
+Glacier2.Client.Trace.Override=1
+Glacier2.Server.Trace.Override=1
+Glacier2.Client.Trace.Reject=1
+Glacier2.Trace.Session=1
+Glacier2.Trace.RoutingTable=1
+
+#
+# Other settings.
+#
+
+#Ice.Trace.Network=1
+#Ice.Trace.Protocol=1
+Ice.Warn.Connections=1
+
+Ice.Plugin.IceSSL=IceSSL:create
+IceSSL.Client.CertPath=../../../certs
+IceSSL.Client.Config=sslconfig.xml
+IceSSL.Server.CertPath=../../../certs
+IceSSL.Server.Config=sslconfig.xml
+#IceSSL.Trace.Security=1
diff --git a/py/demo/Glacier2/callback/config.server b/py/demo/Glacier2/callback/config.server
new file mode 100644
index 00000000000..51658a9d790
--- /dev/null
+++ b/py/demo/Glacier2/callback/config.server
@@ -0,0 +1,15 @@
+#
+# The endpoint of the server's object adapter. This should be an
+# endpoint on an internal network (like 192.168.x.x), or on the
+# loopback, so that the server is not directly accessible from the
+# Internet.
+#
+Callback.Server.Endpoints=tcp -h 127.0.0.1 -p 10000
+
+#
+# Other settings.
+#
+
+#Ice.Trace.Network=1
+#Ice.Trace.Protocol=1
+Ice.Warn.Connections=1
diff --git a/py/demo/Glacier2/callback/config.sessionserver b/py/demo/Glacier2/callback/config.sessionserver
new file mode 100644
index 00000000000..16448e075c4
--- /dev/null
+++ b/py/demo/Glacier2/callback/config.sessionserver
@@ -0,0 +1,15 @@
+#
+# The endpoint of the session server's object adapter. This should be
+# an endpoint on an internal network (like 192.168.x.x), or on the
+# loopback, so that the session server is not directly accessible from
+# the Internet.
+#
+SessionServer.Endpoints=tcp -h 127.0.0.1 -p 10001
+
+#
+# Other settings.
+#
+
+#Ice.Trace.Network=1
+#Ice.Trace.Protocol=1
+Ice.Warn.Connections=1
diff --git a/py/demo/IceGrid/simple/Client.py b/py/demo/IceGrid/simple/Client.py
new file mode 100644
index 00000000000..c51765155ff
--- /dev/null
+++ b/py/demo/IceGrid/simple/Client.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+import sys, traceback, Ice, IceGrid
+
+Ice.loadSlice('Hello.ice')
+import Demo
+
+
+def menu():
+ print """
+usage:
+t: send greeting as twoway
+s: shutdown server
+x: exit
+?: help
+"""
+
+class Client(Ice.Application):
+ def run(self, args):
+ hello = None
+ try:
+ hello = Demo.HelloPrx.checkedCast(self.communicator().stringToProxy("hello"))
+ except Ice.NotRegisteredException:
+ proxy = self.communicator().getProperties().getProperty("IceGrid.InstanceName") + "/Query"
+ query = IceGrid.QueryPrx.checkedCast(self.communicator().stringToProxy(proxy))
+ hello = Demo.HelloPrx.checkedCast(query.findObjectByType("::Demo::Hello"))
+
+ if not hello:
+ print self.appName() + ": couldn't find a `::Demo::Hello' object."
+ return False
+
+ menu()
+
+ c = None
+ while c != 'x':
+ try:
+ c = raw_input("==> ")
+ if c == 't':
+ hello.sayHello()
+ elif c == 's':
+ hello.shutdown()
+ elif c == 'x':
+ pass # Nothing to do
+ elif c == '?':
+ menu()
+ else:
+ print "unknown command `" + c + "'"
+ menu()
+ except EOFError:
+ break
+
+ return True
+
+app = Client()
+sys.exit(app.main(sys.argv, "config"))
diff --git a/py/demo/IceGrid/simple/Hello.ice b/py/demo/IceGrid/simple/Hello.ice
new file mode 100644
index 00000000000..176763722ce
--- /dev/null
+++ b/py/demo/IceGrid/simple/Hello.ice
@@ -0,0 +1,24 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#ifndef HELLO_ICE
+#define HELLO_ICE
+
+module Demo
+{
+
+interface Hello
+{
+ nonmutating void sayHello();
+ idempotent void shutdown();
+};
+
+};
+
+#endif
diff --git a/py/demo/IceGrid/simple/README b/py/demo/IceGrid/simple/README
new file mode 100644
index 00000000000..9de3cbfbd86
--- /dev/null
+++ b/py/demo/IceGrid/simple/README
@@ -0,0 +1,38 @@
+To run the demo, first start the IceGrid service:
+
+$ icegridnode --Ice.Config=config --warn
+
+In a separate window:
+
+$ icegridadmin --Ice.Config=config -e "application add 'application.xml'"
+$ python Client.py
+
+This will deploy the application described in the file "application.xml"
+and start the client.
+
+Messages will be displayed in the IceGrid service window.
+
+You can also use the descriptors in the following files to deploy the
+application:
+
+- application_with_template.xml: These descriptors demonstrate the use
+ of templates for the server definition. Templates make it easy to
+ deploy multiple instances of the same server.
+
+- application_with_replication.xml: These descriptors demonstrate the
+ use of replication to balance the load of the application over
+ several servers.
+
+If you have already deployed the application, you can update it to try
+a new set of descriptors, for example:
+
+$ icegridadmin --Ice.Config=config -e "application update \
+ 'application_with_template.xml'"
+
+When using the descriptors from 'application_with_template.xml' or
+'application_with_replication.xml', you can easily deploy more servers
+based on the `SimpleServer' template. For example, you can use the
+following command to deploy a new server:
+
+$ icegridadmin --Ice.Config=config -e "server template instantiate \
+ Simple localhost SimpleServer index=4"
diff --git a/py/demo/IceGrid/simple/Server.py b/py/demo/IceGrid/simple/Server.py
new file mode 100644
index 00000000000..1b0751eeec2
--- /dev/null
+++ b/py/demo/IceGrid/simple/Server.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+import sys, traceback, Ice
+
+Ice.loadSlice('Hello.ice')
+import Demo
+
+class HelloI(Demo.Hello):
+ def __init__(self, name):
+ self.name = name
+
+ def sayHello(self, current=None):
+ print self.name + " says Hello World!"
+
+ def shutdown(self, current=None):
+ print self.name + " shutting down..."
+ current.adapter.getCommunicator().shutdown()
+
+class Server(Ice.Application):
+ def run(self, args):
+ properties = self.communicator().getProperties()
+ adapter = self.communicator().createObjectAdapter("Hello")
+ id = Ice.stringToIdentity(properties.getProperty("Identity"))
+ adapter.add(HelloI(properties.getProperty("Ice.ServerId")), id)
+ adapter.activate()
+ self.communicator().waitForShutdown()
+ return True
+
+app = Server()
+sys.exit(app.main(sys.argv))
diff --git a/py/demo/IceGrid/simple/application.xml b/py/demo/IceGrid/simple/application.xml
new file mode 100644
index 00000000000..2bb5e9de444
--- /dev/null
+++ b/py/demo/IceGrid/simple/application.xml
@@ -0,0 +1,28 @@
+<!--
+ **********************************************************************
+
+ Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
+
+ This copy of Ice is licensed to you under the terms described in the
+ ICE_LICENSE file included in this distribution.
+
+ **********************************************************************
+-->
+
+<icegrid>
+
+ <application name="Simple">
+
+ <node name="localhost">
+ <server id="SimpleServer" exe="python" activation="on-demand">
+ <option>Server.py</option>
+ <adapter name="Hello" endpoints="tcp" register-process="true">
+ <object identity="hello" type="::Demo::Hello"/>
+ </adapter>
+ <property name="Identity" value="hello"/>
+ </server>
+ </node>
+
+ </application>
+
+</icegrid>
diff --git a/py/demo/IceGrid/simple/application_with_replication.xml b/py/demo/IceGrid/simple/application_with_replication.xml
new file mode 100644
index 00000000000..9a87bd934bc
--- /dev/null
+++ b/py/demo/IceGrid/simple/application_with_replication.xml
@@ -0,0 +1,38 @@
+<!--
+ **********************************************************************
+
+ Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
+
+ This copy of Ice is licensed to you under the terms described in the
+ ICE_LICENSE file included in this distribution.
+
+ **********************************************************************
+-->
+
+<icegrid>
+
+ <application name="Simple">
+
+ <server-template id="SimpleServer">
+ <parameter name="index"/>
+ <server id="SimpleServer-${index}" exe="python" activation="on-demand">
+ <option>Server.py</option>
+ <adapter name="Hello" endpoints="tcp" register-process="true" replica-group="ReplicatedHelloAdapter"/>
+ <property name="Identity" value="hello"/>
+ </server>
+ </server-template>
+
+ <replica-group id="ReplicatedHelloAdapter">
+ <load-balancing type="round-robin"/>
+ <object identity="hello" type="::Demo::Hello"/>
+ </replica-group>
+
+ <node name="localhost">
+ <server-instance template="SimpleServer" index="1"/>
+ <server-instance template="SimpleServer" index="2"/>
+ <server-instance template="SimpleServer" index="3"/>
+ </node>
+
+ </application>
+
+</icegrid>
diff --git a/py/demo/IceGrid/simple/application_with_template.xml b/py/demo/IceGrid/simple/application_with_template.xml
new file mode 100644
index 00000000000..a6a63ce7cf1
--- /dev/null
+++ b/py/demo/IceGrid/simple/application_with_template.xml
@@ -0,0 +1,35 @@
+<!--
+ **********************************************************************
+
+ Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
+
+ This copy of Ice is licensed to you under the terms described in the
+ ICE_LICENSE file included in this distribution.
+
+ **********************************************************************
+-->
+
+<icegrid>
+
+ <application name="Simple">
+
+ <server-template id="SimpleServer">
+ <parameter name="index"/>
+ <server id="SimpleServer-${index}" exe="python" activation="on-demand">
+ <option>Server.py</option>
+ <adapter name="Hello" endpoints="tcp" register-process="true">
+ <object identity="hello-${index}" type="::Demo::Hello"/>
+ </adapter>
+ <property name="Identity" value="hello-${index}"/>
+ </server>
+ </server-template>
+
+ <node name="localhost">
+ <server-instance template="SimpleServer" index="1"/>
+ <server-instance template="SimpleServer" index="2"/>
+ <server-instance template="SimpleServer" index="3"/>
+ </node>
+
+ </application>
+
+</icegrid>
diff --git a/py/demo/IceGrid/simple/config b/py/demo/IceGrid/simple/config
new file mode 100644
index 00000000000..5f12392aa12
--- /dev/null
+++ b/py/demo/IceGrid/simple/config
@@ -0,0 +1,33 @@
+IceGrid.InstanceName=DemoIceGrid
+
+#
+# The IceGrid locator proxy.
+#
+Ice.Default.Locator=DemoIceGrid/Locator:default -p 12000
+
+#
+# IceGrid registry configuration.
+#
+IceGrid.Registry.Client.Endpoints=default -p 12000
+IceGrid.Registry.Server.Endpoints=default
+IceGrid.Registry.Internal.Endpoints=default
+IceGrid.Registry.Admin.Endpoints=default
+IceGrid.Registry.Data=db/registry
+
+#
+# IceGrid node configuration.
+#
+IceGrid.Node.Name=localhost
+IceGrid.Node.Endpoints=default
+IceGrid.Node.Data=db/node
+IceGrid.Node.CollocateRegistry=1
+#IceGrid.Node.Output=db
+#IceGrid.Node.RedirectErrToOut=1
+
+#
+# Trace properties.
+#
+IceGrid.Node.Trace.Activator=1
+IceGrid.Node.Trace.Patch=1
+#IceGrid.Node.Trace.Adapter=2
+#IceGrid.Node.Trace.Server=3
diff --git a/py/demo/IceGrid/simple/db/node/.dummy b/py/demo/IceGrid/simple/db/node/.dummy
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/py/demo/IceGrid/simple/db/node/.dummy
diff --git a/py/demo/IceGrid/simple/db/registry/.dummy b/py/demo/IceGrid/simple/db/registry/.dummy
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/py/demo/IceGrid/simple/db/registry/.dummy
diff --git a/py/demo/IceStorm/README b/py/demo/IceStorm/README
new file mode 100644
index 00000000000..8e7c57b451b
--- /dev/null
+++ b/py/demo/IceStorm/README
@@ -0,0 +1,5 @@
+Demos in this directory:
+
+- clock
+
+ A simple publisher/subscriber application for IceStorm.
diff --git a/py/demo/IceStorm/clock/Clock.ice b/py/demo/IceStorm/clock/Clock.ice
new file mode 100644
index 00000000000..662346a5fea
--- /dev/null
+++ b/py/demo/IceStorm/clock/Clock.ice
@@ -0,0 +1,23 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#ifndef CLOCK_ICE
+#define CLOCK_ICE
+
+module Demo
+{
+
+interface Clock
+{
+ void tick();
+};
+
+};
+
+#endif
diff --git a/py/demo/IceStorm/clock/Publisher.py b/py/demo/IceStorm/clock/Publisher.py
new file mode 100644
index 00000000000..fd28e504299
--- /dev/null
+++ b/py/demo/IceStorm/clock/Publisher.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+import sys, traceback, Ice, IceStorm
+
+Ice.loadSlice('Clock.ice')
+import Demo
+
+class Publisher(Ice.Application):
+ def run(self, args):
+ properties = self.communicator().getProperties()
+
+ proxyProperty = 'IceStorm.TopicManager.Proxy'
+ proxy = properties.getProperty(proxyProperty)
+ if len(proxy) == 0:
+ print self.appName() + ": property `" + proxyProperty + "' not set"
+ return False
+
+ base = self.communicator().stringToProxy(proxy)
+ manager = IceStorm.TopicManagerPrx.checkedCast(base)
+ if not manager:
+ print args[0] + ": invalid proxy"
+ return False
+
+ #
+ # Retrieve the topic named "time".
+ #
+ try:
+ topic = manager.retrieve("time")
+ except IceStorm.NoSuchTopic, e:
+ print self.appName() + ": no such topic name: " + e.name
+ return False
+
+ #
+ # Get the topic's publisher object, verify that it supports
+ # the Clock type, and create a oneway Clock proxy (for efficiency
+ # reasons).
+ #
+ obj = topic.getPublisher()
+ if not obj.ice_isDatagram():
+ obj = obj.ice_oneway()
+ clock = Demo.ClockPrx.uncheckedCast(obj)
+
+ print "publishing 10 tick events"
+ for i in range(0, 10):
+ clock.tick()
+
+ return True
+
+app = Publisher()
+sys.exit(app.main(sys.argv, "config"))
diff --git a/py/demo/IceStorm/clock/README b/py/demo/IceStorm/clock/README
new file mode 100644
index 00000000000..c4e9f435a83
--- /dev/null
+++ b/py/demo/IceStorm/clock/README
@@ -0,0 +1,20 @@
+To run the demo:
+
+Start the IceStorm service:
+
+$ icebox --Ice.Config=config_service
+
+This configuration assumes there is a subdirectory named db in the
+current working directory.
+
+In a separate window:
+
+$ icestormadmin --Ice.Config=config -e "create time"
+$ python Subscriber.py
+
+In another window:
+
+$ python Publisher.py
+
+Ten "tick" messages should be displayed in the subscriber window for
+each run of the publisher.
diff --git a/py/demo/IceStorm/clock/Subscriber.py b/py/demo/IceStorm/clock/Subscriber.py
new file mode 100644
index 00000000000..a5bdc14ee8b
--- /dev/null
+++ b/py/demo/IceStorm/clock/Subscriber.py
@@ -0,0 +1,97 @@
+#!/usr/bin/env python
+# **********************************************************************
+#
+# Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+import sys, traceback, Ice, IceStorm
+
+Ice.loadSlice('Clock.ice')
+import Demo
+
+class ClockI(Demo.Clock):
+ def tick(self, current=None):
+ print "tick"
+
+class Subscriber(Ice.Application):
+ def run(self, args):
+ properties = self.communicator().getProperties()
+
+ proxyProperty = 'IceStorm.TopicManager.Proxy'
+ proxy = properties.getProperty(proxyProperty)
+ if len(proxy) == 0:
+ print self.appName() + ": property `" + proxyProperty + "' not set"
+ return False
+
+ base = self.communicator().stringToProxy(proxy)
+ manager = IceStorm.TopicManagerPrx.checkedCast(base)
+ if not manager:
+ print args[0] + ": invalid proxy"
+ return False
+
+ #
+ # Gather the set of topics to which to subscribe. It is either
+ # the set provided on the command line, or the topic "time".
+ #
+ topics = []
+ if len(args) > 1:
+ for i in range(1, len(args)):
+ topics.append(args[i])
+ else:
+ topics.append("time")
+
+ #
+ # Set the requested quality of service "reliability" =
+ # "batch". This tells IceStorm to send events to the subscriber
+ # in batches at regular intervals.
+ #
+ qos = {}
+ qos["reliability"] = "batch"
+
+ #
+ # Create the servant to receive the events.
+ #
+ adapter = self.communicator().createObjectAdapter("Clock.Subscriber")
+ clock = ClockI()
+
+
+ #
+ # List of all subscribers.
+ #
+ subscribers = {}
+
+ #
+ # Add the servant to the adapter for each topic. A ServantLocator
+ # could have been used for the same purpose.
+ #
+ for i in range(0, len(topics)):
+ object = adapter.addWithUUID(clock)
+ try:
+ topic = manager.retrieve(topics[i])
+ topic.subscribe(qos, object)
+ except IceStorm.NoSuchTopic, e:
+ print self.appName() + ": no such topic name: " + e.name
+ break
+
+ subscribers[topics[i]] = object
+
+ if len(subscribers) == len(topics):
+ adapter.activate()
+ self.shutdownOnInterrupt()
+ self.communicator().waitForShutdown()
+
+ for name in subscribers.keys():
+ try:
+ topic = manager.retrieve(name)
+ topic.unsubscribe(subscribers[name])
+ except IceStorm.NoSuchTopic, e:
+ print self.appName() + ": no such topic name: " + e.name
+
+ return True
+
+app = Subscriber()
+sys.exit(app.main(sys.argv, "config"))
diff --git a/py/demo/IceStorm/clock/config b/py/demo/IceStorm/clock/config
new file mode 100644
index 00000000000..032a8cbc106
--- /dev/null
+++ b/py/demo/IceStorm/clock/config
@@ -0,0 +1,72 @@
+#
+# This property is used to configure the endpoints of the clock
+# subscriber adapter.
+#
+Clock.Subscriber.Endpoints=tcp
+
+#
+# This property is used by the clients to connect to IceStorm.
+#
+IceStorm.TopicManager.Proxy=DemoIceStorm/TopicManager:default -p 10000
+
+#
+# This property defines the endpoints on which the IceStorm
+# TopicManager listens.
+#
+IceStorm.TopicManager.Endpoints=default -p 10000
+
+#
+# This property defines the endpoints on which the topic
+# publisher objects listen.
+#
+IceStorm.Publish.Endpoints=default
+
+#
+# TopicManager Tracing
+#
+# 0 = no tracing
+# 1 = trace topic creation, subscription, unsubscription
+# 2 = like 1, but with more detailed subscription information
+#
+IceStorm.Trace.TopicManager=2
+
+#
+# Topic Tracing
+#
+# 0 = no tracing
+# 1 = trace unsubscription diagnostics
+#
+IceStorm.Trace.Topic=1
+
+#
+# Subscriber Tracing
+#
+# 0 = no tracing
+# 1 = subscriber diagnostics (subscription, unsubscription, event
+# propagation failures)
+#
+IceStorm.Trace.Subscriber=1
+
+#
+# Flush Tracing (for batch mode transfer flushing)
+#
+# 0 = no tracing
+# 1 = trace activity of flusher thread
+#
+IceStorm.Trace.Flush=1
+
+#
+# Network Tracing
+#
+# 0 = no network tracing
+# 1 = trace connection establishment and closure
+# 2 = like 1, but more detailed
+# 3 = like 2, but also trace data transfer
+#
+Ice.Trace.Network=0
+
+#
+# Amount of time in milliseconds between flushes for batch mode
+# transfer. The minimum allowable value is 100ms.
+#
+IceStorm.Flush.Timeout = 2000
diff --git a/py/demo/IceStorm/clock/config_service b/py/demo/IceStorm/clock/config_service
new file mode 100644
index 00000000000..18102a0f209
--- /dev/null
+++ b/py/demo/IceStorm/clock/config_service
@@ -0,0 +1,44 @@
+#
+# The IceBox server endpoint configuration
+#
+IceBox.ServiceManager.Endpoints=tcp -p 9998
+
+#
+# The IceStorm service
+#
+IceBox.Service.IceStorm=IceStormService,30:create --Ice.Config=config
+
+#
+# This property defines the home directory of the Freeze
+# database environment for the IceStorm service.
+#
+Freeze.DbEnv.IceStorm.DbHome=db
+
+#
+# The IceStorm service instance name.
+#
+IceStorm.InstanceName=DemoIceStorm
+
+#
+# Warn about connection exceptions
+#
+#Ice.Warn.Connections=1
+
+#
+# Network Tracing
+#
+# 0 = no network tracing
+# 1 = trace connection establishment and closure
+# 2 = like 1, but more detailed
+# 3 = like 2, but also trace data transfer
+#
+#Ice.Trace.Network=1
+
+#
+# Protocol Tracing
+#
+# 0 = no protocol tracing
+# 1 = trace protocol messages
+#
+#Ice.Trace.Protocol=1
+
diff --git a/py/demo/IceStorm/clock/db/.dummy b/py/demo/IceStorm/clock/db/.dummy
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/py/demo/IceStorm/clock/db/.dummy