curator-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randgalt <...@git.apache.org>
Subject [GitHub] curator pull request: Curator 161
Date Mon, 11 May 2015 04:05:14 GMT
Github user Randgalt commented on a diff in the pull request:

    https://github.com/apache/curator/pull/56#discussion_r30012227
  
    --- Diff: curator-framework/src/main/java/org/apache/curator/framework/imps/RemoveWatchesBuilderImpl.java
---
    @@ -0,0 +1,214 @@
    +package org.apache.curator.framework.imps;
    +
    +import java.util.concurrent.Callable;
    +import java.util.concurrent.Executor;
    +
    +import org.apache.curator.RetryLoop;
    +import org.apache.curator.TimeTrace;
    +import org.apache.curator.framework.api.BackgroundCallback;
    +import org.apache.curator.framework.api.BackgroundPathable;
    +import org.apache.curator.framework.api.BackgroundPathableQuietly;
    +import org.apache.curator.framework.api.CuratorEvent;
    +import org.apache.curator.framework.api.CuratorEventType;
    +import org.apache.curator.framework.api.CuratorWatcher;
    +import org.apache.curator.framework.api.Pathable;
    +import org.apache.curator.framework.api.RemoveWatchesLocal;
    +import org.apache.curator.framework.api.RemoveWatchesBuilder;
    +import org.apache.curator.framework.api.RemoveWatchesType;
    +import org.apache.zookeeper.AsyncCallback;
    +import org.apache.zookeeper.KeeperException;
    +import org.apache.zookeeper.Watcher;
    +import org.apache.zookeeper.Watcher.WatcherType;
    +import org.apache.zookeeper.ZooKeeper;
    +
    +
    +public class RemoveWatchesBuilderImpl implements RemoveWatchesBuilder, RemoveWatchesType,
RemoveWatchesLocal, BackgroundOperation<String>
    +{
    +    private CuratorFrameworkImpl client;
    +    private Watcher watcher;
    +    private WatcherType watcherType;
    +    private boolean local;
    +    private boolean quietly;
    +    private Backgrounding backgrounding;
    +    
    +    public RemoveWatchesBuilderImpl(CuratorFrameworkImpl client)
    +    {
    +        this.client = client;
    +        this.watcher = null;
    +        this.watcherType = WatcherType.Any;
    +        this.local = false;
    +        this.quietly = false;
    +        this.backgrounding = new Backgrounding();
    +    }
    +    
    +    @Override
    +    public RemoveWatchesType remove(Watcher watcher)
    +    {
    +        this.watcher = watcher == null ? null : client.getNamespaceWatcherMap().getNamespaceWatcher(watcher);
    +        return this;
    +    }
    +    
    +    @Override
    +    public RemoveWatchesType remove(CuratorWatcher watcher)
    +    {
    +        this.watcher = watcher == null ? null : client.getNamespaceWatcherMap().getNamespaceWatcher(watcher);
    +        return this;
    +    }    
    +
    +    @Override
    +    public RemoveWatchesType removeAll()
    +    {
    +        this.watcher = null;
    +        return this;
    +    }
    +
    +    @Override
    +    public RemoveWatchesLocal ofType(WatcherType watcherType)
    +    {
    +        this.watcherType = watcherType;
    +        
    +        return this;
    +    }
    +
    +    @Override
    +    public Pathable<Void> inBackground(BackgroundCallback callback, Object context)
    +    {
    +        backgrounding = new Backgrounding(callback, context);
    +        return this;
    +    }
    +
    +    @Override
    +    public Pathable<Void> inBackground(BackgroundCallback callback, Object context,
Executor executor)
    +    {
    +        backgrounding = new Backgrounding(client, callback, context, executor);
    +        return this;
    +    }
    +
    +    @Override
    +    public Pathable<Void> inBackground(BackgroundCallback callback)
    +    {
    +        backgrounding = new Backgrounding(callback);
    +        return this;
    +    }
    +
    +    @Override
    +    public Pathable<Void> inBackground(BackgroundCallback callback, Executor executor)
    +    {
    +        backgrounding = new Backgrounding(client, callback, executor);
    +        return this;
    +    }
    +
    +    @Override
    +    public Pathable<Void> inBackground()
    +    {
    +        backgrounding = new Backgrounding(true);
    +        return this;
    +    }
    +
    +    @Override
    +    public Pathable<Void> inBackground(Object context)
    +    {
    +        backgrounding = new Backgrounding(context);
    +        return this;
    +    }
    +
    +    @Override
    +    public BackgroundPathableQuietly<Void> locally()
    +    {
    +        local = true;
    +        return this;
    +    }
    +    
    +    @Override
    +    public BackgroundPathable<Void> quietly()
    +    {
    +        quietly = true;
    +        return this;
    +    }
    +    
    +    @Override
    +    public Void forPath(String path) throws Exception
    +    {
    +        final String adjustedPath = client.fixForNamespace(path);
    +        
    +        if(backgrounding.inBackground())
    +        {
    +            pathInBackground(adjustedPath);
    +        }
    +        else
    +        {
    +            pathInForeground(adjustedPath);
    +        }        
    +        
    +        return null;
    +    }    
    +    
    +    private void pathInBackground(String path)
    +    {
    +        OperationAndData.ErrorCallback<String>  errorCallback = null;        
    +        client.processBackgroundOperation(new OperationAndData<String>(this, path,
backgrounding.getCallback(), errorCallback, backgrounding.getContext()), null);
    +    }
    +    
    +    private void pathInForeground(final String path) throws Exception
    +    {
    +        RetryLoop.callWithRetry(client.getZookeeperClient(), 
    +                new Callable<Void>()
    +                {
    +                    @Override
    +                    public Void call() throws Exception
    +                    {
    +                        try
    +                        {
    +                            ZooKeeper zkClient = client.getZooKeeper();
    +                            if(watcher == null)
    --- End diff --
    
    Don't forget to look at these lines. It seems wrong to me. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message