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 AsyncMultiCommand(AsyncMultiExecutor parent, AsyncCluster cluster, AsyncNode node, bool stopOnNotFound)
     : base(cluster)
 {
     this.parent = parent;
     this.fixedNode = node;
     this.stopOnNotFound = stopOnNotFound;
 }
        public AsyncBatchExistsArrayExecutor(
			AsyncCluster cluster,
			BatchPolicy policy,
			Key[] keys,
			ExistsArrayListener listener
		)
            : base(cluster, policy, keys)
        {
            this.existsArray = new bool[keys.Length];
            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 AsyncBatchExistsArrayCommand(this, cluster, batchNode, policy, keys, existsArray);
                }
                else
                {
                    // Old batch only allows one namespace per call.
                    foreach (BatchNode.BatchNamespace batchNamespace in batchNode.batchNamespaces)
                    {
                        tasks[count++] = new AsyncBatchExistsArrayDirect(this, cluster, (AsyncNode)batchNode.node, batchNamespace, policy, keys, existsArray);
                    }
                }
            }
            // Dispatch commands to nodes.
            Execute(tasks, policy.maxConcurrentThreads);
        }
 public AsyncReadHeader(AsyncCluster cluster, Policy policy, RecordListener listener, Key key)
     : base(cluster)
 {
     this.policy = policy;
     this.listener = listener;
     this.key = key;
     this.partition = new Partition(key);
 }
Esempio n. 5
0
 public AsyncRead(AsyncCluster cluster, Policy policy, RecordListener listener, Key key, string[] binNames)
     : base(cluster)
 {
     this.policy = policy;
     this.listener = listener;
     this.key = key;
     this.partition = new Partition(key);
     this.binNames = binNames;
 }
 public AsyncExecute(AsyncCluster cluster, WritePolicy writePolicy, ExecuteListener listener, Key key, string packageName, string functionName, Value[] args)
     : base(cluster, writePolicy, null, key, null)
 {
     this.writePolicy = writePolicy;
     this.executeListener = listener;
     this.packageName = packageName;
     this.functionName = functionName;
     this.args = args;
 }
 public AsyncBatchExistsArrayCommand
 (
     AsyncMultiExecutor parent,
     AsyncCluster cluster,
     BatchNode batch,
     BatchPolicy batchPolicy,
     Key[] keys,
     bool[] existsArray
 ) : base(parent, cluster, batch, batchPolicy)
 {
     this.keys        = keys;
     this.existsArray = existsArray;
 }
Esempio n. 8
0
 public AsyncBatchReadSequenceCommand
 (
     AsyncMultiExecutor parent,
     AsyncCluster cluster,
     BatchNode batch,
     BatchPolicy batchPolicy,
     BatchSequenceListener listener,
     List <BatchRead> records
 ) : base(parent, cluster, batch, batchPolicy)
 {
     this.listener = listener;
     this.records  = records;
 }
 public AsyncBatchExistsSequenceCommand
 (
     AsyncMultiExecutor parent,
     AsyncCluster cluster,
     BatchNode batch,
     BatchPolicy batchPolicy,
     Key[] keys,
     ExistsSequenceListener listener
 ) : base(parent, cluster, batch, batchPolicy)
 {
     this.keys     = keys;
     this.listener = listener;
 }
Esempio n. 10
0
 public AsyncBatchReadListCommand
 (
     AsyncMultiExecutor parent,
     AsyncCluster cluster,
     BatchNode batch,
     BatchPolicy batchPolicy,
     List <BatchRead> records
 ) : base(parent, cluster, batchPolicy, (AsyncNode)batch.node, false)
 {
     this.batch       = batch;
     this.batchPolicy = batchPolicy;
     this.records     = records;
 }
