class Embulk::Input::ApacheDummyLogInputPlugin
Constants
- AGENT_LIST
- AGENT_LIST_STRING
- HOSTS
- PAGES
- PAGE_CATEGORIES
- RANDOM
- RECORDS
Public Class Methods
resume(task, columns, count) { |task, columns, count| ... }
click to toggle source
# File lib/embulk/input/apache-dummy-log.rb, line 187 def self.resume(task, columns, count, &control) commit_reports = yield(task, columns, count) next_config_diff = {} return next_config_diff end
transaction(config, &control)
click to toggle source
# File lib/embulk/input/apache-dummy-log.rb, line 164 def self.transaction(config, &control) # configuration code: task = { "size" => config.param("size", :integer, default: 100), } columns = [ Column.new(0, "remote_host", :string), Column.new(1, "identity_check", :string), Column.new(2, "user", :string), Column.new(3, "datetime", :timestamp), Column.new(4, "method", :string), Column.new(5, "path", :string), Column.new(6, "protocol", :string), Column.new(7, "status", :long), Column.new(8, "size", :long), Column.new(9, "referer", :string), Column.new(10,"user_agent", :string) ] resume(task, columns, 1, &control) end
Public Instance Methods
grand(n)
click to toggle source
# File lib/embulk/input/apache-dummy-log.rb, line 213 def grand(n) RANDOM.rand(n) end
init()
click to toggle source
# File lib/embulk/input/apache-dummy-log.rb, line 194 def init # initialization code: @size = @task["size"] @ip = "#{(grand(210)+20)/4*4}.#{(grand(210)+20)/3*3}.#{grand(210)+20}.#{grand(210)+20}" @agents = [] @pages = [] @size.times do @pages << Page.new end @hosts = [] HOSTS.times do @hosts << Host.new end end
run()
click to toggle source
# File lib/embulk/input/apache-dummy-log.rb, line 217 def run now = Time.now.to_i @size.times do now += grand(5) page = @pages[grand(@pages.size)] host = @hosts[grand(@hosts.size)] record = [ host.ip, # remote_host '-', # identity_check '-', # user Time.new, # datetime page.method, # method page.path, # path 'HTTP/1.1', # protocol grand(10000) == 0 ? 500 : page.code, # status page.size, # page.size (grand(2) == 0 ? @pages[grand(@pages.size)].path : page.referer) || '-', # referer host.agent, # agent ] page_builder.add(record) end page_builder.finish commit_report = {} return commit_report end