private void ConnectSync()
        {
            ClientPolicy policy = new ClientPolicy();

            policy.clusterName = clusterName;
            policy.tlsPolicy   = tlsPolicy;
            policy.authMode    = authMode;

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

            client = new AerospikeClient(policy, hosts);

            try
            {
                SetServerSpecific();
            }
            catch (Exception e)
            {
                client.Close();
                client = null;
                throw e;
            }
        }
示例#2
0
        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;
            }
        }
        public IActionResult Index()
        {
            AerospikeClient client = new AerospikeClient("127.0.0.1", 3000);

            // Initialize policy.
            WritePolicy policy = new WritePolicy();

            policy.SetTimeout(50);  // 50 millisecond timeout.

            // Write single or multiple values.
            Key key  = new Key("test", "myset", "mykey");
            Bin bin1 = new Bin("name", "John");
            Bin bin2 = new Bin("age", 25);

            client.Put(policy, key, bin1, bin2);

            Record record = client.Get(policy, key, "name");

            if (record != null)
            {
                Console.WriteLine("Got name: " + record.GetValue("name"));
            }



            client.Close();


            return(View());
        }
示例#4
0
        public static void RunTest()
        {
            AerospikeClient client = new AerospikeClient("172.28.128.3", 3000);

            try
            {
                string ns        = "test";
                string set       = "QueryTest";
                string indexName = "queryindexint";
                string keyPrefix = "querykeyint";
                string binName   = "querybinint";
                string binName2  = "querybinint2";
                int    size      = 10;

                //CreateIndex(client, ns, set, indexName, binName);
                WriteRecords(client, ns, set, keyPrefix, binName, size);
                RunQuery(client, ns, set, indexName, binName);

                //CreateIndex(client, ns, set, indexName, binName2);
                WriteRecords(client, ns, set, keyPrefix, binName2, size);
                //RunQuery(client, ns, set, indexName, binName2);
            }
            finally
            {
                client.Close();
            }
        }
示例#5
0
        public List <string> GetUserEmailsFromCity(string city)
        {
            List <string>   userEmails = new List <string>();
            AerospikeClient client     = new AerospikeClient(server, port);

            Statement stmt = new Statement();

            stmt.SetNamespace("test");
            stmt.SetSetName("Users");
            stmt.SetBinNames("Email");
            stmt.SetFilters(Filter.Equal("City", city));

            RecordSet userEmailsRecordSet = client.Query(null, stmt);

            try
            {
                while (userEmailsRecordSet.Next())
                {
                    Record emailRecord       = userEmailsRecordSet.Record;
                    string userEmailFromCity = emailRecord.GetValue("Email").ToString();
                    userEmails.Add(userEmailFromCity);
                }
            }
            finally
            {
                userEmailsRecordSet.Close();
                client.Close();
            }

            return(userEmails);
        }
示例#6
0
        public static void Run2()
        {
            AerospikeClient client = new AerospikeClient("172.28.128.3", 3000);
            // Initialize policy.
            WritePolicy policy = new WritePolicy();

            policy.SetTimeout(50);  // 50 millisecond timeout


            // Write single value.
            Key key = new Key("test", "myset", "mykey");
            Bin bin = new Bin("mybin", "myvalue");

            client.Put(policy, key, bin);



            Record record = client.Get(policy, key, "mybin");

            if (record != null)
            {
                Console.WriteLine("Got name: " + record.GetValue("mybin"));
            }

            client.Close();
        }
示例#7
0
        public static void Run()
        {
            AerospikeClient client = new AerospikeClient("172.28.128.3", 3000);
            // Initialize policy.
            WritePolicy policy = new WritePolicy();

            policy.SetTimeout(50);  // 50 millisecond timeout


            Key key  = new Key("test", "MultiSet", "mykey");
            Bin bin1 = new Bin("name", "John");
            Bin bin2 = new Bin("age", 25);

            client.Put(policy, key, bin1, bin2);


            Record record = client.Get(policy, key);

            if (record != null)
            {
                foreach (KeyValuePair <string, object> entry in record.bins)
                {
                    Console.WriteLine("Name=" + entry.Key + " Value=" + entry.Value);
                }
            }

            client.Close();
        }