Esempio n. 11
0
 public AsyncBatchExistsArrayDirect
 (
     AsyncMultiExecutor parent,
     AsyncCluster cluster,
     AsyncNode node,
     BatchNode.BatchNamespace batch,
     Policy policy,
     Key[] keys,
     bool[] existsArray
 ) : base(parent, cluster, policy, node, false)
 {
     this.batch       = batch;
     this.keys        = keys;
     this.existsArray = existsArray;
 }
Esempio n. 12
0
 public AsyncBatchExistsSequenceDirect
 (
     AsyncMultiExecutor parent,
     AsyncCluster cluster,
     AsyncNode node,
     BatchNode.BatchNamespace batch,
     Policy policy,
     Key[] keys,
     ExistsSequenceListener listener
 ) : base(parent, cluster, policy, node, false)
 {
     this.batch    = batch;
     this.keys     = keys;
     this.listener = listener;
 }
        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();
                }
            }
        }
 /// <summary>
 /// Clone constructor.
 /// </summary>
 public AsyncCommand(AsyncCommand other)
     : base(other.socketTimeout, other.totalTimeout, other.maxRetries)
 {
     // Retry constructor.
     this.cluster             = other.cluster;
     this.policy              = other.policy;
     this.node                = other.node;
     this.eventArgs           = other.eventArgs;
     this.eventArgs.UserToken = this;
     this.segmentOrig         = other.segmentOrig;
     this.segment             = other.segment;
     this.totalWatch          = other.totalWatch;
     this.iteration           = other.iteration;
     this.commandSentCounter  = other.commandSentCounter;
 }
 public AsyncBatchReadSequenceCommand
 (
     AsyncMultiExecutor parent,
     AsyncCluster cluster,
     BatchNode batch,
     BatchPolicy policy,
     BatchSequenceListener listener,
     List <BatchRead> records
 ) : base(parent, cluster, (AsyncNode)batch.node, false)
 {
     this.batch    = batch;
     this.policy   = policy;
     this.listener = listener;
     this.records  = records;
 }
 public AsyncBatchExistsArrayCommand
 (
     AsyncMultiExecutor parent,
     AsyncCluster cluster,
     BatchNode batch,
     BatchPolicy policy,
     Key[] keys,
     bool[] existsArray
 ) : base(parent, cluster, (AsyncNode)batch.node, false)
 {
     this.batch       = batch;
     this.policy      = policy;
     this.keys        = keys;
     this.existsArray = existsArray;
 }
 public AsyncBatchExistsSequenceCommand
 (
     AsyncMultiExecutor parent,
     AsyncCluster cluster,
     BatchNode batch,
     BatchPolicy policy,
     Key[] keys,
     ExistsSequenceListener listener
 ) : base(parent, cluster, (AsyncNode)batch.node, false)
 {
     this.batch    = batch;
     this.policy   = policy;
     this.keys     = keys;
     this.listener = listener;
 }
 public AsyncCommand(AsyncCommand other)
 {
     // Retry constructor.
     this.cluster             = other.cluster;
     this.policy              = other.policy;
     this.node                = other.node;
     this.eventArgs           = other.eventArgs;
     this.eventArgs.UserToken = this;
     this.segmentOrig         = other.segmentOrig;
     this.segment             = other.segment;
     this.watch               = other.watch;
     this.iteration           = other.iteration;
     this.commandSentCounter  = other.commandSentCounter;
     this.isRead              = other.isRead;
     this.usingSocketTimeout  = other.usingSocketTimeout;
 }
        public AsyncBatchExistsArrayExecutor(AsyncCluster cluster, BatchPolicy policy, Key[] keys, ExistsArrayListener listener)
            : base(cluster, policy, keys)
        {
            this.existsArray = new bool[keys.Length];
            this.listener    = listener;

            // Dispatch asynchronous commands to nodes.
            foreach (BatchNode batchNode in batchNodes)
            {
                foreach (BatchNode.BatchNamespace batchNamespace in batchNode.batchNamespaces)
                {
                    AsyncBatchExistsArray async = new AsyncBatchExistsArray(this, cluster, (AsyncNode)batchNode.node, batchNamespace, policy, keys, existsArray);
                    async.Execute();
                }
            }
        }
