Support for execution forks (concurrent request execution) by request execution interceptors

This commit is contained in:
Oleg Kalnichevski 2018-01-04 11:21:01 +01:00
parent 26bb4b6b9c
commit 1c73280983
6 changed files with 21 additions and 1 deletions

View File

@ -33,7 +33,7 @@ import org.apache.hc.core5.concurrent.Cancellable;
* This interface represents an object that can be made aware of
* long running, potentially blocking processes.
*
* @since 5.0
* TODO: replace with CancellableDependency from HttpCore 5.0b2
*/
public interface CancellableAware {

View File

@ -80,4 +80,6 @@ public interface AsyncExecRuntime {
void markConnectionNonReusable();
AsyncExecRuntime fork();
}

View File

@ -29,6 +29,7 @@ package org.apache.hc.client5.http.classic;
import java.io.IOException;
import org.apache.hc.client5.http.CancellableAware;
import org.apache.hc.client5.http.HttpRoute;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.core5.annotation.Internal;
@ -84,4 +85,6 @@ public interface ExecRuntime {
void setConnectionValidFor(TimeValue duration);
ExecRuntime fork(CancellableAware cancellableAware);
}

View File

@ -249,4 +249,9 @@ class InternalHttp2AsyncExecRuntime implements AsyncExecRuntime {
}
}
@Override
public AsyncExecRuntime fork() {
return new InternalHttp2AsyncExecRuntime(log, connPool);
}
}

View File

@ -281,4 +281,9 @@ class InternalHttpAsyncExecRuntime implements AsyncExecRuntime {
validDuration = null;
}
@Override
public AsyncExecRuntime fork() {
return new InternalHttpAsyncExecRuntime(log, manager, connectionInitiator, versionPolicy);
}
}

View File

@ -255,4 +255,9 @@ class InternalExecRuntime implements ExecRuntime, Cancellable {
return !alreadyReleased;
}
@Override
public ExecRuntime fork(final CancellableAware cancellableAware) {
return new InternalExecRuntime(log, manager, requestExecutor, cancellableAware);
}
}