public abstract class ClientSharedUtils
extends java.lang.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 java.lang.ThreadLocal |
ALLOW_THREADCONTEXT_CLASSLOADER |
static java.util.TimeZone |
currentTimeZone
The cached timezone of this VM.
|
static long |
currentTimeZoneOffset
The cached timezone offset not including daylight savings.
|
static java.lang.String |
currentTZShortName
short display name of current timezone in current locale
|
static java.lang.String |
currentTZShortNameDST
short display name of current timezone+daylight in current locale
|
static char[] |
HEX_DIGITS |
static char[] |
HEX_DIGITS_UCASE |
static java.lang.String |
lineSeparator
the system line separator
|
static java.lang.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 long |
PARK_NANOS_MAX
Maximum nanos to park thread to wait for reading/writing data in
non-blocking mode (if selector is present then it will explicitly signal)
|
static int |
RETRIES_BEFORE_PARK
Retries before waiting for
PARK_NANOS_FOR_READ_WRITE
(when there is no selector to signal) |
static java.lang.String |
USE_LINK_LOCAL_ADDRESSES_PROPERTY
Optional system property to enable GemFire usage of link-local addresses
|
static java.lang.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 java.util.logging.Level |
convertToJavaLogLevel(org.apache.log4j.Level log4jLevel) |
static org.apache.log4j.Level |
convertToLog4LogLevel(java.util.logging.Level level) |
static org.apache.log4j.Level |
convertToLog4LogLevel(java.lang.String level) |
static void |
dumpThreadStack(java.lang.management.ThreadInfo tInfo,
java.lang.StringBuilder msg,
java.lang.String lineSeparator) |
static java.nio.ByteBuffer |
ensureCapacity(java.nio.ByteBuffer buffer,
int newLength,
boolean useDirectBuffer,
java.lang.String owner)
Allocate new ByteBuffer if capacity of given ByteBuffer has exceeded.
|
static boolean |
equalBuffers(byte[] bytes,
java.nio.ByteBuffer buffer) |
static void |
formatDate(long time,
int tzOffset,
java.lang.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,
java.lang.StringBuilder sb) |
static byte[] |
fromHexString(java.lang.String s,
int offset,
int length)
Convert a hexidecimal string generated by toHexString() back into a byte
array.
|
static java.lang.reflect.Field |
getAnyField(java.lang.Class<?> c,
java.lang.String name) |
static java.lang.reflect.Method |
getAnyMethod(java.lang.Class<?> c,
java.lang.String name,
java.lang.Class<?> returnType,
java.lang.Class<?>... parameterTypes) |
static int[] |
getBigIntInternalMagnitude(java.math.BigInteger val)
Returns the internal int[] magnitude from given BigInteger, if possble,
else returns null.
|
static int |
getBigIntMagnitudeSizeInBytes(int[] magnitude) |
static java.net.InetAddress |
getCachedLocalHost() |
static java.net.InetAddress |
getLocalHost()
All GemFire code should use this method instead of
InetAddress.getLocalHost().
|
static java.util.Properties |
getLog4jConfProperties(java.lang.String snappyHome) |
static java.lang.String |
getLog4jLogFile(org.apache.log4j.Logger rootLogger)
Return currently configured log4j log-file or null if file logging is not set.
|
static java.util.logging.Logger |
getLogger() |
static java.util.Set<java.net.InetAddress> |
getMyAddresses(boolean includeLocal)
returns a set of the non-loopback InetAddresses for this machine
|
static java.nio.file.Path |
getProductJarsDirectory(java.lang.Class<?> c) |
static void |
getStackTrace(java.lang.Throwable t,
java.lang.StringBuilder sb,
java.lang.String lineSep)
Append the backtrace of given exception to provided
StringBuilder. |
static java.lang.String |
getStatementToken(java.lang.String sql,
int idx)
Moved from Derby's
Statement.getStatementToken to shared between
client and server code. |
static int |
getUTFLength(java.lang.String str,
int strLen) |
static java.lang.Object[] |
getZeroLenObjectArray() |
static void |
initLog4j(java.lang.String logFile,
org.apache.log4j.Level level) |
static void |
initLog4j(java.lang.String logFile,
java.util.Properties userProps,
org.apache.log4j.Level level) |
static void |
initLogger(java.lang.String loggerName,
java.lang.String logFile,
boolean initLog4j,
boolean skipIfInitialized,
java.util.logging.Level level,
java.util.logging.Handler handler) |
static boolean |
isLoggerInitialized() |
static boolean |
isSocketToSameHost(java.nio.channels.Channel channel) |
static boolean |
isSocketToSameHost(java.net.SocketAddress localSockAddress,
java.net.SocketAddress remoteSockAddress) |
static boolean |
isThriftDefault() |
static boolean |
isUsingThrift(boolean defaultValue) |
static java.lang.RuntimeException |
newRuntimeException(java.lang.String message,
java.lang.Throwable cause) |
static java.lang.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(java.lang.Object obj,
java.lang.StringBuilder sb)
Get proper string for an object including arrays.
|
static void |
objectStringNonRecursive(java.lang.Object obj,
java.lang.StringBuilder sb)
Get proper string for an an object including arrays with upto one dimension
of arrays.
|
static long |
parkThreadForAsyncOperationIfRequired(StreamChannel channel,
long parkedNanos,
int numTries) |
static boolean |
parseBoolean(java.lang.String s) |
static long |
parseMemorySize(java.lang.String v,
long defaultValue,
int defaultShiftMultiplier) |
static boolean |
preferIPv6Addresses()
All classes should use this instead of relying on the JRE system property
|
static java.lang.String |
readChars(java.io.InputStream in,
boolean noecho) |
static java.lang.String |
reverseDNS(java.net.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(java.net.Socket sock,
java.io.InputStream sockStream,
int keepIdle,
int keepInterval,
int keepCount)
Enable TCP KeepAlive settings for the socket.
|
static void |
setKeepAliveOptionsServer(java.net.Socket socket,
java.io.InputStream socketStream)
Set the keep-alive options on the socket from server-side properties.
|
static void |
setLogger(java.util.logging.Logger log) |
static void |
setThriftDefault(boolean defaultValue) |
static byte[] |
toBytes(java.nio.ByteBuffer buffer) |
static byte[] |
toBytes(java.nio.ByteBuffer buffer,
int bufferSize,
int length) |
static byte[] |
toBytesCopy(java.nio.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 java.lang.String |
toHexString(byte[] data,
int offset,
int length)
Convert a byte array to a String with a hexidecimal format.
|
static java.lang.String |
toHexString(java.nio.ByteBuffer buffer)
Convert a ByteBuffer to a String with a hexidecimal format.
|
static void |
toHexString(java.nio.ByteBuffer buffer,
java.lang.StringBuilder sb)
Convert a ByteBuffer to a string appending to given
StringBuilder
with a hexidecimal format. |
static java.lang.String |
toHexStringUpperCase(byte[] data,
int offset,
int length)
Convert a byte array to a String with upper case hexidecimal format.
|
static java.lang.String |
toString(java.nio.ByteBuffer buffer) |
static boolean |
wrapsFullArray(java.nio.ByteBuffer byteBuffer) |
public static final java.lang.String LOGGER_NAME
public static final java.lang.String USE_LINK_LOCAL_ADDRESSES_PROPERTY
public static final java.lang.String USE_THRIFT_AS_DEFAULT_PROP
jdbc:gemfirexd:// URLpublic static final java.lang.String lineSeparator
public static final long PARK_NANOS_FOR_READ_WRITE
public static final int RETRIES_BEFORE_PARK
PARK_NANOS_FOR_READ_WRITE
(when there is no selector to signal)public static final long PARK_NANOS_MAX
public static char[] HEX_DIGITS
public static char[] HEX_DIGITS_UCASE
public static final java.util.TimeZone currentTimeZone
public static final long currentTimeZoneOffset
public static final java.lang.String currentTZShortName
public static final java.lang.String currentTZShortNameDST
public static final long MAG_MASK
public static final java.lang.ThreadLocal ALLOW_THREADCONTEXT_CLASSLOADER
public static boolean isUsingThrift(boolean defaultValue)
public static boolean isThriftDefault()
public static void setThriftDefault(boolean defaultValue)
public static long parseMemorySize(java.lang.String v,
long defaultValue,
int defaultShiftMultiplier)
public static boolean parseBoolean(java.lang.String s)
public static java.lang.String newWrappedString(char[] chars,
int offset,
int size)
public static java.lang.String readChars(java.io.InputStream in,
boolean noecho)
public static java.net.InetAddress getLocalHost()
throws java.net.UnknownHostException
java.net.UnknownHostExceptionpublic static java.net.InetAddress getCachedLocalHost()
public static boolean preferIPv6Addresses()
public static java.lang.reflect.Method getAnyMethod(java.lang.Class<?> c,
java.lang.String name,
java.lang.Class<?> returnType,
java.lang.Class<?>... parameterTypes)
throws java.lang.NoSuchMethodException,
java.lang.SecurityException
java.lang.NoSuchMethodExceptionjava.lang.SecurityExceptionpublic static java.lang.reflect.Field getAnyField(java.lang.Class<?> c,
java.lang.String name)
throws java.lang.NoSuchFieldException,
java.lang.SecurityException
java.lang.NoSuchFieldExceptionjava.lang.SecurityExceptionpublic static java.lang.String reverseDNS(java.net.InetAddress addr)
addr - the address to be looked uppublic static java.util.Set<java.net.InetAddress> getMyAddresses(boolean includeLocal)
throws java.net.SocketException
java.net.SocketExceptionpublic static void setKeepAliveOptionsServer(java.net.Socket socket,
java.io.InputStream socketStream)
throws java.net.SocketException
java.net.SocketExceptionsetKeepAliveOptions(java.net.Socket, java.io.InputStream, int, int, int)public static void setKeepAliveOptions(java.net.Socket sock,
java.io.InputStream sockStream,
int keepIdle,
int keepInterval,
int keepCount)
throws java.net.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 deadjava.net.SocketException - if the base keep-alive cannot be enabled on the socketpublic static void getStackTrace(java.lang.Throwable t,
java.lang.StringBuilder sb,
java.lang.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(java.lang.management.ThreadInfo tInfo,
java.lang.StringBuilder msg,
java.lang.String lineSeparator)
public static java.lang.Object[] getZeroLenObjectArray()
public static void formatDate(long currentTimeInMillis,
java.lang.StringBuilder sb)
public static void formatDate(long time,
int tzOffset,
java.lang.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 java.lang.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 java.lang.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 java.lang.String toHexString(java.nio.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(java.nio.ByteBuffer byteBuffer)
public static java.lang.String toString(java.nio.ByteBuffer buffer)
public static void toHexString(java.nio.ByteBuffer buffer,
java.lang.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(java.lang.String s,
int offset,
int length)
s - String to convertoffset - starting character (zero based) to convertlength - number of characters to convertjava.lang.IllegalArgumentException - if the given string is not a hex-encoded onepublic static void setCommonRuntimeException(CommonRunTimeException e)
public static java.lang.RuntimeException newRuntimeException(java.lang.String message,
java.lang.Throwable cause)
public static java.nio.file.Path getProductJarsDirectory(java.lang.Class<?> c)
throws java.io.IOException
java.io.IOExceptionpublic static java.util.logging.Level convertToJavaLogLevel(org.apache.log4j.Level log4jLevel)
public static org.apache.log4j.Level convertToLog4LogLevel(java.lang.String level)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentExceptionpublic static org.apache.log4j.Level convertToLog4LogLevel(java.util.logging.Level level)
public static void initLog4j(java.lang.String logFile,
org.apache.log4j.Level level)
throws java.io.IOException
java.io.IOExceptionpublic static java.lang.String getLog4jLogFile(org.apache.log4j.Logger rootLogger)
public static java.util.Properties getLog4jConfProperties(java.lang.String snappyHome)
throws java.io.IOException
java.io.IOExceptionpublic static void initLog4j(java.lang.String logFile,
java.util.Properties userProps,
org.apache.log4j.Level level)
throws java.io.IOException
java.io.IOExceptionpublic static void initLogger(java.lang.String loggerName,
java.lang.String logFile,
boolean initLog4j,
boolean skipIfInitialized,
java.util.logging.Level level,
java.util.logging.Handler handler)
public static void setLogger(java.util.logging.Logger log)
public static boolean isLoggerInitialized()
public static java.util.logging.Logger getLogger()
public static int[] getBigIntInternalMagnitude(java.math.BigInteger val)
public static int getBigIntMagnitudeSizeInBytes(int[] magnitude)
public static final int numBytesWithoutZeros(long value)
public static void clear()
public static void objectStringNonRecursive(java.lang.Object obj,
java.lang.StringBuilder sb)
public static void objectString(java.lang.Object obj,
java.lang.StringBuilder sb)
public static byte[] toBytes(java.nio.ByteBuffer buffer)
public static byte[] toBytes(java.nio.ByteBuffer buffer,
int bufferSize,
int length)
public static byte[] toBytesCopy(java.nio.ByteBuffer buffer,
int bufferSize,
int length)
public static java.lang.String getStatementToken(java.lang.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(byte[] bytes,
java.nio.ByteBuffer buffer)
public static java.nio.ByteBuffer ensureCapacity(java.nio.ByteBuffer buffer,
int newLength,
boolean useDirectBuffer,
java.lang.String owner)
public static int getUTFLength(java.lang.String str,
int strLen)
public static boolean isSocketToSameHost(java.nio.channels.Channel channel)
public static boolean isSocketToSameHost(java.net.SocketAddress localSockAddress,
java.net.SocketAddress remoteSockAddress)
public static long parkThreadForAsyncOperationIfRequired(StreamChannel channel, long parkedNanos, int numTries) throws java.net.SocketTimeoutException
java.net.SocketTimeoutExceptionCopyright © 2010-2015 Pivotal Software, Inc. All rights reserved.