当前位置: 首页>>代码示例>>C#>>正文


C# AerospikeClient.Close方法代码示例

本文整理汇总了C#中Aerospike.Client.AerospikeClient.Close方法的典型用法代码示例。如果您正苦于以下问题:C# AerospikeClient.Close方法的具体用法?C# AerospikeClient.Close怎么用?C# AerospikeClient.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Aerospike.Client.AerospikeClient的用法示例。


在下文中一共展示了AerospikeClient.Close方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Button_Click

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // Establish connection the server
            try
            {
                AerospikeClient client = new AerospikeClient("45.55.231.46", 3000);

                // Create key
                Aerospike.Client.Key key = new Aerospike.Client.Key("test", "myset", "mykey");

                // Create Bins
                Bin bin1 = new Bin("name", "John");
                Bin bin2 = new Bin("age", 25);

                // Write record
                client.Put(null, key, bin1, bin2);

                // Read record
                Record record = client.Get(null, key);

                Record userRecord = client.Get(null, key);
                Console.WriteLine("Info:");
                Console.WriteLine("Name: " + userRecord.GetValue("name"));
                Console.WriteLine("Age: " + userRecord.GetValue("age"));

                // Close connection
                client.Close();
            }
            catch (AerospikeException.Connection conError)
            {
                Console.Write(conError);
            }
        }
开发者ID:bohregard,项目名称:SampleCsAeroSpike,代码行数:33,代码来源:MainWindow.xaml.cs

示例2: RunExample

        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();
                }
            }
        }
开发者ID:Caldas,项目名称:aerospike-client-csharp,代码行数:57,代码来源:BenchmarkExample.cs

示例3: RunExample

        public override void RunExample(Arguments args)
        {
            ClientPolicy policy = new ClientPolicy();
            policy.user = args.user;
            policy.password = args.password;
            policy.failIfNotConnected = true;

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

            try
            {
                args.SetServerSpecific(client);
                RunExample(client, args);
            }
            finally
            {
                client.Close();
            }
        }
开发者ID:vonbv,项目名称:aerospike-client-csharp,代码行数:19,代码来源:SyncExample.cs

示例4: Login

        private void Login()
        {
            string server = hostBox.Text.Trim();
            int port = int.Parse(portBox.Text.Trim());
            string userName = userBox.Text.Trim();
            string password = passwordBox.Text.Trim();

            ClientPolicy policy = new ClientPolicy();
            policy.user = userName;
            policy.password = password;
            policy.failIfNotConnected = true;
            policy.timeout = 600000;

            AerospikeClient client = new AerospikeClient(policy, server, port);

            try
            {
                if (userName.Equals("admin") && password.Equals("admin"))
                {
                    Form form = new PasswordForm(client, userName);
                    form.ShowDialog();
                }

                // Query own user.
                User user = client.QueryUser(null, userName);

                if (user != null)
                {
                    bool admin = user.roles.Contains("user-admin");

                    // Initialize Global Data
                    Globals.RefreshRoles(client, user, admin);

                    Form form = new AdminForm(client, user, admin);
                    form.Show();
                }
                else
                {
                    throw new Exception("Failed to find user: " + userName);
                }
            }
            catch (Exception)
            {
                client.Close();
                throw;
            }
        }
开发者ID:vonbv,项目名称:aerospike-client-csharp,代码行数:47,代码来源:LoginForm.cs

示例5: Main


