private void RunPutGet(AsyncClient client, Arguments args, Key key, Bin bin)
        {
            console.Info("Put: namespace={0} set={1} key={2} value={3}",
                key.ns, key.setName, key.userKey, bin.value);

            client.Put(args.writePolicy, new WriteHandler(this, client, args.writePolicy, key, bin), key, bin);
        }
        private void CreateIndex(AsyncClient client, Arguments args, string indexName, string binName)
        {
            console.Info("Create index: ns=" + args.ns + " set=" + args.set + " index=" + indexName + " bin=" + binName);

            Policy policy = new Policy();
            policy.timeout = 0; // Do not timeout on index create.
            IndexTask task = client.CreateIndex(policy, args.ns, args.set, indexName, binName, IndexType.NUMERIC);
            task.Wait();
        }
        /// <summary>
        /// Asynchronously write and read a bin using alternate methods.
        /// </summary>
        public override void RunExample(AsyncClient client, Arguments args)
        {
            completed = false;
            Key key = new Key(args.ns, args.set, "putgetkey");
            Bin bin = new Bin(args.GetBinName("putgetbin"), "value");

            RunPutGet(client, args, key, bin);
            WaitTillComplete();

            RunPutGetWithTask(client, args, key, bin);
        }
 public BenchmarkThreadAsync(
     Console console,
     BenchmarkArguments args,
     BenchmarkShared shared,
     Example example,
     AsyncClient client
 )
     : base(console, args, shared, example)
 {
     this.client = client;
 }
        /// <summary>
        /// Asynchronous UDF example.
        /// </summary>
        public override void RunExample(AsyncClient client, Arguments args)
        {
            if (! args.hasUdf) {
                console.Info("Execute functions are not supported by the connected Aerospike server.");
                return;
            }

            Register(client, args);
            WriteUsingUdfAsync(client, args);
            WaitTillComplete();
            completed = false;
        }
        /// <summary>
        /// Asynchronous scan example.
        /// </summary>
        public override void RunExample(AsyncClient client, Arguments args)
        {
            console.Info("Asynchronous scan: namespace=" + args.ns + " set=" + args.set);
            recordCount = 0;
            completed = false;

            DateTime begin = DateTime.Now;
            ScanPolicy policy = new ScanPolicy();
            client.ScanAll(policy, new RecordSequenceHandler(this, begin), args.ns, args.set);

            WaitTillComplete();
        }
        /// <summary>
        /// Asynchronous batch examples.
        /// </summary>
        public override void RunExample(AsyncClient client, Arguments args)
        {
            this.client = client;
            this.args = args;
            this.binName = args.GetBinName("batchbin");
            this.taskCount = 0;
            this.taskSize = 0;
            this.completed = false;

            InitializeKeys();
            WriteRecords();
            WaitTillComplete();
        }
