예제 #1
0
    def __init__(self, maxconnection=10):
        # copie de l'état lors de l'initialisation d'une nouvelle instance
        self.__dict__ = self.__shared_state
        if not(self.initialized):
            #N MajorDomoClient
            #print "INIT ConnectionPool"

            zb = ZooBorgFactory(Configuration.getclient()['zookeeper']['mockmode'],
                                Configuration.getclient()['zookeeper']['ip'],
                                Configuration.getclient()['zookeeper']['port'])


            zooconf = zb.getConf(ZooConst.CLIENT)
            connection_str = zooconf['broker']['connectionstr']
            uniq = Uniq()
            for _ in range(1, maxconnection):
                conn = MajorDomoClient(connection_str, False, self)
                self.__availableconnection.append(conn)
                #register connexion
                zb.register(ZooConst.CLIENT, uniq.getid(uniq.CLIENT), self._zconfchanged)
            self.initialized = True
예제 #2
0
    zb.zk.set("/distark/broker/conf/bindstr", b"tcp://*:5555")
    zb.zk.ensure_path("/distark/broker/conf/conf_reload_trigger")


if __name__ == "__main__":
    ##############################################
    #     ARGUMENTS PARSING
    ##############################################
    parser = argparse.ArgumentParser(description="Send requests")
    parser.add_argument("do", help="test initclientconf initworkerconf initbrokerconf initall", type=str)
    parser.set_defaults(do="test")
    args = parser.parse_args()
    print "Program Launched with args:" + str(args)
    print "Do:" + str(args.do)
    zb = None
    ip = Configuration.getclient()["zookeeper"]["ip"]
    port = Configuration.getclient()["zookeeper"]["port"]
    zb = ZooBorg(ip, port)
    try:
        if args.do == "initclientconf":
            _initclientconf(zb)
        elif args.do == "initworkerconf":
            _initworkerconf(zb)
        elif args.do == "initbrokerconf":
            _initbrokerconf(zb)
        elif args.do == "initall":
            _initworkerconf(zb)
            _initclientconf(zb)
            _initbrokerconf(zb)
        else:
            print "do nothing !!!"