//.........这里部分代码省略.........
                            case 3:
                                Console.WriteLine ("Generating position data using CDT and LDT...");
                                generateCustomerProduct (client);
                                Console.WriteLine ("Generating data completed");
                                break;
                            case 4:

                                Console.WriteLine ("CDT vs LDT - Whole list...");
                                long cdtTotal = 0, ldtTotal = 0, cdtProdCount = 0, ldtProdCount = 0;

                                for (int acc = 0; acc < accountTotal; acc++) {
                                    string accString = (acc + 1).ToString ();
                                    Key cdtkey = new Key (ns, cdtSet, accString);
                                    Key ldtkey = new Key (ns, ldtSet, accString);
                                    Aerospike.Helper.Collection.LargeList clist = new Aerospike.Helper.Collection.LargeList (client, null, cdtkey, cdtBinName);
                                    LargeList llist = client.GetLargeList (null, ldtkey, ldtBinName);
                                    stopwatch.Start ();
                                    IList cresult = clist.Scan ();
                                    stopwatch.Stop ();
                                    if (cresult != null)
                                        cdtProdCount += cresult.Count;
                                    cdtTotal += stopwatch.ElapsedMilliseconds;
                                    stopwatch.Reset ();

                                    stopwatch.Start ();
                                    IList lresult = llist.Scan ();
                                    stopwatch.Stop ();
                                    if (lresult != null)
                                        ldtProdCount += lresult.Count;
                                    ldtTotal += stopwatch.ElapsedMilliseconds;
                                }

                                Console.WriteLine ("CDT avg latency: {0:F5} ms", (double)cdtTotal / cdtProdCount);
                                Console.WriteLine ("LDT avg latency: {0:F5} ms", (double)ldtTotal / ldtProdCount);

                                break;
                            case 5:
                                const int attempts = 50000;
                                Console.WriteLine ("CDT vs LDT - one element..., {0} customers, each product for a customer", attempts);
                                cdtTotal = 0;
                                ldtTotal = 0;
                                long prodCount = 0;
                                Random accRand = new Random (12121);
                                for (int i = 0; i < 50000; i++) {
                                    string accString = accRand.Next (1, accountTotal).ToString ();
                                    Key cdtkey = new Key (ns, cdtSet, accString);
                                    Key ldtkey = new Key (ns, ldtSet, accString);
                                    Aerospike.Helper.Collection.LargeList clist = new Aerospike.Helper.Collection.LargeList (client, null, cdtkey, cdtBinName);
                                    LargeList llist = client.GetLargeList (null, ldtkey, ldtBinName);
                                    IList prods = llist.Scan ();
                                    if (prods != null) {
                                        prodCount += prods.Count;
                                        foreach (IDictionary product in prods) {
                                            //Dictionary<string, Object> keyMap = makeKeyMap (product);
                                            // CDT
                                            stopwatch.Start ();

                                            clist.Find (Value.Get (product));

                                            stopwatch.Stop ();
                                            cdtTotal += stopwatch.ElapsedMilliseconds;

                                            stopwatch.Reset ();

                                            // LDT
                                            stopwatch.Start ();

                                            llist.Find (Value.Get (product));

                                            stopwatch.Stop ();
                                            ldtTotal += stopwatch.ElapsedMilliseconds;

                                        }
                                    }
                                }
                                Console.WriteLine ("CDT avg latency: {0:F5} ms", (double)cdtTotal / prodCount);
                                Console.WriteLine ("LDT avg latency: {0:F5} ms", (double)ldtTotal / prodCount);

                                break;
                            default:

                                break;
                            }
                        }
                    }
                }
            } catch (AerospikeException e) {
                Console.WriteLine ("AerospikeException - Message: " + e.Message);
                Console.WriteLine ("AerospikeException - StackTrace: " + e.StackTrace);
            } catch (Exception e) {
                Console.WriteLine ("Exception - Message: " + e.Message);
                Console.WriteLine ("Exception - StackTrace: " + e.StackTrace);
            } finally {
                if (client != null && client.Connected) {
                    // Close Aerospike server connection
                    client.Close ();
                }

            }
        }
开发者ID:helipilot50,项目名称:Aerospike-list-expansion,代码行数:101,代码来源:Program.cs

示例6: ConnectSync

        private void ConnectSync()
        {
            ClientPolicy policy = new ClientPolicy();
            policy.failIfNotConnected = true;

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

            client = new AerospikeClient(policy, host, port);

            try
            {
                SetServerSpecific();
            }
            catch (Exception e)
            {
                client.Close();
                client = null;
                throw e;
            }
        }
