public AsyncBatchGetSequenceExecutor
        (
            AsyncCluster cluster,
            BatchPolicy policy,
            RecordSequenceListener listener,
            Key[] keys,
            string[] binNames,
            int readAttr
        ) : base(cluster, policy, keys)
        {
            this.listener = listener;

            // Create commands.
            AsyncMultiCommand[] tasks = new AsyncMultiCommand[base.taskSize];
            int count = 0;

            foreach (BatchNode batchNode in batchNodes)
            {
                if (batchNode.node.UseNewBatch(policy))
                {
                    // New batch
                    tasks[count++] = new AsyncBatchGetSequenceCommand(this, cluster, batchNode, policy, keys, binNames, listener, readAttr);
                }
                else
                {
                    // Old batch only allows one namespace per call.
                    foreach (BatchNode.BatchNamespace batchNamespace in batchNode.batchNamespaces)
                    {
                        tasks[count++] = new AsyncBatchGetSequenceDirect(this, cluster, (AsyncNode)batchNode.node, batchNamespace, policy, keys, binNames, listener, readAttr);
                    }
                }
            }
            // Dispatch commands to nodes.
            Execute(tasks, policy.maxConcurrentThreads);
        }
        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);
        }
        public AsyncScanExecutor
        (
            AsyncCluster cluster,
            ScanPolicy policy,
            RecordSequenceListener listener,
            string ns,
            string setName,
            string[] binNames
        )
        {
            this.listener = listener;

            Node[] nodes = cluster.Nodes;

            if (nodes.Length == 0)
            {
                throw new AerospikeException(ResultCode.SERVER_NOT_AVAILABLE, "Scan failed because cluster is empty.");
            }

            completedSize = nodes.Length;
            long taskId = Environment.TickCount;

            foreach (Node node in nodes)
            {
                AsyncScan async = new AsyncScan(this, cluster, (AsyncNode)node, policy, listener, ns, setName, binNames, taskId);
                async.Execute();
            }
        }
        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 AsyncBatchGetSequenceCommand(AsyncBatchGetSequenceCommand other) : base(other)
 {
     this.keys     = other.keys;
     this.binNames = other.binNames;
     this.listener = other.listener;
     this.readAttr = other.readAttr;
 }
        public AsyncScanExecutor
        (
            AsyncCluster cluster,
            ScanPolicy policy,
            RecordSequenceListener listener,
            string ns,
            string setName,
            string[] binNames
        )
        {
            this.listener = listener;

            Node[] nodes = cluster.Nodes;

            if (nodes.Length == 0)
            {
                throw new AerospikeException(ResultCode.SERVER_NOT_AVAILABLE, "Scan failed because cluster is empty.");
            }

            ulong taskId = RandomShift.ThreadLocalInstance.NextLong();

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

            foreach (Node node in nodes)
            {
                tasks[count++] = new AsyncScan(this, cluster, (AsyncNode)node, policy, listener, ns, setName, binNames, taskId);
            }
            // Dispatch commands to nodes.
            Execute(tasks, policy.maxConcurrentNodes);
        }
        public AsyncScanExecutor(
			AsyncCluster cluster,
			ScanPolicy policy,
			RecordSequenceListener listener,
			string ns,
			string setName,
			string[] binNames
		)
        {
            this.listener = listener;

            Node[] nodes = cluster.Nodes;

            if (nodes.Length == 0)
            {
                throw new AerospikeException(ResultCode.SERVER_NOT_AVAILABLE, "Scan failed because cluster is empty.");
            }

            ulong taskId = RandomShift.ThreadLocalInstance.NextLong();

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

            foreach (Node node in nodes)
            {
                tasks[count++] = new AsyncScan(this, cluster, (AsyncNode)node, policy, listener, ns, setName, binNames, taskId);
            }
            // Dispatch commands to nodes.
            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);
            }
        }
示例#9
0
 public AsyncBatchGetSequenceDirect(AsyncBatchGetSequenceDirect other) : base(other)
 {
     this.batch    = other.batch;
     this.keys     = other.keys;
     this.binNames = other.binNames;
     this.listener = other.listener;
     this.readAttr = other.readAttr;
 }
示例#10
0
 public AsyncQuery
 (
     AsyncMultiExecutor parent,
     AsyncCluster cluster,
     AsyncNode node,
     QueryPolicy policy,
     RecordSequenceListener listener,
     Statement statement
 ) : base(parent, cluster, policy, node, policy.socketTimeout, policy.totalTimeout)
 {
     this.listener  = listener;
     this.statement = statement;
 }
 public AsyncQuery
 (
     AsyncMultiExecutor parent,
     AsyncCluster cluster,
     AsyncNode node,
     QueryPolicy queryPolicy,
     RecordSequenceListener listener,
     Statement statement
 ) : base(parent, cluster, queryPolicy, node, true)
 {
     this.queryPolicy = queryPolicy;
     this.listener    = listener;
     this.statement   = statement;
 }
        public AsyncQuery(
			AsyncMultiExecutor parent,
			AsyncCluster cluster,
			AsyncNode node,
			QueryPolicy policy,
			RecordSequenceListener listener,
			Statement statement
		)
            : base(parent, cluster, node, true)
        {
            this.policy = policy;
            this.listener = listener;
            this.statement = statement;
        }
        public AsyncBatchGetSequenceExecutor(AsyncCluster cluster, BatchPolicy policy, RecordSequenceListener listener, Key[] keys, HashSet <string> binNames, int readAttr)
            : base(cluster, policy, keys)
        {
            this.listener = listener;

            // Dispatch asynchronous commands to nodes.
            foreach (BatchNode batchNode in batchNodes)
            {
                foreach (BatchNode.BatchNamespace batchNamespace in batchNode.batchNamespaces)
                {
                    AsyncBatchGetSequence async = new AsyncBatchGetSequence(this, cluster, (AsyncNode)batchNode.node, batchNamespace, policy, keys, binNames, listener, readAttr);
                    async.Execute();
                }
            }
        }
示例#14
0
 public AsyncQueryPartition
 (
     AsyncMultiExecutor parent,
     AsyncCluster cluster,
     QueryPolicy policy,
     RecordSequenceListener listener,
     Statement statement,
     PartitionTracker tracker,
     NodePartitions nodePartitions
 ) : base(parent, cluster, policy, (AsyncNode)nodePartitions.node, tracker.socketTimeout, tracker.totalTimeout)
 {
     this.listener       = listener;
     this.statement      = statement;
     this.tracker        = tracker;
     this.nodePartitions = nodePartitions;
 }
 public AsyncBatchGetSequenceCommand
 (
     AsyncMultiExecutor parent,
     AsyncCluster cluster,
     BatchNode batch,
     BatchPolicy batchPolicy,
     Key[] keys,
     string[] binNames,
     RecordSequenceListener listener,
     int readAttr
 ) : base(parent, cluster, batch, batchPolicy)
 {
     this.keys     = keys;
     this.binNames = binNames;
     this.listener = listener;
     this.readAttr = readAttr;
 }
示例#16
0
        public AsyncQueryPartitionExecutor
        (
            AsyncCluster cluster,
            QueryPolicy policy,
            RecordSequenceListener listener,
            Statement statement,
            PartitionTracker tracker
        ) : base(cluster)
        {
            this.policy    = policy;
            this.listener  = listener;
            this.statement = statement;
            this.tracker   = tracker;

            statement.returnData        = true;
            tracker.SleepBetweenRetries = 0;
            QueryPartitions();
        }
示例#17
0
 public AsyncBatchGetSequence
 (
     AsyncMultiExecutor parent,
     AsyncCluster cluster,
     AsyncNode node,
     BatchNode.BatchNamespace batchNamespace,
     Policy policy,
     Key[] keys,
     HashSet <string> binNames,
     RecordSequenceListener listener,
     int readAttr
 ) : base(parent, cluster, node, false, binNames)
 {
     this.batchNamespace = batchNamespace;
     this.policy         = policy;
     this.keys           = keys;
     this.listener       = listener;
     this.readAttr       = readAttr;
 }
