Skip to content

Commit

Permalink
[Broker Clean up] Decouple broker from transport package (apache#3105)
Browse files Browse the repository at this point in the history
Change BrokerRequestHandler to an interface
Move all transport package related classes into ConnectionPoolBrokerRequestHandler implementation
Enhancing broker query log to include servers and exceptions info

Query log example:
2018/08/22 16:53:53.816 INFO [com.linkedin.pinot.broker.requesthandler.ConnectionPoolBrokerRequestHandler] [] Request 7 ScatterGatherStats: <hostName>_O=0,0,0,62
2018/08/22 16:53:53.816 INFO [com.linkedin.pinot.broker.requesthandler.BaseBrokerRequestHandler] [] Request 7:myTable_OFFLINE, time:100ms, docs:10000/44673408, entries:0/80000, servers:1/1, exceptions:0, query:select * from myTable limit 10000

Explaination: first line is the ScatterGatherStats, second line includes tableName, queryTime, numDocsScanned/numTotalDocs, numEntriesScannedIn/PostFilter, serverResponded/Queried, numExceptions, query
  • Loading branch information
Jackie-Jiang authored Aug 24, 2018
1 parent 26b0bda commit 655a9c5
Show file tree
Hide file tree
Showing 16 changed files with 909 additions and 1,248 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.linkedin.pinot.broker.api.resources;

import com.linkedin.pinot.broker.requesthandler.BrokerRequestHandler;
import com.linkedin.pinot.broker.routing.RoutingTable;
import com.linkedin.pinot.broker.routing.TimeBoundaryService;
import com.linkedin.pinot.common.config.TableNameBuilder;
import com.linkedin.pinot.common.metrics.BrokerMeter;
Expand Down Expand Up @@ -44,13 +44,13 @@ public class PinotBrokerDebug {
private static final Logger LOGGER = LoggerFactory.getLogger(PinotBrokerDebug.class);

@Inject
private BrokerRequestHandler requestHandler;
private RoutingTable _routingTable;

@Inject
private BrokerMetrics brokerMetrics;
private BrokerMetrics _brokerMetrics;

@Inject
private TimeBoundaryService timeBoundaryService;
private TimeBoundaryService _timeBoundaryService;

@GET
@Produces(MediaType.APPLICATION_JSON)
Expand All @@ -61,13 +61,13 @@ public class PinotBrokerDebug {
@ApiResponse(code = 500, message = "Internal server error")
})
public String debugRoutingTable(
@ApiParam(value = "Name of the table", required = false) @PathParam("tableName") String tableName
@ApiParam(value = "Name of the table") @PathParam("tableName") String tableName
) {
try {
return requestHandler.getRoutingTableSnapshot(tableName);
return _routingTable.dumpSnapshot(tableName);
} catch (Exception e) {
LOGGER.error("Caught exception while processing GET request", e);
brokerMetrics.addMeteredGlobalValue(BrokerMeter.UNCAUGHT_GET_EXCEPTIONS, 1);
_brokerMetrics.addMeteredGlobalValue(BrokerMeter.UNCAUGHT_GET_EXCEPTIONS, 1);
throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
}
}
Expand All @@ -81,7 +81,7 @@ public String debugRoutingTable(
@ApiResponse(code = 500, message = "Internal server error")
})
public String debugTimeBoundaryService(
@ApiParam(value = "Name of the table", required = false) @PathParam("tableName") String tableName
@ApiParam(value = "Name of the table") @PathParam("tableName") String tableName
) {
try {
String response = "{}";
Expand All @@ -90,15 +90,15 @@ public String debugTimeBoundaryService(
if (tableType == null) {
tableName = TableNameBuilder.OFFLINE.tableNameWithType(tableName);
}
TimeBoundaryService.TimeBoundaryInfo tbInfo = timeBoundaryService.getTimeBoundaryInfoFor(tableName);
TimeBoundaryService.TimeBoundaryInfo tbInfo = _timeBoundaryService.getTimeBoundaryInfoFor(tableName);
if (tbInfo != null) {
response = tbInfo.toJsonString();
}
}
return response;
} catch (Exception e) {
LOGGER.error("Caught exception while processing GET request", e);
brokerMetrics.addMeteredGlobalValue(BrokerMeter.UNCAUGHT_GET_EXCEPTIONS, 1);
_brokerMetrics.addMeteredGlobalValue(BrokerMeter.UNCAUGHT_GET_EXCEPTIONS, 1);
throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.google.common.base.Preconditions;
import com.linkedin.pinot.broker.requesthandler.BrokerRequestHandler;
import com.linkedin.pinot.broker.routing.RoutingTable;
import com.linkedin.pinot.broker.routing.TimeBoundaryService;
import com.linkedin.pinot.common.metrics.BrokerMetrics;
import io.swagger.jaxrs.config.BeanConfig;
Expand All @@ -37,16 +38,16 @@ public class BrokerAdminApiApplication extends ResourceConfig {
private URI _baseUri;
private HttpServer _httpServer;

public BrokerAdminApiApplication(final BrokerServerBuilder brokerServerBuilder, final BrokerMetrics brokerMetrics,
final BrokerRequestHandler brokerRequestHandler, final TimeBoundaryService timeBoundaryService) {
public BrokerAdminApiApplication(BrokerServerBuilder brokerServerBuilder) {
packages(RESOURCE_PACKAGE);
register(new AbstractBinder() {
@Override
protected void configure() {
bind(brokerServerBuilder).to(BrokerServerBuilder.class);
bind(brokerMetrics).to(BrokerMetrics.class);
bind(brokerRequestHandler).to(BrokerRequestHandler.class);
bind(timeBoundaryService).to(TimeBoundaryService.class);
bind(brokerServerBuilder.getRoutingTable()).to(RoutingTable.class);
bind(brokerServerBuilder.getTimeBoundaryService()).to(TimeBoundaryService.class);
bind(brokerServerBuilder.getBrokerMetrics()).to(BrokerMetrics.class);
bind(brokerServerBuilder.getBrokerRequestHandler()).to(BrokerRequestHandler.class);
}
});
registerClasses(io.swagger.jaxrs.listing.ApiListingResource.class);
Expand Down

This file was deleted.

Loading

0 comments on commit 655a9c5

Please sign in to comment.