Class: DLogReader::DistributedLogReader
- Inherits:
-
Object
- Object
- DLogReader::DistributedLogReader
- Defined in:
- lib/distributed_logreader/distributed_log_reader.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#distributer ⇒ Object
Returns the value of attribute distributer.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#log_reader ⇒ Object
readonly
Returns the value of attribute log_reader.
Instance Method Summary collapse
-
#initialize(filename, worker, num_threads = 100) ⇒ DistributedLogReader
constructor
A new instance of DistributedLogReader.
- #log_file ⇒ Object
-
#post_process ⇒ Object
predefined hooks.
-
#pre_process ⇒ Object
predefined hooks.
-
#process ⇒ Object
selector/archiver seem to be strongly connected.
Constructor Details
#initialize(filename, worker, num_threads = 100) ⇒ DistributedLogReader
Returns a new instance of DistributedLogReader.
11 12 13 14 15 |
# File 'lib/distributed_logreader/distributed_log_reader.rb', line 11 def initialize(filename, worker, num_threads = 100) self.filename = filename # self.distributer = SimpleForked.new(worker, 5, num_threads) self.distributer = SimpleThreadPool.new(worker, num_threads) end |
Instance Attribute Details
#distributer ⇒ Object
Returns the value of attribute distributer.
9 10 11 |
# File 'lib/distributed_logreader/distributed_log_reader.rb', line 9 def distributer @distributer end |
#filename ⇒ Object
Returns the value of attribute filename.
9 10 11 |
# File 'lib/distributed_logreader/distributed_log_reader.rb', line 9 def filename @filename end |
#log_reader ⇒ Object (readonly)
Returns the value of attribute log_reader.
10 11 12 |
# File 'lib/distributed_logreader/distributed_log_reader.rb', line 10 def log_reader @log_reader end |
Instance Method Details
#log_file ⇒ Object
34 35 36 |
# File 'lib/distributed_logreader/distributed_log_reader.rb', line 34 def log_file self.filename end |
#post_process ⇒ Object
predefined hooks
43 44 |
# File 'lib/distributed_logreader/distributed_log_reader.rb', line 43 def post_process end |
#pre_process ⇒ Object
predefined hooks
39 40 |
# File 'lib/distributed_logreader/distributed_log_reader.rb', line 39 def pre_process end |
#process ⇒ Object
selector/archiver seem to be strongly connected. it’s possible it needs to be moved into LogReader
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/distributed_logreader/distributed_log_reader.rb', line 19 def process pre_process $dlog_logger.info("Started #{log_file}:") lines_processed = 0 @log_reader = LogReader.new(log_file) do |line| self.distributer.process(line) lines_processed += 1 end @log_reader.run self.distributer.join $dlog_logger.info("Finished #{log_file}: Processed (#{lines_processed}) lines") post_process end |