Esempio n. 1
0
        /// <summary>
        /// Scan all nodes in series and read all records in all sets.
        /// </summary>
        public override void RunExample(AerospikeClient client, Arguments args)
        {
            console.Info("Scan series: namespace=" + args.ns + " set=" + args.set);
            setMap.Clear();

            ScanPolicy policy = new ScanPolicy();

            policy.recordsPerSecond = 5000;

            // Low scan priority will take more time, but it will reduce the load on the server.
            // policy.priority = Priority.LOW;

            Node[]   nodes = client.Nodes;
            DateTime begin = DateTime.Now;

            foreach (Node node in nodes)
            {
                console.Info("Scan node " + node.Name);
                client.ScanNode(policy, node, args.ns, args.set, ScanCallback);

                foreach (KeyValuePair <string, Metrics> entry in setMap)
                {
                    console.Info("Node " + node.Name + " set " + entry.Key + " count: " + entry.Value.count);
                    entry.Value.total += entry.Value.count;
                    entry.Value.count  = 0;
                }
            }

            DateTime end     = DateTime.Now;
            double   seconds = end.Subtract(begin).TotalSeconds;

            console.Info("Elapsed time: " + seconds + " seconds");

            long total = 0;

            foreach (KeyValuePair <string, Metrics> entry in setMap)
            {
                console.Info("Total set " + entry.Key + " count: " + entry.Value.total);
                total += entry.Value.total;
            }
            console.Info("Grand total: " + total);
            double performance = Math.Round((double)total / seconds);

            console.Info("Records/second: " + performance);
        }