Example #8
0
        public void Close()
        {
            if (client != null)
            {
                client.Close();
                client = null;
            }

            if (asyncClient != null)
            {
                asyncClient.Close();
                asyncClient = null;
            }
        }
        private void RunPutGetWithTask(AsyncClient client, Arguments args, Key key, Bin bin)
        {
            console.Info("Put with task: namespace={0} set={1} key={2} value={3}",
                key.ns, key.setName, key.userKey, bin.value);

            CancellationTokenSource cancel = new CancellationTokenSource();
            Task taskput = client.Put(args.writePolicy, cancel.Token, key, bin);
            taskput.Wait();

            console.Info("Get with task: namespace={0} set={1} key={2}",
                key.ns, key.setName, key.userKey);

            Task<Record> taskget = client.Get(args.policy, cancel.Token, key);
            taskget.Wait();

            ValidateBin(key, bin, taskget.Result);
        }
        /// <summary>
        /// Asynchronous Query example.
        /// </summary>
        public override void RunExample(AsyncClient client, Arguments args)
        {
            if (! args.hasUdf) {
                console.Info("Query functions are not supported by the connected Aerospike server.");
                return;
            }

            completed = false;
            string indexName = "asqindex";
            string keyPrefix = "asqkey";
            string binName = args.GetBinName("asqbin");
            int size = 50;

            CreateIndex(client, args, indexName, binName);
            RunQueryExample(client, args, keyPrefix, binName, size);
            WaitTillComplete();
            client.DropIndex(args.policy, args.ns, args.set, indexName);
        }
        public override void RunExample(Arguments args)
        {
            AsyncClientPolicy policy = new AsyncClientPolicy();
            policy.user = args.user;
            policy.password = args.password;
            policy.asyncMaxCommands = args.commandMax;
            policy.failIfNotConnected = true;

            AsyncClient client = new AsyncClient(policy, args.host, args.port);

            try
            {
                args.SetServerSpecific(client);
                RunExample(client, args);
            }
            finally
            {
                client.Close();
            }
        }
 public WriteHandler(AsyncPutGet parent, AsyncClient client, WritePolicy policy, Key key, Bin bin)
 {
     this.parent = parent;
     this.client = client;
     this.policy = policy;
     this.key = key;
     this.bin = bin;
 }
        public override void RunExample(Arguments a)
        {
            this.args = (BenchmarkArguments)a;
            shared = new BenchmarkShared(args);

            if (args.sync)
            {
                ClientPolicy policy = new ClientPolicy();
                policy.user = args.user;
                policy.password = args.password;
                policy.failIfNotConnected = true;
                client = new AerospikeClient(policy, args.host, args.port);

                try
                {
                    args.SetServerSpecific(client);
                    threads = new BenchmarkThreadSync[args.threadMax];
                    for (int i = 0; i < args.threadMax; i++)
                    {
                        threads[i] = new BenchmarkThreadSync(console, args, shared, this, client);
                    }
                    RunThreads();
                }
                finally
                {
                    client.Close();
                }
            }
            else
            {
                console.Info("Maximum concurrent commands: " + args.commandMax);

                AsyncClientPolicy policy = new AsyncClientPolicy();
                policy.user = args.user;
                policy.password = args.password;
                policy.failIfNotConnected = true;
                policy.asyncMaxCommands = args.commandMax;

                AsyncClient client = new AsyncClient(policy, args.host, args.port);
                this.client = client;

                try
                {
                    args.SetServerSpecific(client);
                    threads = new BenchmarkThreadAsync[args.threadMax];
                    for (int i = 0; i < args.threadMax; i++)
                    {
                        threads[i] = new BenchmarkThreadAsync(console, args, shared, this, client);
                    }
                    RunThreads();
                }
                finally
                {
                    client.Close();
                }
            }
        }
 public abstract void RunExample(AsyncClient client, Arguments args);
        private void RunQueryExample(AsyncClient client, Arguments args, string keyPrefix, string binName, int size)
        {
            console.Info("Write " + size + " records.");
            WriteHandler handler = new WriteHandler(this, client, args, binName, size);

            for (int i = 1; i <= size; i++)
            {
                Key key = new Key(args.ns, args.set, keyPrefix + i);
                Bin bin = new Bin(binName, i);
                client.Put(args.writePolicy, handler, key, bin);
            }
        }
 public WriteHandler(AsyncQuery parent, AsyncClient client, Arguments args, string binName, int max)
 {
     this.parent = parent;
     this.client = client;
     this.args = args;
     this.binName = binName;
     this.max = max;
 }
 public WriteHandler(AsyncUserDefinedFunction parent, AsyncClient client, Key key, string binName)
 {
     this.parent = parent;
     this.client = client;
     this.key = key;
     this.binName = binName;
 }
Example #18
0
        private void ConnectAsync()
        {
            AsyncClientPolicy policy = new AsyncClientPolicy();
            policy.asyncMaxCommands = 300;
            policy.failIfNotConnected = true;

            if (!user.Equals(""))
            {
                policy.user = user;
                policy.password = password;
            }

            asyncClient = new AsyncClient(policy, host, port);
        }
        private void WriteUsingUdfAsync(AsyncClient client, Arguments args)
        {
            Key key = new Key(args.ns, args.set, "audfkey1");
            Bin bin = new Bin(args.GetBinName("audfbin1"), "string value");

            console.Info("Write with udf: namespace=" + key.ns + " set=" + key.setName + " key=" + key.userKey + " value=" + bin.value);
            client.Execute(null, new WriteHandler(this, client, key, bin.name), key, "record_example", "writeBin", Value.Get(bin.name), bin.value);
        }
 public WriteHandler(TestAsyncPutGet parent, AsyncClient client, Key key, Bin bin)
 {
     this.parent = parent;
     this.client = client;
     this.key = key;
     this.bin = bin;
 }