Class: LogStash::Outputs::Swift::TemporaryFileFactory
- Inherits:
-
Object
- Object
- LogStash::Outputs::Swift::TemporaryFileFactory
- Defined in:
- lib/logstash/outputs/swift/temporary_file_factory.rb
Overview
Since the file can contains dynamic part, we have to handle a more local structure to allow a nice recovery from a crash.
The local structure will look like this.
<TEMPORARY_PATH>/<UUID>/<prefix>/ls.s3.localhost.%Y-%m-%dT%H.%m.tag_es_fb.part1.txt.gz
Since the UUID should be fairly unique I can destroy the whole path when an upload is complete. I do not have to mess around to check if the other directory have file in it before destroying them.
Defined Under Namespace
Classes: IOWrappedGzip
Constant Summary collapse
- FILE_MODE =
"a"
- GZIP_ENCODING =
"gzip"
- GZIP_EXTENSION =
"txt.gz"
- TXT_EXTENSION =
"txt"
- STRFTIME =
"%Y-%m-%dT%H.%M"
Instance Attribute Summary collapse
-
#counter ⇒ Object
Returns the value of attribute counter.
-
#current ⇒ Object
Returns the value of attribute current.
-
#encoding ⇒ Object
Returns the value of attribute encoding.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#temporary_directory ⇒ Object
Returns the value of attribute temporary_directory.
Instance Method Summary collapse
-
#initialize(prefix, tags, encoding, temporary_directory) ⇒ TemporaryFileFactory
constructor
A new instance of TemporaryFileFactory.
- #rotate! ⇒ Object
Constructor Details
#initialize(prefix, tags, encoding, temporary_directory) ⇒ TemporaryFileFactory
Returns a new instance of TemporaryFileFactory.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/logstash/outputs/swift/temporary_file_factory.rb', line 29 def initialize(prefix, , encoding, temporary_directory) @counter = 0 @prefix = prefix @tags = @encoding = encoding @temporary_directory = temporary_directory @lock = Mutex.new rotate! end |
Instance Attribute Details
#counter ⇒ Object
Returns the value of attribute counter.
27 28 29 |
# File 'lib/logstash/outputs/swift/temporary_file_factory.rb', line 27 def counter @counter end |
#current ⇒ Object
Returns the value of attribute current.
27 28 29 |
# File 'lib/logstash/outputs/swift/temporary_file_factory.rb', line 27 def current @current end |
#encoding ⇒ Object
Returns the value of attribute encoding.
27 28 29 |
# File 'lib/logstash/outputs/swift/temporary_file_factory.rb', line 27 def encoding @encoding end |
#prefix ⇒ Object
Returns the value of attribute prefix.
27 28 29 |
# File 'lib/logstash/outputs/swift/temporary_file_factory.rb', line 27 def prefix @prefix end |
#tags ⇒ Object
Returns the value of attribute tags.
27 28 29 |
# File 'lib/logstash/outputs/swift/temporary_file_factory.rb', line 27 def @tags end |
#temporary_directory ⇒ Object
Returns the value of attribute temporary_directory.
27 28 29 |
# File 'lib/logstash/outputs/swift/temporary_file_factory.rb', line 27 def temporary_directory @temporary_directory end |
Instance Method Details
#rotate! ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/logstash/outputs/swift/temporary_file_factory.rb', line 41 def rotate! @lock.synchronize { @current = new_file increment_counter @current } end |