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 final CuratorMultiTransactionRecord     transaction;
 
     private boolean         isCommitted = false;
 
     {
         this. = client;
          = new CuratorMultiTransactionRecord();
     }
 
     @Override
     public CuratorTransactionFinal and()
     {
         return this;
     }
 
     @Override
     public TransactionCreateBuilder create()
     {
         Preconditions.checkArgument(!);
 
         return new CreateBuilderImpl().asTransactionCreateBuilder(this);
     }
 
     @Override
     public TransactionDeleteBuilder delete()
     {
         Preconditions.checkArgument(!);
 
         return new DeleteBuilderImpl().asTransactionDeleteBuilder(this);
     }
 
     @Override
     {
         Preconditions.checkArgument(!);
 
         return new SetDataBuilderImpl().asTransactionSetDataBuilder(this);
     }
 
     @Override
     public TransactionCheckBuilder check()
     {
         Preconditions.checkArgument(!);
 
         return new TransactionCheckBuilder()
         {
             private int         version = -1;
 
             @Override
             public CuratorTransactionBridge forPath(String paththrows Exception
             {
                 String      fixedPath = .fixForNamespace(path);
                .add(Op.check(fixedPath), .path);
                return CuratorTransactionImpl.this;
            }
            @Override
            public Pathable<CuratorTransactionBridgewithVersion(int version)
            {
                this. = version;
                return this;
            }
        };
    }
    @Override
    {
        Preconditions.checkArgument(!);
         = true;
        final AtomicBoolean firstTime = new AtomicBoolean(true);
        List<OpResult>      resultList = RetryLoop.callWithRetry
        (
            .getZookeeperClient(),
            new Callable<List<OpResult>>()
            {
                @Override
                public List<OpResultcall() throws Exception
                {
                    return doOperation(firstTime);
                }
            }
        );
        
        if ( resultList.size() != .metadataSize() )
        {
            throw new IllegalStateException(String.format("Result size (%d) doesn't match input size (%d)"resultList.size(), .metadataSize()));
        }
        ImmutableList.Builder<CuratorTransactionResult>     builder = ImmutableList.builder();
        for ( int i = 0; i < resultList.size(); ++i )
        {
            OpResult                                    opResult = resultList.get(i);
            CuratorMultiTransactionRecord.TypeAndPath   metadata = .getMetadata(i);
            CuratorTransactionResult                    curatorResult = makeCuratorResult(opResultmetadata);
            builder.add(curatorResult);
        }
        return builder.build();
    }
    private List<OpResultdoOperation(AtomicBoolean firstTimethrows Exception
    {
        boolean         localFirstTime = firstTime.getAndSet(false);
        if ( !localFirstTime )
        {
        }
        List<OpResult>  opResults = .getZooKeeper().multi();
        if ( opResults.size() > 0 )
        {
            OpResult        firstResult = opResults.get(0);
            if ( firstResult.getType() == .. )
            {
                OpResult.ErrorResult        error = (OpResult.ErrorResult)firstResult;
                KeeperException.Code        code = KeeperException.Code.get(error.getErr());
                if ( code == null )
                {
                    code = ..;
                }
                throw KeeperException.create(code);
            }
        }
        return opResults;
    }
    {
        String                                      resultPath = null;
        Stat resultStat = null;
        switch ( opResult.getType() )
        {
            default:
            {
                // NOP
                break;
            }
            case ..:
            {
                OpResult.CreateResult       createResult = (OpResult.CreateResult)opResult;
                resultPath = .unfixForNamespace(createResult.getPath());
                break;
            }
            case ..:
            {
                OpResult.SetDataResult      setDataResult = (OpResult.SetDataResult)opResult;
                resultStat = setDataResult.getStat();
                break;
            }
        }
        return new CuratorTransactionResult(metadata.typemetadata.forPathresultPathresultStat);
    }
New to GrepCode? Check out our FAQ X