Exemplo n.º 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 = ZooBorg(Configuration.getclient()['zookeeper']['ip'],
                      Configuration.getclient()['zookeeper']['port'])
         zooconf = zb.getConf(ZooBorg.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(zb.CLIENT, uniq.getid(uniq.CLIENT), self._zconfchanged)
         self.initialized=True
Exemplo n.º 2
0
    def test_client(self):
        ip = Configuration.getclient()['zookeeper']['ip']
        port = Configuration.getclient()['zookeeper']['port']
        zb = ZooBorg(ip, port)
        try:
            client_id = 'client_test_id'
            zb.register(ZooBorg.CLIENT, client_id, self.stubhandler)
            # conf must be updated

            # client id must be in client list
            cl = zb.getList(ZooBorg.CLIENT)
            assert client_id in cl
            #just the one created here (connection pools are dead here)
            #print "clientlist:",cl
            assert len(cl) == 1
        except:
            traceback.print_exc()
            assert 0
        finally:
            zb.unregister(ZooBorg.CLIENT, client_id)
Exemplo n.º 3
0
    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 !!!'
Exemplo n.º 4
0
 def test_conf_client(self):
     assert Configuration.getclient() is not None
     assert Configuration.initialized is True
     assert Configuration.client_initialized is True
     assert len(Configuration.getclient()['zookeeper']['ip'])>0