use of com.yahoo.vespa.clustercontroller.utils.communication.http.SyncHttpClient in project vespa by vespa-engine.
the class ApacheAsyncHttpClient method execute.
@Override
public AsyncOperation<HttpResult> execute(HttpRequest r) {
// Gonna modify it to extract proxy information
final HttpRequest request = r.clone();
final Settings settings = new Settings(request);
final SyncHttpClient instance = getFittingInstance(settings);
final AsyncOperationImpl<HttpResult> op = new AsyncOperationImpl<>(r.toString(), r.toString(true));
executor.execute(new Runnable() {
@Override
public void run() {
HttpResult result;
Exception failure = null;
try {
result = instance.execute(request);
} catch (Exception e) {
result = new HttpResult().setHttpCode(500, "Apache client failed to execute request.");
failure = e;
}
insertInstance(settings, instance);
// call can reuse same instance
if (failure != null) {
op.setFailure(failure, result);
} else {
op.setResult(result);
}
}
});
return op;
}
use of com.yahoo.vespa.clustercontroller.utils.communication.http.SyncHttpClient in project vespa by vespa-engine.
the class ApacheAsyncHttpClient method close.
@Override
public void close() {
synchronized (apacheInstances) {
closed = true;
for (LinkedList<SyncHttpClient> list : apacheInstances.values()) {
for (SyncHttpClient instance : list) {
instance.close();
}
}
apacheInstances.clear();
}
}
Aggregations