Fixes #20: Fix runtime port and heartbeat sending logic
- Sentinel should not send heartbeat to dashboard until the runtime port has been settled down Signed-off-by: Eric Zhao <sczyh16@gmail.com>
This commit is contained in:
parent
f144a2713f
commit
1c9f1606ca
|
|
@ -42,6 +42,10 @@ public class TransportConfig {
|
||||||
return SentinelConfig.getConfig(CONSOLE_SERVER);
|
return SentinelConfig.getConfig(CONSOLE_SERVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getRuntimePort() {
|
||||||
|
return runtimePort;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Server port of this HTTP server.
|
* Get Server port of this HTTP server.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -124,9 +124,7 @@ public class SimpleHttpCommandCenter implements CommandCenter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (success) {
|
if (!success) {
|
||||||
tmpPort = port;
|
|
||||||
} else {
|
|
||||||
tmpPort = PORT_UNINITIALIZED;
|
tmpPort = PORT_UNINITIALIZED;
|
||||||
}
|
}
|
||||||
TransportConfig.setRuntimePort(tmpPort);
|
TransportConfig.setRuntimePort(tmpPort);
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ public class SimpleHttpHeartbeatSender implements HeartbeatSender {
|
||||||
public SimpleHttpHeartbeatSender() {
|
public SimpleHttpHeartbeatSender() {
|
||||||
// Retrieve the list of default addresses.
|
// Retrieve the list of default addresses.
|
||||||
List<InetSocketAddress> newAddrs = getDefaultConsoleIps();
|
List<InetSocketAddress> newAddrs = getDefaultConsoleIps();
|
||||||
RecordLog.info("Default console address list retrieved: " + newAddrs);
|
RecordLog.info("[SimpleHttpHeartbeatSender] Default console address list retrieved: " + newAddrs);
|
||||||
this.addressList = newAddrs;
|
this.addressList = newAddrs;
|
||||||
// Set interval config.
|
// Set interval config.
|
||||||
String interval = System.getProperty(TransportConfig.HEARTBEAT_INTERVAL_MS, String.valueOf(DEFAULT_INTERVAL));
|
String interval = System.getProperty(TransportConfig.HEARTBEAT_INTERVAL_MS, String.valueOf(DEFAULT_INTERVAL));
|
||||||
|
|
@ -61,6 +61,10 @@ public class SimpleHttpHeartbeatSender implements HeartbeatSender {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean sendHeartbeat() throws Exception {
|
public boolean sendHeartbeat() throws Exception {
|
||||||
|
if (TransportConfig.getRuntimePort() <= 0) {
|
||||||
|
RecordLog.info("[SimpleHttpHeartbeatSender] Runtime port not initialized, won't send heartbeat");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
InetSocketAddress addr = getAvailableAddress();
|
InetSocketAddress addr = getAvailableAddress();
|
||||||
if (addr == null) {
|
if (addr == null) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue