Module brave

Class Platform


  • public abstract class Platform
    extends java.lang.Object
    Access to platform-specific features.

    Note: Logging is centralized here to avoid classloader problems.

    Originally designed by OkHttp team, derived from okhttp3.internal.platform.Platform

    • Constructor Summary

      Constructors 
      Constructor Description
      Platform()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      Clock clock()  
      static Platform get()  
      abstract java.lang.String getHostString​(java.net.InetSocketAddress socket)
      Guards InetSocketAddress.getHostString(), as it isn't available until Java 7
      java.lang.String linkLocalIp()  
      void log​(java.lang.String msg, java.lang.Object param1, java.lang.Throwable thrown)
      Like Logger.log(Level, String, Object), except with a throwable arg
      void log​(java.lang.String msg, java.lang.Throwable thrown)
      Like Logger.log(Level, String)
      abstract long nextTraceIdHigh()
      Returns the high 8-bytes for 128-bit trace IDs.
      abstract long randomLong()
      This class uses pseudo-random number generators to provision IDs.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Platform

        public Platform()
    • Method Detail

      • getHostString

        @Nullable
        public abstract java.lang.String getHostString​(java.net.InetSocketAddress socket)
        Guards InetSocketAddress.getHostString(), as it isn't available until Java 7
      • linkLocalIp

        @Nullable
        public java.lang.String linkLocalIp()
      • log

        public void log​(java.lang.String msg,
                        @Nullable
                        java.lang.Throwable thrown)
        Like Logger.log(Level, String)
      • log

        public void log​(java.lang.String msg,
                        java.lang.Object param1,
                        @Nullable
                        java.lang.Throwable thrown)
        Like Logger.log(Level, String, Object), except with a throwable arg
      • randomLong

        public abstract long randomLong()
        This class uses pseudo-random number generators to provision IDs.

        This optimizes speed over full coverage of 64-bits, which is why it doesn't share a SecureRandom. It will use ThreadLocalRandom unless used in JRE 6 which doesn't have the class.

      • nextTraceIdHigh

        public abstract long nextTraceIdHigh()
        Returns the high 8-bytes for 128-bit trace IDs.

        The upper 4-bytes are epoch seconds and the lower 4-bytes are random. This makes it convertible to Amazon X-Ray trace ID format v1.

      • clock

        public Clock clock()