Skip to content

Commit 2c03bc9

Browse files
committed
Renamed the API for function worker liveliness probe
1 parent d0a2208 commit 2c03bc9

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/FunctionsImpl.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
@Slf4j
7070
public class FunctionsImpl extends ComponentImpl implements Functions<PulsarWorkerService> {
7171

72-
private boolean isIllegalStateException = false;
72+
private boolean isFunctionWorkerAlive = true;
7373

7474
public FunctionsImpl(Supplier<PulsarWorkerService> workerServiceSupplier) {
7575
super(workerServiceSupplier, Function.FunctionDetails.ComponentType.FUNCTION);
@@ -695,7 +695,7 @@ public void updateFunctionOnWorkerLeader(final String tenant,
695695
try {
696696
functionMetaDataManager.updateFunctionOnLeader(functionMetaData, delete);
697697
} catch (IllegalStateException e) {
698-
this.isIllegalStateException = true;
698+
this.isFunctionWorkerAlive = false;
699699
throw new RestException(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage());
700700
} catch (IllegalArgumentException e) {
701701
throw new RestException(Response.Status.BAD_REQUEST, e.getMessage());
@@ -792,7 +792,7 @@ private Function.FunctionDetails validateUpdateRequestParams(final String tenant
792792
}
793793
}
794794

795-
public boolean checkForIllegalStateException() {
796-
return this.isIllegalStateException;
795+
public boolean checkLiveliness() {
796+
return this.isFunctionWorkerAlive;
797797
}
798798
}

pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/v3/FunctionsApiV3Resource.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,10 @@ public void updateFunctionOnWorkerLeader(final @PathParam("tenant") String tenan
432432
}
433433

434434
@GET
435-
@Path("/restart")
436-
public Response checkForIllegalStateException() {
437-
boolean isIllegalStateException = functions().checkForIllegalStateException();
438-
if (isIllegalStateException) {
435+
@Path("/live")
436+
public Response checkLiveliness() {
437+
boolean isAlive = functions().checkLiveliness();
438+
if (!isAlive) {
439439
return Response.status(Response.Status.SERVICE_UNAVAILABLE)
440440
.entity("There is IllegalStateException, Service is not running. Need to restart.")
441441
.build();

pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/service/api/Functions.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,5 @@ FunctionInstanceStatusData getFunctionInstanceStatus(String tenant,
103103

104104
List<FunctionDefinition> getBuiltinFunctions(AuthenticationParameters authParams);
105105

106-
boolean checkForIllegalStateException();
106+
boolean checkLiveliness();
107107
}

0 commit comments

Comments
 (0)