org.apache.cassandra.utils

## Class FBUtilities

- java.lang.Object
- - org.apache.cassandra.utils.FBUtilities

    public class FBUtilities
    extends java.lang.Object

### Field Summary

Fields
`static int` `MAX_UNSIGNED_SHORT`
`static java.math.BigInteger` `TWO`

### Constructor Summary

Constructors
Constructor and Description
`FBUtilities()`

### Method Summary

All Methods Static Methods Concrete Methods
`static long` `abs(long index)`
`static java.io.File` `cassandraTriggerDir()`
`static <T> java.lang.Class<T>` `classForName(java.lang.String classname, java.lang.String readable)`
`static <T> CloseableIterator<T>` `closeableIterator(java.util.Iterator<T> iterator)`
`static int` `compareUnsigned(byte[] bytes1, byte[] bytes2)`
`static int` `compareUnsigned(byte[] bytes1, byte[] bytes2, int offset1, int offset2, int len1, int len2)`
`static <T> T` `construct(java.lang.String classname, java.lang.String readable)` Constructs an instance of the given class, which must have a no-arg or default constructor.
`static long` `copy(java.io.InputStream from, java.io.OutputStream to, long limit)`
`static void` `directCheckSum(java.util.zip.Adler32 checksum, java.nio.ByteBuffer bb)`
`static void` `exec(java.lang.ProcessBuilder pb)` Starts and waits for the given @param pb to finish.
`static java.util.List<java.lang.String>` `fromJsonList(java.lang.String json)`
`static java.util.Map<java.lang.String,java.lang.String>` `fromJsonMap(java.lang.String json)`
`static java.util.Collection<java.net.InetAddress>` `getAllLocalAddresses()`
`static int` `getAvailableProcessors()`
`static java.net.InetAddress` `getBroadcastAddress()`
`static java.net.InetAddress` `getBroadcastRpcAddress()`
`static java.net.InetAddress` `getLocalAddress()` Please use getBroadcastAddress instead.
`static java.lang.String` `getNetworkInterface(java.net.InetAddress localAddress)`
`static java.lang.reflect.Field` `getProtectedField(java.lang.Class klass, java.lang.String fieldName)` Used to get access to protected/private field of the specified class
`static java.lang.String` `getReleaseVersionString()`
`static byte[]` `getThreadLocalScratchBuffer()`
`static java.io.File` `getToolsOutputDirectory()`
`static byte[]` `hash(java.nio.ByteBuffer... data)`
`static java.math.BigInteger` `hashToBigInteger(java.nio.ByteBuffer data)`
`static boolean` `hasProcFS()`
`static <T> T` `instanceOrConstruct(java.lang.String classname, java.lang.String readable)` Constructs an instance of the given class, which must have a no-arg or default constructor.
`static boolean` `isWindows()`
`static java.lang.String` `json(java.lang.Object object)`
`static Pair<java.math.BigInteger,java.lang.Boolean>` `midpoint(java.math.BigInteger left, java.math.BigInteger right, int sigbits)` Given two bit arrays represented as BigIntegers, containing the given number of significant bits, calculate a midpoint.
`static IAuthenticator` `newAuthenticator(java.lang.String className)`
`static IAuthorizer` `newAuthorizer(java.lang.String className)`
`static java.security.MessageDigest` `newMessageDigest(java.lang.String algorithm)`
`static IPartitioner` `newPartitioner(java.lang.String partitionerClassName)`
`static IRoleManager` `newRoleManager(java.lang.String className)`
`static java.lang.String` `prettyPrintMemory(long size)`
`protected static void` `reset()`
`static java.lang.String` `resourceToFile(java.lang.String filename)`
`static <T> byte[]` `serialize(T object, IVersionedSerializer<T> serializer, int version)`
`static <T> java.util.SortedSet<T>` `singleton(T column, java.util.Comparator<? super T> comparator)`
`static void` `sortSampledKeys(java.util.List<DecoratedKey> keys, Range<Token> range)`
`static boolean` `supportsDirectChecksum()`
`static java.security.MessageDigest` `threadLocalMD5Digest()`
`static long` `timestampMicros()`
`static java.lang.String` `toString(java.util.Map<?,?> map)` Make straing out of the given `Map`.
`static byte[]` `toWriteUTFBytes(java.lang.String s)`
`static void` `updateChecksumInt(java.util.zip.Checksum checksum, int v)`
`static void` `updateWithByte(java.security.MessageDigest digest, int val)`
`static void` `updateWithInt(java.security.MessageDigest digest, int val)`
`static void` `updateWithLong(java.security.MessageDigest digest, long val)`
`static void` `updateWithShort(java.security.MessageDigest digest, int val)`
`static <T> T` `waitOnFuture(java.util.concurrent.Future<T> future)`
`static <T> java.util.List<T>` `waitOnFutures(java.lang.Iterable<? extends java.util.concurrent.Future<? extends T>> futures)`
`static void` `waitOnFutures(java.util.List<AsyncOneResponse> results, long ms)`
`static byte[]` `xor(byte[] left, byte[] right)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### TWO

    public static final java.math.BigInteger TWO

#### MAX_UNSIGNED_SHORT

    public static final int MAX_UNSIGNED_SHORT

See Also:
  Constant Field Values

### Constructor Detail

#### FBUtilities

    public FBUtilities()

### Method Detail

#### getAvailableProcessors

    public static int getAvailableProcessors()

#### threadLocalMD5Digest

    public static java.security.MessageDigest threadLocalMD5Digest()

#### newMessageDigest

    public static java.security.MessageDigest newMessageDigest(java.lang.String algorithm)

#### getLocalAddress

    public static java.net.InetAddress getLocalAddress()

Please use getBroadcastAddress instead. You need this only when you have to listen/connect.

#### getBroadcastAddress

    public static java.net.InetAddress getBroadcastAddress()

#### getBroadcastRpcAddress

    public static java.net.InetAddress getBroadcastRpcAddress()

#### getAllLocalAddresses

    public static java.util.Collection<java.net.InetAddress> getAllLocalAddresses()

#### getNetworkInterface

    public static java.lang.String getNetworkInterface(java.net.InetAddress localAddress)

#### midpoint

    public static Pair<java.math.BigInteger,java.lang.Boolean> midpoint(java.math.BigInteger left,
                                                                        java.math.BigInteger right,
                                                                        int sigbits)

Given two bit arrays represented as BigIntegers, containing the given number of significant bits, calculate a midpoint.

Parameters:
  `left` - The left point.
  `right` - The right point.
  `sigbits` - The number of bits in the points that are significant.
Returns:
  A midpoint that will compare bitwise halfway between the params, and a boolean representing whether a non-zero lsbit remainder was generated.

#### compareUnsigned

    public static int compareUnsigned(byte[] bytes1,
                                      byte[] bytes2,
                                      int offset1,
                                      int offset2,
                                      int len1,
                                      int len2)

#### compareUnsigned

    public static int compareUnsigned(byte[] bytes1,
                                      byte[] bytes2)

#### xor

    public static byte[] xor(byte[] left,
                             byte[] right)

Returns:
  The bitwise XOR of the inputs. The output will be the same length as the longer input, but if either input is null, the output will be null.

#### hash

    public static byte[] hash(java.nio.ByteBuffer... data)

#### hashToBigInteger

    public static java.math.BigInteger hashToBigInteger(java.nio.ByteBuffer data)

#### sortSampledKeys

    public static void sortSampledKeys(java.util.List<DecoratedKey> keys,
                                       Range<Token> range)

#### resourceToFile

    public static java.lang.String resourceToFile(java.lang.String filename)
                                           throws ConfigurationException

Throws:
  `ConfigurationException`

#### cassandraTriggerDir

    public static java.io.File cassandraTriggerDir()

#### getReleaseVersionString

    public static java.lang.String getReleaseVersionString()

#### timestampMicros

    public static long timestampMicros()

#### waitOnFutures

    public static <T> java.util.List<T> waitOnFutures(java.lang.Iterable<? extends java.util.concurrent.Future<? extends T>> futures)

#### waitOnFuture

    public static <T> T waitOnFuture(java.util.concurrent.Future<T> future)

#### waitOnFutures

    public static void waitOnFutures(java.util.List<AsyncOneResponse> results,
                                     long ms)
                              throws java.util.concurrent.TimeoutException

Throws:
  `java.util.concurrent.TimeoutException`

#### newPartitioner

    public static IPartitioner newPartitioner(java.lang.String partitionerClassName)
                                       throws ConfigurationException

Throws:
  `ConfigurationException`

#### newAuthorizer

    public static IAuthorizer newAuthorizer(java.lang.String className)
                                     throws ConfigurationException

Throws:
  `ConfigurationException`

#### newAuthenticator

    public static IAuthenticator newAuthenticator(java.lang.String className)
                                           throws ConfigurationException

Throws:
  `ConfigurationException`

#### newRoleManager

    public static IRoleManager newRoleManager(java.lang.String className)
                                       throws ConfigurationException

Throws:
  `ConfigurationException`

#### classForName

    public static <T> java.lang.Class<T> classForName(java.lang.String classname,
                                                      java.lang.String readable)
                                               throws ConfigurationException

Parameters:
  `classname` - Fully qualified classname.
  `readable` - Descriptive noun for the role the class plays.
Returns:
  The Class for the given name.
Throws:
  `ConfigurationException` - If the class cannot be found.

#### instanceOrConstruct

    public static <T> T instanceOrConstruct(java.lang.String classname,
                                            java.lang.String readable)
                                     throws ConfigurationException

Constructs an instance of the given class, which must have a no-arg or default constructor.

Parameters:
  `classname` - Fully qualified classname.
  `readable` - Descriptive noun for the role the class plays.
Throws:
  `ConfigurationException` - If the class cannot be found.

#### construct

    public static <T> T construct(java.lang.String classname,
                                  java.lang.String readable)
                           throws ConfigurationException

Constructs an instance of the given class, which must have a no-arg or default constructor.

Parameters:
  `classname` - Fully qualified classname.
  `readable` - Descriptive noun for the role the class plays.
Throws:
  `ConfigurationException` - If the class cannot be found.

#### singleton

    public static <T> java.util.SortedSet<T> singleton(T column,
                                                       java.util.Comparator<? super T> comparator)

#### toString

    @Nonnull
    public static java.lang.String toString(@Nullable
                                                     java.util.Map<?,?> map)

Make straing out of the given `Map`.

Parameters:
  `map` - Map to make string.
Returns:
  String representation of all entries in the map, where key and value pair is concatenated with ':'.

#### getProtectedField

    public static java.lang.reflect.Field getProtectedField(java.lang.Class klass,
                                                            java.lang.String fieldName)

Used to get access to protected/private field of the specified class

Parameters:
  `klass` - - name of the class
  `fieldName` - - name of the field
Returns:
  Field or null on error

#### closeableIterator

    public static <T> CloseableIterator<T> closeableIterator(java.util.Iterator<T> iterator)

#### fromJsonMap

    public static java.util.Map<java.lang.String,java.lang.String> fromJsonMap(java.lang.String json)

#### fromJsonList

    public static java.util.List<java.lang.String> fromJsonList(java.lang.String json)

#### json

    public static java.lang.String json(java.lang.Object object)

#### prettyPrintMemory

    public static java.lang.String prettyPrintMemory(long size)

#### exec

    public static void exec(java.lang.ProcessBuilder pb)
                     throws java.io.IOException

Starts and waits for the given @param pb to finish.

Throws:
  `java.io.IOException` - on non-zero exit code

#### updateChecksumInt

    public static void updateChecksumInt(java.util.zip.Checksum checksum,
                                         int v)

#### getThreadLocalScratchBuffer

    public static byte[] getThreadLocalScratchBuffer()

#### supportsDirectChecksum

    public static boolean supportsDirectChecksum()

#### directCheckSum

    public static void directCheckSum(java.util.zip.Adler32 checksum,
                                      java.nio.ByteBuffer bb)

#### abs

    public static long abs(long index)

#### serialize

    public static <T> byte[] serialize(T object,
                                       IVersionedSerializer<T> serializer,
                                       int version)

#### copy

    public static long copy(java.io.InputStream from,
                            java.io.OutputStream to,
                            long limit)
                     throws java.io.IOException

Throws:
  `java.io.IOException`

#### getToolsOutputDirectory

    public static java.io.File getToolsOutputDirectory()

#### isWindows

    public static boolean isWindows()

#### hasProcFS

    public static boolean hasProcFS()

#### updateWithShort

    public static void updateWithShort(java.security.MessageDigest digest,
                                       int val)

#### updateWithByte

    public static void updateWithByte(java.security.MessageDigest digest,
                                      int val)

#### updateWithInt

    public static void updateWithInt(java.security.MessageDigest digest,
                                     int val)

#### updateWithLong

    public static void updateWithLong(java.security.MessageDigest digest,
                                      long val)

#### toWriteUTFBytes

    public static byte[] toWriteUTFBytes(java.lang.String s)

#### reset

    protected static void reset()