@Override
public void handleGet(ServletServiceRequest request, ServletServiceResponse response,
OperationDiagnostics stats) throws IOException
{
final OperationMetrics metrics = _listMetrics;
Context timer = (metrics == null) ? null : metrics.start();
String str = request.getQueryParameter(ClusterMateConstants.QUERY_PARAM_SINCE);
try {
if (str == null) {
response = _syncHandler.missingArgument(response, ClusterMateConstants.QUERY_PARAM_SINCE);
} else {
long since = -1;
try {
since = Long.parseLong(str);
} catch (NumberFormatException e) { }
if (since < 0L) {
response = _syncHandler.invalidArgument(response, ClusterMateConstants.QUERY_PARAM_SINCE, str);
} else {
try {
response = _syncHandler.listEntries(request, response, since, stats);
} catch (IllegalStateException e) {
// Swallow during shutdown
if (!_terminated.get()) {
LOG.error("Failed syncHandler.listEntries(): "+e.getMessage(), e);
}
response.internalError("Failed syncHandler.listEntries(): "+e.getMessage());
} catch (InterruptedException e) {
// Swallow during shutdown (mostly during tests)
if (!_terminated.get()) {
/* 08-Jan-2013, tatu: This seems to occur during shutdowns, should
* find a way to pipe shutdown notifications to servlet too.
* But for now, let's just customize message a bit:
*/
throw new IOException("syncHandler.listEntries() interrupted, system not yet shut down: probably harmless");
}
LOG.info("SyncListServlet interupted due to termination, ignoring");
return;
}
_addStdHeaders(response);
}
}
response.writeOut(_jsonWriter);
} finally {
if (metrics != null) {
metrics.finish(timer, stats);
}
}
}