提交 9b06b6aa 编写于 作者: F fjy

misc fixes for router

上级 291dac8d
......@@ -61,8 +61,8 @@ public abstract class AbstractTask implements Task
protected AbstractTask(String id, String groupId, TaskResource taskResource, String dataSource)
{
this.id = Preconditions.checkNotNull(id.toLowerCase(), "id");
this.groupId = Preconditions.checkNotNull(groupId.toLowerCase(), "groupId");
this.id = Preconditions.checkNotNull(id, "id");
this.groupId = Preconditions.checkNotNull(groupId, "groupId");
this.taskResource = Preconditions.checkNotNull(taskResource, "resource");
this.dataSource = Preconditions.checkNotNull(dataSource.toLowerCase(), "dataSource");
}
......
......@@ -50,10 +50,14 @@ public class QueryHostFinder<T>
{
final Pair<String, ServerDiscoverySelector> selected = hostSelector.select(query);
final String serviceName = selected.lhs;
final ServerDiscoverySelector selector = selected.rhs;
if (selected == null) {
log.error("Danger, Will Robinson! Unable to find any brokers!");
}
final String serviceName = selected == null ? hostSelector.getDefaultServiceName() : selected.lhs;
final ServerDiscoverySelector selector = selected == null ? null : selected.rhs;
Server server = selector.pick();
Server server = selector == null ? null : selector.pick();
if (server == null) {
log.error(
"WTF?! No server found for serviceName[%s]. Using backup",
......
......@@ -122,7 +122,7 @@ public class TieredBrokerHostSelector<T> implements HostSelector<T>
{
synchronized (lock) {
if (!ruleManager.isStarted() || !started) {
return null;
return getDefaultLookup();
}
}
......@@ -157,7 +157,7 @@ public class TieredBrokerHostSelector<T> implements HostSelector<T>
}
if (baseRule == null) {
return null;
return getDefaultLookup();
}
// in the baseRule, find the broker of highest priority
......@@ -192,4 +192,11 @@ public class TieredBrokerHostSelector<T> implements HostSelector<T>
return new Pair<>(brokerServiceName, retVal);
}
private Pair<String, ServerDiscoverySelector> getDefaultLookup()
{
final String brokerServiceName = tierConfig.getDefaultBrokerServiceName();
final ServerDiscoverySelector retVal = selectorMap.get(brokerServiceName);
return new Pair<>(brokerServiceName, retVal);
}
}
......@@ -142,19 +142,18 @@ public class TieredBrokerHostSelectorTest
@Test
public void testSelectMatchesNothing() throws Exception
{
Pair retVal = brokerSelector.select(
String brokerName = (String) brokerSelector.select(
Druids.newTimeseriesQueryBuilder()
.dataSource("test")
.granularity("all")
.aggregators(Arrays.<AggregatorFactory>asList(new CountAggregatorFactory("rows")))
.intervals(Arrays.<Interval>asList(new Interval("2010-08-31/2010-09-01")))
.build()
);
).lhs;
Assert.assertEquals(null, retVal);
Assert.assertEquals("hotBroker", brokerName);
}
@Test
public void testSelectMultiInterval() throws Exception
{
......
......@@ -86,6 +86,7 @@ public class RouterJettyServerInitializer implements JettyServerInitializer
), "/druid/v2/*"
);
queries.addFilter(GzipFilter.class, "/druid/v2/*", null);
queries.addFilter(GuiceFilter.class, "/status/*", null);
final ServletContextHandler root = new ServletContextHandler(ServletContextHandler.SESSIONS);
root.addServlet(new ServletHolder(new DefaultServlet()), "/*");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册