public void performBackgroundOperation(OperationAndData <PathAndBytes> operationAndData) { try { TimeTrace trace = client.getZookeeperClient().startTracer("SetDataBuilderImpl-Background"); object taskCtx = backgrounding.getContext(); Task <Stat> task = client.getZooKeeper().setDataAsync ( operationAndData.getData().getPath(), operationAndData.getData().getData(), version //, // new AsyncCallback.StatCallback() // { // public void processResult(int rc, String path, Object ctx, Stat stat) // { // trace.commit(); // ICuratorEvent @event = new CuratorEventImpl(client, CuratorEventType.SET_DATA, rc, path, null, ctx, stat, null, null, null, null); // client.processBackgroundOperation(operationAndData, @event); // }; // }, // backgrounding.getContext() ); task.ContinueWith(statTask => { trace.commit(); int errorCode = 0; if (statTask.IsFaulted) { if (!(statTask.Exception.InnerException is KeeperException)) { throw new Exception($"{nameof(SetDataBuilderImpl)}." + $"{nameof(performBackgroundOperation)} operation failed " + $"with unexpected exception of type " + $"{statTask.Exception.InnerException.GetType().FullName}." + $"Expected type {nameof(KeeperException)}"); } KeeperException keeperException = (KeeperException)statTask.Exception.InnerException; errorCode = (int)keeperException.getCode(); } ICuratorEvent @event = new CuratorEventImpl(client, CuratorEventType.SET_DATA, errorCode, operationAndData.getData().getPath(), null, taskCtx, statTask.Result, null, null, null, null); client.processBackgroundOperation(operationAndData, @event); }); } catch (Exception e) { backgrounding.checkError(e); } }
public void processResult(int rc, String path, Object ctx, Stat stat) { trace.commit(); CuratorEvent @event = new CuratorEventImpl(client, CuratorEventType.EXISTS, rc, path, null, ctx, stat, null, null, null, null); client.processBackgroundOperation(operationAndData, @event); }
public Stat forPath(String path) { path = client.fixForNamespace(path); Stat resultStat = null; if (backgrounding.inBackground()) { client.processBackgroundOperation(new OperationAndData <String>(this, path, backgrounding.getCallback(), null, backgrounding.getContext()), null); } else { resultStat = pathInForeground(path); } return(resultStat); }
internal void processBackgroundOperation <DATA_TYPE>(OperationAndData <DATA_TYPE> operationAndData, ICuratorEvent @event) { client.processBackgroundOperation(operationAndData, @event); }
public void retriesExhausted(OperationAndData <Void> operationAndData) { operationAndData.reset(); client.processBackgroundOperation(operationAndData, null); }