Sha256: 8f190cc91dd6ac5477e70756d3ae35c35b04806e7db0ff73633dc9388c70169b
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
class GlobalApplicationInterfaceApp<Service provides :globalApp class ApplicationNotFoundException<Exception end class Application attr_reader :name, :instance def initialize(name,instance,interface) @interface=interface @name=name @instance=instance @mutex=Mutex.new getApi end def info [name,instance] end def method_missing(name,*args) @interface.callRemote(self,name,args) end private def getApi # FIXME: get api from somewhere end end def initialize(cluster,options) super(cluster,options,:globalApp) @appNodes={} @mutex=Mutex.new end def get(name,instance=nil) Application.new(name,instance,self) end def callRemote(app,funcName,args) serviceName=[app.name,app.instance] nodes=getNodes(serviceName) #pp "SERVICE ",serviceName #pp nodes raise ApplicationNotFoundException.new(app) if nodes.nil? or nodes.length==0 # take one node nodes.shuffle! loop do node=nodes.shift begin result=getApp(:fullNetworkNode).api.send(node,:globalApp,app.info,funcName,args) result=result.wait return result #rescue RemoteException=>e # simply take next node end end # FIXME - raise Exception end def getNodes(appName) @mutex.synchronize { return @appNodes[appName].dup if @appNodes[appName] } key=[:appNodes,appName] result=getApp(:directoryService).lookup(key) #result=getApp(:directoryService).get(k) #result=@appNodes[appName].dup result end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
appswarm-0.0.1 | apps/global_application_interface/global_application_interface.rb |