private void updateExchangeWithResult(ProductionContext context, OperationResult result) { ZooKeeperMessage out = new ZooKeeperMessage(context.node, result.getStatistics(), context.in.getHeaders()); if (result.isOk()) { out.setBody(result.getResult()); } else { context.exchange.setException(result.getException()); } context.exchange.setOut(out); }
private OperationResult synchronouslyDelete(ProductionContext ctx) throws Exception { DeleteOperation setData = new DeleteOperation(ctx.connection, ctx.node); setData.setVersion(ctx.version); OperationResult result = setData.get(); if (!result.isOk() && configuration.shouldCreate() && result.failedDueTo(Code.NONODE)) { log.warn(format("Node '%s' did not exist, creating it.", ctx.node)); result = createNode(ctx); } return result; }
public void processResult(int rc, String node, Object ctx, Stat statistics) { if (Code.NONODE.equals(Code.get(rc))) { if (configuration.shouldCreate()) { log.warn(format("Node '%s' did not exist, creating it...", node)); ProductionContext context = (ProductionContext) ctx; OperationResult<String> result = null; try { result = createNode(context); } catch (Exception e) { log.error(format("Error trying to create node '%s'", node), e); } if (result == null || !result.isOk()) { log.error(format("Error creating node '%s'", node), result.getException()); } } } else { logStoreComplete(node, statistics); } }