public AsyncBatchCommand(AsyncBatchCommand other) : base(other)
 {
     this.batch       = other.batch;
     this.batchPolicy = other.batchPolicy;
     this.sequenceAP  = other.sequenceAP;
     this.sequenceSC  = other.sequenceSC;
 }
        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.º 3
0
        public AsyncBatchExistsArrayExecutor
        (
            AsyncCluster cluster,
            BatchPolicy policy,
            Key[] keys,
            ExistsArrayListener listener
        )
        {
            this.keys        = keys;
            this.existsArray = new bool[keys.Length];
            this.listener    = listener;

            // Create commands.
            List <BatchNode> batchNodes = BatchNode.GenerateList(cluster, policy, keys);

            AsyncBatchCommand[] commands = new AsyncBatchCommand[batchNodes.Count];
            int count = 0;

            foreach (BatchNode batchNode in batchNodes)
            {
                commands[count++] = new AsyncBatchExistsArrayCommand(this, cluster, batchNode, policy, keys, existsArray);
            }
            // Dispatch commands to nodes.
            Execute(commands);
        }
Ejemplo n.º 4
0
        public AsyncBatchGetSequenceExecutor
        (
            AsyncCluster cluster,
            BatchPolicy policy,
            RecordSequenceListener listener,
            Key[] keys,
            string[] binNames,
            int readAttr
        )
        {
            this.listener = listener;

            // Create commands.
            List <BatchNode> batchNodes = BatchNode.GenerateList(cluster, policy, keys);

            AsyncBatchCommand[] commands = new AsyncBatchCommand[batchNodes.Count];
            int count = 0;

            foreach (BatchNode batchNode in batchNodes)
            {
                commands[count++] = new AsyncBatchGetSequenceCommand(this, cluster, batchNode, policy, keys, binNames, listener, readAttr);
            }
            // Dispatch commands to nodes.
            Execute(commands);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        public AsyncBatchReadSequenceExecutor
        (
            AsyncCluster cluster,
            BatchPolicy policy,
            BatchSequenceListener listener,
            List <BatchRead> records
        )
        {
            this.listener = listener;

            // Create commands.
            List <BatchNode> batchNodes = BatchNode.GenerateList(cluster, policy, records);

            AsyncBatchCommand[] commands = new AsyncBatchCommand[batchNodes.Count];
            int count = 0;

            foreach (BatchNode batchNode in batchNodes)
            {
                commands[count++] = new AsyncBatchReadSequenceCommand(this, cluster, batchNode, policy, listener, records);
            }
            // Dispatch commands to nodes.
            Execute(commands);
        }
Ejemplo n.º 7
0
 public AsyncBatchCommand(AsyncBatchCommand other) : base(other)
 {
     this.batch       = other.batch;
     this.batchPolicy = other.batchPolicy;
 }