protected internal override bool RetryBatch()
        {
            // Retry requires keys for this node to be split among other nodes.
            // This can cause an exponential number of commands.
            List <BatchNode> batchNodes = GenerateBatchNodes();

            if (batchNodes.Count == 1 && batchNodes[0].node == batch.node)
            {
                // Batch node is the same.  Go through normal retry.
                return(false);
            }

            // Close original command.
            base.PutBackArgsOnError();

            // Execute new commands.
            AsyncMultiCommand[] cmds = new AsyncMultiCommand[batchNodes.Count];
            int count = 0;

            foreach (BatchNode batchNode in batchNodes)
            {
                AsyncBatchCommand cmd = CreateCommand(batchNode);
                cmd.sequenceAP = sequenceAP;
                cmd.sequenceSC = sequenceSC;
                cmd.SetBatchRetry(this);
                cmds[count++] = cmd;
            }
            parent.ExecuteBatchRetry(cmds, this);
            return(true);
        }
Ejemplo n.º 2
0
        protected internal override bool RetryBatch()
        {
            List <BatchNode> batchNodes = null;

            try
            {
                // Retry requires keys for this node to be split among other nodes.
                // This can cause an exponential number of commands.
                batchNodes = GenerateBatchNodes();

                if (batchNodes.Count == 1 && batchNodes[0].node == batch.node)
                {
                    // Batch node is the same.  Go through normal retry.
                    // Normal retries reuse eventArgs, so PutBackArgsOnError()
                    // should not be called here.
                    return(false);
                }
            }
            catch (Exception)
            {
                // Close original command.
                base.PutBackArgsOnError();
                throw;
            }

            // Close original command.
            base.PutBackArgsOnError();

            // Execute new commands.
            AsyncMultiCommand[] cmds = new AsyncMultiCommand[batchNodes.Count];
            int count = 0;

            foreach (BatchNode batchNode in batchNodes)
            {
                AsyncBatchCommand cmd = CreateCommand(batchNode);
                cmd.sequenceAP = sequenceAP;
                cmd.sequenceSC = sequenceSC;
                cmd.SetBatchRetry(this);
                cmds[count++] = cmd;
            }

            // Retry new commands.
            parent.Retry(cmds);

            // Return true so original batch command is stopped.
            return(true);
        }