Exemple #1
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

                // TODO: Establish a connection to Aerospike cluster
                // Exercise 1
                Console.WriteLine("\nTODO: Establish a connection to Aerospike cluster");

                // TODO: Check to see if the cluster connection succeeded
                // Exercise 1
                Console.WriteLine("\nTODO: Check to see if the cluster connection succeeded");

                if (false)
                {
                    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();
                            us.updatePasswordUsingCAS();
                            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
            {
                // TODO: Close Aerospike cluster connection
                // Exercise 1
                Console.WriteLine("\nTODO: Close Aerospike cluster connection");
                Console.ReadLine();
            }
        } //main
Exemple #2
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
Exemple #3
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
        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 = "172.16.159.198";
                // 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);

                    // 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();
            }
        }