Skip to content

Commit

Permalink
fetch datasources from broker endpoint when refresh new datasources (a…
Browse files Browse the repository at this point in the history
…pache#5183)

* fetch datasources from broker endpoint when refresh new datasources

* remove get_base_coordinator_url as out of use

* add broker_endpoint in get_test_cluster_obj
  • Loading branch information
liyuance authored and mistercrunch committed Jun 13, 2018
1 parent 1fa00ba commit 8ee368f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions superset/connectors/druid/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ def get_base_url(host, port):
url = '{0}:{1}'.format(host, port) if port else host
return url

def get_base_coordinator_url(self):
def get_base_broker_url(self):
base_url = self.get_base_url(
self.coordinator_host, self.coordinator_port)
return '{base_url}/{self.coordinator_endpoint}'.format(**locals())
self.broker_host, self.broker_port)
return '{base_url}/{self.broker_endpoint}'.format(**locals())

def get_pydruid_client(self):
cli = PyDruid(
Expand All @@ -133,7 +133,7 @@ def get_pydruid_client(self):
return cli

def get_datasources(self):
endpoint = self.get_base_coordinator_url() + '/datasources'
endpoint = self.get_base_broker_url() + '/datasources'
return json.loads(requests.get(endpoint).text)

def get_druid_version(self):
Expand Down
5 changes: 3 additions & 2 deletions tests/druid_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def get_test_cluster_obj(self):
coordinator_port=7979,
broker_host='localhost',
broker_port=7980,
broker_endpoint='druid/v2',
metadata_last_refreshed=datetime.now())

def get_cluster(self, PyDruid):
Expand Down Expand Up @@ -456,8 +457,8 @@ def test_urls(self):
'https://localhost:9999')

self.assertEquals(
cluster.get_base_coordinator_url(),
'http://localhost:7979/druid/coordinator/v1/metadata')
cluster.get_base_broker_url(),
'http://localhost:7980/druid/v2')


if __name__ == '__main__':
Expand Down

0 comments on commit 8ee368f

Please sign in to comment.