Skip to content

Commit

Permalink
throw exception when commit transaction failed
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaorongsheng committed Jun 5, 2024
1 parent 8865427 commit d6db248
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,12 @@ class StreamLoader(settings: SparkSettings, isStreaming: Boolean) extends Loader
if (response.getEntity != null) {
val loadResult = EntityUtils.toString(response.getEntity)
val res = MAPPER.readValue(loadResult, new TypeReference[util.HashMap[String, String]]() {})
if (res.get("status") == "Fail" && !ResponseUtil.isCommitted(res.get("msg"))) throw new StreamLoadException("Commit failed " + loadResult)
else LOG.info("load result {}", loadResult)
if (res.get("status") == "Success" || ResponseUtil.isCommitted(res.get("msg"))) LOG.info("commit transaction {} succeed, load result: {}.", msg.value, loadResult)
else {
LOG.error("commit transaction {} failed. load result: {}", msg.value, loadResult)
throw new StreamLoadException("Commit failed " + loadResult)
}
}

} match {
case Success(_) => client.close()
case Failure(e) =>
Expand Down

0 comments on commit d6db248

Please sign in to comment.