Beispiel #1
0
        public void performBackgroundOperation(OperationAndData <String> operationAndData)
        {
            try
            {
                TimeTrace trace        = client.getZookeeperClient().startTracer("SyncBuilderImpl-Background");
                String    path         = operationAndData.getData();
                String    adjustedPath = client.fixForNamespace(path);

                AsyncCallback.VoidCallback voidCallback = new AsyncCallback.VoidCallback()
                {
        public Stat forPath(String path)
        {
            path = client.fixForNamespace(path);

            Stat resultStat = null;

            if (backgrounding.inBackground())
            {
                client.processBackgroundOperation(new OperationAndData <String>(this, path, backgrounding.getCallback(), null, backgrounding.getContext()), null);
            }
            else
            {
                resultStat = pathInForeground(path);
            }
            return(resultStat);
        }
Beispiel #3
0
        public Stat forPath(String path, byte[] data)
        {
            if (compress)
            {
                data = client.getCompressionProvider().compress(path, data);
            }

            path = client.fixForNamespace(path);

            Stat resultStat = null;

            if (backgrounding.inBackground())
            {
                client.processBackgroundOperation(new OperationAndData <PathAndBytes>(this, new PathAndBytes(path, data), backgrounding.getCallback(), null, backgrounding.getContext()), null);
            }
            else
            {
                resultStat = pathInForeground(path, data);
            }
            return(resultStat);
        }
        public String forPath(String givenPath, byte[] data)
        {
            if (compress)
            {
                data = client.getCompressionProvider().compress(givenPath, data);
            }

            String adjustedPath = adjustPath(client.fixForNamespace(givenPath, createMode.isSequential()));

            String returnPath = null;

            if (backgrounding.inBackground())
            {
                pathInBackground(adjustedPath, data, givenPath);
            }
            else
            {
                String path = protectedPathInForeground(adjustedPath, data);
                returnPath = client.unfixForNamespace(path);
            }
            return(returnPath);
        }
Beispiel #5
0
        public byte[] forPath(String path)
        {
            String localPath = client.fixForNamespace(path);

            TimeTrace trace = client.getZookeeperClient().startTracer("GetDataBuilderImpl-Foreground");

            byte[]
            responseData = RetryLoop.callWithRetry
                           (
                client.getZookeeperClient(),
                CallableUtils.FromFunc(() =>
            {
                var dataAsync = client.getZooKeeper().getDataAsync(localPath, false);
                dataAsync.Wait();
                responseStat = dataAsync.Result.Stat;
                return(dataAsync.Result.Data);
            })
                           );
            trace.commit();

            return(decompress
                    ? client.getCompressionProvider().decompress(path, responseData)
                    : responseData);
        }