use of water.util.Utils.ExpectedExceptionForDebug in project h2o-2 by h2oai.
the class Job method fork.
/**
* Forks computation of this job.
*
* <p>The call does not block.</p>
* @return always returns this job.
*/
public Job fork() {
init();
H2OCountedCompleter task = new H2OCountedCompleter() {
@Override
public void compute2() {
try {
try {
// Exec always waits till the end of computation
Job.this.exec();
Job.this.remove();
} catch (Throwable t) {
if (!(t instanceof ExpectedExceptionForDebug))
Log.err(t);
Job.this.cancel(t);
}
} finally {
tryComplete();
}
}
};
start(task);
H2O.submitTask(task);
return this;
}
use of water.util.Utils.ExpectedExceptionForDebug in project h2o-2 by h2oai.
the class RequestServer method serve.
@Override
public NanoHTTPD.Response serve(String uri, String method, Properties header, Properties parms) {
// Jack priority for user-visible requests
Thread.currentThread().setPriority(Thread.MAX_PRIORITY - 1);
// update arguments and determine control variables
uri = maybeTransformRequest(uri);
// determine the request type
Request.RequestType type = Request.RequestType.requestType(uri);
String requestName = type.requestName(uri);
maybeLogRequest(uri, method, parms, header);
// determine version
int version = parseVersion(uri);
int idx = version >> 16;
version &= 0xFFFF;
String uripath = uri.substring(idx);
// Strip suffix type from middle of URI
String path = requestName(uripath);
Method meth = null;
try {
// Find handler for url
meth = lookup(method, path);
if (meth != null) {
return wrap(HTTP_OK, handle(type, meth, version, parms), type);
}
} catch (IllegalArgumentException e) {
return wrap(HTTP_BADREQUEST, new HTTP404V1(e.getMessage(), uri), type);
} catch (Exception e) {
// make sure that no Exception is ever thrown out from the request
return wrap(e.getMessage() != "unimplemented" ? HTTP_INTERNALERROR : HTTP_NOTIMPLEMENTED, new HTTP500V1(e), type);
}
// Wasn't a new type of handler:
try {
// determine if we have known resource
Request request = _requests.get(requestName);
// found
if (request == null)
return getResource(uri);
// Some requests create an instance per call
request = request.create(parms);
// call the request
return request.serve(this, parms, type);
} catch (Exception e) {
if (!(e instanceof ExpectedExceptionForDebug))
e.printStackTrace();
// make sure that no Exception is ever thrown out from the request
parms.setProperty(Request.ERROR, e.getClass().getSimpleName() + ": " + e.getMessage());
return _http500.serve(this, parms, type);
}
}
Aggregations