Tabnine Logo
TraceAndSpanIdGenerator.convertBytesToLong
Code IndexAdd Tabnine to your IDE (free)

How to use
convertBytesToLong
method
in
com.nike.wingtips.TraceAndSpanIdGenerator

Best Java code snippets using com.nike.wingtips.TraceAndSpanIdGenerator.convertBytesToLong (Showing top 4 results out of 315)

origin: Nike-Inc/wingtips

/**
 * @return A random long pulled from the full 64-bit random search space (as opposed to the 48 bits of randomness you get from
 *          {@link java.util.Random#nextLong()}).
 */
public static long generate64BitRandomLong() {
  byte[] random8Bytes = new byte[8];
  random.nextBytes(random8Bytes);
  return convertBytesToLong(random8Bytes);
}
origin: Nike-Inc/wingtips

@Test
public void convertBytesToLong_should_work_correctly_for_known_value() {
  // given: byte[] that maps to known long value
  final long EXPECTED_LONG_VALUE = 4242424242L;
  ByteBuffer buffer = ByteBuffer.allocate(Long.SIZE / 8);
  buffer.putLong(EXPECTED_LONG_VALUE);
  byte[] longAsByteArray = buffer.array();
  assertThat(longAsByteArray.length).isEqualTo(8);
  // when: convertBytesToLong() is called
  long returnVal = TraceAndSpanIdGenerator.convertBytesToLong(longAsByteArray);
  // then: the return value is what we expect
  assertThat(returnVal).isEqualTo(EXPECTED_LONG_VALUE);
}
origin: Nike-Inc/wingtips

@Test(expected = IllegalArgumentException.class)
public void convertBytesToLong_should_explode_if_byte_array_is_less_than_8_bytes() {
  byte[] badByteArray = new byte[]{0, 0, 0, 0, 0, 0, 1};
  assertThat(badByteArray.length).isLessThan(8);
  TraceAndSpanIdGenerator.convertBytesToLong(badByteArray);
  fail("Expected IllegalArgumentException but none was thrown");
}
origin: Nike-Inc/wingtips

@Test(expected = IllegalArgumentException.class)
public void convertBytesToLong_should_explode_if_byte_array_is_more_than_8_bytes() {
  byte[] badByteArray = new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 1};
  assertThat(badByteArray.length).isGreaterThan(8);
  TraceAndSpanIdGenerator.convertBytesToLong(badByteArray);
  fail("Expected IllegalArgumentException but none was thrown");
}
com.nike.wingtipsTraceAndSpanIdGeneratorconvertBytesToLong

Javadoc

Converts the given 8 bytes to a long value. Implementation for this taken from java.util.UUID#UUID(byte[]).

Popular methods of TraceAndSpanIdGenerator

  • generateId
  • longToUnsignedLowerHexString
  • unsignedLowerHexStringToLong
  • generate64BitRandomLong
  • getRandomInstance
    Tries to retrieve and return the SecureRandom with the given implementation using SecureRandom#getIn

Popular in Java

  • Finding current android device location
  • onRequestPermissionsResult (Fragment)
  • setRequestProperty (URLConnection)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • JLabel (javax.swing)
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now