示例#18
0
 public AsyncBatchGetSequenceDirect
 (
     AsyncMultiExecutor parent,
     AsyncCluster cluster,
     AsyncNode node,
     BatchNode.BatchNamespace batch,
     Policy policy,
     Key[] keys,
     string[] binNames,
     RecordSequenceListener listener,
     int readAttr
 ) : base(parent, cluster, policy, node, false)
 {
     this.batch    = batch;
     this.keys     = keys;
     this.binNames = binNames;
     this.listener = listener;
     this.readAttr = readAttr;
 }
 public AsyncScan
 (
     AsyncMultiExecutor parent,
     AsyncCluster cluster,
     AsyncNode node,
     ScanPolicy scanPolicy,
     RecordSequenceListener listener,
     string ns,
     string setName,
     string[] binNames,
     ulong taskId
 ) : base(parent, cluster, scanPolicy, node, scanPolicy.socketTimeout, scanPolicy.totalTimeout)
 {
     this.scanPolicy   = scanPolicy;
     this.listener     = listener;
     this.ns           = ns;
     this.setName      = setName;
     this.binNamesScan = binNames;
     this.taskId       = taskId;
 }
示例#20
0
        public AsyncScan(
			AsyncMultiExecutor parent,
			AsyncCluster cluster,
			AsyncNode node,
			ScanPolicy policy,
			RecordSequenceListener listener,
			string ns,
			string setName,
			string[] binNames,
			ulong taskId
		)
            : base(parent, cluster, node, true)
        {
            this.policy = policy;
            this.listener = listener;
            this.ns = ns;
            this.setName = setName;
            this.binNamesScan = binNames;
            this.taskId = taskId;
        }
示例#21
0
 public AsyncScan
 (
     AsyncMultiExecutor parent,
     AsyncCluster cluster,
     AsyncNode node,
     ScanPolicy policy,
     RecordSequenceListener listener,
     string ns,
     string setName,
     string[] binNames,
     long taskId
 ) : base(parent, cluster, node, true)
 {
     this.policy       = policy;
     this.listener     = listener;
     this.ns           = ns;
     this.setName      = setName;
     this.binNamesScan = binNames;
     this.taskId       = taskId;
 }
        public AsyncScanExecutor
        (
            AsyncCluster cluster,
            ScanPolicy policy,
            RecordSequenceListener listener,
            string ns,
            string setName,
            string[] binNames,
            Node[] nodes
        ) : base(cluster)
        {
            this.listener = listener;
            policy.Validate();

            ulong taskId = RandomShift.ThreadLocalInstance.NextLong();

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

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

            // Dispatch commands to nodes.
            if (policy.failOnClusterChange && hasClusterStable)
            {
                ExecuteValidate(tasks, policy.maxConcurrentNodes, ns);
            }
            else
            {
                Execute(tasks, policy.maxConcurrentNodes);
            }
        }
