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;
 
 
 {
     private final CuratorFrameworkImpl client;
     private Backgrounding backgrounding;
     private int                                     version;
 
     {
         this. = client;
          = new Backgrounding();
          = -1;
     }
 
     {
         return new TransactionSetDataBuilder()
         {
             @Override
             public CuratorTransactionBridge forPath(String pathbyte[] datathrows Exception
             {
                 String      fixedPath = .fixForNamespace(path);
                 transaction.add(Op.setData(fixedPathdata), .path);
                 return curatorTransaction;
             }
 
             @Override
             public CuratorTransactionBridge forPath(String paththrows Exception
             {
                 return forPath(path.getDefaultData());
             }
 
             @Override
             public PathAndBytesable<CuratorTransactionBridgewithVersion(int version)
             {
                 SetDataBuilderImpl.this.withVersion(version);
                 return this;
             }
         };
     }
 
     @Override
     public BackgroundPathAndBytesable<StatwithVersion(int version)
     {
         this. = version;
         return this;
     }
 
     @Override
     {
          = new Backgrounding(callback);
         return this;
     }
 
     @Override
     public PathAndBytesable<StatinBackground()
     {
          = new Backgrounding(true);
         return this;
     }
 
     @Override
     public PathAndBytesable<StatinBackground(Object context)
    {
         = new Backgrounding(context);
        return this;
    }
    @Override
    public PathAndBytesable<StatinBackground(BackgroundCallback callbackExecutor executor)
    {
         = new Backgrounding(callbackexecutor);
        return this;
    }
    @Override
    public void performBackgroundOperation(final OperationAndData<PathAndBytesoperationAndDatathrows Exception
    {
        final TimeTrace   trace = .getZookeeperClient().startTracer("SetDataBuilderImpl-Background");
        .getZooKeeper().setData
        (
            operationAndData.getData().getPath(),
            operationAndData.getData().getData(),
            ,
            new AsyncCallback.StatCallback()
            {
                @SuppressWarnings({"unchecked"})
                @Override
                public void processResult(int rcString pathObject ctxStat stat)
                {
                    trace.commit();
                    CuratorEvent event = new CuratorEventImpl(.rcpathnullctxstatnullnullnullnull);
                    .processBackgroundOperation(operationAndDataevent);
                }
            },
            .getContext()
        );
    }
    @Override
    public Stat forPath(String paththrows Exception
    {
        return forPath(path.getDefaultData());
    }
    @Override
    public Stat forPath(String pathbyte[] datathrows Exception
    {
        path = .fixForNamespace(path);
        Stat        resultStat = null;
        if ( .inBackground()  )
        {
            .processBackgroundOperation(new OperationAndData<PathAndBytes>(thisnew PathAndBytes(pathdata), .getCallback(), null), null);
        }
        else
        {
            resultStat = pathInForeground(pathdata);
        }
        return resultStat;
    }
    int getVersion()
    {
        return ;
    }
    private Stat pathInForeground(final String pathfinal byte[] datathrows Exception
    {
        TimeTrace   trace = .getZookeeperClient().startTracer("SetDataBuilderImpl-Foreground");
        Stat        resultStat = RetryLoop.callWithRetry
        (
            .getZookeeperClient(),
            new Callable<Stat>()
            {
                @Override
                public Stat call() throws Exception
                {
                    return .getZooKeeper().setData(pathdata);
                }
            }
        );
        trace.commit();
        return resultStat;
    }
New to GrepCode? Check out our FAQ X