kafka.utils

Utils

object Utils extends Logging

Helper functions!

Inherited
  1. Hide All
  2. Show all
  1. Logging
  2. AnyRef
  3. Any
Visibility
  1. Public
  2. All

Value Members

  1. def !=(arg0: AnyRef): Boolean

    attributes: final
    definition classes: AnyRef
  2. def !=(arg0: Any): Boolean

    o != arg0 is the same as !(o == (arg0)).

    o != arg0 is the same as !(o == (arg0)).

    arg0

    the object to compare against this object for dis-equality.

    returns

    false if the receiver object is equivalent to the argument; true otherwise.

    attributes: final
    definition classes: Any
  3. def ##(): Int

    attributes: final
    definition classes: AnyRef → Any
  4. def $asInstanceOf[T0](): T0

    attributes: final
    definition classes: AnyRef
  5. def $isInstanceOf[T0](): Boolean

    attributes: final
    definition classes: AnyRef
  6. def ==(arg0: AnyRef): Boolean

    o == arg0 is the same as if (o eq null) arg0 eq null else o.equals(arg0).

    o == arg0 is the same as if (o eq null) arg0 eq null else o.equals(arg0).

    arg0

    the object to compare against this object for equality.

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

    attributes: final
    definition classes: AnyRef
  7. def ==(arg0: Any): Boolean

    o == arg0 is the same as o.equals(arg0).

    o == arg0 is the same as o.equals(arg0).

    arg0

    the object to compare against this object for equality.

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

    attributes: final
    definition classes: Any
  8. def asInstanceOf[T0]: T0

    This method is used to cast the receiver object to be of type T0.

    This method is used to cast the receiver object to be of type T0.

    Note that the success of a cast at runtime is modulo Scala's erasure semantics. Therefore the expression1.asInstanceOf[String] will throw a ClassCastException at runtime, while the expressionList(1).asInstanceOf[List[String]] will not. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the requested typed.

    returns

    the receiver object.

    attributes: final
    definition classes: Any
  9. def checkRequiredArgs(parser: OptionParser, options: OptionSet, required: joptsimple.OptionSpec[_]*): Unit

  10. def circularIterator[T](coll: Iterable[T]): Iterator[T]

    Create a circular (looping) iterator over a collection.

    Create a circular (looping) iterator over a collection.

    coll

    An iterable over the underlying collection.

    returns

    A circular iterator over the collection.

  11. def clone(): AnyRef

    This method creates and returns a copy of the receiver object.

    This method creates and returns a copy of the receiver object.

    The default implementation of the clone method is platform dependent.

    returns

    a copy of the receiver object.

    attributes: protected
    definition classes: AnyRef
  12. def crc32(bytes: Array[Byte], offset: Int, size: Int): Long

    Compute the CRC32 of the segment of the byte array given by the specificed size and offset

    Compute the CRC32 of the segment of the byte array given by the specificed size and offset

    bytes

    The bytes to checksum

    returns

    The CRC32

  13. def crc32(bytes: Array[Byte]): Long

    Compute the CRC32 of the byte array

    Compute the CRC32 of the byte array

    bytes

    The array to compute the checksum for

    returns

    The CRC32

  14. def croak(message: String): Unit

    Print an error message and shutdown the JVM

    Print an error message and shutdown the JVM

    message

    The error message

  15. def daemonThread(name: String, fun: () ⇒ Unit): Thread

    Create a daemon thread

    Create a daemon thread

    name

    The name of the thread

    fun

    The runction to execute in the thread

    returns

    The unstarted thread

  16. def daemonThread(name: String, runnable: Runnable): Thread

    Create a daemon thread

    Create a daemon thread

    name

    The name of the thread

    runnable

    The runnable to execute in the background

    returns

    The unstarted thread

  17. def debug(msg: ⇒ String, e: ⇒ Throwable): Unit

    definition classes: Logging
  18. def debug(e: ⇒ Throwable): Any

    definition classes: Logging
  19. def debug(msg: ⇒ String): Unit

    definition classes: Logging
  20. def eq(arg0: AnyRef): Boolean

    This method is used to test whether the argument (arg0) is a reference to the receiver object (this).

    This method is used to test whether the argument (arg0) is a reference to the receiver object (this).

    The eq method implements an [http://en.wikipedia.org/wiki/Equivalence_relation equivalence relation] on non-null instances of AnyRef: * It is reflexive: for any non-null instance x of type AnyRef, x.eq(x) returns true. * It is symmetric: for any non-null instances x and y of type AnyRef, x.eq(y) returns true if and only if y.eq(x) returns true. * It is transitive: for any non-null instances x, y, and z of type AnyRef if x.eq(y) returns true and y.eq(z) returns true, then x.eq(z) returns true.

    Additionally, the eq method has three other properties. * It is consistent: for any non-null instances x and y of type AnyRef, multiple invocations of x.eq(y) consistently returns true or consistently returns false. * For any non-null instance x of type AnyRef, x.eq(null) and null.eq(x) returns false. * null.eq(null) returns true.

    When overriding the equals or hashCode methods, it is important to ensure that their behavior is consistent with reference equality. Therefore, if two objects are references to each other (o1 eq o2), they should be equal to each other (o1 == o2) and they should hash to the same value (o1.hashCode == o2.hashCode).

    arg0

    the object to compare against this object for reference equality.

    returns

    true if the argument is a reference to the receiver object; false otherwise.

    attributes: final
    definition classes: AnyRef
  21. def equal(b1: ByteBuffer, b2: ByteBuffer): Boolean

    Test if two byte buffers are equal.

    Test if two byte buffers are equal. In this case equality means having the same bytes from the current position to the limit

  22. def equals(arg0: Any): Boolean

    This method is used to compare the receiver object (this) with the argument object (arg0) for equivalence.

    This method is used to compare the receiver object (this) with the argument object (arg0) for equivalence.

    The default implementations of this method is an [http://en.wikipedia.org/wiki/Equivalence_relation equivalence relation]: * It is reflexive: for any instance x of type Any, x.equals(x) should return true. * It is symmetric: for any instances x and y of type Any, x.equals(y) should return true if and only if y.equals(x) returns true. * It is transitive: for any instances x, y, and z of type AnyRef if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.

    If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is often necessary to override hashCode to ensure that objects that are "equal" (o1.equals(o2) returns true) hash to the same scala.Int (o1.hashCode.equals(o2.hashCode)).

    arg0

    the object to compare against this object for equality.

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

    definition classes: AnyRef → Any
  23. def error(msg: ⇒ String, e: ⇒ Throwable): Unit

    definition classes: Logging
  24. def error(e: ⇒ Throwable): Any

    definition classes: Logging
  25. def error(msg: ⇒ String): Unit

    definition classes: Logging
  26. def fatal(msg: ⇒ String, e: ⇒ Throwable): Unit

    definition classes: Logging
  27. def fatal(e: ⇒ Throwable): Any

    definition classes: Logging
  28. def fatal(msg: ⇒ String): Unit

    definition classes: Logging
  29. def finalize(): Unit

    This method is called by the garbage collector on the receiver object when garbage collection determines that there are no more references to the object.

    This method is called by the garbage collector on the receiver object when garbage collection determines that there are no more references to the object.

    The details of when and if the finalize method are invoked, as well as the interaction between finalizeand non-local returns and exceptions, are all platform dependent.

    attributes: protected
    definition classes: AnyRef
  30. def getBoolean(props: Properties, name: String, default: Boolean): Boolean

    Read a boolean value from the properties instance

    Read a boolean value from the properties instance

    props

    The properties to read from

    name

    The property name

    default

    The default value to use if the property is not found

    returns

    the boolean value

  31. def getCSVList(csvList: String): Seq[String]

  32. def getClass(): java.lang.Class[_]

    Returns a representation that corresponds to the dynamic class of the receiver object.

    Returns a representation that corresponds to the dynamic class of the receiver object.

    The nature of the representation is platform dependent.

    returns

    a representation that corresponds to the dynamic class of the receiver object.

    attributes: final
    definition classes: AnyRef
  33. def getCompressionCodec(props: Properties, codec: String): CompressionCodec

  34. def getConsumerTopicMap(consumerTopicString: String): Map[String, Int]

  35. def getHostPort(hostport: String): (String, Int)

  36. def getInt(props: Properties, name: String, default: Int): Int

    Read an integer from the properties instance

    Read an integer from the properties instance

    props

    The properties to read from

    name

    The property name

    default

    The default value to use if the property is not found

    returns

    the integer value

  37. def getInt(props: Properties, name: String): Int

    Read a required integer property value or throw an exception if no such property is found

    Read a required integer property value or throw an exception if no such property is found

  38. def getIntInRange(props: Properties, name: String, default: Int, range: (Int, Int)): Int

    Read an integer from the properties instance.

    Read an integer from the properties instance. Throw an exception if the value is not in the given range (inclusive)

    props

    The properties to read from

    name

    The property name

    default

    The default value to use if the property is not found

    range

    The range in which the value must fall (inclusive)

    returns

    the integer value

  39. def getLong(props: Properties, name: String, default: Long): Long

    Read an long from the properties instance

    Read an long from the properties instance

    props

    The properties to read from

    name

    The property name

    default

    The default value to use if the property is not found

    returns

    the long value

  40. def getLong(props: Properties, name: String): Long

    Read a required long property value or throw an exception if no such property is found

    Read a required long property value or throw an exception if no such property is found

  41. def getLongInRange(props: Properties, name: String, default: Long, range: (Long, Long)): Long

    Read an long from the properties instance.

    Read an long from the properties instance. Throw an exception if the value is not in the given range (inclusive)

    props

    The properties to read from

    name

    The property name

    default

    The default value to use if the property is not found

    range

    The range in which the value must fall (inclusive)

    returns

    the long value

  42. def getObject[T <: AnyRef](className: String): T

  43. def getProps(props: Properties, name: String, default: Properties): Properties

    Get a property of type java.

    Get a property of type java.util.Properties or return the default if no such property is defined

  44. def getProps(props: Properties, name: String): Properties

    Get a property of type java.

    Get a property of type java.util.Properties or throw and exception if no such property is defined.

  45. def getString(props: Properties, name: String): String

    Get a string property or throw and exception if no such property is defined.

    Get a string property or throw and exception if no such property is defined.

  46. def getString(props: Properties, name: String, default: String): String

    Get a string property, or, if no such property is defined, return the given default value

    Get a string property, or, if no such property is defined, return the given default value

  47. def getTopicFlushIntervals(allIntervals: String): Map[String, Int]

  48. def getTopicPartition(topicPartition: String): (String, Int)

  49. def getTopicPartitions(allPartitions: String): Map[String, Int]

  50. def getTopicRentionHours(retentionHours: String): Map[String, Int]

  51. def getUnsignedInt(buffer: ByteBuffer, index: Int): Long

    Read an unsigned integer from the given position without modifying the buffers position

    Read an unsigned integer from the given position without modifying the buffers position

    index

    the index from which to read the integer

    returns

    The integer read, as a long to avoid signedness

  52. def getUnsignedInt(buffer: ByteBuffer): Long

    Read an unsigned integer from the current position in the buffer, incrementing the position by 4 bytes

    Read an unsigned integer from the current position in the buffer, incrementing the position by 4 bytes

    returns

    The integer read, as a long to avoid signedness

  53. def groupby[K, V](vals: Iterable[V], f: (V) ⇒ K): Map[K, List[V]]

    Group the given values by keys extracted with the given function

    Group the given values by keys extracted with the given function

  54. def hashCode(): Int

    Returns a hash code value for the object.

    Returns a hash code value for the object.

    The default hashing algorithm is platform dependent.

    Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.

    returns

    the hash code value for the object.

    definition classes: AnyRef → Any
  55. def hashcode(as: Any*): Int

    Compute the hash code for the given items

    Compute the hash code for the given items

  56. def info(msg: ⇒ String, e: ⇒ Throwable): Unit

    definition classes: Logging
  57. def info(e: ⇒ Throwable): Any

    definition classes: Logging
  58. def info(msg: ⇒ String): Unit

    definition classes: Logging
  59. def isInstanceOf[T0]: Boolean

    This method is used to test whether the dynamic type of the receiver object is T0.

    This method is used to test whether the dynamic type of the receiver object is T0.

    Note that the test result of the test is modulo Scala's erasure semantics. Therefore the expression1.isInstanceOf[String] will return false, while the expression List(1).isInstanceOf[List[String]] will return true. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the requested typed.

    returns

    true if the receiver object is an instance of erasure of type T0; false otherwise.

    attributes: final
    definition classes: Any
  60. def loadProps(filename: String): Properties

    Read a properties file from the given path

    Read a properties file from the given path

    filename

    The path of the file to read

  61. var logIdent: String

    attributes: protected
    definition classes: Logging
  62. def loggedRunnable(fun: () ⇒ Unit): Runnable

    Wrap the given function in a java.

    Wrap the given function in a java.lang.Runnable that logs any errors encountered

    fun

    A function

    returns

    A Runnable that just executes the function

  63. lazy val logger: Logger

    definition classes: Logging
  64. val loggerName: String

    definition classes: Logging
  65. def ne(arg0: AnyRef): Boolean

    o.ne(arg0) is the same as !(o.eq(arg0)).

    o.ne(arg0) is the same as !(o.eq(arg0)).

    arg0

    the object to compare against this object for reference dis-equality.

    returns

    false if the argument is not a reference to the receiver object; true otherwise.

    attributes: final
    definition classes: AnyRef
  66. def newThread(name: String, runnable: Runnable, daemon: Boolean): Thread

    Create a new thread

    Create a new thread

    name

    The name of the thread

    runnable

    The work for the thread to do

    daemon

    Should the thread block JVM shutdown?

    returns

    The unstarted thread

  67. def notNull[V](v: V): V

  68. def notify(): Unit

    Wakes up a single thread that is waiting on the receiver object's monitor.

    Wakes up a single thread that is waiting on the receiver object's monitor.

    attributes: final
    definition classes: AnyRef
  69. def notifyAll(): Unit

    Wakes up all threads that are waiting on the receiver object's monitor.

    Wakes up all threads that are waiting on the receiver object's monitor.

    attributes: final
    definition classes: AnyRef
  70. def openChannel(file: File, mutable: Boolean): FileChannel

    Open a channel for the given file

    Open a channel for the given file

  71. def propertyExists(prop: String): Boolean

  72. def putUnsignedInt(buffer: ByteBuffer, index: Int, value: Long): Unit

    Write the given long value as a 4 byte unsigned integer.

    Write the given long value as a 4 byte unsigned integer. Overflow is ignored.

    buffer

    The buffer to write to

    index

    The position in the buffer at which to begin writing

    value

    The value to write

  73. def putUnsignedInt(buffer: ByteBuffer, value: Long): Unit

    Write the given long value as a 4 byte unsigned integer.

    Write the given long value as a 4 byte unsigned integer. Overflow is ignored.

    buffer

    The buffer to write to

    value

    The value to write

  74. def read(channel: ReadableByteChannel, buffer: ByteBuffer): Int

    Read some bytes into the provided buffer, and return the number of bytes read.

    Read some bytes into the provided buffer, and return the number of bytes read. If the channel has been closed or we get -1 on the read for any reason, throw an EOFException

  75. def readBytes(buffer: ByteBuffer, offset: Int, size: Int): Array[Byte]

    Read a byte array from the given offset and size in the buffer TODO: Should use System.

    Read a byte array from the given offset and size in the buffer TODO: Should use System.arraycopy

  76. def readShortString(buffer: ByteBuffer, encoding: String): String

    Read size prefixed string where the size is stored as a 2 byte short.

    Read size prefixed string where the size is stored as a 2 byte short.

    buffer

    The buffer to read from

    encoding

    The encoding in which to read the string

  77. def registerMBean(mbean: AnyRef, name: String): Boolean

    Register the given mbean with the platform mbean server, unregistering any mbean that was there before.

    Register the given mbean with the platform mbean server, unregistering any mbean that was there before. Note, this method will not throw an exception if the registration fails (since there is nothing you can do and it isn't fatal), instead it just returns false indicating the registration failed.

    mbean

    The object to register as an mbean

    name

    The name to register this mbean with

  78. def rm(file: File): Unit

    Recursively delete the given file/directory and any subfiles (if any exist)

    Recursively delete the given file/directory and any subfiles (if any exist)

    file

    The root file at which to begin deleting

  79. def rm(file: String): Unit

    Recursively delete the given file/directory and any subfiles (if any exist)

    Recursively delete the given file/directory and any subfiles (if any exist)

    file

    The root file at which to begin deleting

  80. def runnable(fun: () ⇒ Unit): Runnable

    Wrap the given function in a java.

    Wrap the given function in a java.lang.Runnable

    fun

    A function

    returns

    A Runnable that just executes the function

  81. def stackTrace(e: Throwable): String

  82. def swallow(log: (AnyRef, Throwable) ⇒ Unit, action: ⇒ Unit): Unit

    Do the given action and log any exceptions thrown without rethrowing them

    Do the given action and log any exceptions thrown without rethrowing them

    log

    The log method to use for logging. E.g. logger.warn

    action

    The action to execute

  83. def synchronized[T0](arg0: T0): T0

    attributes: final
    definition classes: AnyRef
  84. def toString(buffer: ByteBuffer, encoding: String): String

    Translate the given buffer into a string

    Translate the given buffer into a string

    buffer

    The buffer to translate

    encoding

    The encoding to use in translating bytes to characters

  85. def toString(): String

    Returns a string representation of the object.

    Returns a string representation of the object.

    The default representation is platform dependent.

    returns

    a string representation of the object.

    definition classes: AnyRef → Any
  86. def trace(msg: ⇒ String, e: ⇒ Throwable): Unit

    definition classes: Logging
  87. def trace(e: ⇒ Throwable): Any

    definition classes: Logging
  88. def trace(msg: ⇒ String): Unit

    definition classes: Logging
  89. def tryCleanupZookeeper(zkUrl: String, groupId: String): Unit

  90. def unregisterMBean(name: String): Unit

    Unregister the mbean with the given name, if there is one registered

    Unregister the mbean with the given name, if there is one registered

    name

    The mbean name to unregister

  91. def wait(): Unit

    attributes: final
    definition classes: AnyRef
  92. def wait(arg0: Long, arg1: Int): Unit

    attributes: final
    definition classes: AnyRef
  93. def wait(arg0: Long): Unit

    attributes: final
    definition classes: AnyRef
  94. def warn(msg: ⇒ String, e: ⇒ Throwable): Unit

    definition classes: Logging
  95. def warn(e: ⇒ Throwable): Any

    definition classes: Logging
  96. def warn(msg: ⇒ String): Unit

    definition classes: Logging
  97. def writeShortString(buffer: ByteBuffer, string: String, encoding: String): Unit

    Write a size prefixed string where the size is stored as a 2 byte short

    Write a size prefixed string where the size is stored as a 2 byte short

    buffer

    The buffer to write to

    string

    The string to write

    encoding

    The encoding in which to write the string