Class: LogStash::Outputs::S3::TemporaryFileFactory
- Inherits:
-
Object
- Object
- LogStash::Outputs::S3::TemporaryFileFactory
- Defined in:
- lib/logstash/outputs/s3/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"
- 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.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/logstash/outputs/s3/temporary_file_factory.rb', line 26 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.
24 25 26 |
# File 'lib/logstash/outputs/s3/temporary_file_factory.rb', line 24 def counter @counter end |
#current ⇒ Object
Returns the value of attribute current.
24 25 26 |
# File 'lib/logstash/outputs/s3/temporary_file_factory.rb', line 24 def current @current end |
#encoding ⇒ Object
Returns the value of attribute encoding.
24 25 26 |
# File 'lib/logstash/outputs/s3/temporary_file_factory.rb', line 24 def encoding @encoding end |
#prefix ⇒ Object
Returns the value of attribute prefix.
24 25 26 |
# File 'lib/logstash/outputs/s3/temporary_file_factory.rb', line 24 def prefix @prefix end |
#tags ⇒ Object
Returns the value of attribute tags.
24 25 26 |
# File 'lib/logstash/outputs/s3/temporary_file_factory.rb', line 24 def @tags end |
#temporary_directory ⇒ Object
Returns the value of attribute temporary_directory.
24 25 26 |
# File 'lib/logstash/outputs/s3/temporary_file_factory.rb', line 24 def temporary_directory @temporary_directory end |
Instance Method Details
#rotate! ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/logstash/outputs/s3/temporary_file_factory.rb', line 38 def rotate! @lock.synchronize { @current = new_file increment_counter @current } end |