Skip to content

Commit d0a2208

Browse files
committed
Updated the API for function worker readiness probe
1 parent 87c9f28 commit d0a2208

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ private Function.FunctionDetails validateUpdateRequestParams(final String tenant
792792
}
793793
}
794794

795-
public boolean checkReadiness() {
795+
public boolean checkForIllegalStateException() {
796796
return this.isIllegalStateException;
797797
}
798798
}

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

+12-3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import javax.ws.rs.Produces;
3636
import javax.ws.rs.QueryParam;
3737
import javax.ws.rs.core.MediaType;
38+
import javax.ws.rs.core.Response;
3839
import javax.ws.rs.core.StreamingOutput;
3940
import lombok.extern.slf4j.Slf4j;
4041
import org.apache.pulsar.common.functions.FunctionConfig;
@@ -431,8 +432,16 @@ public void updateFunctionOnWorkerLeader(final @PathParam("tenant") String tenan
431432
}
432433

433434
@GET
434-
@Path("/readiness")
435-
public boolean checkReadiness() {
436-
return functions().checkReadiness();
435+
@Path("/restart")
436+
public Response checkForIllegalStateException() {
437+
boolean isIllegalStateException = functions().checkForIllegalStateException();
438+
if (isIllegalStateException) {
439+
return Response.status(Response.Status.SERVICE_UNAVAILABLE)
440+
.entity("There is IllegalStateException, Service is not running. Need to restart.")
441+
.build();
442+
} else {
443+
return Response.ok("There is no IllegalStateException, Service is running.")
444+
.build();
445+
}
437446
}
438447
}

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 checkReadiness();
106+
boolean checkForIllegalStateException();
107107
}

0 commit comments

Comments
 (0)