Example #1
0
                    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);
                    }
Example #2
0
        public void close()
        {
            log.Debug("Closing");
            if (state.CompareAndSet(CuratorFrameworkState.STARTED, CuratorFrameworkState.STOPPED))
            {
                listeners.forEach(listener =>
                {
                    ICuratorEvent @event = new CuratorEventImpl(this, CuratorEventType.CLOSING, 0, null, null, null, null, null, null, null, null);
                    try
                    {
                        listener.eventReceived(this, @event);
                    }
                    catch (Exception e)
                    {
                        ThreadUtils.checkInterrupted(e);
                        log.Error("Exception while sending Closing event", e);
                    }
                    return(null);
                });

                if (executorService != null)
                {
                    executorService.Dispose();
                }

                listeners.clear();
                unhandledErrorListeners.clear();
                connectionStateManager.Dispose();
                client.Dispose();
                namespaceWatcherMap.Dispose();
            }
        }
Example #3
0
        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);
            }
        }
Example #4
0
            public override Task process(WatchedEvent watchedEvent)
            {
                string        unfixForNs = _curatorFrameworkImpl.unfixForNamespace(watchedEvent.getPath());
                ICuratorEvent @event     = new CuratorEventImpl(_curatorFrameworkImpl,
                                                                CuratorEventType.WATCHED,
                                                                (int)watchedEvent.getState(),
                                                                unfixForNs,
                                                                null,
                                                                null,
                                                                null,
                                                                null,
                                                                null,
                                                                watchedEvent,
                                                                null);

                processEvent(@event);
                return(Task.FromResult <object>(null));
            }
Example #5
0
 public void processResult(int rc, String path, Object ctx)
 {
     trace.commit();
     if ((rc == KeeperException.Code.NOTEMPTY.intValue()) && deletingChildrenIfNeeded)
     {
         backgroundDeleteChildrenThenNode(operationAndData);
     }
     else
     {
         CuratorEvent @event = new CuratorEventImpl(client,
                                                    CuratorEventType.DELETE,
                                                    rc,
                                                    path,
                                                    null,
                                                    ctx,
                                                    null,
                                                    null,
                                                    null,
                                                    null,
                                                    null);
         client.processBackgroundOperation(operationAndData, event);
     }
 }
        public void close()
        {
            log.Debug("Closing");
            if (state.CompareAndSet(CuratorFrameworkState.STARTED, CuratorFrameworkState.STOPPED))
            {
                listeners.forEach(listener =>
                {
                    ICuratorEvent @event = new CuratorEventImpl(this, CuratorEventType.CLOSING, 0, null, null, null, null, null, null, null, null);
                    try
                    {
                        listener.eventReceived(this, @event);
                    }
                    catch (Exception e)
                    {
                        ThreadUtils.checkInterrupted(e);
                        log.Error("Exception while sending Closing event", e);
                    }
                    return null;
                });

                if ( executorService != null )
                {
                    executorService.Dispose();
                }

                listeners.clear();
                unhandledErrorListeners.clear();
                connectionStateManager.Dispose();
                client.Dispose();
                namespaceWatcherMap.Dispose();
            }
        }