@@ -129,12 +129,12 @@ void openAsync(final Request request,
129129port =getPort (scheme ,uri .getPort ());
130130 }
131131
132- final String partitionId =getPartitionId (request ,proxy );
132+ final String partitionId =getPartitionId (request . getInetAddress (), request ,proxy );
133133Endpoint endpoint =endpointMap .get (partitionId );
134134if (endpoint ==null ) {
135135final boolean isSecure =Utils .isSecure (scheme );
136136endpoint =new AhcEndpoint (partitionId ,
137- isSecure ,host ,port ,request .getLocalAddress (),
137+ isSecure ,request . getInetAddress (), host ,port ,request .getLocalAddress (),
138138defaultConnectionHandler );
139139
140140endpointMap .put (partitionId ,endpoint );
@@ -164,11 +164,11 @@ Connection openSync(final Request request)
164164
165165final boolean isSecure =Utils .isSecure (scheme );
166166
167- final String partitionId =getPartitionId (request ,proxy );
167+ final String partitionId =getPartitionId (request . getInetAddress (), request ,proxy );
168168Endpoint endpoint =endpointMap .get (partitionId );
169169if (endpoint ==null ) {
170170endpoint =new AhcEndpoint (partitionId ,
171- isSecure ,host ,port ,request .getLocalAddress (),
171+ isSecure ,request . getInetAddress (), host ,port ,request .getLocalAddress (),
172172defaultConnectionHandler );
173173
174174endpointMap .put (partitionId ,endpoint );
@@ -219,10 +219,11 @@ static boolean isKeepAlive(final Connection connection) {
219219return !IS_NOT_KEEP_ALIVE .isSet (connection );
220220 }
221221
222- private static String getPartitionId (Request request ,
222+ private static String getPartitionId (InetAddress overrideAddress , Request request ,
223223ProxyServer proxyServer ) {
224- return request .getConnectionPoolPartitioning ()
225- .getPartitionKey (request .getUri (),proxyServer ).toString ();
224+ return (overrideAddress !=null ?overrideAddress .toString () +"_" :"" ) +
225+ request .getConnectionPoolPartitioning ()
226+ .getPartitionKey (request .getUri (),proxyServer ).toString ();
226227 }
227228
228229private static int getPort (final String scheme ,final int p ) {
@@ -244,19 +245,21 @@ private class AhcEndpoint extends Endpoint<SocketAddress> {
244245
245246private final String partitionId ;
246247private final boolean isSecure ;
248+ private final InetAddress remoteOverrideAddress ;
247249private final String host ;
248250private final int port ;
249251private final InetAddress localAddress ;
250252private final ConnectorHandler <SocketAddress >connectorHandler ;
251253
252254private AhcEndpoint (final String partitionId ,
253255final boolean isSecure ,
254- final String host ,final int port ,
256+ final InetAddress remoteOverrideAddress , final String host ,final int port ,
255257final InetAddress localAddress ,
256258final ConnectorHandler <SocketAddress >connectorHandler ) {
257259
258260this .partitionId =partitionId ;
259261this .isSecure =isSecure ;
262+ this .remoteOverrideAddress =remoteOverrideAddress ;
260263this .host =host ;
261264this .port =port ;
262265this .localAddress =localAddress ;
@@ -275,12 +278,19 @@ public Object getId() {
275278@ Override
276279public GrizzlyFuture <Connection >connect () {
277280return (GrizzlyFuture <Connection >)connectorHandler .connect (
278- new InetSocketAddress ( host , port ),
281+ buildRemoteSocketAddress ( ),
279282localAddress !=null
280283 ?new InetSocketAddress (localAddress ,0 )
281284 :null );
282285 }
283286
287+ private InetSocketAddress buildRemoteSocketAddress ()
288+ {
289+ return remoteOverrideAddress !=null
290+ ?new InetSocketAddress (remoteOverrideAddress ,port )
291+ :new InetSocketAddress (host ,port );
292+ }
293+
284294@ Override
285295protected void onConnect (final Connection connection ,
286296final SingleEndpointPool <SocketAddress >pool ) {