コード例 #1
0
ファイル: api.py プロジェクト: neiodavince/hue
def _get_server_properties():
    global _api_cache

    if not _api_cache:  # If we need to refresh the list or if previously no servers were up
        _api_cache_lock.acquire()

        try:
            if not _api_cache:

                servers = []
                client = ZookeeperClient(hosts=get_sentry_server_ha_zookeeper_quorum())
                sentry_servers = client.get_children_data(namespace=get_sentry_server_ha_zookeeper_namespace())

                for data in sentry_servers:
                    server = json.loads(data.decode("utf-8"))
                    servers.append(
                        {
                            "hostname": server["address"],
                            "port": server["sslPort"] if server["sslPort"] else server["port"],
                        }
                    )

                _api_cache = servers
        except Exception, e:
            raise PopupException(_("Error in retrieving Sentry server properties from Zookeeper."), detail=e)
        finally:
コード例 #2
0
ファイル: tests.py プロジェクト: tclcx111/hue
  def test_get_children_data(self):
    root_node = '%s/%s' % (TestWithZooKeeper.namespace, 'test_path_exists')
    client = ZookeeperClient(hosts=zkensemble(), read_only=False)

    client.zk.start()
    try:
      client.zk.create(root_node, value='test_path_exists', makepath=True)
    finally:
      client.zk.stop()

    db = client.get_children_data(namespace=TestWithZooKeeper.namespace)
    assert_true(len(db) > 0)
コード例 #3
0
    def test_get_children_data(self):
        root_node = '%s/%s' % (TestWithZooKeeper.namespace, 'test_path_exists')
        client = ZookeeperClient(hosts=zkensemble(), read_only=False)

        client.zk.start()
        try:
            client.zk.create(root_node,
                             value='test_path_exists',
                             makepath=True)
        finally:
            client.zk.stop()

        db = client.get_children_data(namespace=TestWithZooKeeper.namespace)
        assert_true(len(db) > 0)
コード例 #4
0
def _get_server_properties():
  global _api_cache

  if not _api_cache: # If we need to refresh the list or if previously no servers were up 
    _api_cache_lock.acquire()

    try:
      if not _api_cache:

        servers = []
        client = ZookeeperClient(hosts=get_sentry_server_ha_zookeeper_quorum())
        sentry_servers = client.get_children_data(namespace=get_sentry_server_ha_zookeeper_namespace())

        for data in sentry_servers:
          server = json.loads(data.decode("utf-8"))
          servers.append({'hostname': server['address'], 'port': server['sslPort'] if server['sslPort'] else server['port']})

        _api_cache = servers
    except Exception, e:
      raise PopupException(_('Error in retrieving Sentry server properties from Zookeeper.'), detail=e)
    finally:
コード例 #5
0
ファイル: tests.py プロジェクト: luodongfu/XLS_BigData_Hue
 def test_get_children_data(self):
     client = ZookeeperClient(hosts=zkensemble())
     db = client.get_children_data(namespace='')
     assert_true(len(db) > 0)
コード例 #6
0
ファイル: tests.py プロジェクト: renxiawang/hue
 def test_get_children_data(self):
   client = ZookeeperClient(hosts=zkensemble())
   db = client.get_children_data(namespace='')
   assert_true(len(db) > 0)