示例#8
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();
                }
            }
        }
示例#9
0
 public virtual void TearDown()
 {
     Console.WriteLine("Closing AerospikeClient");
     client.Close();
     if (caughtException != null)
     {
         Console.WriteLine(string.Format("TestFixtureSetUp failed in {0} - {1} {2}", this.GetType(), caughtException.GetType(), caughtException.Message));
     }
 }
示例#10
0
        public IActionResult Index()
        {
            AerospikeClient client = new AerospikeClient("127.0.0.1", 3000);

            client.Close();


            return(View());
        }
        public IActionResult Index()
        {
            #region Initialize
            AerospikeClient client = new AerospikeClient("127.0.0.1", 3000);

            // Initialize policy.
            WritePolicy policy = new WritePolicy();
            policy.SetTimeout(50);  // 50 millisecond timeout.
            #endregion

            #region Write Records
            // Write single value.
            Key key = new Key("test", "myset", "mykey");
            Bin bin = new Bin("mybin", "myvalue");
            client.Put(policy, key, bin);

            // Write multiple values.
            Key key2 = new Key("test", "myset", "mykey");
            Bin bin1 = new Bin("name", "John");
            Bin bin2 = new Bin("age", 25);
            client.Put(policy, key2, bin1, bin2);
            #endregion

            #region Read Records
            //Reading a Single or Multiple  Value
            Record record = client.Get(policy, key, "name");
            if (record != null)
            {
                Console.WriteLine("Got name: " + record.GetValue("name"));
            }
            Record recordMultiple = client.Get(policy, key);
            if (recordMultiple != null)
            {
                foreach (KeyValuePair <string, object> entry in recordMultiple.bins)
                {
                    Console.WriteLine("Name=" + entry.Key + " Value=" + entry.Value);
                }
            }
            #endregion

            #region Delete Record
            Key keyDel = new Key("test", "myset", "mykey");
            client.Delete(policy, keyDel);
            #endregion



            #region Cleaning Up
            //Call Close() when all transactions are finished and the application is ready to shutdown.
            //The AerospikeClient object can no longer be called after calling Close).
            client.Close();
            #endregion


            return(View());
        }
示例#12
0
        private static void CloseClient()
        {
            if (client != null)
            {
                client.Close();
            }

            client      = null;
            writePolicy = null;
        }
示例#13
0
        private void Login()
        {
            int port = int.Parse(portBox.Text.Trim());

            Host[] hosts    = Host.ParseHosts(hostBox.Text.Trim(), tlsName, port);
            string userName = userBox.Text.Trim();
            string password = passwordBox.Text.Trim();

            ClientPolicy policy = new ClientPolicy();

            policy.user               = userName;
            policy.password           = password;
            policy.clusterName        = clusterName;
            policy.failIfNotConnected = true;
            policy.timeout            = 600000;
            policy.tlsPolicy          = tlsPolicy;
            policy.authMode           = authMode;

            AerospikeClient client = new AerospikeClient(policy, hosts);

            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;
            }
        }
示例#14
0
        public IActionResult Index()
        {
            #region Initialize
            AerospikeClient client = new AerospikeClient("127.0.0.1", 3000);

            // Initialize policy.
            WritePolicy policy = new WritePolicy();
            policy.SetTimeout(50);  // 50 millisecond timeout.
            #endregion

            #region Write Records
            // Write single value.
            Key key = new Key("test", "myset", "mykey");
            Bin bin = new Bin("mybin", "myvalue");
            client.Put(policy, key, bin);

            // Write multiple values.
            Key key2 = new Key("test", "myset", "mykey");
            Bin bin1 = new Bin("name", "John");
            Bin bin2 = new Bin("age", 25);
            client.Put(policy, key2, bin1, bin2);
            #endregion

            #region Read Records
            //Reading a Single or Multiple  Value
            Record record = client.Get(policy, key, "name");
            if (record != null)
            {
                Console.WriteLine("Got name: " + record.GetValue("name"));
            }
            Record recordMultiple = client.Get(policy, key);
            if (recordMultiple != null)
            {
                foreach (KeyValuePair <string, object> entry in recordMultiple.bins)
                {
                    Console.WriteLine("Name=" + entry.Key + " Value=" + entry.Value);
                }
            }
            #endregion



            #region Cleaning Up

            #endregion
            client.Close();


            return(View());
        }
