Skip to content

Commit 1052b5d

Browse files
[Enhancement] Add http service to get service id in shared-data mode (backport #65816) (#65966)
Signed-off-by: xiangguangyxg <[email protected]> Co-authored-by: xiangguangyxg <[email protected]>
1 parent 68d6d34 commit 1052b5d

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

fe/fe-core/src/main/java/com/starrocks/http/HttpServer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import com.starrocks.http.meta.MetaService.JournalIdAction;
6161
import com.starrocks.http.meta.MetaService.PutAction;
6262
import com.starrocks.http.meta.MetaService.RoleAction;
63+
import com.starrocks.http.meta.MetaService.ServiceIdAction;
6364
import com.starrocks.http.meta.MetaService.VersionAction;
6465
import com.starrocks.http.rest.BootstrapFinishAction;
6566
import com.starrocks.http.rest.CancelStreamLoadAction;
@@ -257,6 +258,7 @@ private void registerActions() throws IllegalArgException {
257258
CheckAction.registerAction(controller);
258259
DumpAction.registerAction(controller);
259260
DumpStarMgrAction.registerAction(controller);
261+
ServiceIdAction.registerAction(controller);
260262
RoleAction.registerAction(controller);
261263

262264
// external usage

fe/fe-core/src/main/java/com/starrocks/http/meta/MetaService.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,4 +483,40 @@ public void executeGet(BaseRequest request, BaseResponse response) {
483483
return;
484484
}
485485
}
486+
487+
public static class ServiceIdAction extends MetaBaseAction {
488+
489+
public ServiceIdAction(ActionController controller) {
490+
super(controller);
491+
}
492+
493+
public static void registerAction(ActionController controller)
494+
throws IllegalArgException {
495+
controller.registerHandler(HttpMethod.GET, "/service_id", new ServiceIdAction(controller));
496+
}
497+
498+
@Override
499+
public boolean needAdmin() {
500+
return true;
501+
}
502+
503+
@Override
504+
protected boolean needCheckClientIsFe() {
505+
return false;
506+
}
507+
508+
@Override
509+
public void executeGet(BaseRequest request, BaseResponse response) {
510+
if (RunMode.getCurrentRunMode() != RunMode.SHARED_DATA) {
511+
String str = "Current run mode " + RunMode.name() + " does not support service id.";
512+
response.appendContent(str);
513+
writeResponse(request, response, HttpResponseStatus.NOT_FOUND);
514+
} else {
515+
response.setContentType("application/json");
516+
String serviceId = GlobalStateMgr.getCurrentState().getStarOSAgent().getRawServiceId();
517+
response.appendContent("{\"service_id\": \"" + serviceId + "\"}");
518+
writeResponse(request, response);
519+
}
520+
}
521+
}
486522
}

0 commit comments

Comments
 (0)