public class Utils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
SUN_JAVA_COMMAND
Sun property pointing the main class and its arguments.
|
Modifier and Type | Method and Description |
---|---|
static String |
bytesToHex(byte[] bytes)
Convert a byte array to a hex string.
|
static String |
convertToByteStringRepresentation(long value)
Convert to byte string representation.
|
static Object |
deserialize(ByteBuffer b)
Deserialize an object from a ByteBuffer.
|
static Set<Long> |
discretizeRange(com.google.common.collect.Range<Long> range)
Turn a range into a set of discrete longs.
|
static Set<Long> |
discretizeRangeSet(com.google.common.collect.RangeSet<Long> ranges)
Turn a set of ranges into a discrete set.
|
static TailsResponse |
getAllTails(Layout layout,
CorfuRuntime runtime)
Fetches the max global log tail and all stream tails from the log unit cluster.
|
static StreamsAddressResponse |
getLogAddressSpace(Layout layout,
CorfuRuntime runtime)
Retrieve the space of addresses of the log, i.e., for all streams in the log.
|
static long |
getLogTail(Layout layout,
CorfuRuntime runtime)
Get global log tail.
|
static <T> T |
getOption(Map<String,Object> optionsMap,
String option,
Class<T> type) |
static <T> T |
getOption(Map<String,Object> optionsMap,
String option,
Class<T> type,
T defaultValue) |
static void |
hexdump(byte[] bulk)
Hex dump contents of byte[] to stdout.
|
static void |
hexdump(io.netty.buffer.ByteBuf b)
Hex dump readable contents of ByteBuf to stdout.
|
static String |
insnToString(jdk.internal.org.objectweb.asm.tree.AbstractInsnNode insn) |
static byte[] |
intToBigEndianByteArray(int in) |
static byte[] |
longToBigEndianByteArray(long in) |
static UUID |
murmerhash3(UUID key,
long seed)
murmer hash 3 implementation specialized for UUIDs,
based on googlecode C implementation from:
http://smhasher.googlecode.com/svn/trunk/MurmurHash3.cpp
|
static UUID |
nextDeterministicUuid(UUID uuid,
long seed) |
static long |
parseLong(Object toParseObj)
A fancy parser which parses suffixes.
|
static String |
printByteCode(byte[] bytes)
Print byte code.
|
static void |
printLogAnatomy(CorfuRuntime runtime,
ILogData logData)
Print the anatomy of a LogData
|
static ByteBuffer |
serialize(Object obj)
Serialize an object into a ByteBuffer.
|
static UUID |
simpleUUIDHash(UUID key,
long seed)
simple UUID hashing, which is *not* hashing, and is effectively
customized to the task of deterministically allocating new UUIDs
based on a given UUID (which is necessary in the assignment of stream
IDs in ICOrfuDBObjects that contain others, since syncing the log in
multiple clients needs allocators to produce the same streamID/object
every time).
|
static String |
toReadableId(UUID id)
Generates a human readable UUID string (4 hex chars) using time_mid.
|
public static final String SUN_JAVA_COMMAND
public static String bytesToHex(byte[] bytes)
bytes
- Byte array to convertpublic static byte[] intToBigEndianByteArray(int in)
public static byte[] longToBigEndianByteArray(long in)
public static String printByteCode(byte[] bytes)
bytes
- Byte array that represents the byte codepublic static String insnToString(jdk.internal.org.objectweb.asm.tree.AbstractInsnNode insn)
public static long parseLong(Object toParseObj)
toParseObj
- public static <T> T getOption(Map<String,Object> optionsMap, String option, Class<T> type, T defaultValue)
public static <T> T getOption(Map<String,Object> optionsMap, String option, Class<T> type)
public static Set<Long> discretizeRange(com.google.common.collect.Range<Long> range)
range
- The range to discretize.public static Set<Long> discretizeRangeSet(com.google.common.collect.RangeSet<Long> ranges)
ranges
- A set of ranges to discretize.public static String convertToByteStringRepresentation(long value)
value
- The value to convert.public static ByteBuffer serialize(Object obj)
obj
- Object to serializepublic static Object deserialize(ByteBuffer b)
b
- Bufferpublic static void hexdump(io.netty.buffer.ByteBuf b)
b
- ByteBuf with readable bytes available.public static void hexdump(byte[] bulk)
bulk
- Bytes.public static UUID murmerhash3(UUID key, long seed)
key
- key to hashseed
- hash seedpublic static UUID simpleUUIDHash(UUID key, long seed)
key
- key to hashseed
- seedpublic static String toReadableId(UUID id)
id
- The UUID to parsepublic static void printLogAnatomy(CorfuRuntime runtime, ILogData logData)
Print how many streams are contained in the Metadata and how many entries per stream.
Pretty useful for understanding how the the db is being used from the application perspective.
logData
- Data entry to printpublic static long getLogTail(Layout layout, CorfuRuntime runtime)
layout
- Latest layout to query log tail from Log Unitruntime
- Runtimepublic static TailsResponse getAllTails(Layout layout, CorfuRuntime runtime)
layout
- Latest layout to get clients to fetch tails.public static StreamsAddressResponse getLogAddressSpace(Layout layout, CorfuRuntime runtime)
layout
- latest layout.runtime
- current runtime.Copyright © 2019 CorfuDB. All rights reserved.