Esempio n. 20
0
        public void SetArgs(AsyncCluster cluster, WritePolicy writePolicy, OperateArgs args)
        {
            base.policy      = writePolicy;
            this.writePolicy = writePolicy;
            this.args        = args;

            if (args.hasWrite)
            {
                base.partition = Partition.Write(cluster, writePolicy, key);
            }
            else
            {
                base.isRead    = true;
                base.partition = Partition.Read(cluster, writePolicy, key);
            }
        }
 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;
 }
 public AsyncBatchGetArrayCommand
 (
     AsyncMultiExecutor parent,
     AsyncCluster cluster,
     BatchNode batch,
     BatchPolicy batchPolicy,
     Key[] keys,
     string[] binNames,
     Record[] records,
     int readAttr
 ) : base(parent, cluster, batch, batchPolicy)
 {
     this.keys     = keys;
     this.binNames = binNames;
     this.records  = records;
     this.readAttr = readAttr;
 }
 public AsyncExecute
 (
     AsyncCluster cluster,
     WritePolicy writePolicy,
     ExecuteListener listener,
     Key key,
     string packageName,
     string functionName,
     Value[] args
 ) : base(cluster, writePolicy, key)
 {
     this.writePolicy     = writePolicy;
     this.executeListener = listener;
     this.packageName     = packageName;
     this.functionName    = functionName;
     this.args            = args;
 }
Esempio n. 24
0
        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;
            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(cluster, tasks, policy.maxConcurrentNodes, ns);
            }
            else
            {
                Execute(tasks, policy.maxConcurrentNodes);
            }
        }
Esempio n. 25
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();
        }
Esempio n. 26
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;
 }
 public AsyncBatchGetArray
 (
     AsyncMultiExecutor parent,
     AsyncCluster cluster,
     AsyncNode node,
     BatchNode.BatchNamespace batch,
     Policy policy,
     Key[] keys,
     HashSet <string> binNames,
     Record[] records,
     int readAttr
 ) : base(parent, cluster, node, false, binNames)
 {
     this.batch    = batch;
     this.policy   = policy;
     this.keys     = keys;
     this.records  = records;
     this.readAttr = readAttr;
 }
Esempio n. 28
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 AsyncBatchExistsSequenceExecutor
        (
            AsyncCluster cluster,
            BatchPolicy policy,
            Key[] keys,
            ExistsSequenceListener listener
        ) : 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 AsyncBatchExistsSequenceCommand(this, cluster, batchNode, policy, keys, listener);
            }
            // Dispatch commands to nodes.
            Execute(tasks, 0);
        }
        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);
            }
        }
        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 AsyncBatchExistsArrayExecutor
        (
            AsyncCluster cluster,
            BatchPolicy policy,
            Key[] keys,
            ExistsArrayListener listener
        ) : base(cluster, policy, keys, true)
        {
            this.existsArray = new bool[keys.Length];
            this.listener    = listener;

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

            foreach (BatchNode batchNode in batchNodes)
            {
                tasks[count++] = new AsyncBatchExistsArrayCommand(this, cluster, batchNode, policy, keys, existsArray);
            }
            // Dispatch commands to nodes.
            Execute(tasks, 0);
        }
