Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix hex_random for v0.14 #148

Merged
merged 1 commit into from
Jun 30, 2016
Merged

fix hex_random for v0.14 #148

merged 1 commit into from
Jun 30, 2016

Conversation

sonots
Copy link
Member

@sonots sonots commented May 30, 2016

For fluent/fluentd#994
NameError: uninitialized constant Fluent::FileBufferChunk

Unifying logic of generating hex_random

Logic of generating hex_random was trivially changed. Now, the logic to generate hex_random was unified to get from chunk.unique_id. Before, it was generated from chunk.unique_id for FileBufferChunk and was generated from SecureRandom.hex for others.

Below is the list of how unique_id is generated. I analyzed that hex_random can be generated as unique_hex(chunk).reverse[0...@hex_random_length] for all of them with good randomness. So, I made codes common for all of them.

v0.12

FileBufferChunk

      now = Time.now.utc
      timestamp = ((now.to_i * 1000 * 1000 + now.usec) << 12 | rand(0xfff))
      tsuffix = timestamp.to_s(16)
      # why *2 ? frsyuki said that I forgot why completely.
      tsuffix.scan(/../).map {|x| x.to_i(16) }.pack('C*') * 2

MemoryBufferChunk

      now = Time.now.utc
      u1 = ((now.to_i * 1000 * 1000 + now.usec) << 12 | rand(0xfff))
      [u1 >> 32, u1 & 0xffffffff, rand(0xffffffff), rand(0xffffffff)].pack('NNNN')

LighteningBufferChunk

same with MemoryBufferChunk (as it extends MemoryBufferChunk)

v0.14

      now = Time.now.utc
      u1 = ((now.to_i * 1000 * 1000 + now.usec) << 12 | rand(0xfff))
      [u1 >> 32, u1 & 0xffffffff, rand(0xffffffff), rand(0xffffffff)].pack('NNNN')

@sonots
Copy link
Member Author

sonots commented May 31, 2016

tests failed, but seems not related with this commit.

@repeatedly repeatedly merged commit ab92ec3 into fluent:master Jun 30, 2016
@sonots sonots deleted the v0.14 branch June 30, 2016 05:59
ahsandar added a commit to ahsandar/google-fluentd that referenced this pull request Jan 18, 2018
Update `fluent-plugin-s3` to `0.8.4` as `0.6.8` causes `s3` upload issues as elaborated in fluent/fluent-plugin-s3#148
dhrupadb pushed a commit to GoogleCloudPlatform/google-fluentd that referenced this pull request Jan 19, 2018
Update `fluent-plugin-s3` to `0.8.4` as `0.6.8` causes `s3` upload issues as elaborated in fluent/fluent-plugin-s3#148
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants