Exemple #1
0
        public async Task InitializeMembershipTable(bool tryInitTableVersion)
        {
            await Task.Run(async() =>
            {
                _clientPolicy = new AsyncClientPolicy()
                {
                    user     = _options.Username,
                    password = _options.Password
                };

                _client = new AsyncClient(_clientPolicy, _options.Host, _options.Port);


                if (_options.CleanupOnInit)
                {
                    _client.Truncate(null, _options.Namespace, _options.SetName, null);
                }

                await PutTableVersionEntry(new TableVersion(0, ""));

                try
                {
                    var task = _client.CreateIndex(null, _options.Namespace, _options.SetName, _options.SetName + "_clusterIdx", "clusterid", IndexType.STRING);
                    task.Wait();
                }
                catch (Exception)
                {
                    // todo: evaluate if error comes from multiple index creation or other source
                }
            });
        }
        public void CreateStringIndex <TEntity>(string propertyName) where TEntity : IAeroEntity, new()
        {
            Type   entityType = typeof(TEntity);
            string indexName  = GetIndexName <TEntity>(propertyName);
            var    resultTask = _aerospikeClient
                                .CreateIndex(null, _namespace, entityType.Name, indexName, propertyName,
                                             IndexType.STRING);

            resultTask.Wait();
        }
Exemple #3
0
        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();
        }
Exemple #4
0
        public async Task Init()
        {
            _client = new AsyncClient(_options.Host, _options.Port);

            await Task.Run(() =>
            {
                try
                {
                    var task = _client.CreateIndex(new Policy(), _options.Namespace, _options.SetName + "_" + _serviceId, "grainhashIdx", "grainhash", IndexType.NUMERIC);
                    task.Wait();
                }
                catch (Exception)
                { }
            });
        }
Exemple #5
0
        public async Task InitializeMembershipTable(bool tryInitTableVersion)
        {
            _client = new AsyncClient(_options.Host, _options.Port);

            await Task.Run(async() =>
            {
                await PutTableVersionEntry(new TableVersion(0, ""));

                try
                {
                    var task = _client.CreateIndex(new Policy(), _options.Namespace, _options.SetName, "clusterIdx", "clusterid", IndexType.STRING);
                    task.Wait();
                }
                catch (Exception)
                { }
            });
        }
        public Task Init()
        {
            return(Task.Run(() =>
            {
                _clientPolicy = new AsyncClientPolicy()
                {
                    user = _options.Username,
                    password = _options.Password
                };

                _client = new AsyncClient(_clientPolicy, _options.Host, _options.Port);

                try
                {
                    var task = _client.CreateIndex(new Policy(), _options.Namespace, _options.SetName + "_" + _serviceId, "grainhashIdx", "grainhash", IndexType.NUMERIC);
                    task.Wait();
                }
                catch (Exception)
                { }
            }));
        }
        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.totalTimeout = 0;             // Do not timeout on index create.

            try
            {
                IndexTask task = client.CreateIndex(policy, args.ns, args.set, indexName, binName, IndexType.NUMERIC);
                task.Wait();
            }
            catch (AerospikeException ae)
            {
                if (ae.Result != ResultCode.INDEX_ALREADY_EXISTS)
                {
                    throw;
                }
            }
        }
Exemple #8
0
        static async Task Main(string[] args)
        {
            var host = Host();

            var client = new AsyncClient(host.Item1, host.Item2);

            var key1 = new Key("test", "myset1", "mykey1");
            var key2 = new Key("test", "myset2", "mykey2");
            var key3 = new Key("test", "myset3", "mykey3");

            var bin1 = new Bin("name", "John");
            var bin2 = new Bin("age", 25);
            var bin3 = new Bin("hello", "world");
            var bin4 = new Bin("first", "first");
            var bin5 = new Bin("first", "last");

            // Synchronous methods
            client.Put(null, key1, bin1, bin2);
            client.Add(null, key1, bin3);
            client.Prepend(null, key1, bin4);
            client.Append(null, key1, bin5);

            _ = client.Get(null, key1);
            _ = client.Exists(null, key1);
            _ = client.Get(null, new[] { key1, key2, key3 });
            _ = client.Exists(null, new[] { key1, key2, key3 });

            client.CreateIndex(null, "test", "myset1", indexName: "age", binName: "age", IndexType.NUMERIC).Wait();

            var statement = new Statement
            {
                Namespace = "test",
                SetName   = "myset1",
                BinNames  = new[] { "name", "age" },
                Filter    = Filter.Range("age", 20, 30)
            };

            var result = client.Query(new QueryPolicy(), statement);

            while (result.Next())
            {
                ;                   // Force the query to execute
            }
            client.Delete(null, key1);

            // Asynchronous methods
            await client.Put(null, CancellationToken.None, key1, bin1, bin2);

            await client.Add(null, CancellationToken.None, key1, bin3);

            await client.Prepend(null, CancellationToken.None, key1, bin4);

            await client.Append(null, CancellationToken.None, key1, bin5);

            _ = await client.Get(null, CancellationToken.None, key1);

            _ = await client.Exists(null, CancellationToken.None, key1);

            _ = await client.Get(null, CancellationToken.None, new[] { key1, key2, key3 });

            _ = await client.Exists(null, CancellationToken.None, new[] { key1, key2, key3 });

            await client.Delete(null, CancellationToken.None, key1);

            client.DropIndex(null, "test", "myset1", indexName: "age").Wait();

            client.Close();
        }