Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class FrontendsProcNode implements ProcNodeInterface {
public static final ImmutableList<String> TITLE_NAMES = new ImmutableList.Builder<String>()
.add("Name").add("IP").add("HostName").add("EditLogPort").add("HttpPort").add("QueryPort").add("RpcPort")
.add("Role").add("IsMaster").add("ClusterId").add("Join").add("Alive")
.add("ReplayedJournalId").add("LastHeartbeat").add("IsHelper").add("ErrMsg")
.add("ReplayedJournalId").add("LastHeartbeat").add("IsHelper").add("ErrMsg").add("Version")
.build();

public static final int HOSTNAME_INDEX = 2;
Expand Down Expand Up @@ -126,6 +126,8 @@ public static void getFrontendsInfo(Catalog catalog, List<List<String>> infos) {

info.add(fe.getHeartbeatErrMsg());

info.add(fe.getVersion());

infos.add(info);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.google.gson.Gson;

import io.netty.handler.codec.http.HttpMethod;
import org.apache.doris.common.Version;

/*
* fe_host:fe_http_port/api/bootstrap
Expand All @@ -43,6 +44,7 @@ public class BootstrapFinishAction extends RestBaseAction {
public static final String REPLAYED_JOURNAL_ID = "replayedJournalId";
public static final String QUERY_PORT = "queryPort";
public static final String RPC_PORT = "rpcPort";
public static final String VERSION = "version";

public BootstrapFinishAction(ActionController controller) {
super(controller);
Expand Down Expand Up @@ -92,6 +94,7 @@ public void execute(BaseRequest request, BaseResponse response) throws DdlExcept
result.setMaxReplayedJournal(replayedJournalId);
result.setQueryPort(Config.query_port);
result.setRpcPort(Config.rpc_port);
result.setVersion(Version.DORIS_BUILD_VERSION + "-" + Version.DORIS_BUILD_SHORT_HASH);
}
}
} else {
Expand All @@ -108,6 +111,7 @@ public static class BootstrapResult extends RestBaseResult {
private long replayedJournalId = 0;
private int queryPort = 0;
private int rpcPort = 0;
private String version = "";

public BootstrapResult() {
super();
Expand Down Expand Up @@ -141,6 +145,14 @@ public int getRpcPort() {
return rpcPort;
}

public String getVersion() {
return version;
}

public void setVersion(String version) {
this.version = version;
}

@Override
public String toJson() {
Gson gson = new Gson();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public final class GlobalVariable {
public static final String PERFORMANCE_SCHEMA = "performance_schema";

@VariableMgr.VarAttr(name = VERSION_COMMENT, flag = VariableMgr.READ_ONLY)
public static String versionComment = "Doris version " + Version.DORIS_BUILD_VERSION;
public static String versionComment = "Doris version " +
Version.DORIS_BUILD_VERSION + "-" + Version.DORIS_BUILD_SHORT_HASH;

@VariableMgr.VarAttr(name = VERSION, flag = VariableMgr.READ_ONLY)
public static String version = "5.1.0";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class Frontend implements Writable {
private String nodeName;
private String host;
private int editLogPort;
private String version;

private int queryPort;
private int rpcPort;
Expand Down Expand Up @@ -60,6 +61,10 @@ public FrontendNodeType getRole() {
public String getHost() {
return this.host;
}

public String getVersion() {
return version;
}

public String getNodeName() {
return nodeName;
Expand Down Expand Up @@ -103,6 +108,7 @@ public boolean handleHbResponse(FrontendHbResponse hbResponse) {
boolean isChanged = false;
if (hbResponse.getStatus() == HbStatus.OK) {
isAlive = true;
version = hbResponse.getVersion();
queryPort = hbResponse.getQueryPort();
rpcPort = hbResponse.getRpcPort();
replayedJournalId = hbResponse.getReplayedJournalId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,21 @@ public class FrontendHbResponse extends HeartbeatResponse implements Writable {
private int queryPort;
private int rpcPort;
private long replayedJournalId;
private String version;

public FrontendHbResponse() {
super(HeartbeatResponse.Type.FRONTEND);
}

public FrontendHbResponse(String name, int queryPort, int rpcPort, long replayedJournalId, long hbTime) {
public FrontendHbResponse(String name, int queryPort, int rpcPort, long replayedJournalId, long hbTime, String version) {
super(HeartbeatResponse.Type.FRONTEND);
this.status = HbStatus.OK;
this.name = name;
this.queryPort = queryPort;
this.rpcPort = rpcPort;
this.replayedJournalId = replayedJournalId;
this.hbTime = hbTime;
this.version = version;
}

public FrontendHbResponse(String name, String errMsg) {
Expand All @@ -72,6 +74,10 @@ public long getReplayedJournalId() {
return replayedJournalId;
}

public String getVersion() {
return version;
}

public static FrontendHbResponse read(DataInput in) throws IOException {
FrontendHbResponse result = new FrontendHbResponse();
result.readFields(in);
Expand Down Expand Up @@ -101,6 +107,7 @@ public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(super.toString());
sb.append(", name: ").append(name);
sb.append(", version: ").append(version);
sb.append(", queryPort: ").append(queryPort);
sb.append(", rpcPort: ").append(rpcPort);
sb.append(", replayedJournalId: ").append(replayedJournalId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.doris.common.Config;
import org.apache.doris.common.FeConstants;
import org.apache.doris.common.ThreadPoolManager;
import org.apache.doris.common.Version;
import org.apache.doris.common.util.MasterDaemon;
import org.apache.doris.common.util.Util;
import org.apache.doris.http.rest.BootstrapFinishAction;
Expand Down Expand Up @@ -153,7 +154,7 @@ protected void runAfterCatalogReady() {
// we also add a 'mocked' master Frontends heartbeat response to synchronize master info to other Frontends.
hbPackage.addHbResponse(new FrontendHbResponse(masterFeNodeName,
Config.query_port, Config.rpc_port, Catalog.getCurrentCatalog().getEditLog().getMaxJournalId(),
System.currentTimeMillis()));
System.currentTimeMillis(), Version.DORIS_BUILD_VERSION + "-" + Version.DORIS_BUILD_SHORT_HASH));

// write edit log
Catalog.getCurrentCatalog().getEditLog().logHeartbeat(hbPackage);
Expand Down Expand Up @@ -190,7 +191,7 @@ private boolean handleHbResponse(HeartbeatResponse response, boolean isReplay) {
FsBroker broker = Catalog.getCurrentCatalog().getBrokerMgr().getBroker(
hbResponse.getName(), hbResponse.getHost(), hbResponse.getPort());
if (broker != null) {
boolean isChanged = broker.handleHbResponse(hbResponse);
boolean isChanged = broker.handleHbResponse(hbResponse);
if (hbResponse.getStatus() != HbStatus.OK) {
// invalid all connections cached in ClientPool
ClientPool.brokerPool.clearPool(new TNetworkAddress(broker.ip, broker.port));
Expand Down Expand Up @@ -281,7 +282,8 @@ public HeartbeatResponse call() {
// heartbeat to self
if (Catalog.getCurrentCatalog().isReady()) {
return new FrontendHbResponse(fe.getNodeName(), Config.query_port, Config.rpc_port,
Catalog.getCurrentCatalog().getReplayedJournalId(), System.currentTimeMillis());
Catalog.getCurrentCatalog().getReplayedJournalId(), System.currentTimeMillis(),
Version.DORIS_BUILD_VERSION + "-" + Version.DORIS_BUILD_SHORT_HASH);
} else {
return new FrontendHbResponse(fe.getNodeName(), "not ready");
}
Expand Down Expand Up @@ -310,8 +312,9 @@ public HeartbeatResponse call() {
long replayedJournalId = root.getLong(BootstrapFinishAction.REPLAYED_JOURNAL_ID);
int queryPort = root.getInt(BootstrapFinishAction.QUERY_PORT);
int rpcPort = root.getInt(BootstrapFinishAction.RPC_PORT);
String version = root.getString(BootstrapFinishAction.VERSION);
return new FrontendHbResponse(fe.getNodeName(), queryPort, rpcPort, replayedJournalId,
System.currentTimeMillis());
System.currentTimeMillis(), version == null ? "unknown" : version);
}
} else if (root.has("code")) {
// new return
Expand All @@ -323,8 +326,9 @@ public HeartbeatResponse call() {
long replayedJournalId = dataObj.getLong(BootstrapFinishAction.REPLAYED_JOURNAL_ID);
int queryPort = dataObj.getInt(BootstrapFinishAction.QUERY_PORT);
int rpcPort = dataObj.getInt(BootstrapFinishAction.RPC_PORT);
// TODO(wb) support new return for version here
return new FrontendHbResponse(fe.getNodeName(), queryPort, rpcPort, replayedJournalId,
System.currentTimeMillis());
System.currentTimeMillis(), "unknown");
}
} else {
throw new Exception("invalid return value: " + result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,26 +70,38 @@ public void setUp() {
public void testFrontendHbHandler() {
new MockUp<Util>() {
@Mock
public String getResultForUrl(String urlStr, String encodedAuthInfo, int connectTimeoutMs,
int readTimeoutMs) {
public String getResultForUrl(String urlStr, String encodedAuthInfo,
int connectTimeoutMs, int readTimeoutMs) {

if (urlStr.contains("192.168.1.1")) {
return "{\"replayedJournalId\":191224,\"queryPort\":9131,\"rpcPort\":9121,\"status\":\"OK\",\"msg\":\"Success\"}";
return "{\"replayedJournalId\":191224," +
"\"queryPort\":9131," +
"\"rpcPort\":9121," +
"\"status\":\"OK\"," +
"\"msg\":\"Success\"," +
"\"version\":\"test\"}";
} else {
return "{\"replayedJournalId\":0,\"queryPort\":0,\"rpcPort\":0,\"status\":\"FAILED\",\"msg\":\"not ready\"}";
return "{\"replayedJournalId\":0," +
"\"queryPort\":0," +
"\"rpcPort\":0," +
"\"status\":\"FAILED\"," +
"\"msg\":\"not ready\"," +
"\"version\":\"unknown\"}";
}
}
};

Frontend fe = new Frontend(FrontendNodeType.FOLLOWER, "test", "192.168.1.1", 9010);
FrontendHeartbeatHandler handler = new FrontendHeartbeatHandler(fe, 12345, "abcd");
HeartbeatResponse response = handler.call();

Assert.assertTrue(response instanceof FrontendHbResponse);
FrontendHbResponse hbResponse = (FrontendHbResponse) response;
Assert.assertEquals(191224, hbResponse.getReplayedJournalId());
Assert.assertEquals(9121, hbResponse.getRpcPort());
Assert.assertEquals(9131, hbResponse.getQueryPort());
Assert.assertEquals(9121, hbResponse.getRpcPort());
Assert.assertEquals(HbStatus.OK, hbResponse.getStatus());
Assert.assertEquals("test", hbResponse.getVersion());

Frontend fe2 = new Frontend(FrontendNodeType.FOLLOWER, "test2", "192.168.1.2", 9010);
handler = new FrontendHeartbeatHandler(fe2, 12345, "abcd");
Expand All @@ -98,8 +110,8 @@ public String getResultForUrl(String urlStr, String encodedAuthInfo, int connect
Assert.assertTrue(response instanceof FrontendHbResponse);
hbResponse = (FrontendHbResponse) response;
Assert.assertEquals(0, hbResponse.getReplayedJournalId());
Assert.assertEquals(0, hbResponse.getRpcPort());
Assert.assertEquals(0, hbResponse.getQueryPort());
Assert.assertEquals(0, hbResponse.getRpcPort());
Assert.assertEquals(HbStatus.BAD, hbResponse.getStatus());

}
Expand Down
2 changes: 2 additions & 0 deletions gensrc/script/gen_build_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,15 @@ public class Version {

public static final String DORIS_BUILD_VERSION = "${build_version}";
public static final String DORIS_BUILD_HASH = "${build_hash}";
public static final String DORIS_BUILD_SHORT_HASH = "${build_short_hash}";
public static final String DORIS_BUILD_TIME = "${build_time}";
public static final String DORIS_BUILD_INFO = "${build_info}";
public static final String DORIS_JAVA_COMPILE_VERSION = "${java_version_str}";

public static void main(String[] args) {
System.out.println("doris_build_version: " + DORIS_BUILD_VERSION);
System.out.println("doris_build_hash: " + DORIS_BUILD_HASH);
System.out.println("doris_build_short_hash: " + DORIS_BUILD_SHORT_HASH);
System.out.println("doris_build_time: " + DORIS_BUILD_TIME);
System.out.println("doris_build_info: " + DORIS_BUILD_INFO);
System.out.println("doris_java_compile_version: " + DORIS_JAVA_COMPILE_VERSION);
Expand Down