mirror of https://github.com/apache/druid.git
SQL: Fix race with metadata caching. (#4674)
If DruidSchema started too long after the BrokerServerView, its initialization callback would never get called, and it would sit there not knowing about any tables. This moves the registration of the callback into the constructor, where it belongs.
This commit is contained in:
parent
bf28d0775b
commit
5ff8c52f16
|
@ -133,6 +133,37 @@ public class DruidSchema extends AbstractSchema
|
|||
this.viewManager = Preconditions.checkNotNull(viewManager, "viewManager");
|
||||
this.cacheExec = ScheduledExecutors.fixed(1, "DruidSchema-Cache-%d");
|
||||
this.tables = Maps.newConcurrentMap();
|
||||
|
||||
serverView.registerTimelineCallback(
|
||||
MoreExecutors.sameThreadExecutor(),
|
||||
new TimelineServerView.TimelineCallback()
|
||||
{
|
||||
@Override
|
||||
public ServerView.CallbackAction timelineInitialized()
|
||||
{
|
||||
synchronized (lock) {
|
||||
isServerViewInitialized = true;
|
||||
lock.notifyAll();
|
||||
}
|
||||
|
||||
return ServerView.CallbackAction.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerView.CallbackAction segmentAdded(final DruidServerMetadata server, final DataSegment segment)
|
||||
{
|
||||
addSegment(server, segment);
|
||||
return ServerView.CallbackAction.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerView.CallbackAction segmentRemoved(final DataSegment segment)
|
||||
{
|
||||
removeSegment(segment);
|
||||
return ServerView.CallbackAction.CONTINUE;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@LifecycleStart
|
||||
|
@ -239,37 +270,6 @@ public class DruidSchema extends AbstractSchema
|
|||
}
|
||||
}
|
||||
);
|
||||
|
||||
serverView.registerTimelineCallback(
|
||||
MoreExecutors.sameThreadExecutor(),
|
||||
new TimelineServerView.TimelineCallback()
|
||||
{
|
||||
@Override
|
||||
public ServerView.CallbackAction timelineInitialized()
|
||||
{
|
||||
synchronized (lock) {
|
||||
isServerViewInitialized = true;
|
||||
lock.notifyAll();
|
||||
}
|
||||
|
||||
return ServerView.CallbackAction.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerView.CallbackAction segmentAdded(final DruidServerMetadata server, final DataSegment segment)
|
||||
{
|
||||
addSegment(server, segment);
|
||||
return ServerView.CallbackAction.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerView.CallbackAction segmentRemoved(final DataSegment segment)
|
||||
{
|
||||
removeSegment(segment);
|
||||
return ServerView.CallbackAction.CONTINUE;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@LifecycleStop
|
||||
|
|
Loading…
Reference in New Issue