Example #1
0
 def work(self):
     print("***** Welcome to Aerospike Developer Training *****\n")
     print("INFO: Connecting to Aerospike cluster...")
         #  Establish connection to Aerospike server
     if not self.client:
         print("\nERROR: Connection to Aerospike cluster failed! Please check the server settings and try again!")
     else:
           print("\nINFO: Connection to Aerospike cluster succeeded!\n")
           #  Create instance of UserService
           us = UserService(self.client)
           #  Create instance of TweetService
           ts = TweetService(self.client)
           #  Present options
           print("\nWhat would you like to do:\n")
           print("1> Create A User And A Tweet\n")
           print("2> Read A User Record\n")
           print("3> Batch Read Tweets For A User\n")
           print("4> Scan All Tweets For All Users\n")
           print("5> Record UDF -- Update User Password\n")
           print("6> Query Tweets By Username And Users By Tweet Count Range\n")
           print("7> Stream UDF -- Aggregation Based on Tweet Count By Region\n")
           print("0> Exit\n")
           print("\nSelect 0-7 and hit enter:\n")
           try:
             feature=int(raw_input('Input:'))
           except ValueError:
             print("Input a valid feature number")
             sys.exit(0)
           if feature != 0:
               if feature==1:
                   print("\n********** Your Selection: Create User And A Tweet **********\n")
                   us.createUser()
                   ts.createTweet()
               elif feature==2:
                   print("\n********** Your Selection: Read A User Record **********\n")
                   us.getUser()
               elif feature==3:
                   print("\n********** Your Selection: Batch Read Tweets For A User **********\n")
                   us.batchGetUserTweets()
               elif feature==4:
                   print("\n********** Your Selection: Scan All Tweets For All Users **********\n")
                   ts.scanAllTweetsForAllUsers()
               elif feature==5:
                   print("\n********** Your Selection: Record UDF -- Update User Password **********\n")
                   us.updatePasswordUsingUDF()
               elif feature==6:
                   print("\n********** Your Selection: Query Tweets By Username And Users By Tweet Count Range **********\n")
                   ts.queryTweetsByUsername()
                   ts.queryUsersByTweetCount()
               elif feature==7:
                   print("\n********** Your Selection: Stream UDF -- Aggregation Based on Tweet Count By Region **********\n")
                   us.aggregateUsersByTweetCountByRegion()
               elif feature==12:
                   print("\n********** Create Users **********\n")
                   us.createUsers()
               elif feature==23:
                   print("\n********** Create Tweets **********\n")
                   ts.createTweets()
               else:
                 print ("Enter a Valid number from above menue !!")
Example #2
0
 def work(self):
     print("***** Welcome to Aerospike Developer Training *****\n")
     print("INFO: Connecting to Aerospike cluster...")
     #  Establish connection to Aerospike server
     if not self.client:
         print(
             "\nERROR: Connection to Aerospike cluster failed! Please check the server settings and try again!"
         )
     else:
         print("\nINFO: Connection to Aerospike cluster succeeded!\n")
         #  Create instance of UserService
         us = UserService(self.client)
         #  Create instance of TweetService
         ts = TweetService(self.client)
         #  Present options
         print("\nWhat would you like to do:\n")
         print("1> Create A User And A Tweet\n")
         print("2> Read A User Record\n")
         print("3> Batch Read Tweets For A User\n")
         print("4> Scan All Tweets For All Users\n")
         print("5> Record UDF -- Update User Password\n")
         print(
             "6> Query Tweets By Username And Users By Tweet Count Range\n")
         print(
             "7> Stream UDF -- Aggregation Based on Tweet Count By Region\n"
         )
         print("0> Exit\n")
         print("\nSelect 0-7 and hit enter:\n")
         try:
             feature = int(raw_input('Input:'))
         except ValueError:
             print("Input a valid feature number")
             sys.exit(0)
         if feature != 0:
             if feature == 1:
                 print(
                     "\n********** Your Selection: Create User And A Tweet **********\n"
                 )
                 us.createUser()
                 ts.createTweet()
             elif feature == 2:
                 print(
                     "\n********** Your Selection: Read A User Record **********\n"
                 )
                 us.getUser()
             elif feature == 3:
                 print(
                     "\n********** Your Selection: Batch Read Tweets For A User **********\n"
                 )
                 us.batchGetUserTweets()
             elif feature == 4:
                 print(
                     "\n********** Your Selection: Scan All Tweets For All Users **********\n"
                 )
                 ts.scanAllTweetsForAllUsers()
             elif feature == 5:
                 print(
                     "\n********** Your Selection: Record UDF -- Update User Password **********\n"
                 )
                 us.updatePasswordUsingUDF()
             elif feature == 6:
                 print(
                     "\n********** Your Selection: Query Tweets By Username And Users By Tweet Count Range **********\n"
                 )
                 ts.queryTweetsByUsername()
                 ts.queryUsersByTweetCount()
             elif feature == 7:
                 print(
                     "\n********** Your Selection: Stream UDF -- Aggregation Based on Tweet Count By Region **********\n"
                 )
                 us.aggregateUsersByTweetCountByRegion()
             elif feature == 12:
                 print("\n********** Create Users **********\n")
                 us.createUsers()
             elif feature == 23:
                 print("\n********** Create Tweets **********\n")
                 ts.createTweets()
             else:
                 print("Enter a Valid number from above menue !!")
