public abstract class ClientSharedUtils extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ClientSharedUtils.ThreadContextObjectInputStream
allow using Thread context ClassLoader to load classes
|
| Modifier and Type | Field and Description |
|---|---|
static ThreadLocal |
ALLOW_THREADCONTEXT_CLASSLOADER |
static TimeZone |
currentTimeZone
The cached timezone of this VM.
|
static long |
currentTimeZoneOffset
The cached timezone offset not including daylight savings.
|
static String |
currentTZShortName
short display name of current timezone in current locale
|
static String |
currentTZShortNameDST
short display name of current timezone+daylight in current locale
|
static char[] |
HEX_DIGITS |
static char[] |
HEX_DIGITS_UCASE |
static boolean |
isLittleEndian |
static String |
lineSeparator
the system line separator
|
static String |
LOGGER_NAME
The name of java.util.logging.Logger for GemFireXD.
|
static long |
MAG_MASK |
static long |
PARK_NANOS_FOR_READ_WRITE
The default wait to use when waiting to read/write a channel
(when there is no selector to signal)
|
static String |
USE_LINK_LOCAL_ADDRESSES_PROPERTY
Optional system property to enable GemFire usage of link-local addresses
|
static String |
USE_THRIFT_AS_DEFAULT_PROP
System property (with "gemfirexd." prefix) to specify that Thrift is to be
used as the default for default
jdbc:gemfirexd:// URL |
| Modifier and Type | Method and Description |
|---|---|
static void |
clear() |
static Level |
converToJavaLogLevel(org.apache.log4j.Level log4jLevel) |
static void |
dumpThreadStack(ThreadInfo tInfo,
StringBuilder msg,
String lineSeparator) |
static ByteBuffer |
ensureCapacity(ByteBuffer buffer,
int newLength,
boolean useDirectBuffer,
String owner)
Allocate new ByteBuffer if capacity of given ByteBuffer has exceeded.
|
static boolean |
equalBuffers(byte[] bytes,
ByteBuffer buffer) |
static boolean |
equalBuffers(ByteBuffer connToken,
ByteBuffer otherId) |
static void |
formatDate(long time,
int tzOffset,
StringBuilder sb)
Adapted from Derby's CheapDateFormatter to make use of given calendar and
make it more efficient using StringBuilder.
|
static void |
formatDate(long currentTimeInMillis,
StringBuilder sb) |
static byte[] |
fromHexString(String s,
int offset,
int length)
Convert a hexidecimal string generated by toHexString() back into a byte
array.
|
static Field |
getAnyField(Class<?> c,
String name) |
static Method |
getAnyMethod(Class<?> c,
String name,
Class<?> returnType,
Class<?>... parameterTypes) |
static int[] |
getBigIntInternalMagnitude(BigInteger val)
Returns the internal int[] magnitude from given BigInteger, if possble,
else returns null.
|
static int |
getBigIntMagnitudeSizeInBytes(int[] magnitude) |
static InetAddress |
getCachedLocalHost() |
static InetAddress |
getLocalHost()
All GemFire code should use this method instead of
InetAddress.getLocalHost().
|
static Logger |
getLogger() |
static Set<InetAddress> |
getMyAddresses(boolean includeLocal)
returns a set of the non-loopback InetAddresses for this machine
|
static void |
getStackTrace(Throwable t,
StringBuilder sb,
String lineSep)
Append the backtrace of given exception to provided
StringBuilder. |
static String |
getStatementToken(String sql,
int idx)
Moved from Derby's
Statement.getStatementToken to shared between
client and server code. |
static int |
getUTFLength(String str,
int strLen) |
static Object[] |
getZeroLenObjectArray() |
static void |
initLog4J(String logFile,
Level level) |
static void |
initLog4J(String logFile,
Properties userProps,
Level level) |
static void |
initLogger(String loggerName,
String logFile,
boolean initLog4j,
boolean skipIfInitialized,
Level level,
Handler handler) |
static boolean |
isThriftDefault() |
static boolean |
isUsingThrift(boolean defaultValue) |
static RuntimeException |
newRuntimeException(String message,
Throwable cause) |
static String |
newWrappedString(char[] chars,
int offset,
int size) |
static int |
numBytesWithoutZeros(long value)
Get the number of bytes occupied in the given unsigned integer value.
|
static void |
objectString(Object obj,
StringBuilder sb)
Get proper string for an object including arrays.
|
static void |
objectStringNonRecursive(Object obj,
StringBuilder sb)
Get proper string for an an object including arrays with upto one dimension
of arrays.
|
static boolean |
preferIPv6Addresses()
All classes should use this instead of relying on the JRE system property
|
static String |
readChars(InputStream in,
boolean noecho) |
static String |
reverseDNS(InetAddress addr)
This method uses JNDI to look up an address in DNS and return its name.
|
static void |
setCommonRuntimeException(CommonRunTimeException e) |
static void |
setKeepAliveOptions(Socket sock,
InputStream sockStream,
int keepIdle,
int keepInterval,
int keepCount)
Enable TCP KeepAlive settings for the socket.
|
static void |
setKeepAliveOptionsServer(Socket socket,
InputStream socketStream)
Set the keep-alive options on the socket from server-side properties.
|
static void |
setLogger(Logger log) |
static void |
setThriftDefault(boolean defaultValue) |
static byte[] |
toBytes(ByteBuffer buffer) |
static byte[] |
toBytes(ByteBuffer buffer,
int bufferSize,
int length) |
static byte[] |
toBytesCopy(ByteBuffer buffer,
int bufferSize,
int length) |
static char[] |
toHexChars(byte[] data,
int offset,
int length)
Convert a byte array to a char[] with a hexidecimal format.
|
static String |
toHexString(byte[] data,
int offset,
int length)
Convert a byte array to a String with a hexidecimal format.
|
static String |
toHexString(ByteBuffer buffer)
Convert a ByteBuffer to a String with a hexidecimal format.
|
static void |
toHexString(ByteBuffer buffer,
StringBuilder sb)
Convert a ByteBuffer to a string appending to given
StringBuilder
with a hexidecimal format. |
static String |
toHexStringUpperCase(byte[] data,
int offset,
int length)
Convert a byte array to a String with upper case hexidecimal format.
|
static String |
toString(ByteBuffer buffer) |
static boolean |
wrapsFullArray(ByteBuffer byteBuffer) |
public static final String LOGGER_NAME
public static final String USE_LINK_LOCAL_ADDRESSES_PROPERTY
public static final String USE_THRIFT_AS_DEFAULT_PROP
jdbc:gemfirexd:// URLpublic static final boolean isLittleEndian
public static final String lineSeparator
public static final long PARK_NANOS_FOR_READ_WRITE
public static char[] HEX_DIGITS
public static char[] HEX_DIGITS_UCASE
public static final TimeZone currentTimeZone
public static final long currentTimeZoneOffset
public static final String currentTZShortName
public static final String currentTZShortNameDST
public static final long MAG_MASK
public static final ThreadLocal ALLOW_THREADCONTEXT_CLASSLOADER
public static boolean isUsingThrift(boolean defaultValue)
public static boolean isThriftDefault()
public static void setThriftDefault(boolean defaultValue)
public static String newWrappedString(char[] chars, int offset, int size)
public static String readChars(InputStream in, boolean noecho)
public static InetAddress getLocalHost() throws UnknownHostException
UnknownHostExceptionpublic static InetAddress getCachedLocalHost()
public static boolean preferIPv6Addresses()
public static Method getAnyMethod(Class<?> c, String name, Class<?> returnType, Class<?>... parameterTypes) throws NoSuchMethodException, SecurityException
public static Field getAnyField(Class<?> c, String name) throws NoSuchFieldException, SecurityException
public static String reverseDNS(InetAddress addr)
addr - the address to be looked uppublic static Set<InetAddress> getMyAddresses(boolean includeLocal) throws SocketException
SocketExceptionpublic static void setKeepAliveOptionsServer(Socket socket, InputStream socketStream) throws SocketException
public static void setKeepAliveOptions(Socket sock, InputStream sockStream, int keepIdle, int keepInterval, int keepCount) throws SocketException
sock - the underlying Java Socket to set the keep-alivesockStream - the InputStream of the socket (can be null); if non-null then it
is used to determine the underlying socket kernel handle else if
null then reflection on the socket itself is usedkeepIdle - keep-alive time between two transmissions on socket in idle
condition (in seconds)keepInterval - keep-alive duration between successive transmissions on socket if
no reply to packet sent after idle timeout (in seconds)keepCount - number of retransmissions to be sent before declaring the other
end to be deadSocketException - if the base keep-alive cannot be enabled on the socketpublic static void getStackTrace(Throwable t, StringBuilder sb, String lineSep)
StringBuilder.t - the exception whose backtrace is requiredsb - the StringBuilder to which the stack trace is to be
appendedlineSep - the line separator to use, or null to use the default from system
"line.separator" propertypublic static void dumpThreadStack(ThreadInfo tInfo, StringBuilder msg, String lineSeparator)
public static Object[] getZeroLenObjectArray()
public static void formatDate(long currentTimeInMillis,
StringBuilder sb)
public static void formatDate(long time,
int tzOffset,
StringBuilder sb)
time - The current time in milliseconds since Jan. 1, 1970tzOffset - The offset of TimeZone including DST.sb - Append the date formatted as yyyy/mm/dd hh:mm:ss.ddd to the
StringBuilder.public static String toHexString(byte[] data, int offset, int length)
b & 0xf0),
the second character represents the low nibble (b & 0x0f). data[offset] is represented by the first two
characters in the returned String.data - byte arrayoffset - starting byte (zero based) to convert.length - number of bytes to convert.public static String toHexStringUpperCase(byte[] data, int offset, int length)
b & 0xf0),
the second character represents the low nibble (b & 0x0f). data[offset] is represented by the first two
characters in the returned String.data - byte arrayoffset - starting byte (zero based) to convert.length - number of bytes to convert.public static char[] toHexChars(byte[] data,
int offset,
int length)
b & 0xf0),
the second character represents the low nibble (b & 0x0f). data[offset] is represented by the first two
characters in the returned char[].data - byte arrayoffset - starting byte (zero based) to convert.length - number of bytes to convert.public static String toHexString(ByteBuffer buffer)
b & 0xf0),
the second character represents the low nibble (b & 0x0f). data[offset] is represented by the first two
characters in the returned String.buffer - the ByteBuffer to convertpublic static boolean wrapsFullArray(ByteBuffer byteBuffer)
public static String toString(ByteBuffer buffer)
public static void toHexString(ByteBuffer buffer, StringBuilder sb)
StringBuilder
with a hexidecimal format. The string may be converted back to a byte array
using fromHexString. b & 0xf0),
the second character represents the low nibble (b & 0x0f). data[offset] is represented by the first two
characters in the returned string.buffer - the ByteBuffer to convertsb - the StringBuilder to which conversion result is appendedpublic static byte[] fromHexString(String s, int offset, int length)
s - String to convertoffset - starting character (zero based) to convertlength - number of characters to convertIllegalArgumentException - if the given string is not a hex-encoded onepublic static void setCommonRuntimeException(CommonRunTimeException e)
public static RuntimeException newRuntimeException(String message, Throwable cause)
public static Level converToJavaLogLevel(org.apache.log4j.Level log4jLevel)
public static void initLog4J(String logFile, Level level) throws IOException
IOExceptionpublic static void initLog4J(String logFile, Properties userProps, Level level) throws IOException
IOExceptionpublic static void initLogger(String loggerName, String logFile, boolean initLog4j, boolean skipIfInitialized, Level level, Handler handler)
public static void setLogger(Logger log)
public static Logger getLogger()
public static int[] getBigIntInternalMagnitude(BigInteger val)
public static int getBigIntMagnitudeSizeInBytes(int[] magnitude)
public static final int numBytesWithoutZeros(long value)
public static void clear()
public static void objectStringNonRecursive(Object obj, StringBuilder sb)
public static void objectString(Object obj, StringBuilder sb)
public static byte[] toBytes(ByteBuffer buffer)
public static byte[] toBytes(ByteBuffer buffer, int bufferSize, int length)
public static byte[] toBytesCopy(ByteBuffer buffer, int bufferSize, int length)
public static String getStatementToken(String sql, int idx)
Statement.getStatementToken to shared between
client and server code.
Step past any initial non-significant characters to find first significant SQL token so we can classify statement.
public static boolean equalBuffers(ByteBuffer connToken, ByteBuffer otherId)
public static boolean equalBuffers(byte[] bytes,
ByteBuffer buffer)
public static ByteBuffer ensureCapacity(ByteBuffer buffer, int newLength, boolean useDirectBuffer, String owner)
public static int getUTFLength(String str, int strLen)
Copyright © 2010-2015 Pivotal Software, Inc. All rights reserved.