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 |
---|---|
HttpClientException | Client exceptions |
HttpClientConnectionRefusedException | HiTSDB server refused connection |
HttpClientInitException | Client exception during initialization |
HttpClientSocketTimeoutException | Request time-out |
HttpServerErrorException | HiTSDB server returned 5xx-level error code |
HttpServerNotSupportException | HiTSDB server returned 4xx-level error code |
HttpUnknowStatusException | HiTSDB server returned undefined error code |
BufferQueueFullException | Asynchronous 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);
}
};