public AsyncQueryExecutor
        (
            AsyncCluster cluster,
            QueryPolicy policy,
            RecordSequenceListener listener,
            Statement statement,
            Node[] nodes
        ) : base(cluster)
        {
            this.listener = listener;
            statement.Prepare(true);

            // Create commands.
            AsyncQuery[] tasks = new AsyncQuery[nodes.Length];
            int          count = 0;

            foreach (Node node in nodes)
            {
                tasks[count++] = new AsyncQuery(this, cluster, (AsyncNode)node, policy, listener, statement);
            }

            // Dispatch commands to nodes.
            if (policy.failOnClusterChange)
            {
                ExecuteValidate(tasks, policy.maxConcurrentNodes, statement.ns);
            }
            else
            {
                Execute(tasks, policy.maxConcurrentNodes);
            }
        }
        public AsyncQueryExecutor(AsyncCluster cluster, QueryPolicy policy, RecordSequenceListener listener, Statement statement)
        {
            this.listener = listener;
            statement.Prepare(true);

            Node[] nodes = cluster.Nodes;
            if (nodes.Length == 0)
            {
                throw new AerospikeException(ResultCode.SERVER_NOT_AVAILABLE, "Query failed because cluster is empty.");
            }

            // Create commands.
            AsyncQuery[] tasks            = new AsyncQuery[nodes.Length];
            int          count            = 0;
            bool         hasClusterStable = true;

            foreach (Node node in nodes)
            {
                if (!node.HasClusterStable)
                {
                    hasClusterStable = false;
                }
                tasks[count++] = new AsyncQuery(this, cluster, (AsyncNode)node, policy, listener, statement);
            }

            // Dispatch commands to nodes.
            if (policy.failOnClusterChange && hasClusterStable)
            {
                ExecuteValidate(cluster, tasks, policy.maxConcurrentNodes, statement.ns);
            }
            else
            {
                Execute(tasks, policy.maxConcurrentNodes);
            }
        }
        public AsyncQueryExecutor(AsyncCluster cluster, QueryPolicy policy, RecordSequenceListener listener, Statement statement)
        {
            this.listener = listener;
            statement.Prepare(true);

            Node[] nodes = cluster.Nodes;
            if (nodes.Length == 0)
            {
                throw new AerospikeException(ResultCode.SERVER_NOT_AVAILABLE, "Query failed because cluster is empty.");
            }

            // Create commands.
            AsyncQuery[] tasks = new AsyncQuery[nodes.Length];
            int count = 0;

            foreach (Node node in nodes)
            {
                tasks[count++] = new AsyncQuery(this, cluster, (AsyncNode)node, policy, listener, statement);
            }
            // Dispatch commands to nodes.
            Execute(tasks, policy.maxConcurrentNodes);
        }