示例#15
0
        public static void Run()
        {
            AerospikeClient client = new AerospikeClient("172.28.128.3", 3000);
            // Initialize policy.
            WritePolicy policy = new WritePolicy();

            policy.SetTimeout(50);  // 50 millisecond timeout

            Key key = new Key("test", "myset", "mykey");

            client.Delete(policy, key);

            client.Close();
        }
示例#16
0
        public void Close()
        {
            if (client != null)
            {
                client.Close();
                client = null;
            }

            if (asyncClient != null)
            {
                asyncClient.Close();
                asyncClient = null;
            }
        }
        public IActionResult Index()
        {
            AerospikeClient client = new AerospikeClient("127.0.0.1", 3000);

            // Initialize policy.
            WritePolicy policy = new WritePolicy();

            policy.SetTimeout(50);  // 50 millisecond timeout.


            client.Close();


            return(View());
        }
示例#18
0
        public static void RunTest()
        {
            AerospikeClient client = new AerospikeClient("172.28.128.3", 3000);

            try
            {
                QueryTest.RunTest();
                //Querytestten gelen binler;
                string binName  = "querybinint";
                string binName2 = "querybinint2";



                Policy policy = new Policy();
                policy.SetTimeout(100);


                //Assembly assembly = Assembly.GetExecutingAssembly();
                //RegisterTask rtask = client.Register(policy, "example.lua", "example.lua", Language.LUA);
                //rtask.Wait();


                //rtask.Wait();
                //if (rtask.IsDone())
                //{
                //    Console.WriteLine("done");

                //}

                int begin = 1;
                int end   = 10;

                Statement stmt = new Statement();
                stmt.SetNamespace("test");
                stmt.SetSetName("QueryTest");
                stmt.SetFilter(Filter.Range("querybinint", begin, end));

                ExecuteTask task = client.Execute(null, stmt, "example", "processRecord", Value.Get(binName), Value.Get(binName2), Value.Get(100));
                //task.Wait(3000, 3000);
                task.Wait();
            }
            finally
            {
                client.Close();
            }
        }
示例#19
0
        public void SaveUser(CLM.AerospikeDemo.Domain.User userToSave)
        {
            AerospikeClient client = new AerospikeClient(server, port);

            Key userKey = new Key("test", "Users", userToSave.Email);

            Bin[] userBins = new Bin[7];

            Bin firstNameBin = new Bin("FirstName", userToSave.FirstName);

            userBins[0] = firstNameBin;

            Bin lastNameBin = new Bin("LastName", userToSave.LastName);

            userBins[1] = lastNameBin;

            Bin emailBin = new Bin("Email", userToSave.Email);

            userBins[2] = emailBin;

            Bin cityBin = new Bin("City", userToSave.City);

            userBins[3] = cityBin;

            Bin countryBin = new Bin("Country", userToSave.Country);

            userBins[4] = countryBin;

            Bin jobBin = new Bin("Job", userToSave.Job);

            userBins[5] = jobBin;

            Bin companyBin = new Bin("Company", userToSave.Company);

            userBins[6] = companyBin;

            try
            {
                client.Put(null, userKey, userBins);
            }
            finally
            {
                client.Close();
            }
        }
        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();
            }
        }
示例#21
0
        public override void RunExample(Arguments args)
        {
            ClientPolicy policy = new ClientPolicy();

            policy.user        = args.user;
            policy.password    = args.password;
            policy.clusterName = args.clusterName;
            policy.tlsPolicy   = args.tlsPolicy;

            AerospikeClient client = new AerospikeClient(policy, args.hosts);

            try
            {
                args.SetServerSpecific(client);
                RunExample(client, args);
            }
            finally
            {
                client.Close();
            }
        }