Esempio n. 33
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 AsyncConnectorExecutor
        (
            AsyncCluster cluster,
            AsyncNode node,
            int maxConnections,
            int maxConcurrent,
            bool wait
        )
        {
            this.cluster        = cluster;
            this.node           = node;
            this.maxConnections = maxConnections;
            this.maxConcurrent  = (maxConnections >= maxConcurrent) ? maxConcurrent : maxConnections;
            this.wait           = wait;

            for (int i = 0; i < this.maxConcurrent; i++)
            {
                try
                {
                    SocketAsyncEventArgs eventArgs = new SocketAsyncEventArgs();
                    eventArgs.RemoteEndPoint = node.address;
                    eventArgs.Completed     += AsyncConnector.SocketListener;

                    byte[] dataBuffer = (cluster.user != null) ? new byte[256] : null;

                    new AsyncConnector(cluster, node, this, eventArgs, dataBuffer);
                }
                catch (Exception e)
                {
                    OnFailure("Node " + node + " failed to create connection: " + e.Message);
                    return;
                }
            }

            if (wait)
            {
                WaitTillComplete();
            }
        }
        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 AsyncBatchReadSequenceExecutor
        (
            AsyncCluster cluster,
            BatchPolicy policy,
            BatchSequenceListener listener,
            List <BatchRead> records
        ) : base(cluster, false)
        {
            this.listener = listener;

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

            AsyncMultiCommand[] tasks = new AsyncMultiCommand[batchNodes.Count];
            int count = 0;

            foreach (BatchNode batchNode in batchNodes)
            {
                tasks[count++] = new AsyncBatchReadSequenceCommand(this, cluster, batchNode, policy, listener, records);
            }
            // Dispatch commands to nodes.
            Execute(tasks, 0);
        }
Esempio n. 37
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)
            {
                tasks[count++] = new AsyncBatchGetSequenceCommand(this, cluster, batchNode, policy, keys, binNames, listener, readAttr);
            }
            // Dispatch commands to nodes.
            Execute(tasks, 0);
        }
        public AsyncConnection(IPEndPoint address, AsyncCluster cluster)
        {
            this.maxSocketIdleMillis = (double)(cluster.maxSocketIdleMillis);

            try
            {
                socket = new Socket(address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
                socket.NoDelay = true;

                // Docs say Blocking flag is ignored for async operations.
                // socket.Blocking = false;

                // Avoid internal TCP send/receive buffers.
                // Use application buffers directly.
                socket.SendBufferSize = 0;
                socket.ReceiveBufferSize = 0;

                timestamp = DateTime.UtcNow;
            }
            catch (Exception e)
            {
                throw new AerospikeException.Connection(e);
            }
        }
Esempio n. 39
0
        public AsyncBatchExistsSequenceCommand(
			AsyncMultiExecutor parent,
			AsyncCluster cluster,
			BatchNode batch,
			BatchPolicy policy,
			Key[] keys,
			ExistsSequenceListener listener
		)
            : base(parent, cluster, (AsyncNode)batch.node, false)
        {
            this.batch = batch;
            this.policy = policy;
            this.keys = keys;
            this.listener = listener;
        }
Esempio n. 40
0
        public AsyncBatchExistsArrayCommand(
			AsyncMultiExecutor parent,
			AsyncCluster cluster,
			BatchNode batch,
			BatchPolicy policy,
			Key[] keys,
			bool[] existsArray
		)
            : base(parent, cluster, (AsyncNode)batch.node, false)
        {
            this.batch = batch;
            this.policy = policy;
            this.keys = keys;
            this.existsArray = existsArray;
        }
Esempio n. 41
0
        public AsyncBatchExistsArrayDirect(
			AsyncMultiExecutor parent,
			AsyncCluster cluster,
			AsyncNode node,
			BatchNode.BatchNamespace batch,
			Policy policy,
			Key[] keys,
			bool[] existsArray
		)
            : base(parent, cluster, node, false)
        {
            this.batch = batch;
            this.policy = policy;
            this.keys = keys;
            this.existsArray = existsArray;
        }
Esempio n. 42
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);
        }
Esempio n. 43
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);
            AsyncMultiCommand[] tasks = new AsyncMultiCommand[batchNodes.Count];
            int count = 0;

            foreach (BatchNode batchNode in batchNodes)
            {
                if (!batchNode.node.hasBatchIndex)
                {
                    throw new AerospikeException(ResultCode.PARAMETER_ERROR, "Requested command requires a server that supports new batch index protocol.");
                }
                tasks[count++] = new AsyncBatchReadSequenceCommand(this, cluster, batchNode, policy, listener, records);
            }
            // Dispatch commands to nodes.
            Execute(tasks, policy.maxConcurrentThreads);
        }
