use of org.bboxdb.network.server.handler.query.QueryHandler in project bboxdb by jnidzwetzki.
the class ClientConnectionHandler method handleQuery.
/**
* Handle query package
* @param bb
* @param packageSequence
* @return
* @throws PackageEncodeException
* @throws IOException
*/
protected boolean handleQuery(final ByteBuffer encodedPackage, final short packageSequence) throws IOException, PackageEncodeException {
final byte queryType = NetworkPackageDecoder.getQueryTypeFromRequest(encodedPackage);
if (!queryHandlerList.containsKey(queryType)) {
logger.warn("Unsupported query type: {}", queryType);
final ErrorResponse errorResponse = new ErrorResponse(packageSequence, ErrorMessages.ERROR_UNSUPPORTED_PACKAGE_TYPE);
writeResultPackage(errorResponse);
return false;
}
if (activeQueries.size() > MAX_RUNNING_QUERIES) {
logger.warn("Client requested more than {} parallel queries", MAX_RUNNING_QUERIES);
final ErrorResponse errorResponse = new ErrorResponse(packageSequence, ErrorMessages.ERROR_QUERY_TO_MUCH);
writeResultPackage(errorResponse);
} else {
final QueryHandler queryHandler = queryHandlerList.get(queryType);
queryHandler.handleQuery(encodedPackage, packageSequence, this);
}
return true;
}
Aggregations