示例#22
0
        public IActionResult Index()
        {
            AerospikeClient client = new AerospikeClient("127.0.0.1", 3000);

            // Initialize policy.
            WritePolicy policy = new WritePolicy();

            policy.SetTimeout(50);  // 50 millisecond timeout.

            // Write single value.
            Key key = new Key("test", "myset", "mykey");
            Bin bin = new Bin("mybin", "myvalue");

            client.Put(policy, key, bin);



            client.Close();


            return(View());
        }
示例#23
0
        public IActionResult Index()
        {
            AerospikeClient client = new AerospikeClient(new ClientPolicy(), "127.0.0.1", 3000);

            // Initialize policy.
            WritePolicy policy = new WritePolicy();

            policy.SetTimeout(50);  // 50 millisecond timeout.

            // Write single or multiple values.
            Key key  = new Key("test", "myset", "mykey");
            Bin bin1 = new Bin("name", "John");
            Bin bin2 = new Bin("age", 25);

            client.Put(policy, key, bin1, bin2);



            client.Close();


            return(View());
        }
示例#24
0
        public static void Run()
        {
            AerospikeClient client = new AerospikeClient("172.28.128.3", 3000);

            // Initialize policy.
            WritePolicy policy = new WritePolicy();

            policy.SetTimeout(50);  // 50 millisecond timeout


            Key    key     = new Key("test", "Add", "mykey");
            string binName = "addbin";

            // Delete record if it already exists.
            client.Delete(null, key);

            // Perform some adds and check results.
            Bin bin = new Bin(binName, 10);

            client.Add(null, key, bin);

            bin = new Bin(binName, 5);
            client.Add(null, key, bin);


            Record record = client.Get(null, key, bin.name);

            //AssertBinEqual(key, record, bin.name, 15);
            Console.WriteLine(record.GetInt(binName));

            // test add and get combined.
            bin    = new Bin(binName, 30);
            record = client.Operate(null, key, Operation.Add(bin), Operation.Get(bin.name));
            Console.WriteLine(record.GetInt(binName));

            client.Close();
        }