Esempio n. 44
0
        public AsyncBatchReadSequenceCommand(
			AsyncMultiExecutor parent,
			AsyncCluster cluster,
			BatchNode batch,
			BatchPolicy policy,
			BatchSequenceListener listener,
			List<BatchRead> records
		)
            : base(parent, cluster, (AsyncNode)batch.node, false)
        {
            this.batch = batch;
            this.policy = policy;
            this.listener = listener;
            this.records = records;
        }
 public AsyncSingleCommand(AsyncCluster cluster)
     : base(cluster)
 {
 }
 public AsyncOperate(AsyncCluster cluster, WritePolicy policy, RecordListener listener, Key key, Operation[] operations)
     : base(cluster, policy, listener, key, null)
 {
     this.writePolicy = policy;
     this.operations = operations;
 }
 public AsyncCommand(AsyncCluster cluster)
 {
     this.cluster = cluster;
 }
Esempio n. 48
0
        public AsyncBatchExistsSequenceDirect(
			AsyncMultiExecutor parent,
			AsyncCluster cluster,
			AsyncNode node,
			BatchNode.BatchNamespace batch,
			Policy policy,
			Key[] keys,
			ExistsSequenceListener listener
		)
            : base(parent, cluster, node, false)
        {
            this.batch = batch;
            this.policy = policy;
            this.keys = keys;
            this.listener = listener;
        }
Esempio n. 49
0
        public AsyncBatchGetArrayCommand(
			AsyncMultiExecutor parent,
			AsyncCluster cluster,
			BatchNode batch,
			BatchPolicy policy,
			Key[] keys,
			string[] binNames,
			Record[] records,
			int readAttr
		)
            : base(parent, cluster, (AsyncNode)batch.node, false)
        {
            this.batch = batch;
            this.policy = policy;
            this.keys = keys;
            this.binNames = binNames;
            this.records = records;
            this.readAttr = readAttr;
        }
Esempio n. 50
0
 /// <summary>
 /// Initialize server node with connection parameters.
 /// </summary>
 /// <param name="cluster">collection of active server nodes</param>
 /// <param name="nv">connection parameters</param>
 public AsyncNode(AsyncCluster cluster, NodeValidator nv)
     : base(cluster, nv)
 {
     this.cluster = cluster;
     asyncConnQueue = new BlockingCollection<AsyncConnection>(cluster.MaxCommands);
 }
Esempio n. 51
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>
 /// Initialize asynchronous client with suitable hosts to seed the cluster map.
 /// The client policy is used to set defaults and size internal data structures.
 /// For each host connection that succeeds, the client will:
 /// <list type="bullet">
 /// <item>Add host to the cluster map</item>
 /// <item>Request host's list of other nodes in cluster</item>
 /// <item>Add these nodes to cluster map</item>
 /// </list>
 /// <para>
 /// In most cases, only one host is necessary to seed the cluster. The remaining hosts 
 /// are added as future seeds in case of a complete network failure.
 /// </para>
 /// <para>
 /// If one connection succeeds, the client is ready to process database requests.
 /// If all connections fail and the policy's failIfNotConnected is true, a connection 
 /// exception will be thrown. Otherwise, the cluster will remain in a disconnected state
 /// until the server is activated.
 /// </para>
 /// </summary>
 /// <param name="policy">client configuration parameters, pass in null for defaults</param>
 /// <param name="hosts">array of potential hosts to seed the cluster</param>
 /// <exception cref="AerospikeException">if all host connections fail</exception>
 public AsyncClient(AsyncClientPolicy policy, params Host[] hosts)
     : base(policy)
 {
     if (policy == null)
     {
         policy = new AsyncClientPolicy();
     }
     this.cluster = new AsyncCluster(policy, hosts);
     base.cluster = this.cluster;
 }