Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   *
   *  Copyright 2011 Netflix, Inc.
   *
   *     Licensed under the Apache License, Version 2.0 (the "License");
   *     you may not use this file except in compliance with the License.
   *     You may obtain a copy of the License at
   *
   *         http://www.apache.org/licenses/LICENSE-2.0
  *
  *     Unless required by applicable law or agreed to in writing, software
  *     distributed under the License is distributed on an "AS IS" BASIS,
  *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  *     See the License for the specific language governing permissions and
  *     limitations under the License.
  *
  */
 package com.netflix.curator.framework.imps;
 
 import java.util.List;
 
 {
     private final CuratorFrameworkImpl client;
 
     private ACLing              acling;
     private Backgrounding       backgrounding;
     private int                 version;
 
     {
         this. = client;
          = new Backgrounding();
          = new ACLing();
          = -1;
     }
 
     @Override
     public BackgroundPathable<StatwithACL(List<ACLaclList)
     {
          = new ACLing(aclList);
         return this;
     }
 
     @Override
     public ACLable<BackgroundPathable<Stat>> withVersion(int version)
     {
         this. = version;
         return this;
     }
 
     @Override
     public Pathable<StatinBackground()
     {
          = new Backgrounding(true);
         return this;
     }
 
     @Override
     public Pathable<StatinBackground(Object context)
     {
          = new Backgrounding(context);
         return this;
     }
 
     @Override
     public Pathable<StatinBackground(BackgroundCallback callback)
     {
          = new Backgrounding(callback);
         return this;
     }
 
     @Override
     public Pathable<StatinBackground(BackgroundCallback callbackExecutor executor)
     {
          = new Backgrounding(callbackexecutor);
         return this;
     }
 
     @Override
     public Stat forPath(String paththrows Exception
     {
         path = .fixForNamespace(path);
 
         Stat        resultStat = null;
         if ( .inBackground()  )
         {
            .processBackgroundOperation(new OperationAndData<String>(thispath.getCallback(), null), null);
        }
        else
        {
            resultStat = pathInForeground(path);
        }
        return resultStat;
    }
    @Override
    public void performBackgroundOperation(final OperationAndData<StringoperationAndDatathrows Exception
    {
        final TimeTrace   trace = .getZookeeperClient().startTracer("SetACLBuilderImpl-Background");
        .getZooKeeper().setACL
        (
            operationAndData.getData(),
            .getAclList(),
            ,
            new AsyncCallback.StatCallback()
            {
                @SuppressWarnings({"unchecked"})
                @Override
                public void processResult(int rcString pathObject ctxStat stat)
                {
                    trace.commit();
                    CuratorEvent event = new CuratorEventImpl(.rcpathnullctxstatnullnullnullnull);
                    .processBackgroundOperation(operationAndDataevent);
                }
            },
            .getContext()
        );
    }
    private Stat pathInForeground(final String paththrows Exception
    {
        TimeTrace   trace = .getZookeeperClient().startTracer("SetACLBuilderImpl-Foreground");
        Stat        resultStat = RetryLoop.callWithRetry
        (
            .getZookeeperClient(),
            new Callable<Stat>()
            {
                @Override
                public Stat call() throws Exception
                {
                    return .getZooKeeper().setACL(path.getAclList(), );
                }
            }
        );
        trace.commit();
        return resultStat;
    }
New to GrepCode? Check out our FAQ X