Beispiel #1
0
def main():
    parser = setup_parser(OptionParser())
    (options, args) = parser.parse_args()

    # Parsing all the options (for the database and webserver)
    database_string = options.database
    inserts = check_int_field(options.inserts)
    selects = check_int_field(options.selects)

    url = options.url
    port = check_int_field(options.port)
    gets = check_int_field(options.get_requests)
    posts = check_int_field(options.post_requests)
    threads = check_threads_field(options.threads)
    create = options.create_table
    # Configuration, which is derived from a specificc file
    config = ConfigParser.RawConfigParser()
    config.read('config.conf')

    logger = Logger.initialize('performance')
    database = get_database(database_string, config, logger)

    streamer = None

    if options.database != None:
        streamer = TweetStream.get_instance(logger, inserts, selects, database,
                                            config)
        if create and options.database == 'postgres':
            logger.log("Creating database tables...")
            database.connect_to_database()
            database.create_table()
            database.disconnect()
            exit()
        logger.log("Initalized tool, connecting to " + database.to_string() + " and performing " +str(inserts)+" writes and " + \
        str(selects) + " reads.")
    elif options.url != None:
        streamer = MultiWeb.initialize(url, port, gets, posts, logger, config,
                                       threads)
    else:
        print "Please enter the correct arguments"

    # Running the streamer
    streamer.run()
Beispiel #2
0
def main():
  parser = setup_parser(OptionParser())
  (options, args) = parser.parse_args()
  
  # Parsing all the options (for the database and webserver)
  database_string = options.database
  inserts = check_int_field(options.inserts)
  selects = check_int_field(options.selects)
  
  url = options.url
  port = check_int_field(options.port)
  gets = check_int_field(options.get_requests)
  posts = check_int_field(options.post_requests)
  threads = check_threads_field(options.threads)
  create = options.create_table
  # Configuration, which is derived from a specificc file
  config = ConfigParser.RawConfigParser()
  config.read('config.conf')
  
  logger = Logger.initialize('performance')
  database = get_database(database_string, config, logger)
  
  
  streamer = None
  
  if options.database != None:
    streamer = TweetStream.get_instance(logger, inserts, selects, database, config)
    if create and options.database == 'postgres':
      logger.log("Creating database tables...")
      database.connect_to_database()
      database.create_table()
      database.disconnect()
      exit()
    logger.log("Initalized tool, connecting to " + database.to_string() + " and performing " +str(inserts)+" writes and " + \
    str(selects) + " reads.")
  elif options.url != None:
    streamer = MultiWeb.initialize(url, port, gets, posts, logger, config, threads)
  else:
    print "Please enter the correct arguments"
  
  # Running the streamer
  streamer.run()
Beispiel #3
0
 def run(self):
     for x in xrange(self.thread_count):
         s = TweetStream.get_instance(self.logger, self.inserts,
                                      self.selects, self.database,
                                      self.config).start()
Beispiel #4
0
 def run(self):
   for x in xrange(self.thread_count):
     s = TweetStream.get_instance(self.logger, self.inserts, self.selects, self.database, self.config).start()