Search in sources :

Example 1 with ContinuousBoundingBoxClientQuery

use of org.bboxdb.network.server.ContinuousBoundingBoxClientQuery in project bboxdb by jnidzwetzki.

the class HandleContinuousBoundingBoxQuery method handleQuery.

@Override
public /**
 * Handle a bounding box query
 */
void handleQuery(final ByteBuffer encodedPackage, final short packageSequence, final ClientConnectionHandler clientConnectionHandler) throws IOException, PackageEncodeException {
    try {
        if (clientConnectionHandler.getActiveQueries().containsKey(packageSequence)) {
            logger.error("Query sequence {} is already known, please close old query first", packageSequence);
            return;
        }
        final QueryBoundingBoxContinuousRequest queryRequest = QueryBoundingBoxContinuousRequest.decodeTuple(encodedPackage);
        final TupleStoreName requestTable = queryRequest.getTable();
        if (!QueryHelper.handleNonExstingTable(requestTable, packageSequence, clientConnectionHandler)) {
            return;
        }
        final BoundingBox boundingBox = queryRequest.getBoundingBox();
        final ClientQuery clientQuery = new ContinuousBoundingBoxClientQuery(boundingBox, clientConnectionHandler, packageSequence, requestTable);
        clientConnectionHandler.getActiveQueries().put(packageSequence, clientQuery);
        clientConnectionHandler.sendNextResultsForQuery(packageSequence, packageSequence);
    } catch (PackageEncodeException e) {
        logger.warn("Got exception while decoding package", e);
        clientConnectionHandler.writeResultPackage(new ErrorResponse(packageSequence, ErrorMessages.ERROR_EXCEPTION));
    }
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) ContinuousBoundingBoxClientQuery(org.bboxdb.network.server.ContinuousBoundingBoxClientQuery) ClientQuery(org.bboxdb.network.server.ClientQuery) ContinuousBoundingBoxClientQuery(org.bboxdb.network.server.ContinuousBoundingBoxClientQuery) PackageEncodeException(org.bboxdb.network.packages.PackageEncodeException) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) QueryBoundingBoxContinuousRequest(org.bboxdb.network.packages.request.QueryBoundingBoxContinuousRequest) ErrorResponse(org.bboxdb.network.packages.response.ErrorResponse)

Aggregations

BoundingBox (org.bboxdb.commons.math.BoundingBox)1 PackageEncodeException (org.bboxdb.network.packages.PackageEncodeException)1 QueryBoundingBoxContinuousRequest (org.bboxdb.network.packages.request.QueryBoundingBoxContinuousRequest)1 ErrorResponse (org.bboxdb.network.packages.response.ErrorResponse)1 ClientQuery (org.bboxdb.network.server.ClientQuery)1 ContinuousBoundingBoxClientQuery (org.bboxdb.network.server.ContinuousBoundingBoxClientQuery)1 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)1