示例#23
0
        public AsyncScanPartitionExecutor
        (
            AsyncCluster cluster,
            ScanPolicy policy,
            RecordSequenceListener listener,
            string ns,
            string setName,
            string[] binNames,
            PartitionTracker tracker
        ) : base(cluster)
        {
            this.policy   = policy;
            this.listener = listener;
            this.ns       = ns;
            this.setName  = setName;
            this.binNames = binNames;
            this.tracker  = tracker;

            policy.Validate();
            tracker.SleepBetweenRetries = 0;
            ScanPartitions();
        }
        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);
        }
        public AsyncBatchGetSequenceExecutor
        (
            AsyncCluster cluster,
            BatchPolicy policy,
            RecordSequenceListener listener,
            Key[] keys,
            string[] binNames,
            int readAttr
        ) : base(cluster, policy, keys, false)
        {
            this.listener = listener;

            // Create commands.
            AsyncMultiCommand[] tasks = new AsyncMultiCommand[base.taskSize];
            int count = 0;

            foreach (BatchNode batchNode in batchNodes)
            {
                tasks[count++] = new AsyncBatchGetSequenceCommand(this, cluster, batchNode, policy, keys, binNames, listener, readAttr);
            }
            // Dispatch commands to nodes.
            Execute(tasks, 0);
        }
 public AsyncScanPartition
 (
     AsyncMultiExecutor executor,
     AsyncCluster cluster,
     ScanPolicy scanPolicy,
     RecordSequenceListener listener,
     string ns,
     string setName,
     string[] binNames,
     ulong taskId,
     PartitionTracker tracker,
     NodePartitions nodePartitions
 ) : base(executor, cluster, scanPolicy, (AsyncNode)nodePartitions.node, tracker.socketTimeout, tracker.totalTimeout)
 {
     this.scanPolicy     = scanPolicy;
     this.listener       = listener;
     this.ns             = ns;
     this.setName        = setName;
     this.binNames       = binNames;
     this.taskId         = taskId;
     this.tracker        = tracker;
     this.nodePartitions = nodePartitions;
 }
 public void Get(Policy policy, RecordSequenceListener listener, Key[] keys)
 {
     BatchPolicy batchPolicy = GetAsyncBatchPolicy(policy);
     Get(batchPolicy, listener, keys);
 }
 //-------------------------------------------------------
 // Query Operations
 //-------------------------------------------------------
 /// <summary>
 /// Asynchronously execute query on all server nodes.  The query policy's 
 /// <code>maxConcurrentNodes</code> dictate how many nodes can be queried in parallel.
 /// The default is to query all nodes in parallel.
 /// <para>
 /// This method schedules the node's query commands with channel selectors and returns.
 /// Selector threads will process the commands and send the results to the listener.
 /// </para>
 /// </summary>
 /// <param name="policy">query configuration parameters, pass in null for defaults</param>
 /// <param name="listener">where to send results</param>
 /// <param name="statement">database query command parameters</param>
 /// <exception cref="AerospikeException">if query fails</exception>
 public void Query(QueryPolicy policy, RecordSequenceListener listener, Statement statement)
 {
     if (policy == null)
     {
         policy = queryPolicyDefault;
     }
     new AsyncQueryExecutor(cluster, policy, listener, statement);
 }
        //-------------------------------------------------------
        // Scan Operations
        //-------------------------------------------------------
        /// <summary>
        /// Asynchronously read all records in specified namespace and set.  If the policy's 
        /// concurrentNodes is specified, each server node will be read in
        /// parallel.  Otherwise, server nodes are read in series.
        /// <para>
        /// This method schedules the scan command with a channel selector and returns.
        /// Another thread will process the command and send the results to the listener.
        /// </para>
        /// </summary>
        /// <param name="policy">scan configuration parameters, pass in null for defaults</param>
        /// <param name="listener">where to send results, pass in null for fire and forget</param>
        /// <param name="ns">namespace - equivalent to database name</param>
        /// <param name="setName">optional set name - equivalent to database table</param>
        /// <param name="binNames">
        /// optional bin to retrieve. All bins will be returned if not specified.
        /// Aerospike 2 servers ignore this parameter.
        /// </param>
        /// <exception cref="AerospikeException">if queue is full</exception>
        public void ScanAll(ScanPolicy policy, RecordSequenceListener listener, string ns, string setName, params string[] binNames)
        {
            if (policy == null)
            {
                policy = scanPolicyDefault;
            }

            new AsyncScanExecutor(cluster, policy, listener, ns, setName, binNames);
        }
