-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the connection manager to become an endpoint manager, it als…
…o becomes agnostic of connections
- Loading branch information
Showing
30 changed files
with
224 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,13 +12,13 @@ | |
|
||
import io.vertx.core.Future; | ||
import io.vertx.core.impl.ContextInternal; | ||
import io.vertx.core.net.impl.pool.Endpoint; | ||
import io.vertx.core.net.impl.endpoint.Endpoint; | ||
import io.vertx.core.spi.metrics.ClientMetrics; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Julien Viet</a> | ||
*/ | ||
abstract class ClientHttpEndpointBase<C> extends Endpoint<C> { | ||
abstract class ClientHttpEndpointBase<C> extends Endpoint { | ||
|
||
private final ClientMetrics metrics; // Shall be removed later combining the PoolMetrics with HttpClientMetrics | ||
|
||
|
@@ -28,7 +28,6 @@ abstract class ClientHttpEndpointBase<C> extends Endpoint<C> { | |
this.metrics = metrics; | ||
} | ||
|
||
@Override | ||
public Future<C> requestConnection(ContextInternal ctx, long timeout) { | ||
Future<C> fut = requestConnection2(ctx, timeout); | ||
if (metrics != null) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,17 +8,14 @@ | |
* | ||
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
*/ | ||
package io.vertx.core.net.impl.pool; | ||
|
||
import io.vertx.core.Future; | ||
import io.vertx.core.impl.ContextInternal; | ||
package io.vertx.core.net.impl.endpoint; | ||
|
||
/** | ||
* An endpoint, i.e a set of connection to the same address. | ||
* | ||
* @author <a href="mailto:[email protected]">Julien Viet</a> | ||
*/ | ||
public abstract class Endpoint<C> { | ||
public abstract class Endpoint { | ||
|
||
private final Runnable dispose; | ||
private boolean closed; | ||
|
@@ -30,28 +27,28 @@ public Endpoint(Runnable dispose) { | |
this.dispose = dispose; | ||
} | ||
|
||
public Future<C> getConnection(ContextInternal ctx, long timeout) { | ||
boolean before() { | ||
synchronized (this) { | ||
if (disposed) { | ||
return null; | ||
return false; | ||
} | ||
pendingRequestCount++; | ||
} | ||
return requestConnection(ctx, timeout).andThen(ar -> { | ||
boolean dispose; | ||
synchronized (Endpoint.this) { | ||
pendingRequestCount--; | ||
dispose = checkDispose(); | ||
} | ||
// Dispose before callback otherwise we can have the callback handler retrying the same | ||
// endpoint and never get the callback it expects to creating an infinite loop | ||
if (dispose) { | ||
disposeInternal(); | ||
} | ||
}); | ||
return true; | ||
} | ||
|
||
public abstract Future<C> requestConnection(ContextInternal ctx, long timeout); | ||
void after() { | ||
boolean dispose; | ||
synchronized (Endpoint.this) { | ||
pendingRequestCount--; | ||
dispose = checkDispose(); | ||
} | ||
// Dispose before callback otherwise we can have the callback handler retrying the same | ||
// endpoint and never get the callback it expects to creating an infinite loop | ||
if (dispose) { | ||
disposeInternal(); | ||
} | ||
} | ||
|
||
protected void checkExpired() { | ||
} | ||
|
@@ -96,7 +93,7 @@ protected void dispose() { | |
} | ||
|
||
/** | ||
* Close the endpoint, this will close all connections, this method is called by the {@link ConnectionManager} when | ||
* Close the endpoint, this will close all connections, this method is called by the {@link EndpointManager} when | ||
* it is closed. | ||
*/ | ||
protected void close() { | ||
|
Oops, something went wrong.