Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
[DCOS-59064] Improve status check to verify topic successfully create…
Browse files Browse the repository at this point in the history
…d in ZK (#458)

* Added conditional status to check failure at topic creation

* Changed condition to check for successful topic creation

The condition now checks for "Created topic" sub-string as a part of response message to provide appropriate status response

* Updated Response code to server-side specific
  • Loading branch information
vibhujain authored and rishabh96b committed Nov 17, 2019
1 parent 6d17b3e commit f340fe3
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,16 @@ public Response createTopic(
try {
int partCount = Integer.parseInt(partitionCount);
int replFactor = Integer.parseInt(replicationFactor);
return ResponseUtils.jsonOkResponse(cmdExecutor.createTopic(name, partCount, replFactor));
JSONObject result = cmdExecutor.createTopic(name, partCount, replFactor);
String message = result.getString("message");
Response.Status status;
if (message.contains("Created topic")) {
status = Response.Status.OK;
} else {
status = Response.Status.INTERNAL_SERVER_ERROR;
log.error("Failed to verify the topic creation: " + name + " with output: " + message);
}
return ResponseUtils.jsonResponse(result, status);
} catch (Exception ex) {
log.error("Failed to create topic: " + name + " with exception: " + ex);
return Response.serverError().build();
Expand Down

0 comments on commit f340fe3

Please sign in to comment.