Merge pull request #192 from airbnb/kim/misc_hack

Fix Druid metadata refresh.
This commit is contained in:
Maxime Beauchemin 2016-03-25 22:16:54 -07:00
commit fdce2aac0d
1 changed files with 12 additions and 4 deletions

View File

@ -864,8 +864,12 @@ class DruidDatasource(Model, AuditMixinNullable, Queryable):
return
max_time = results[0]['result']['maxTime']
max_time = parse(max_time)
intervals = (max_time - timedelta(seconds=1)).isoformat() + '/'
intervals += (max_time + timedelta(seconds=1)).isoformat()
# Query segmentMetadata for 7 days back. However, due to a bug,
# we need to set this interval to more than 1 day ago to exclude
# realtime segments, which trigged a bug (fixed in druid 0.8.2).
# https://groups.google.com/forum/#!topic/druid-user/gVCqqspHqOQ
intervals = (max_time - timedelta(days=7)).isoformat() + '/'
intervals += (max_time - timedelta(days=1)).isoformat()
segment_metadata = client.segment_metadata(
datasource=self.datasource_name,
intervals=intervals)
@ -1117,7 +1121,9 @@ class DruidMetric(Model, AuditMixinNullable):
datasource_name = Column(
String(250),
ForeignKey('datasources.datasource_name'))
datasource = relationship('DruidDatasource', backref='metrics')
# Setting enable_typechecks=False disables polymorphic inheritance.
datasource = relationship('DruidDatasource', backref='metrics',
enable_typechecks=False)
json = Column(Text)
description = Column(Text)
@ -1139,7 +1145,9 @@ class DruidColumn(Model, AuditMixinNullable):
datasource_name = Column(
String(250),
ForeignKey('datasources.datasource_name'))
datasource = relationship('DruidDatasource', backref='columns')
# Setting enable_typechecks=False disables polymorphic inheritance.
datasource = relationship('DruidDatasource', backref='columns',
enable_typechecks=False)
column_name = Column(String(256))
is_active = Column(Boolean, default=True)
type = Column(String(32))