Esempio n. 1
0
    def __init__(self,name):
        """初始化远程调用对象
        @param port: int 远程分布服的端口号
        @param rootaddr: 根节点服务器地址
        """
        self._name = name
        self._factory = pb.PBClientFactory()
        self._reference = ProxyReference(self)
        self._service = Service('proxy')
        serviceControl.initControl(self._service)

        self._addr = None
Esempio n. 2
0
    def __init__(self, name):
        """初始化远程调用对象
        @param port: int 远程分布服的端口号
        @param rootaddr: 根节点服务器地址
        """
        self._name = name
        self._factory = pb.PBClientFactory()
        self._reference = ProxyReference(self)
        self._service = Service('proxy')
        serviceControl.initControl(self._service)

        self._addr = None
Esempio n. 3
0
    def config(self,config,dbconfig = None,memconfig = None,masterconf=None):
        """配置服务器
        """
        remoteportlist = config.get('remoteport',[])#remote节点配置列表
        servername = config.get('name')#服务器名称
        logpath = config.get('log')#日志
        hasdb = config.get('db')#数据库连接
        hasmem = config.get('mem')#memcached连接
        app = config.get('app')#入口模块名称
        mreload = config.get('reload')#重新加载模块名称
        self.servername = servername


        if masterconf:
            masterport = masterconf.get('rootport')
            addr = ('localhost', masterport)
            leafnode = leafNode(servername)
            serviceControl.initControl(leafnode.getServiceChannel())

            leafnode.connect(addr)
            GlobalObject().leafNode = leafnode


        for cnf in remoteportlist:
            rname = cnf.get('rootname')
            rport = cnf.get('rootport')
            self.remote[rname] = leafNode(servername)
            addr = ('localhost',rport)
            self.remote[rname].connect(addr)

        GlobalObject().remote = self.remote

        if hasdb and dbconfig:
            log.msg(str(dbconfig))
            dbpool.initPool(**dbconfig)

        if hasmem and memconfig:
            urls = memconfig.get('urls')
            hostname = str(memconfig.get('hostname'))
            mclient.connect(urls, hostname)

        if logpath:
            log.addObserver(loogoo(logpath))#日志处理
        log.startLogging(sys.stdout)

        if app:
            reactor.callLater(0.1, __import__, app)

        if mreload:
            GlobalObject().reloadmodule = __import__(mreload)
Esempio n. 4
0
    def config(self, config, dbconfig=None, memconfig=None, masterconf=None):
        """配置服务器
        """
        rootport = config.get('rootport')#root节点配置
        servername = config.get('name')#服务器名称
        logpath = config.get('log')#日志
        hasdb = config.get('db')#数据库连接
        hasmem = config.get('mem')#memcached连接
        app = config.get('app')#入口模块名称
        self.servername = servername


        if masterconf:
            masterport = masterconf.get('rootport')
            addr = ('localhost', masterport)
            leafnode = leafNode(servername)
            serviceControl.initControl(leafnode.getServiceChannel())
            leafnode.connect(addr)
            GlobalObject().leafNode = leafnode


        if rootport:
            self.root = PBRoot("rootservice")
            reactor.listenTCP(rootport, BilateralFactory(self.root))
            GlobalObject().root = self.root

        if hasdb and dbconfig:
            log.msg(str(dbconfig))
            dbpool.initPool(**dbconfig)

        if hasmem and memconfig:
            urls = memconfig.get('urls')
            hostname = str(memconfig.get('hostname'))
            mclient.connect(urls, hostname)

        if logpath:
            log.addObserver(loogoo(logpath))#日志处理
        log.startLogging(sys.stdout)


        if app:
            reactor.callLater(0.1,__import__,app)
