-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sahil Suneja <sahilsuneja@gmail.com>
- Loading branch information
1 parent
d74c595
commit e536c55
Showing
17 changed files
with
311 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import cStringIO | ||
from yapsy.IPlugin import IPlugin | ||
from formatters import (write_in_csv_format, | ||
write_in_json_format, | ||
write_in_graphite_format) | ||
from utils.crawler_exceptions import (EmitterUnsupportedFormat) | ||
|
||
|
||
class IEmitter(IPlugin): | ||
|
||
""" | ||
Base emitter class from which emitters like FileEmitter, StdoutEmitter | ||
should inherit. The main idea is that all emitters get a url, and should | ||
implement an emit() function given an iostream (a buffer with the features | ||
to emit). | ||
""" | ||
|
||
def init(self, url, timeout=1, max_retries=5, emit_format='csv'): | ||
self.url = url | ||
self.timeout = timeout | ||
self.max_retries = max_retries | ||
self.emit_per_line = False | ||
|
||
self.supported_formats = {'csv': write_in_csv_format, | ||
'graphite': write_in_graphite_format, | ||
'json': write_in_json_format} | ||
|
||
if emit_format in self.supported_formats: | ||
self.formatter = self.supported_formats[emit_format] | ||
else: | ||
raise EmitterUnsupportedFormat('Not supported: %s' % emit_format) | ||
|
||
def get_emitter_protocol(self): | ||
raise NotImplementedError() | ||
|
||
def format(self, frame): | ||
# this writes the frame metadata and data into iostream | ||
# Pass iostream to the emitters so they can send its content to their | ||
# respective url | ||
iostream = cStringIO.StringIO() | ||
self.formatter(iostream, frame) | ||
return iostream | ||
|
||
def emit(self, frame, compress=False, | ||
metadata={}, snapshot_num=0): | ||
""" | ||
:param iostream: a CStringIO used to buffer the formatted features. | ||
:param compress: | ||
:param metadata: | ||
:param snapshot_num: | ||
:return: | ||
""" | ||
# this formats and emits an input frame | ||
raise NotImplementedError() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[Core] | ||
Name = File Emitter | ||
Module = file_emitter | ||
|
||
[Documentation] | ||
Author = IBM | ||
Version = 0.1 | ||
Description = Plugin to emit frame to file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[Core] | ||
Name = Http Emitter | ||
Module = http_emitter | ||
|
||
[Documentation] | ||
Author = IBM | ||
Version = 0.1 | ||
Description = Plugin to post frame data to http server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[Core] | ||
Name = Kafka Emitter | ||
Module = kafka_emitter | ||
|
||
[Documentation] | ||
Author = IBM | ||
Version = 0.1 | ||
Description = Plugin to emit frame over kafka |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[Core] | ||
Name = MTGraphite Emitter | ||
Module = mtgraphite_emitter | ||
|
||
[Documentation] | ||
Author = IBM | ||
Version = 0.1 | ||
Description = Plugin to emit frame to MTGraphite server |
Oops, something went wrong.