client.processBackgroundOperation(operationAndData, null);
}
private String pathInForeground(final String path, final byte[] data) throws Exception
{
TimeTrace trace = client.getZookeeperClient().startTracer("CreateBuilderImpl-Foreground");
final AtomicBoolean firstTime = new AtomicBoolean(true);
String returnPath = RetryLoop.callWithRetry
(
client.getZookeeperClient(),
new Callable<String>()
{
@Override
public String call() throws Exception
{
boolean localFirstTime = firstTime.getAndSet(false);
String createdPath = null;
if ( !localFirstTime && doProtected )
{
createdPath = findProtectedNodeInForeground(path);
}
if ( createdPath == null )
{
try
{
createdPath = client.getZooKeeper().create(path, data, acling.getAclList(path), createMode);
}
catch ( KeeperException.NoNodeException e )
{
if ( createParentsIfNeeded )
{
ZKPaths.mkdirs(client.getZooKeeper(), path, false, client.getAclProvider());
createdPath = client.getZooKeeper().create(path, data, acling.getAclList(path), createMode);
}
else
{
throw e;
}
}
}
if ( failNextCreateForTesting )
{
failNextCreateForTesting = false;
throw new KeeperException.ConnectionLossException();
}
return createdPath;
}
}
);
trace.commit();
return returnPath;
}