public class FBUtilities
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static boolean |
isLinux |
static boolean |
isWindows |
static int |
MAX_UNSIGNED_SHORT |
static java.math.BigInteger |
TWO |
static java.lang.String |
UNKNOWN_RELEASE_VERSION |
Constructor and Description |
---|
FBUtilities() |
Modifier and Type | Method and Description |
---|---|
static long |
abs(long index) |
static long |
align(long val,
int boundary) |
static java.util.concurrent.Future<java.util.List> |
allOf(java.util.Collection<java.util.concurrent.Future<?>> futures)
Returns a new
Future wrapping the given list of futures and returning a list of their results. |
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 void |
closeAll(java.util.Collection<? extends java.lang.AutoCloseable> l) |
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 <T> java.util.NavigableSet<T> |
emptySortedSet(java.util.Comparator<? super T> comparator) |
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 int |
getAvailableProcessors() |
static InetAddressAndPort |
getBroadcastAddressAndPort()
Get the broadcast address and port for intra-cluster storage traffic.
|
static InetAddressAndPort |
getBroadcastNativeAddressAndPort()
This returns the address that is bound to for the native protocol for communicating with clients.
|
static java.net.InetAddress |
getJustBroadcastAddress()
Retrieve just the broadcast address but not the port.
|
static java.net.InetAddress |
getJustBroadcastNativeAddress()
This returns the address that is bound to for the native protocol for communicating with clients.
|
static java.net.InetAddress |
getJustLocalAddress()
Please use getJustBroadcastAddress instead.
|
static InetAddressAndPort |
getLocalAddressAndPort()
The address and port to listen on for intra-cluster storage traffic (not client).
|
static java.lang.String |
getNetworkInterface(java.net.InetAddress localAddress) |
static java.lang.String |
getPreviousReleaseVersionString() |
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 |
getReleaseVersionMajor() |
static java.lang.String |
getReleaseVersionString() |
static java.io.File |
getToolsOutputDirectory() |
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 |
isAuditLoggerClassExists(java.lang.String className) |
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 IAuditLogger |
newAuditLogger(java.lang.String className,
java.util.Map<java.lang.String,java.lang.String> parameters) |
static IAuthenticator |
newAuthenticator(java.lang.String className) |
static IAuthorizer |
newAuthorizer(java.lang.String className) |
static java.security.MessageDigest |
newMessageDigest(java.lang.String algorithm) |
static INetworkAuthorizer |
newNetworkAuthorizer(java.lang.String className) |
static IPartitioner |
newPartitioner(Descriptor desc)
Create a new instance of a partitioner defined in an SSTable Descriptor
|
static IPartitioner |
newPartitioner(java.lang.String partitionerClassName) |
static IRoleManager |
newRoleManager(java.lang.String className) |
static int |
nowInSeconds() |
static java.lang.String |
prettyPrintMemory(long size) |
static java.lang.String |
prettyPrintMemory(long size,
boolean includeSpace) |
static java.lang.String |
prettyPrintMemoryPerSecond(long rate) |
static java.lang.String |
prettyPrintMemoryPerSecond(long bytes,
long timeInNano) |
static void |
preventIllegalAccessWarnings()
Hack to prevent the ugly "illegal access" warnings in Java 11+ like the following.
|
static void |
reset() |
static java.lang.String |
resourceToFile(java.lang.String filename) |
static <T> byte[] |
serialize(T object,
IVersionedSerializer<T> serializer,
int version) |
static void |
setBroadcastInetAddress(java.net.InetAddress addr)
THIS IS FOR TESTING ONLY!!
|
static void |
setBroadcastInetAddressAndPort(InetAddressAndPort addr)
THIS IS FOR TESTING ONLY!!
|
static void |
setPreviousReleaseVersionString(java.lang.String previousReleaseVersionString) |
static <T> java.util.NavigableSet<T> |
singleton(T column,
java.util.Comparator<? super T> comparator) |
static void |
sleepQuietly(long millis) |
static void |
sortSampledKeys(java.util.List<DecoratedKey> keys,
Range<Token> range) |
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 |
updateChecksum(java.util.zip.CRC32 checksum,
java.nio.ByteBuffer buffer)
Updates checksum with the provided ByteBuffer.
|
static void |
updateChecksum(java.util.zip.CRC32 checksum,
java.nio.ByteBuffer buffer,
int offset,
int length)
Updates checksum with the provided ByteBuffer at the given offset + length.
|
static void |
updateChecksumInt(java.util.zip.Checksum checksum,
int v) |
static <T> java.util.concurrent.Future<? extends T> |
waitOnFirstFuture(java.lang.Iterable<? extends java.util.concurrent.Future<? extends T>> futures) |
static <T> java.util.concurrent.Future<? extends T> |
waitOnFirstFuture(java.lang.Iterable<? extends java.util.concurrent.Future<? extends T>> futures,
long delay)
Only wait for the first future to finish from a list of futures.
|
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 <T> java.util.List<T> |
waitOnFutures(java.lang.Iterable<? extends java.util.concurrent.Future<? extends T>> futures,
long timeout,
java.util.concurrent.TimeUnit units)
Block for a collection of futures, with optional timeout.
|
public static final java.lang.String UNKNOWN_RELEASE_VERSION
public static final java.math.BigInteger TWO
public static final boolean isWindows
public static final boolean isLinux
public static final int MAX_UNSIGNED_SHORT
public static int getAvailableProcessors()
public static java.security.MessageDigest newMessageDigest(java.lang.String algorithm)
public static java.net.InetAddress getJustLocalAddress()
public static InetAddressAndPort getLocalAddressAndPort()
public static java.net.InetAddress getJustBroadcastAddress()
public static InetAddressAndPort getBroadcastAddressAndPort()
public static void setBroadcastInetAddress(java.net.InetAddress addr)
public static void setBroadcastInetAddressAndPort(InetAddressAndPort addr)
public static java.net.InetAddress getJustBroadcastNativeAddress()
public static InetAddressAndPort getBroadcastNativeAddressAndPort()
public static java.lang.String getNetworkInterface(java.net.InetAddress localAddress)
public static Pair<java.math.BigInteger,java.lang.Boolean> midpoint(java.math.BigInteger left, java.math.BigInteger right, int sigbits)
left
- The left point.right
- The right point.sigbits
- The number of bits in the points that are significant.public static int compareUnsigned(byte[] bytes1, byte[] bytes2, int offset1, int offset2, int len1, int len2)
public static int compareUnsigned(byte[] bytes1, byte[] bytes2)
public static void sortSampledKeys(java.util.List<DecoratedKey> keys, Range<Token> range)
public static java.lang.String resourceToFile(java.lang.String filename) throws ConfigurationException
ConfigurationException
public static java.io.File cassandraTriggerDir()
public static void setPreviousReleaseVersionString(java.lang.String previousReleaseVersionString)
public static java.lang.String getPreviousReleaseVersionString()
public static java.lang.String getReleaseVersionString()
public static java.lang.String getReleaseVersionMajor()
public static long timestampMicros()
public static int nowInSeconds()
public static <T> java.util.List<T> waitOnFutures(java.lang.Iterable<? extends java.util.concurrent.Future<? extends T>> futures)
public static <T> java.util.List<T> waitOnFutures(java.lang.Iterable<? extends java.util.concurrent.Future<? extends T>> futures, long timeout, java.util.concurrent.TimeUnit units)
futures
- timeout
- The number of units to wait in total. If this value is less than or equal to zero,
no tiemout value will be passed to Future.get()
.units
- The units of timeout.public static <T> T waitOnFuture(java.util.concurrent.Future<T> future)
public static <T> java.util.concurrent.Future<? extends T> waitOnFirstFuture(java.lang.Iterable<? extends java.util.concurrent.Future<? extends T>> futures)
public static <T> java.util.concurrent.Future<? extends T> waitOnFirstFuture(java.lang.Iterable<? extends java.util.concurrent.Future<? extends T>> futures, long delay)
futures
- The futures to wait onpublic static java.util.concurrent.Future<java.util.List> allOf(java.util.Collection<java.util.concurrent.Future<?>> futures)
Future
wrapping the given list of futures and returning a list of their results.public static IPartitioner newPartitioner(Descriptor desc) throws java.io.IOException
desc
- Descriptor of an sstablejava.io.IOException
public static IPartitioner newPartitioner(java.lang.String partitionerClassName) throws ConfigurationException
ConfigurationException
public static IAuthorizer newAuthorizer(java.lang.String className) throws ConfigurationException
ConfigurationException
public static IAuthenticator newAuthenticator(java.lang.String className) throws ConfigurationException
ConfigurationException
public static IRoleManager newRoleManager(java.lang.String className) throws ConfigurationException
ConfigurationException
public static INetworkAuthorizer newNetworkAuthorizer(java.lang.String className)
public static IAuditLogger newAuditLogger(java.lang.String className, java.util.Map<java.lang.String,java.lang.String> parameters) throws ConfigurationException
ConfigurationException
public static boolean isAuditLoggerClassExists(java.lang.String className)
public static <T> java.lang.Class<T> classForName(java.lang.String classname, java.lang.String readable) throws ConfigurationException
classname
- Fully qualified classname.readable
- Descriptive noun for the role the class plays.ConfigurationException
- If the class cannot be found.public static <T> T instanceOrConstruct(java.lang.String classname, java.lang.String readable) throws ConfigurationException
classname
- Fully qualified classname.readable
- Descriptive noun for the role the class plays.ConfigurationException
- If the class cannot be found.public static <T> T construct(java.lang.String classname, java.lang.String readable) throws ConfigurationException
classname
- Fully qualified classname.readable
- Descriptive noun for the role the class plays.ConfigurationException
- If the class cannot be found.public static <T> java.util.NavigableSet<T> singleton(T column, java.util.Comparator<? super T> comparator)
public static <T> java.util.NavigableSet<T> emptySortedSet(java.util.Comparator<? super T> comparator)
@Nonnull public static java.lang.String toString(@Nullable java.util.Map<?,?> map)
Map
.map
- Map to make string.public static java.lang.reflect.Field getProtectedField(java.lang.Class klass, java.lang.String fieldName)
klass
- - name of the classfieldName
- - name of the fieldpublic static <T> CloseableIterator<T> closeableIterator(java.util.Iterator<T> iterator)
public static java.util.Map<java.lang.String,java.lang.String> fromJsonMap(java.lang.String json)
public static java.util.List<java.lang.String> fromJsonList(java.lang.String json)
public static java.lang.String json(java.lang.Object object)
public static java.lang.String prettyPrintMemory(long size)
public static java.lang.String prettyPrintMemory(long size, boolean includeSpace)
public static java.lang.String prettyPrintMemoryPerSecond(long rate)
public static java.lang.String prettyPrintMemoryPerSecond(long bytes, long timeInNano)
public static void exec(java.lang.ProcessBuilder pb) throws java.io.IOException
java.io.IOException
- on non-zero exit codepublic static void updateChecksumInt(java.util.zip.Checksum checksum, int v)
public static void updateChecksum(java.util.zip.CRC32 checksum, java.nio.ByteBuffer buffer, int offset, int length)
public static void updateChecksum(java.util.zip.CRC32 checksum, java.nio.ByteBuffer buffer)
public static long abs(long index)
public static <T> byte[] serialize(T object, IVersionedSerializer<T> serializer, int version)
public static long copy(java.io.InputStream from, java.io.OutputStream to, long limit) throws java.io.IOException
java.io.IOException
public static java.io.File getToolsOutputDirectory()
public static void closeAll(java.util.Collection<? extends java.lang.AutoCloseable> l) throws java.lang.Exception
java.lang.Exception
public static byte[] toWriteUTFBytes(java.lang.String s)
public static void sleepQuietly(long millis)
public static long align(long val, int boundary)
public static void reset()
public static void preventIllegalAccessWarnings()
Copyright © 2009- The Apache Software Foundation