lib/rubberband_flamethrower/flamethrower.rb
# Batch inserts randomly generated JSON data objects into an Elastic Search server.
# Example of the object inserted:
#  {
#   "message":"utilizing plowed popularizing demeanor anesthesia specializes chaperon pedaling.",
#   "username":"pummeling",
#   "post_date":"20130408T15:41:28"
#  }
# 
# @param [Integer] how_many - how many randomly generated data objects to insert
# @param [Integer] starting_id - starting id for randomly generated data objects, will increment from this number
# @param [String] server_url - url of the Elastic Search server
# @param [String] index - name of the Elastic Search index to insert data into
# @param [String] type - name of the Elastic Search type to insert data into
# @param [Integer] printing_level - 0 = no printing | 1 = progress dots | 2 = debug level
Batch inserts randomly generated JSON data objects into an Elastic Search server.
Batch inserts randomly generated JSON data objects into an Elastic Search server .
def fire(how_many, starting_id, server_url, index, type, printing_level=0)
      ($stdout.sync = true) if printing_level == 1
      id = starting_id.to_i
      data = DataGenerator.new
      how_many.to_i.times do |i|
        insert_data = data.generate_random_insert_data
        (puts insert_data) if printing_level == 2
        response = HTTParty.put("#{server_url}/#{index}/#{type}/#{id}", body: insert_data) 
        (puts response.body) if printing_level == 2
        (print ".") if printing_level == 1
        id = id + 1
      end
    end
def fire ( how_many , starting_id , server_url , index , type , printing_level = 0 ) ( $stdout . sync = true ) if printing_level == 1 id = starting_id . to_i data = DataGenerator . new how_many . to_i . times do | i | insert_data = data . generate_random_insert_data ( puts insert_data ) if printing_level == 2 response = HTTParty . put ( "#{server_url}/#{index}/#{type}/#{id}" , body : insert_data ) ( puts response . body ) if printing_level == 2 ( print "." ) if printing_level == 1 id = id + 1 end end
Batch inserts randomly generated JSON data objects into an Elastic Search server.
Batch inserts randomly generated JSON data objects into an Elastic Search server .
# this will constantly flush the printing to the display so the progress dots appear for each insert # a unique ID must be provided for each document stored in Elastic Search # initialize the random data generator object # loop through inserting random data # generate a piece of random data to insert that approxiamates a tweet # insert the random data into local elastic search index "twitter" as type "tweet" with set id #increment the insert id
how_many
<not_specific>
starting_id
<not_specific>
server_url
<not_specific>
index
<not_specific>
type
<not_specific>
printing_level
<not_specific>
<not_specific>
0 = no printing | 1 = progress dots | 2 = debug level
0 = no printing | 1 = progress dots | 2 = debug level