示例#30
0
        public AsyncBatchGetSequenceExecutor(
			AsyncCluster cluster,
			BatchPolicy policy,
			RecordSequenceListener listener,
			Key[] keys,
			string[] binNames,
			int readAttr
		)
            : base(cluster, policy, keys)
        {
            this.listener = listener;

            // Create commands.
            AsyncMultiCommand[] tasks = new AsyncMultiCommand[base.taskSize];
            int count = 0;

            foreach (BatchNode batchNode in batchNodes)
            {
                if (batchNode.node.UseNewBatch(policy))
                {
                    // New batch
                    tasks[count++] = new AsyncBatchGetSequenceCommand(this, cluster, batchNode, policy, keys, binNames, listener, readAttr);
                }
                else
                {
                    // Old batch only allows one namespace per call.
                    foreach (BatchNode.BatchNamespace batchNamespace in batchNode.batchNamespaces)
                    {
                        tasks[count++] = new AsyncBatchGetSequenceDirect(this, cluster, (AsyncNode)batchNode.node, batchNamespace, policy, keys, binNames, listener, readAttr);
                    }
                }
            }
            // Dispatch commands to nodes.
            Execute(tasks, policy.maxConcurrentThreads);
        }
 public void Get(Policy policy, RecordSequenceListener listener, Key[] keys, params string[] binNames)
 {
     BatchPolicy batchPolicy = GetAsyncBatchPolicy(policy);
     Get(batchPolicy, listener, keys, binNames);
 }
 /// <summary>
 /// Asynchronously read multiple record headers and bins for specified keys in one batch call.
 /// Schedule the batch get command with a channel selector and return.
 /// Another thread will process the command and send the results to the listener in multiple unordered calls.
 /// <para>
 /// If a key is not found, the record will be null.
 /// The policy can be used to specify timeouts.
 /// </para>
 /// </summary>
 /// <param name="policy">generic configuration parameters, pass in null for defaults</param>
 /// <param name="listener">where to send results</param>
 /// <param name="keys">array of unique record identifiers</param>
 /// <param name="binNames">array of bins to retrieve</param>
 /// <exception cref="AerospikeException">if queue is full</exception>
 public void Get(BatchPolicy policy, RecordSequenceListener listener, Key[] keys, params string[] binNames)
 {
     if (keys.Length == 0)
     {
         listener.OnSuccess();
         return;
     }
     if (policy == null)
     {
         policy = batchPolicyDefault;
     }
     new AsyncBatchGetSequenceExecutor(cluster, policy, listener, keys, binNames, Command.INFO1_READ);
 }
示例#33
0
        public AsyncBatchGetSequenceDirect(
			AsyncMultiExecutor parent,
			AsyncCluster cluster,
			AsyncNode node,
			BatchNode.BatchNamespace batch,
			Policy policy,
			Key[] keys,
			string[] binNames,
			RecordSequenceListener listener,
			int readAttr
		)
            : base(parent, cluster, node, false)
        {
            this.batch = batch;
            this.policy = policy;
            this.keys = keys;
            this.binNames = binNames;
            this.listener = listener;
            this.readAttr = readAttr;
        }
 /// <summary>
 /// Asynchronously read multiple records for specified keys in one batch call.
 /// Schedule the get command with a channel selector and return.
 /// Another thread will process the command and send the results to the listener in multiple unordered calls.
 /// <para>
 /// If a key is not found, the record will be null.
 /// The policy can be used to specify timeouts.
 /// </para>
 /// </summary>
 /// <param name="policy">generic configuration parameters, pass in null for defaults</param>
 /// <param name="listener">where to send results</param>
 /// <param name="keys">array of unique record identifiers</param>
 /// <exception cref="AerospikeException">if queue is full</exception>
 public void Get(BatchPolicy policy, RecordSequenceListener listener, Key[] keys)
 {
     if (keys.Length == 0)
     {
         listener.OnSuccess();
         return;
     }
     if (policy == null)
     {
         policy = batchPolicyDefault;
     }
     new AsyncBatchGetSequenceExecutor(cluster, policy, listener, keys, null, Command.INFO1_READ | Command.INFO1_GET_ALL);
 }