Example #3
0
    def work(self):
        print("***** Welcome to Aerospike Developer Training *****\n")

        if self.client:
            print("\nINFO: Connection to Aerospike cluster succeeded!\n")
            #  Create instance of UserService
            us = UserService(self.client)
            #  Create instance of TweetService
            ts = TweetService(self.client)
            #  Present options
            print("\nWhat would you like to do:")
            print("1> Create A User")
            print("2> Create A Tweet By A User")
            print("3> Read A User Record")
            print("4> Batch Read Tweets For A User")
            print("5> Scan All Tweets For All Users")
            print("6> Update User Password using CAS")
            print("7> Update User Password using Record UDF")
            print("8> Query Tweets By Username")
            print("9> Query Users By Tweet Count Range")
            print(
                "10> Stream UDF -- Aggregation Based on Tweet Count By Region")
            print("11> Create A Test Set of Users")
            print("12> Create A Test Set of Tweets")
            print("0> Exit\n")
            print("\nSelect 0-12 and hit enter:\n")
            try:
                feature = int(input('Input:'))
            except ValueError:
                print("Input a valid feature number")
                sys.exit(0)
            if feature != 0:
                if feature == 1:
                    print(
                        "\n********** Your Selection: Create A User **********\n"
                    )
                    us.createUser()
                elif feature == 2:
                    print(
                        "\n********** Your Selection: Create A Tweet By A User **********\n"
                    )
                    ts.createTweet()
                elif feature == 3:
                    print(
                        "\n********** Your Selection: Read A User Record **********\n"
                    )
                    us.getUser()
                elif feature == 4:
                    print(
                        "\n********** Your Selection: Batch Read Tweets For A User **********\n"
                    )
                    us.batchGetUserTweets()
                elif feature == 5:
                    print(
                        "\n********** Your Selection: Scan All Tweets For All Users **********\n"
                    )
                    ts.scanAllTweetsForAllUsers()
                elif feature == 6:
                    print(
                        "\n********** Your Selection: Update User Password using CAS **********\n"
                    )
                    us.updatePasswordUsingCAS()
                elif feature == 7:
                    print(
                        "\n********** Your Selection: Update User Password using Record UDF **********\n"
                    )
                    us.updatePasswordUsingUDF()
                elif feature == 8:
                    print(
                        "\n********** Your Selection: Query Tweets By Username **********\n"
                    )
                    ts.queryTweetsByUsername()
                elif feature == 9:
                    print(
                        "\n********** Your Selection: Query Users By Tweet Count Range **********\n"
                    )
                    ts.queryUsersByTweetCount()
                elif feature == 10:
                    print(
                        "\n********** Your Selection: Stream UDF -- Aggregation Based on Tweet Count By Region **********\n"
                    )
                    us.aggregateUsersByTweetCountByRegion()
                elif feature == 11:
                    print(
                        "\n********** Create A Test Set of Users **********\n")
                    us.createUsers()
                elif feature == 12:
                    print(
                        "\n********** Create A Test Set of Tweets **********\n"
                    )
                    ts.createTweets()
                else:
                    print("Enter a Valid number from above menu !!")
            #Exercise K1
            self.client.close()