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 int                         version;
     private Backgrounding               backgrounding;
     private boolean                     guaranteed;
 
     {
         this. = client;
          = -1;
          = new Backgrounding();
          = false;
     }
 
     TransactionDeleteBuilder    asTransactionDeleteBuilder(final CuratorTransactionImpl curatorTransactionfinal CuratorMultiTransactionRecord transaction)
     {
         return new TransactionDeleteBuilder()
         {
             @Override
             public CuratorTransactionBridge forPath(String paththrows Exception
             {
                 String      fixedPath = .fixForNamespace(path);
                 transaction.add(Op.delete(fixedPath), .path);
                 return curatorTransaction;
             }
 
             @Override
             public Pathable<CuratorTransactionBridgewithVersion(int version)
             {
                 DeleteBuilderImpl.this.withVersion(version);
                 return this;
             }
         };
     }
 
     @Override
     public DeleteBuilderBase guaranteed()
     {
          = true;
         return this;
     }
 
     @Override
     public BackgroundPathable<VoidwithVersion(int version)
     {
         this. = version;
         return this;
     }
 
     @Override
     public Pathable<VoidinBackground(BackgroundCallback callback)
     {
          = new Backgrounding(callback);
         return this;
     }
 
     @Override
     public Pathable<VoidinBackground(BackgroundCallback callbackExecutor executor)
     {
          = new Backgrounding(callbackexecutor);
         return this;
    }
    @Override
    public Pathable<VoidinBackground()
    {
         = new Backgrounding(true);
        return this;
    }
    @Override
    public Pathable<VoidinBackground(Object context)
    {
         = new Backgrounding(context);
        return this;
    }
    @Override
    public void performBackgroundOperation(final OperationAndData<StringoperationAndDatathrows Exception
    {
        final TimeTrace   trace = .getZookeeperClient().startTracer("DeleteBuilderImpl-Background");
        .getZooKeeper().delete
        (
            operationAndData.getData(),
            ,
            new AsyncCallback.VoidCallback()
            {
                @Override
                public void processResult(int rcString pathObject ctx)
                {
                    trace.commit();
                    CuratorEvent event = new CuratorEventImpl(.rcpathnullctxnullnullnullnullnull);
                    .processBackgroundOperation(operationAndDataevent);
                }
            },
            .getContext()
        );
    }
    @Override
    public Void forPath(String paththrows Exception
    {
        path = .fixForNamespace(path);
        if ( .inBackground() )
        {
            OperationAndData.ErrorCallback<String>  errorCallback = null;
            if (  )
            {
                errorCallback = new OperationAndData.ErrorCallback<String>()
                {
                    @Override
                    public void retriesExhausted(OperationAndData<StringoperationAndData)
                    {
                        .getFailedDeleteManager().addFailedDelete(operationAndData.getData());
                    }
                };
            }
            .processBackgroundOperation(new OperationAndData<String>(thispath.getCallback(), errorCallback), null);
        }
        else
        {
            pathInForeground(path);
        }
        return null;
    }
    protected int getVersion()
    {
        return ;
    }
    private void pathInForeground(final String paththrows Exception
    {
        TimeTrace       trace = .getZookeeperClient().startTracer("DeleteBuilderImpl-Foreground");
        try
        {
            RetryLoop.callWithRetry
            (
                .getZookeeperClient(),
                new Callable<Void>()
                {
                    @Override
                    public Void call() throws Exception
                    {
                        .getZooKeeper().delete(path);
                        return null;
                    }
                }
            );
        }
        catch ( KeeperException.NodeExistsException e )
        {
            throw e;
        }
        catch ( Exception e )
        {
            if (  )
            {
                .getFailedDeleteManager().addFailedDelete(path);
            }
            throw e;
        }
        trace.commit();
    }
New to GrepCode? Check out our FAQ X