A `parent' object, managing many sister-servers.
I maintain a list of all "sister" servers who are connected, so that all
servers can connect to each other. I also negotiate which distributed
objects are owned by which sister servers, so that if any sister-server
needs to locate an object it can be made available.
Methods
|
|
__getstate__
__init__
_cbLocked
_ebLocked
loadResource
lockResource
perspective_callPath
registerResourceLoader
startService
|
|
__getstate__
|
__getstate__ ( self )
|
|
__init__
|
__init__ (
self,
parentHost,
parentPort,
parentService,
localPort,
sharedSecret,
serviceName="twisted.sister",
application=None,
)
Initialize me.
|
|
_cbLocked
|
_cbLocked (
self,
result,
path,
)
|
|
_ebLocked
|
_ebLocked (
self,
error,
path,
)
|
|
loadResource
|
loadResource ( self, path )
Load a resource on a path.
If the server sends you this message, it means that as soon as this
method completes (successfully), you must be ready to handle messages
being sent to that resource.
(Keep in mind that you do not need to run this method atomically; all
remote methods may be postponed by returning a Deferred.)
|
|
lockResource
|
lockResource ( self, path )
Attempt to lock a resource.
Arguments:
path: a tuple of strings, describing the path to the resource on my
parent server. For example, for a twisted.wors chatroom of the
name "foobar", this path would be (twisted.words , groups ,
foobar ). For a user of the name "joe", this path would be
(twisted.words , users , joe ).
Attempt to lock a resource accessible via a given path on my parent
server, for some local activity. This is useful in services which
require ownership of stateful objects with behavior that must be
processed.
Returns:
A deferred which will fire when the resource has either been locked
or determined to be locked on another server. The result of this
deferred will be a 2-tuple. The first element of the tuple will be
true if the resource was in fact locked, and the second element
will be the local instance created by loadResource.
If the resource was locked by another server, then the first
element of the tuple will be false, and the second element will be
a descriptor tuple of (host, portno) describing where we can go
looking for said resource.
|
|
perspective_callPath
|
perspective_callPath (
self,
path,
name,
*args,
*kw,
)
Exceptions
|
|
Error("I do not own this resource: %s" % repr( path ) )
|
|
|
registerResourceLoader
|
registerResourceLoader (
self,
resourcePath,
resourceLoader,
)
By convention, calls to loadResource will use the first
element of the path to determine how to load them; for
example, (twisted.words , group , foobar ) is a
twisted.words group, and there will be a twisted.words loader
that will deal with constructing it. (Loading the object just means constructing it in some way;
it does not have to be loaded from external media)
|
|
startService
|
startService ( self )
|
|