Esempio n. 5
0
    def config(self, config, dbconfig=None, memconfig=None, masterconf=None):
        """配置服务器
        """
        netport = config.get('netport')  #客户端连接
        gatelist = config.get('remoteport', [])  #remote节点配置列表
        servername = config.get('name')  #服务器名称
        logpath = config.get('log')  #日志
        app = config.get('app')  #入口模块名称
        self.servername = servername

        if masterconf:
            masterport = masterconf.get('rootport')
            addr = ('localhost', masterport)
            leafnode = leafNode(servername)
            serviceControl.initControl(leafnode.getServiceChannel())
            leafnode.connect(addr)
            GlobalObject().leafNode = leafnode

        if netport:
            self.netfactory = LiberateFactory()
            netservice = services.CommandService("netservice")
            self.netfactory.addServiceChannel(netservice)
            reactor.listenTCP(netport, self.netfactory)
            GlobalObject().netfactory = self.netfactory

        for cnf in gatelist:
            rname = cnf.get('rootname')
            rport = cnf.get('rootport')
            self.gates[rname] = leafNode(servername)
            addr = ('localhost', rport)
            self.gates[rname].connect(addr)

        GlobalObject().remote = self.gates

        if logpath:
            log.addObserver(loogoo(logpath))  #日志处理
        log.startLogging(sys.stdout)

        if app:
            reactor.callLater(0.1, __import__, app)
Esempio n. 6
0
    def config(self, config, dbconfig = None,memconfig = None,masterconf=None):
        """配置服务器
        """
        netport = config.get('netport')#客户端连接
        gatelist = config.get('remoteport',[])#remote节点配置列表
        servername = config.get('name')#服务器名称
        logpath = config.get('log')#日志
        app = config.get('app')#入口模块名称
        self.servername = servername

        if masterconf:
            masterport = masterconf.get('rootport')
            addr = ('localhost', masterport)
            leafnode = leafNode(servername)
            serviceControl.initControl(leafnode.getServiceChannel())
            leafnode.connect(addr)
            GlobalObject().leafNode = leafnode

        if netport:
            self.netfactory = LiberateFactory()
            netservice = services.CommandService("netservice")
            self.netfactory.addServiceChannel(netservice)
            reactor.listenTCP(netport, self.netfactory)
            GlobalObject().netfactory = self.netfactory

        for cnf in gatelist:
            rname = cnf.get('rootname')
            rport = cnf.get('rootport')
            self.gates[rname] = leafNode(servername)
            addr = ('localhost', rport)
            self.gates[rname].connect(addr)

        GlobalObject().remote = self.gates

        if logpath:
            log.addObserver(loogoo(logpath))  #日志处理
        log.startLogging(sys.stdout)

        if app:
            reactor.callLater(0.1, __import__, app)
Esempio n. 7
0
    def config(self, config, dbconfig=None, memconfig=None, masterconf=None):
        """配置服务器
        """
        rootport = config.get('rootport')  #root节点配置
        servername = config.get('name')  #服务器名称
        logpath = config.get('log')  #日志
        hasdb = config.get('db')  #数据库连接
        hasmem = config.get('mem')  #memcached连接
        app = config.get('app')  #入口模块名称
        self.servername = servername

        if masterconf:
            masterport = masterconf.get('rootport')
            addr = ('localhost', masterport)
            leafnode = leafNode(servername)
            serviceControl.initControl(leafnode.getServiceChannel())
            leafnode.connect(addr)
            GlobalObject().leafNode = leafnode

        if rootport:
            self.root = PBRoot("rootservice")
            reactor.listenTCP(rootport, BilateralFactory(self.root))
            GlobalObject().root = self.root

        if hasdb and dbconfig:
            log.msg(str(dbconfig))
            dbpool.initPool(**dbconfig)

        if hasmem and memconfig:
            urls = memconfig.get('urls')
            hostname = str(memconfig.get('hostname'))
            mclient.connect(urls, hostname)

        if logpath:
            log.addObserver(loogoo(logpath))  #日志处理
        log.startLogging(sys.stdout)

        if app:
            reactor.callLater(0.1, __import__, app)
Esempio n. 8
0
 def addServiceChannel(self,service):
     """设置引用对象"""
     self._service = service
     serviceControl.initControl(self._service)
Esempio n. 9
0
 def addServiceChannel(self, service):
     """设置引用对象"""
     self._service = service
     serviceControl.initControl(self._service)