开发者ID:vonbv,项目名称:aerospike-client-csharp,代码行数:24,代码来源:Args.cs

示例7: Main


//.........这里部分代码省略.........
                client = new AerospikeClient(asServerIP, asServerPort);

                // Check to see if the cluster connection succeeded
                if (client.Connected)
                {
                    Console.WriteLine("INFO: Connection to Aerospike cluster succeeded!\n");

                    // Create instance of UserService
                    UserService us = new UserService(client);
                    // Create instance of TweetService
                    TweetService ts = new TweetService(client);

                    // Present options
                    Console.WriteLine("What would you like to do:");
                    Console.WriteLine("1> Create A User And A Tweet");
                    Console.WriteLine("2> Read A User Record");
                    Console.WriteLine("3> Batch Read Tweets For A User");
                    Console.WriteLine("4> Scan All Tweets For All Users");
                    Console.WriteLine("5> Record UDF -- Update User Password");
                    Console.WriteLine("6> Query Tweets By Username And Users By Tweet Count Range");
                    Console.WriteLine("7> Stream UDF -- Aggregation Based on Tweet Count By Region");
                    Console.WriteLine("0> Exit");
                    Console.Write("\nSelect 0-7 and hit enter:");
                    byte feature = byte.Parse(Console.ReadLine());

                    if (feature != 0)
                    {
                        switch (feature)
                        {
                            case 1:
                                Console.WriteLine("\n********** Your Selection: Create User And A Tweet **********\n");
                                us.createUser();
                                ts.createTweet();
                                break;
                            case 2:
                                Console.WriteLine("\n********** Your Selection: Read A User Record **********\n");
                                us.getUser();
                                break;
                            case 3:
                                Console.WriteLine("\n********** Your Selection: Batch Read Tweets For A User **********\n");
                                us.batchGetUserTweets();
                                break;
                            case 4:
                                Console.WriteLine("\n**********  Your Selection: Scan All Tweets For All Users **********\n");
                                ts.scanAllTweetsForAllUsers();
                                break;
                            case 5:
                                Console.WriteLine("\n********** Your Selection: Record UDF -- Update User Password **********\n");
                                us.updatePasswordUsingUDF();
                                break;
                            case 6:
                                Console.WriteLine("\n**********  Your Selection: Query Tweets By Username And Users By Tweet Count Range **********\n");
                                ts.queryTweetsByUsername();
                                ts.queryUsersByTweetCount();
                                break;
                            case 7:
                                Console.WriteLine("\n**********  Your Selection: Stream UDF -- Aggregation Based on Tweet Count By Region **********\n");
                                us.aggregateUsersByTweetCountByRegion();
                                break;
                            case 12:
                                Console.WriteLine("\n********** Create Users **********\n");
                                us.createUsers();
                                break;
                            case 23:
                                Console.WriteLine("\n********** Create Tweets **********\n");
                                ts.createTweets();
                                break;
                            default:
                                Console.WriteLine("\n********** Invalid Selection **********\n");
                                break;
                        }
                    }
                }
                else
                {
                    Console.Write("ERROR: Connection to Aerospike cluster failed! Please check IP & Port settings and try again!");
                    Console.ReadLine();
                }
            }
            catch (AerospikeException e)
            {
                Console.WriteLine("AerospikeException - Message: " + e.Message);
                Console.WriteLine("AerospikeException - StackTrace: " + e.StackTrace);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception - Message: " + e.Message);
                Console.WriteLine("Exception - StackTrace: " + e.StackTrace);
            }
            finally
            {
                if (client != null && client.Connected)
                {
                    // Close Aerospike server connection
                    client.Close();
                }
                Console.Write("\n\nINFO: Press any key to exit...");
                Console.ReadLine();
            }
        }
开发者ID:rmondragon,项目名称:student-workbook,代码行数:101,代码来源:Program.cs


注:本文中的Aerospike.Client.AerospikeClient.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。