示例#1
0
 /// <summary>
 /// Copy async client policy from another async client policy.
 /// </summary>
 public AsyncClientPolicy(AsyncClientPolicy other) : base(other)
 {
     this.asyncMaxCommandAction = other.asyncMaxCommandAction;
     this.asyncMaxCommands      = other.asyncMaxCommands;
     this.asyncMinConnsPerNode  = other.asyncMinConnsPerNode;
     this.asyncMaxConnsPerNode  = other.asyncMaxConnsPerNode;
 }
示例#2
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 Args()
        {
            var config = new ConfigurationBuilder()
                         .AddJsonFile("settings.json")
                         .Build();

            string ps       = config["Port"];
            int    port     = int.Parse(config["Port"]);
            string user     = config["User"];
            string password = config["Password"];

            Host[] hosts = Host.ParseHosts(config["Host"], null, port);

            AsyncClientPolicy policy = new AsyncClientPolicy();

            policy.asyncMaxCommands = 200;

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

            // Set very short expiration, so tests can verify record will expire.
            // Normal expiration should be much longer than this testing case.
            expiration = TimeSpan.FromSeconds(2);

            cache = new AerospikeCache(new AerospikeCacheOptions()
            {
                Hosts        = hosts,
                ClientPolicy = policy,
                Namespace    = config["Namespace"],
                Set          = config["Set"]
            });
        }
示例#4
0
        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.tlsPolicy = args.tlsPolicy;
                policy.authMode  = args.authMode;
                client           = new AerospikeClient(policy, args.hosts);

                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.tlsPolicy        = args.tlsPolicy;
                policy.authMode         = args.authMode;
                policy.asyncMaxCommands = args.commandMax;

                AsyncClient client = new AsyncClient(policy, args.hosts);
                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 Task InitializeGatewayListProvider()
        {
            return(Task.Run(() =>
            {
                _clientPolicy = new AsyncClientPolicy()
                {
                    user = _options.Username,
                    password = _options.Password
                };

                _client = new AsyncClient(_clientPolicy, _options.Host, _options.Port);
            }));
        }
示例#6
0
        private void ConnectAsync()
        {
            AsyncClientPolicy policy = new AsyncClientPolicy();

            policy.asyncMaxCommands = 300;

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

            asyncClient = new AsyncClient(policy, hosts);
        }
        public async Task Init(CancellationToken cancellationToken)
        {
            _logger.LogInformation($"Init host={_options.Host} port={_options.Port} ns:{_options.Namespace} serializer={_aerospikeSerializer.GetType().Name}");

            _clientPolicy = new AsyncClientPolicy()
            {
                user     = _options.Username,
                password = _options.Password
            };

            _readPolicy = new BatchPolicy(_clientPolicy.batchPolicyDefault)
            {
                sendKey = true
            };

            _writeStatePolicy = new WritePolicy(_clientPolicy.writePolicyDefault)
            {
                recordExistsAction = RecordExistsAction.REPLACE,
                sendKey            = true
            };

            Log.SetLevel(Log.Level.INFO);
            Log.SetCallback((level, message) =>
            {
                LogLevel logLevel = LogLevel.None;
                switch (level)
                {
                case Log.Level.DEBUG:
                    logLevel = LogLevel.Debug;
                    break;

                case Log.Level.ERROR:
                    logLevel = LogLevel.Error;
                    break;

                case Log.Level.INFO:
                    logLevel = LogLevel.Information;
                    break;

                case Log.Level.WARN:
                    logLevel = LogLevel.Warning;
                    break;
                }
                _logger.Log(logLevel, "Aerospike-Message: " + message);
            });

            _client = new AsyncClient(_clientPolicy,
                                      _options.Host,
                                      _options.Port);
        }
示例#8
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);
        }
        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)
                { }
            }));
        }
示例#10
0
        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();
            }
        }
示例#11
0
 /// <summary>
 /// Copy async client policy from another async client policy.
 /// </summary>
 public AsyncClientPolicy(AsyncClientPolicy other) : base(other)
 {
     this.asyncMaxCommandAction = other.asyncMaxCommandAction;
     this.asyncMaxCommands      = other.asyncMaxCommands;
 }