Skip to content

Commit

Permalink
Fix response when set offload policies. (apache#6951)
Browse files Browse the repository at this point in the history
### Motivation

The response should be completed in the zookeeper callback when calling `setData()` asynchronously in `internalSetOffloadPolicies`, otherwise it will always return success.

### Modifications

Complete `internalSetOffloadPolicies` response in the zookeeper callback.
  • Loading branch information
murong00 authored May 19, 2020
1 parent 225baf5 commit 994eb45
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2611,10 +2611,14 @@ protected void internalSetOffloadPolicies(AsyncResponse asyncResponse, OffloadPo
}

policies.offload_policies = offloadPolicies;
String updatedOffloadPolicies = jsonMapper().writeValueAsString(policies.offload_policies);
globalZk().setData(path, jsonMapper().writeValueAsBytes(policies), nodeStat.getVersion(),
(rc, path1, ctx, stat) -> {
if (rc == KeeperException.Code.OK.intValue()) {
policiesCache().invalidate(path(POLICIES, namespaceName.toString()));
log.info("[{}] Successfully updated offload configuration: namespace={}, map={}", clientAppId(),
namespaceName, updatedOffloadPolicies);
asyncResponse.resume(Response.noContent().build());
} else {
String errorMsg = String.format(
"[%s] Failed to update offload configuration for namespace %s",
Expand All @@ -2630,9 +2634,6 @@ protected void internalSetOffloadPolicies(AsyncResponse asyncResponse, OffloadPo
}
}
}, null);
log.info("[{}] Successfully updated offload configuration: namespace={}, map={}", clientAppId(),
namespaceName, jsonMapper().writeValueAsString(policies.offload_policies));
asyncResponse.resume(Response.noContent().build());
} catch (Exception e) {
log.error("[{}] Failed to update offload configuration for namespace {}", clientAppId(), namespaceName,
e);
Expand Down

0 comments on commit 994eb45

Please sign in to comment.