edit-icon download-icon

Process exceptions

Last Updated: Mar 28, 2018

HiTSDB-Client SDK does not forcefully process exceptions. Instead, all exceptions are thrown out in the form of RuntimeException. You can capture and handle exceptions based on your needs.

Common exceptions

Descriptions of exception classes
HttpClientExceptionClient exceptions
HttpClientConnectionRefusedExceptionHiTSDB server refused connection
HttpClientInitExceptionClient exception during initialization
HttpClientSocketTimeoutExceptionRequest time-out
HttpServerErrorExceptionHiTSDB server returned 5xx-level error code
HttpServerNotSupportExceptionHiTSDB server returned 4xx-level error code
HttpUnknowStatusException HiTSDB server returned undefined error code
BufferQueueFullExceptionAsynchronous submission buffer queue already full

Exceptions processing

Synchronous interfaces and exceptions processing

try {
    tsdb.ttl(10000);
} catch(HttpServerNotSupportException e) {
    int status = e.getStatus();
    String message = e.getMessage();
    System.err.println(status + "," + message);
} catch(HttpServerErrorException e) {
    int status = e.getStatus();
    String message = e.getMessage();
    System.err.println(status + "," + message);
}

Asynchronous interfaces and exceptions processing

Rewrite the failed methods when processing exceptions.

QueryCallback cb = new QueryCallback() {

    @Override
    public void response(Query input, List<QueryResult> result) {
        System.out.println("Query parameters:" + input);
        System.out.println("Returned results:" + result);
    }

    // Rewrite the failed methods when processing exceptions
    @Override
    public void failed(Query request, Exception ex) {
        super.failed(request, ex);
    }

};
BatchPutCallback cb = new BatchPutCallback() {

    @Override
    public void response(List<Point> input, Result output) {
        long afterNum = num.addAndGet(input.size());
        System.out.println("Processing succeeded" + input.size() + ", processed" + afterNum);
    }

    @Override
    public void failed(List<Point> input, Exception ex) {
        ex.printStackTrace();
        long afterNum = num.addAndGet(input.size());
        System.out.println("Processing failed" + input.size() + ", processed" + afterNum);
    }
};
Thank you! We've received your feedback.