-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ipAddress to RequestAttempt & include port in serialization (#1692)
- Loading branch information
1 parent
e46ab42
commit ffce212
Showing
4 changed files
with
37 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
import io.netty.handler.timeout.ReadTimeoutException; | ||
|
||
import javax.net.ssl.SSLHandshakeException; | ||
import java.net.InetAddress; | ||
|
||
/** | ||
* User: [email protected] | ||
|
@@ -51,6 +52,7 @@ public class RequestAttempt { | |
private String instanceId; | ||
private String host; | ||
private int port; | ||
private String ipAddress; | ||
private String vip; | ||
private String region; | ||
private String availabilityZone; | ||
|
@@ -61,6 +63,7 @@ public class RequestAttempt { | |
public RequestAttempt( | ||
int attemptNumber, | ||
InstanceInfo server, | ||
InetAddress serverAddr, | ||
String targetVip, | ||
String chosenWarmupLB, | ||
int status, | ||
|
@@ -99,6 +102,10 @@ public RequestAttempt( | |
} | ||
} | ||
|
||
if (serverAddr != null) { | ||
ipAddress = serverAddr.getHostAddress(); | ||
} | ||
|
||
this.status = status; | ||
this.error = error; | ||
this.exceptionType = exceptionType; | ||
|
@@ -108,7 +115,11 @@ public RequestAttempt( | |
} | ||
|
||
public RequestAttempt( | ||
final DiscoveryResult server, final IClientConfig clientConfig, int attemptNumber, int readTimeout) { | ||
final DiscoveryResult server, | ||
InetAddress serverAddr, | ||
final IClientConfig clientConfig, | ||
int attemptNumber, | ||
int readTimeout) { | ||
this.status = -1; | ||
this.attempt = attemptNumber; | ||
this.readTimeout = readTimeout; | ||
|
@@ -141,6 +152,10 @@ public RequestAttempt( | |
} | ||
} | ||
|
||
if (serverAddr != null) { | ||
ipAddress = serverAddr.getHostAddress(); | ||
} | ||
|
||
if (clientConfig != null) { | ||
this.connectTimeout = clientConfig.get(IClientConfigKey.Keys.ConnectTimeout); | ||
} | ||
|
@@ -200,6 +215,10 @@ public int getPort() { | |
return port; | ||
} | ||
|
||
public String getIpAddress() { | ||
return ipAddress; | ||
} | ||
|
||
public String getRegion() { | ||
return region; | ||
} | ||
|
@@ -256,6 +275,10 @@ public void setPort(int port) { | |
this.port = port; | ||
} | ||
|
||
public void setIpAddress(String ipAddress) { | ||
this.ipAddress = ipAddress; | ||
} | ||
|
||
public void setVip(String vip) { | ||
this.vip = vip; | ||
} | ||
|
@@ -338,6 +361,11 @@ public ObjectNode toJsonNode() { | |
putNullableAttribute(root, "asg", asg); | ||
putNullableAttribute(root, "instanceId", instanceId); | ||
putNullableAttribute(root, "vip", vip); | ||
putNullableAttribute(root, "ipAddress", ipAddress); | ||
|
||
if (port > 0) { | ||
root.put("port", port); | ||
} | ||
|
||
if (status < 1) { | ||
root.put("readTimeout", readTimeout); | ||
|
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