示例#25
0
        static void Main(string[] args)
        {
            AerospikeClient client       = null;
            string          asServerIP   = "172.28.128.3";
            int             asServerPort = 3000;



            try
            {
                Console.WriteLine("INFO: Connecting to Aerospike cluster...");
                // Establish connection
                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 User And Tweet");
                    Console.WriteLine("2> Read User Record");
                    Console.WriteLine("3> Batch Read Tweets For 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("8> Create tweet");
                    Console.WriteLine("0> Exit");
                    Console.Write("\nSelect 0-8 and hit enter:");
                    byte feature = byte.Parse(Console.ReadLine());

                    if (feature != 0)
                    {
                        switch (feature)
                        {
                        case 1:
                            Console.WriteLine("\n********** Your Selection: Create User And Tweet **********\n");
                            us.createUser();
                            ts.createTweet();
                            break;

                        case 2:
                            Console.WriteLine("\n********** Your Selection: Read User Record **********\n");
                            us.readUser();
                            break;

                        case 3:
                            Console.WriteLine("\n********** Your Selection: Batch Read Tweets For 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 8:
                            Console.WriteLine("\n**********  Your Selection: Create A Tweet **********\n");
                            ts.createTweet();
                            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!");
                }
            }
            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.ReadLine();
            }
        }
示例#26
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Welcome to Aerospike Developer Training *****\n");
            AerospikeClient client = null;

            try
            {
                Console.WriteLine("INFO: Connecting to Aerospike cluster...");

                // Connecting to Aerospike cluster

                // Specify IP of one of the nodes in the cluster
                // Note: Assign your AWS Instance Public IP address to asServerIP
                string asServerIP = "54.237.175.53";
                // Specity Port that the node is listening on
                int asServerPort = 3000;
                // TODO: Establish connection
                // Exercise K1
                client = new AerospikeClient(asServerIP, asServerPort);

                // TODO: Check to see if the cluster connection succeeded
                // Exercise K1
                if (client != null && 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");
                    Console.WriteLine("2> Create A Tweet By A User");
                    Console.WriteLine("3> Read A User Record");
                    Console.WriteLine("4> Batch Read Tweets For A User");
                    Console.WriteLine("5> Scan All Tweets For All Users");
                    Console.WriteLine("6> Update User Password Using CAS");
                    Console.WriteLine("7> Update User Password Using Record UDF");
                    Console.WriteLine("8> Query Tweets By Username");
                    Console.WriteLine("9> Query Users By Tweet Count Range");
                    Console.WriteLine("10> Stream UDF -- Aggregation Based on Tweet Count By Region");
                    Console.WriteLine("11> Create A Test Set of Users");
                    Console.WriteLine("12> Create A Test Set of Tweets");
                    Console.WriteLine("0> Exit");
                    Console.Write("\nSelect 0-12 and hit enter:");
                    byte feature = byte.Parse(Console.ReadLine());

                    if (feature != 0)
                    {
                        switch (feature)
                        {
                        case 1:
                            Console.WriteLine("\n********** Your Selection: Create A User **********\n");
                            us.createUser();
                            break;

                        case 2:
                            Console.WriteLine("\n********** Your Selection: Create A Tweet By A User **********\n");
                            ts.createTweet();
                            break;

                        case 3:
                            Console.WriteLine("\n********** Your Selection: Read A User Record **********\n");
                            us.getUser();
                            break;

                        case 4:
                            Console.WriteLine("\n********** Your Selection: Batch Read Tweets For A User **********\n");
                            us.batchGetUserTweets();
                            break;

                        case 5:
                            Console.WriteLine("\n**********  Your Selection: Scan All Tweets For All Users **********\n");
                            ts.scanAllTweetsForAllUsers();
                            break;

                        case 6:
                            Console.WriteLine("\n********** Your Selection: Update User Password Using CAS **********\n");
                            us.updatePasswordUsingCAS();
                            break;

                        case 7:
                            Console.WriteLine("\n********** Your Selection: Update User Password Using Record UDF **********\n");
                            us.updatePasswordUsingUDF();
                            break;

                        case 8:
                            Console.WriteLine("\n**********  Your Selection: Query Tweets By Username **********\n");
                            ts.queryTweetsByUsername();
                            break;

                        case 9:
                            Console.WriteLine("\n**********  Your Selection: Query Users By Tweet Count Range **********\n");
                            ts.queryUsersByTweetCount();
                            break;

                        case 10:
                            Console.WriteLine("\n**********  Your Selection: Stream UDF -- Aggregation Based on Tweet Count By Region **********\n");
                            us.aggregateUsersByTweetCountByRegion();
                            break;

                        case 11:
                            Console.WriteLine("\n********** Create A Test Set of Users **********\n");
                            us.createUsers();
                            break;

                        case 12:
                            Console.WriteLine("\n********** Create A Test Set of 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)
                {
                    // TODO: Close Aerospike server connection
                    // Exercise K1
                    client.Close();
                }
                Console.Write("\n\nINFO: Press any key to exit...");
                Console.ReadLine();
            }
        } //main
示例#27
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Welcome to Aerospike Developer Training *****\n");
            AerospikeClient client = null;

            try
            {
                Console.WriteLine("INFO: Connecting to Aerospike cluster...");

                // Connecting to Aerospike cluster

                // Specify IP of one of the nodes in the cluster
                string asServerIP = "127.0.0.1";
                // Specity Port that the node is listening on
                int asServerPort = 3000;
                // Establish connection
                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);
                    // Create instance of UtilityService
                    UtilityService util = new UtilityService(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:");
                    int feature = int.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.queryTweets();
                            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();
            }
        } //main
示例#28
0
 private void FormClose(object sender, FormClosingEventArgs e)
 {
     client.Close();
 }
示例#29
0
        static void Main(string[] args)
        {
            AerospikeClient client = null;

            try
            {
                Console.WriteLine("INFO: Connecting to Aerospike cluster...");

                // Connecting to Aerospike cluster

                // Specify IP of one of the nodes in the cluster
                // Note: Assign your AWS Instance Public IP address to asServerIP
                string asServerIP = "54.236.253.20";
                // Specity Port that the node is listening on
                int asServerPort = 3000;
                // Establish connection

                client = new AerospikeClient(asServerIP, asServerPort);

                // Check to see if the cluster connection succeeded

                if (client != null && client.Connected)
                {
                    Console.WriteLine("INFO: Connection to Aerospike cluster succeeded!\n");

                    // Create instance of TopicTest
                    TopicTest tt = new TopicTest(client);

                    // Present options
                    Console.WriteLine("What would you like to do:");
                    Console.WriteLine("1> Add test records.");
                    Console.WriteLine("2> Increment counter - Update test records.");
                    Console.WriteLine("0> Exit");
                    Console.Write("\nSelect 0-2 and hit enter:");
                    byte feature = byte.Parse(Console.ReadLine());

                    if (feature != 0)
                    {
                        switch (feature)
                        {
                        case 1:
                            Console.WriteLine("\n********** Your Selection: Add records **********\n");
                            tt.addRecords();
                            break;

                        case 2:
                            Console.WriteLine("\n********** Your Selection: Increment counter - Update test records. **********\n");
                            tt.updateRecords();
                            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();
            }
        } //main
示例#30
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Welcome to Aerospike Developer Training *****\n");
            AerospikeClient client = null;

            try
            {
                Console.WriteLine("INFO: Connecting to Aerospike cluster...");

                // Connecting to Aerospike cluster

                // Specify IP of one of the nodes in the cluster
                string asServerIP = "127.0.0.1";
                // Specity Port that the node is listening on
                int asServerPort = 3000;
                // Establish connection
                ClientPolicy clientPolicy = new ClientPolicy();
                clientPolicy.user     = "******";
                clientPolicy.password = "******";
                client = new AerospikeClient(clientPolicy, 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 RoleService
                    RoleService rs = new RoleService(client);

                    // Present options

                    Console.WriteLine("\nWhat would you like to do:\n");
                    Console.WriteLine("1> Create User\n");
                    Console.WriteLine("2> Read User\n");
                    Console.WriteLine("3> Grant Role to User\n");
                    Console.WriteLine("4> Revoke Role from User\n");
                    Console.WriteLine("5> Drop User\n");
                    Console.WriteLine("6> Create Role\n");
                    Console.WriteLine("7> Read Role\n");
                    Console.WriteLine("8> Grant Privilege to Role\n");
                    Console.WriteLine("9> Revoke Privilege from Role\n");
                    Console.WriteLine("10> Drop Role\n");
                    Console.WriteLine("0> Exit\n");
                    Console.Write("\nSelect 0-10 and hit enter:\n");

                    int feature = int.Parse(Console.ReadLine());

                    if (feature != 0)
                    {
                        switch (feature)
                        {
                        case 1:
                            Console.WriteLine("\n********** Your Selection: Create User **********\n");
                            us.createUser();
                            break;

                        case 2:
                            Console.WriteLine("\n********** Your Selection: Read User **********\n");
                            us.getUser();
                            break;

                        case 3:
                            Console.WriteLine("\n********** Your Selection: Grant Role **********\n");
                            us.grantRole();
                            break;

                        case 4:
                            Console.WriteLine("\n**********  Your Selection: Revoke Role **********\n");
                            us.revokeRole();
                            break;

                        case 5:
                            Console.WriteLine("\n********** Your Selection: Drop User **********\n");
                            us.dropUser();
                            break;

                        case 6:
                            Console.WriteLine("\n**********  Your Selection: Create Role **********\n");
                            rs.createRole();
                            break;

                        case 7:
                            Console.WriteLine("\n**********  Your Selection: Read Role **********\n");
                            rs.readRole();
                            break;

                        case 8:
                            Console.WriteLine("\n********** Your Selection: Grant Privilege **********\n");
                            rs.grantPrivilege();
                            break;

                        case 9:
                            Console.WriteLine("\n********** Your Selection: Revoke Privilege **********\n");
                            rs.revokePrivilege();
                            break;

                        case 10:
                            Console.WriteLine("\n********** Your Selection: Drop Role **********\n");
                            rs.dropRole();
                            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();
            }
        } //main