Skip to content

Commit

Permalink
Parsing workers
Browse files Browse the repository at this point in the history
  • Loading branch information
cemsbr committed May 14, 2015
1 parent 397c446 commit 798b0ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sparklogstats/logparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class LogParser:
def __init__(self, filename):
self.start = -1
self.end = -1
self.workers = set()

self._parse_file(filename)

Expand All @@ -20,6 +21,8 @@ def _parse_json(self, json):
self.start = json["Timestamp"]
elif event == "SparkListenerApplicationEnd":
self.end = json["Timestamp"]
elif event == "SparkListenerExecutorAdded":
self.workers.add(json["Executor Info"]["Host"])

@property
def duration(self):
Expand Down
4 changes: 4 additions & 0 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ def test_total_time(self):
rounded_secs = round(log.duration / 1000)
self.assertEqual(rounded_secs, 33)

def test_worker_amount(self):
log = LogParser('app-20150427122457-0000')
self.assertEqual(len(log.workers), 2)


if __name__ == '__main__':
unittest.main()

0 comments on commit 798b0ff

Please sign in to comment.