Modifier and Type | Class and Description |
---|---|
static interface |
IgniteUtils.InterfaceSupplier
Explicit class for
Supplier<Enumeration<NetworkInterface>> . |
Modifier and Type | Field and Description |
---|---|
static Long |
DFLT_MAX_CHECKPOINTING_PAGE_BUFFER_SIZE
Default minimum checkpointing page buffer size (may be adjusted by Ignite).
|
static boolean |
DFLT_MBEAN_APPEND_CLASS_LOADER_ID |
static Long |
DFLT_MIN_CHECKPOINTING_PAGE_BUFFER_SIZE
Minimum checkpointing page buffer size (may be adjusted by Ignite).
|
static String |
DFLT_USER_VERSION
Default user version.
|
static Field[] |
EMPTY_FIELDS
Empty longs.
|
static int[] |
EMPTY_INTS
Empty integers array.
|
static long[] |
EMPTY_LONGS
Empty longs.
|
static long |
GB |
static byte[] |
IGNITE_HEADER
Network packet header.
|
static String |
IGNITE_LOG_DIR
Ignite Logging Directory.
|
static boolean |
IGNITE_MBEANS_DISABLED
Ignite MBeans disabled flag.
|
static boolean |
IGNITE_TEST_FEATURES_ENABLED
Ignite test features enabled flag.
|
static String |
IGNITE_WORK_DIR
Ignite Work Directory.
|
static IgniteUtils.InterfaceSupplier |
INTERFACE_SUPPLIER
Supplier of network interfaces.
|
static String |
JMX_DOMAIN
JMX domain as 'xxx.apache.ignite'.
|
static long |
KB |
static String |
LOC_IGNITE_NAME_EMPTY
Empty local Ignite name.
|
static String |
MAC_INVALID_ARG_MSG
MAC OS invalid argument socket error message.
|
static long |
MB |
static String |
THREAD_DUMP_MSG
Thread dump message.
|
static int |
UTF_BYTE_LIMIT
String limit in bytes for
DataOutput.writeUTF(java.lang.String) and
DataInput.readUTF() , that use "Modified UTF-8". |
Constructor and Description |
---|
IgniteUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
acquire(Semaphore sem)
Acquires a permit from provided semaphore.
|
static <V,C extends Collection<? super V>> |
addAll(C c,
V... vals)
Adds values to collection and returns the same collection to allow chaining.
|
static int[] |
addAll(int[] arr1,
int[] arr2) |
static <K,V,M extends Map<K,V>> |
addAll(M m,
IgniteBiTuple<K,V>... entries)
Adds values to collection and returns the same collection to allow chaining.
|
static <K,V,M extends Map<K,V>> |
addAll(M m,
Map.Entry<K,V>... entries)
Adds values to collection and returns the same collection to allow chaining.
|
static Collection<Handler> |
addJavaNoOpLogger()
Adds no-op console handler for root java logger.
|
static boolean |
addLastCause(@Nullable Throwable e,
@Nullable Throwable cause,
IgniteLogger log)
Adds cause to the end of cause chain.
|
static IgniteBiTuple<Object,Object> |
addLog4jNoOpLogger()
Adds no-op logger to remove no-appender warning.
|
static String |
addressesAsString(ClusterNode node)
Returns string representation of node addresses.
|
static String |
addressesAsString(Collection<String> addrs,
Collection<String> hostNames)
Returns string representation of addresses.
|
static long |
adjustedWalHistorySize(DataStorageConfiguration dsCfg,
@Nullable IgniteLogger log)
Calculates maximum WAL archive size based on maximum checkpoint buffer size, if the default value of
DataStorageConfiguration.getMaxWalArchiveSize() is not overridden. |
static Collection<String> |
allLocalIps()
Gets a list of all local non-loopback IPs known to this JVM.
|
static Collection<String> |
allLocalMACs()
Gets a list of all local enabled MACs known to this JVM.
|
static List<PluginProvider> |
allPluginProviders()
Gets all plugin providers.
|
static boolean |
alphanumericUnderscore(String s) |
static int |
arrayCopy(byte[] src,
int off,
byte[] resBuf,
int resOff,
int len) |
static <T extends R,R> |
arrayList(Collection<T> c) |
static <T extends R,R> |
arrayList(Collection<T> c,
IgnitePredicate<? super T>... p) |
static <T extends R,R> |
arrayList(Iterator<T> c,
int cap,
IgnitePredicate<? super T>... p) |
static <T> Iterable<T> |
asIterable(Enumeration<T> e)
Converts enumeration to iterable so it can be used in
foreach construct. |
static boolean |
assertionsEnabled() |
static void |
assertParameter(boolean cond,
String condDesc)
Throws exception with uniform error message if given parameter's assertion condition
is
false . |
static void |
asyncLogError(IgniteInternalFuture<?> f,
IgniteLogger log)
Adds listener to asynchronously log errors.
|
static int |
availableThreadCount(GridKernalContext ctx,
byte plc,
int reserved) |
static void |
await(Condition cond)
Awaits for condition.
|
static boolean |
await(Condition cond,
long time,
TimeUnit unit)
Awaits for condition.
|
static void |
await(CountDownLatch latch)
Awaits for the latch.
|
static boolean |
await(CountDownLatch latch,
long timeout,
TimeUnit unit)
Awaits for the latch.
|
static void |
awaitForWorkersStop(Collection<GridWorker> workers,
boolean cancel,
IgniteLogger log)
Stops workers from given collection and waits for their completion.
|
static void |
awaitQuiet(Condition cond)
Awaits for condition ignoring interrupts.
|
static void |
awaitQuiet(CountDownLatch latch)
Awaits for the latch until it is counted down,
ignoring interruptions.
|
static void |
awaitQuiet(CyclicBarrier barrier)
Awaits for the barrier ignoring interruptions.
|
static @Nullable Class<?> |
box(@Nullable Class<?> cls)
Gets wrapper class for a primitive type.
|
static void |
broadcastToNodesSupportingFeature(GridKernalContext kctx,
IgniteRunnable job,
boolean srvrsOnly,
IgniteFeatures feature)
Broadcasts given job to nodes that support ignite feature.
|
static String |
byteArray2HexString(byte[] arr)
Converts byte array to hex string.
|
static String |
byteArray2String(byte[] arr,
String hdrFmt,
String bodyFmt)
Converts byte array to formatted string.
|
static boolean |
bytesEqual(byte[] a,
int aOff,
byte[] b,
int bOff,
int len)
Compares fragments of byte arrays.
|
static double |
bytesToDouble(byte[] bytes,
int off)
Constructs double from byte array.
|
static float |
bytesToFloat(byte[] bytes,
int off)
Constructs float from byte array.
|
static IgniteUuid |
bytesToIgniteUuid(byte[] in,
int off)
Converts bytes to
IgniteUuid . |
static int |
bytesToInt(byte[] bytes,
int off)
Constructs
int from byte array. |
static long |
bytesToLong(byte[] bytes,
int off)
Constructs
long from byte array. |
static short |
bytesToShort(byte[] bytes,
int off)
Constructs
short from byte array. |
static UUID |
bytesToUuid(byte[] bytes,
int off)
Reads an
UUID form byte array. |
static GridCacheAttributes[] |
cacheAttributes(ClusterNode n)
Gets cache attributes for the node.
|
static String |
calculateMD5(InputStream in)
Calculate MD5 string.
|
static byte[] |
calculateMD5Digest(@NotNull InputStream in)
Calculate MD5 digits.
|
static int[] |
calculateOptimalBatchSizes(int parallelismLvl,
int size)
Split number of tasks into optimized batches.
|
static void |
cancel(@Nullable GridWorker w)
Cancels given runnable.
|
static void |
cancel(Iterable<? extends GridWorker> ws)
Cancels collection of runnables.
|
static int |
capacity(int expSize)
Returns a capacity that is sufficient to keep the map from being resized as
long as it grows no larger than expSize and the load factor is >= its
default (0.75).
|
static IgniteCheckedException |
cast(Throwable t)
Casts the passed
Throwable t to IgniteCheckedException . |
static int |
ceilPow2(int v)
Gets nearest power of 2 larger or equal than v.
|
static long |
checkpointBufferSize(DataRegionConfiguration regCfg)
Get checkpoint buffer size for the given configuration.
|
static @Nullable Class<?> |
classForName(@Nullable String cls,
@Nullable Class<?> dflt)
Gets class for the given name if it can be loaded or default given class.
|
static @Nullable Class<?> |
classForName(@Nullable String cls,
@Nullable Class<?> dflt,
boolean includePrimitiveTypes)
Gets class for the given name if it can be loaded or default given class.
|
static URL[] |
classLoaderUrls(ClassLoader clsLdr)
Returns URLs of class loader
|
static String |
classNameToResourceName(String clsName)
Gets resource path for the class.
|
static void |
clearClassCache()
Completely clears class cache.
|
static void |
clearClassCache(ClassLoader ldr)
Clears class cache for provided loader.
|
static void |
clearClassFromClassCache(ClassLoader ldr,
String clsName)
Clears class associated with provided class loader from class cache.
|
static void |
close(@Nullable AutoCloseable rsrc,
@Nullable IgniteLogger log)
Closes given resource logging possible checked exception.
|
static void |
close(@Nullable Context rsrc,
@Nullable IgniteLogger log)
Closes given resource logging possible checked exception.
|
static void |
close(@Nullable DatagramSocket rsrc)
Closes given resource.
|
static void |
close(@Nullable SelectionKey rsrc,
@Nullable IgniteLogger log)
Closes given resource logging possible checked exceptions.
|
static void |
close(@Nullable Selector rsrc,
@Nullable IgniteLogger log)
Closes given resource logging possible checked exception.
|
static void |
close(@Nullable URLClassLoader clsLdr,
@Nullable IgniteLogger log)
Closes class loader logging possible checked exception.
|
static void |
closeQuiet(@Nullable AutoCloseable rsrc)
Quietly closes given resource ignoring possible checked exception.
|
static void |
closeQuiet(@Nullable Context rsrc)
Quietly closes given resource ignoring possible checked exception.
|
static void |
closeQuiet(@Nullable SelectionKey rsrc)
Quietly closes given resource ignoring possible checked exceptions.
|
static void |
closeQuiet(@Nullable Selector rsrc)
Quietly closes given resource ignoring possible checked exception.
|
static void |
closeQuiet(@Nullable Socket sock)
Quietly closes given
Socket ignoring possible checked exception. |
static void |
closeWithSuppressingException(@Nullable AutoCloseable rsrc,
@NotNull Exception e)
Closes given resource suppressing possible checked exception.
|
static String |
compact(String s)
Replaces all occurrences of
org.apache.ignite. with o.a.i. ,
org.apache.ignite.internal. with o.a.i.i. ,
org.apache.ignite.internal.visor. with o.a.i.i.v. and
org.apache.ignite.scalar. with o.a.i.s. . |
static int |
compareVersionNumbers(@Nullable String v1,
@Nullable String v2)
Compare java implementation version
|
static int |
concurrentMapSegment(int hash,
int concurLvl) |
static String |
consistentId(Collection<String> addrs) |
static String |
consistentId(Collection<String> addrs,
int port) |
static boolean |
containsAll(Map<?,?> base,
Map<?,?> map)
Checks if the map passed in is contained in base map.
|
static boolean |
containsIntArray(int[] arr,
int val)
Checks for containment of the value in the array.
|
static boolean |
containsObjectArray(@Nullable Object[] arr,
Object val,
Object... vals)
Checks for containment of the value in the array.
|
static boolean |
containsStringArray(String[] arr,
@Nullable String val,
boolean ignoreCase)
Checks for containment of given string value in the specified array.
|
static boolean |
containsStringCollection(Iterable<String> c,
@Nullable String val,
boolean ignoreCase)
Checks for containment of given string value in the specified collection.
|
static IgniteUuid |
contextDeploymentClassLoaderId(GridKernalContext ctx)
Returns Deployment class loader id if method was invoked in the job context
(it may be the context of a cache's operation which was triggered by the distributed job)
or
null if no context was found or Deployment is switched off. |
static IgniteException |
convertException(IgniteCheckedException e) |
static Exception |
convertExceptionNoWrap(IgniteCheckedException e)
Converts exception, but unlike
convertException(IgniteCheckedException)
does not wrap passed in exception if none suitable converter found. |
static <T> Collection<T> |
convertToSingletonList(Collection<T> col) |
static void |
copy(File src,
File dest,
boolean overwrite)
Copy source file (or folder) to destination file (or folder).
|
static int |
copy(InputStream in,
OutputStream out)
Copies input byte stream to output byte stream.
|
static int |
copy(Reader in,
Writer out)
Copies input character stream to output character stream.
|
static int[] |
copyIfExceeded(int[] arr,
int len)
Copies array only if array length greater than needed length.
|
static <K,V> Map<K,V> |
copyMap(Map<K,V> m) |
static byte[] |
copyMemory(long ptr,
int size) |
static void |
courtesy(@Nullable IgniteLogger log,
Object msg)
Depending on whether or not log is provided and quiet mode is enabled logs given messages as
quiet message or normal log WARN message in
org.apache.ignite.CourtesyConfigNotice
category. |
static void |
courtesy(@Nullable IgniteLogger log,
Object longMsg,
Object shortMsg)
Depending on whether or not log is provided and quiet mode is enabled logs given messages as
quiet message or normal log WARN message in
org.apache.ignite.CourtesyConfigNotice
category. |
static Cipher |
createCipher(Key key,
int encMode) |
static @Nullable Method |
ctorFactory()
Return SUN specific constructor factory.
|
static long |
currentTimeMillis() |
static String |
customDirectoryLogFileName(@Nullable String dir,
String fileName)
Substitutes log directory with a custom one.
|
static String |
dash(int len)
Makes a
'+---+' dash line. |
static boolean |
deadlockPresent() |
static void |
debug(IgniteLogger log,
String msg)
Deprecated.
Calls to this method should never be committed to master.
|
static void |
debug(Object msg)
Deprecated.
Calls to this method should never be committed to master.
|
static void |
debugHeapUsage()
Prints heap usage.
|
static void |
debugStack(IgniteLogger log,
String msg)
Deprecated.
Calls to this method should never be committed to master.
|
static void |
debugx(String msg)
Deprecated.
Calls to this method should never be committed to master.
|
static byte[] |
decodeHex(char[] data)
Converts an array of characters representing hexidecimal values into an
array of bytes of those same values.
|
static String |
defaultWorkDirectory()
Get default work directory.
|
static boolean |
delete(@Nullable File file)
Deletes file or directory with all sub-directories and files.
|
static boolean |
delete(Path path)
Deletes file or directory with all sub-directories and files.
|
static ClassLoader |
deploymentClassLoader(GridKernalContext ctx,
IgniteUuid ldrId)
Gets that deployment class loader matching by the specific id, or
null
if the class loader was not found. |
static Class<?> |
detectClass(Object obj)
Tries to detect user class from passed in object inspecting
collections, arrays or maps.
|
static ClassLoader |
detectClassLoader(Class<?> cls)
Detects class loader for given class.
|
static @Nullable ClassLoader |
detectObjectClassLoader(@Nullable Object obj)
Detects class loader for given object's class.
|
static GridPeerDeployAware |
detectPeerDeployAware(GridPeerDeployAware obj)
Unwraps top level user class for wrapped objects.
|
static int[] |
difference(int[] a,
int aLen,
int[] b,
int bLen)
Returns array which is the difference between two arrays
(array of elements contained in first array but not contained in second).
|
static byte |
directProtocolVersion(GridKernalContext ctx,
UUID nodeId)
Defines which protocol version to use for
communication with the provided node.
|
static long |
dirSize(Path path)
Will calculate the size of a directory.
|
static boolean |
discoOrdered(DiscoverySpi discoSpi) |
static <T,R> Collection<R> |
doInParallel(ExecutorService executorSvc,
Collection<T> srcDatas,
IgniteThrowableFunction<T,R> operation)
Execute operation on data in parallel.
|
static <T,R> Collection<R> |
doInParallel(int parallelismLvl,
ExecutorService executorSvc,
Collection<T> srcDatas,
IgniteThrowableFunction<T,R> operation)
Execute operation on data in parallel.
|
static <T,R> Collection<R> |
doInParallelUninterruptibly(int parallelismLvl,
ExecutorService executorSvc,
Collection<T> srcDatas,
IgniteThrowableFunction<T,R> operation)
Execute operation on data in parallel uninterruptibly.
|
static byte[] |
doubleToBytes(double d)
Converts primitive double to byte array.
|
static int |
doubleToBytes(double d,
byte[] bytes,
int off)
Converts primitive
double type to byte array and stores
it in the specified byte array. |
static File |
downloadUrl(URL url,
File file)
Downloads resource by URL.
|
static void |
dumpStack()
Deprecated.
Calls to this method should never be committed to master.
|
static void |
dumpStack(@Nullable IgniteLogger log,
String msg) |
static void |
dumpStack(String msg)
Deprecated.
Calls to this method should never be committed to master.
|
static void |
dumpStack(String msg,
PrintStream out)
Deprecated.
Calls to this method should never be committed to master.
|
static void |
dumpStack(Thread t)
Deprecated.
Calls to this method should never be committed to master.
|
static void |
dumpStack(Thread t,
PrintStream s)
Deprecated.
Calls to this method should never be committed to master.
|
static void |
dumpThreads(@Nullable IgniteLogger log)
Performs thread dump and prints all available info to the given log with WARN logging level.
|
static void |
dumpThreads(@Nullable IgniteLogger log,
boolean isErrorLevel)
Performs thread dump and prints all available info to the given log
with WARN or ERROR logging level depending on
isErrorLevel parameter. |
static ClusterGroupEmptyCheckedException |
emptyTopologyException()
Creates appropriate empty projection exception.
|
static void |
enhanceThreadName(String text)
Puts additional text to thread name.
|
static void |
enhanceThreadName(@Nullable Thread thread,
String text)
Puts additional text to thread name.
|
static void |
ensureDirectory(File dir,
String msg,
IgniteLogger log)
Checks if the given directory exists and attempts to create one if not.
|
static void |
ensureDirectory(Path dir,
String msg,
IgniteLogger log)
Checks if the given directory exists and attempts to create one if not.
|
static long |
ensurePositive(long i,
long dflt)
When
long value given is positive returns that value, otherwise returns provided default value. |
static void |
error(@Nullable IgniteLogger log,
Object msg)
Depending on whether or not log is provided and quiet mode is enabled logs given
messages as quiet message or normal log ERROR message.
|
static void |
error(@Nullable IgniteLogger log,
Object longMsg,
Object shortMsg,
@Nullable Throwable e)
Depending on whether or not log is provided and quiet mode is enabled logs given
messages as quiet message or normal log ERROR message.
|
static void |
error(@Nullable IgniteLogger log,
Object shortMsg,
@Nullable Throwable e)
|
static IgniteCheckedException |
exceptionWithSuppressed(String msg,
@Nullable Collection<Throwable> suppressed)
Creates
IgniteCheckedException with the collection of suppressed exceptions. |
static <T> T |
field(Class<?> cls,
String fieldName)
Gets field value.
|
static <T> T |
field(Object obj,
String fieldName)
Gets field value.
|
static long |
fieldOffset(Class<?> cls,
String fieldName)
Gets object field offset.
|
static int |
fileCount(Path dir)
Return count of regular file in the directory (including in sub-directories)
|
static String |
filler(int len,
char ch) |
static List<InetAddress> |
filterReachable(Collection<InetAddress> addrs) |
static @Nullable Field |
findField(Class<?> cls,
String name) |
static @Nullable Method |
findInheritableMethod(Class<?> cls,
String name,
Class<?>... paramTypes)
Finds a non-static and non-abstract method from the class it parents.
|
static @Nullable Method |
findNonPublicMethod(Class<?> cls,
String name,
Class<?>... paramTypes)
Finds a method in the class and it parents.
|
static <T> T |
firstNotNull(T... vals)
Returns a first non-null value in a given array, if such is present.
|
static String |
fl(String msg,
Object... args)
Creates string for log output.
|
static byte[] |
floatToBytes(float f)
Converts primitive float to byte array.
|
static int |
floatToBytes(float f,
byte[] bytes,
int off)
Converts primitive float to byte array.
|
static @Nullable Constructor<?> |
forceEmptyConstructor(Class<?> cls)
Gets empty constructor for class even if the class does not have empty constructor
declared.
|
static <T> T |
forceNewInstance(Class<?> cls)
Creates new instance of a class even if it does not have public constructor.
|
static String |
format(Date date,
String ptrn)
Formats passed date with specified pattern.
|
static String |
format(long sysTime)
Formats system time in milliseconds for printing in logs.
|
static String |
formatMins(long mins)
Pretty-formatting for minutes.
|
static Class<?> |
forName(String clsName,
@Nullable ClassLoader ldr)
Gets class for provided name.
|
static Class<?> |
forName(String clsName,
@Nullable ClassLoader ldr,
IgnitePredicate<String> clsFilter)
Gets class for provided name.
|
static Class<?> |
forName(String clsName,
@Nullable ClassLoader ldr,
IgnitePredicate<String> clsFilter,
boolean useCache)
Gets class for provided name.
|
static GridIntIterator |
forRange(int start,
int cnt)
Returns
GridIntIterator for range of primitive integers. |
static <T> T |
fromBytes(byte[] data)
Deserialize object from byte array.
|
static <T> T |
get(Future<T> fut)
Gets result from the given future with right exception handling.
|
static <T extends Annotation> |
getAnnotation(Class<?> cls,
Class<T> annCls)
Gets annotation for a class.
|
static BaselineTopology |
getBaselineTopology(@NotNull GridCacheContext cctx) |
static BaselineTopology |
getBaselineTopology(@NotNull GridCacheSharedContext cctx) |
static BaselineTopology |
getBaselineTopology(@NotNull GridKernalContext ctx) |
static <T> T |
getByIndex(Collection<T> vals,
int idx)
Gets collection value by index.
|
static CompilationMXBean |
getCompilerMx()
Gets compilation MBean.
|
static @Nullable String |
getCurrentIgniteName()
Get current Ignite name.
|
static <T extends Annotation> |
getDeclaredAnnotation(Class<?> cls,
Class<T> annCls)
Gets declared annotation for a class.
|
static C1<IgniteCheckedException,IgniteException> |
getExceptionConverter(Class<? extends IgniteCheckedException> clazz)
Gets IgniteClosure for an IgniteCheckedException class.
|
static @Nullable String |
getIgniteHome()
Retrieves
IGNITE_HOME property. |
static InetAddress |
getLocalHost()
Gets local host.
|
static MemoryMXBean |
getMemoryMx()
Gets memory MBean.
|
static @Nullable String |
getNetworkInterfaceName(String addr)
Gets display name of the network interface this IP address belongs to.
|
static @Nullable Method |
getNonPublicMethod(Class<?> cls,
String name,
Class<?>... paramTypes)
Gets a method from the class.
|
static OperatingSystemMXBean |
getOsMx()
Gets OS MBean.
|
static RuntimeMXBean |
getRuntimeMx()
Gets runtime MBean.
|
static String |
getSimpleName(Class<?> cls)
Gets simple class name taking care of empty names.
|
static String |
getTaskName(Class<? extends ComputeTask<?,?>> taskCls)
Gets task name for the given task class.
|
static ThreadMXBean |
getThreadMx()
Gets threading MBean.
|
static long |
getTotalMemoryAvailable()
Gets amount of RAM memory available on this machine.
|
static ClassLoader |
gridClassLoader() |
static String |
gridEventName(int type)
Gets name for given grid event type.
|
static int[] |
gridEvents(int... excl)
Gets all event types.
|
static Collection<UUID> |
gridIds(@Nullable Collection<? extends Ignite> grids)
Converts collection of Grid instances to collection of node IDs.
|
static Collection<String> |
grids2names(@Nullable Collection<? extends Ignite> grids)
Converts collection of Grid instances to collection of grid names.
|
static <T extends Annotation> |
hasAnnotation(Class<?> cls,
Class<T> annCls)
Indicates if class has given annotation.
|
static <T extends Annotation> |
hasAnnotation(Object o,
Class<T> annCls)
Indicates if class has given annotation.
|
static <T extends Annotation> |
hasDeclaredAnnotation(Class<?> cls,
Class<T> annCls)
Indicates if class has given declared annotation.
|
static <T extends Annotation> |
hasDeclaredAnnotation(Object o,
Class<T> annCls)
Indicates if class has given annotation.
|
static boolean |
hasField(Object obj,
String fieldName)
Check that field exist.
|
static int |
hash(int h)
Applies a supplemental hash function to a given hashCode, which
defends against poor quality hash functions.
|
static int |
hash(long key)
A primitive override of
hash(Object) to avoid unnecessary boxing. |
static int |
hash(Object key)
Applies a supplemental hash function to a given hashCode, which
defends against poor quality hash functions.
|
static int |
hashCode(ByteBuffer... bufs)
Calculates hash code for the given byte buffers contents.
|
static int |
hashCode(Object obj)
Calculate a hashCode for an array.
|
static boolean |
hasNearCache(ClusterNode n,
String cacheName)
Checks if given node has near cache enabled for the specified
partitioned cache.
|
static boolean |
hasParent(@Nullable ClassLoader parent,
ClassLoader ldr) |
static boolean |
hasSharedMemory() |
static double |
heapSize(ClusterNode node,
int precision)
Gets heap size in GB rounded to specified precision.
|
static double |
heapSize(int precision)
Returns current JVM maxMemory in the same format as
heapSize(ClusterNode, int) . |
static double |
heapSize(Iterable<ClusterNode> nodes,
int precision)
Gets total heap size in GB rounded to specified precision.
|
static String |
hexInt(int val)
Gets a hex string representation of the given long value.
|
static String |
hexLong(long val)
Gets a hex string representation of the given long value.
|
static byte[] |
hexString2ByteArray(String hex)
Convert string with hex values to byte array.
|
static @Nullable String |
hidePassword(@Nullable String uri)
Replace password in URI string with a single '*' character.
|
static String |
humanReadableByteCount(long bytes)
Converts count of bytes to a human-readable format.
|
static String |
humanReadableDuration(long millis)
Converts duration to a human-readable format.
|
static IgniteClosure<UUID,ClusterNode> |
id2Node(GridKernalContext ctx) |
static String |
id8(IgniteUuid id)
Gets 8-character substring of
IgniteUuid (for terse logging). |
static String |
id8(UUID id)
Gets 8-character substring of UUID (for terse logging).
|
static byte[] |
igniteUuidToBytes(IgniteUuid uuid)
Converts
IgniteUuid to bytes. |
static void |
igniteUuidToBytes(IgniteUuid uuid,
byte[] out,
int off)
Converts
IgniteUuid to bytes. |
static boolean |
inClassPath(String clsName)
Check whether class is in classpath.
|
static Comparator<InetSocketAddress> |
inetAddressesComparator(boolean sameHost)
Returns comparator that sorts remote node addresses.
|
static void |
interrupt(Iterable<? extends Thread> workers)
Convenience method that interrupts a given thread if it's not
null . |
static void |
interrupt(@Nullable Thread t)
Convenience method that interrupts a given thread if it's not
null . |
static byte[] |
intToBytes(int i)
Converts primitive
int type to byte array. |
static int |
intToBytes(int i,
byte[] bytes,
int off)
Converts primitive
int type to byte array and stores it in specified
byte array. |
static <T> T |
invoke(@Nullable Class<?> cls,
@Nullable Object obj,
String mtdName,
Class[] paramTypes,
Object... params)
Invokes method.
|
static <T> T |
invoke(@Nullable Class<?> cls,
@Nullable Object obj,
String mtdName,
Object... params)
Invokes method.
|
static boolean |
isCurrentIgniteNameSet(@Nullable String name)
Check if current Ignite name is set.
|
static boolean |
isEnum(Class cls)
Check if given class represents a Enum.
|
static boolean |
isEqualsMethod(Method mtd) |
static boolean |
isFinal(Class<?> cls) |
static boolean |
isFlagSet(int flags,
int flag)
Check if flag set.
|
static boolean |
isGrid(Class<?> cls)
Checks if given class is of
Grid type. |
static boolean |
isHashCodeMethod(Method mtd) |
static boolean |
isHotSpot()
Indicates whether HotSpot VM is used.
|
static boolean |
isIgnite(Class<?> cls)
Checks if given class is of
Ignite type. |
static boolean |
isIncreasingArray(int[] arr,
int len)
Checks if array prefix increases.
|
static boolean |
isJavaVersionAtLeast(String v)
Compare running Java Runtime version with
v |
static boolean |
isJdk(Class<?> cls)
Check if given class is of JDK type.
|
static boolean |
isLinux()
Indicates whether current OS is Linux flavor.
|
static boolean |
isLoadableBy(String clsName,
@Nullable ClassLoader ldr)
Tests whether or not given class is loadable provided class loader.
|
static boolean |
isLocalAddress(InetAddress addr)
Checks if the address is local.
|
static boolean |
isLocalHostChanged()
Determines whether current local host is different from previously cached.
|
static boolean |
isLocalNodeCoordinator(GridDiscoveryManager discoMgr) |
static boolean |
isMacInvalidArgumentError(Exception e)
Checks if error is MAC invalid argument error which ususally requires special handling.
|
static boolean |
isMacOs()
Indicates whether current OS is Mac OS.
|
static boolean |
isNetWare()
Indicates whether current OS is Netware.
|
static boolean |
isNonDecreasingArray(int[] arr,
int len)
Checks if array prefix do not decreases.
|
static boolean |
isOldestNodeVersionAtLeast(IgniteProductVersion ver,
Iterable<ClusterNode> nodes)
Check that node Ignite product version is not less then specified.
|
static boolean |
isPow2(int i) |
static boolean |
isPrimitiveArray(Object obj)
Checks if object is a primitive array.
|
static boolean |
isPrimitiveOrWrapper(Class<?> cls) |
static boolean |
isRedHat() |
static boolean |
isSolaris()
Indicates whether current OS is Solaris.
|
static boolean |
isSolarisSparc()
Indicates whether current OS is Solaris on Spark box.
|
static boolean |
isSolarisX86()
Indicates whether current OS is Solaris on x86 box.
|
static boolean |
isToStringMethod(Method mtd) |
static boolean |
isUnix()
Indicates whether current OS is UNIX flavor.
|
static boolean |
isVisorNodeStartProperty(String name)
Checks whether property is one added by Visor when node is started via remote SSH session.
|
static boolean |
isVisorRequiredProperty(String name)
Checks whether property is one required by Visor to work correctly.
|
static boolean |
isWindows()
Indicates whether current OS is Windows.
|
static boolean |
isWindows2003()
Indicates whether current OS is Windows Server 2003.
|
static boolean |
isWindows2008()
Indicates whether current OS is Windows Server 2008.
|
static boolean |
isWindows2k()
Indicates whether current OS is Windows 2000.
|
static boolean |
isWindows7()
Indicates whether current OS is Windows 7.
|
static boolean |
isWindows8()
Indicates whether current OS is Windows 8.
|
static boolean |
isWindows81()
Indicates whether current OS is Windows 8.1.
|
static boolean |
isWindows95()
Indicates whether current OS is Windows 95.
|
static boolean |
isWindows98()
Indicates whether current OS is Windows 98.
|
static boolean |
isWindowsNt()
Indicates whether current OS is Windows NT.
|
static boolean |
isWindowsVista()
Indicates whether current OS is Windows Vista.
|
static boolean |
isWindowsXp()
Indicates whether current OS is Windows XP.
|
static String |
jdkName()
Gets JDK name.
|
static String |
jdkString()
Gets JDK string.
|
static String |
jdkVendor()
Gets JDK vendor.
|
static String |
jdkVersion()
Gets JDK version.
|
static JMException |
jmException(Throwable e)
Utility method creating
JMException with given cause. |
static byte[] |
join(byte[]... bufs)
Join byte arrays into single one.
|
static void |
join(GridWorker w)
Joins worker.
|
static boolean |
join(@Nullable GridWorker w,
@Nullable IgniteLogger log)
Joins runnable.
|
static boolean |
join(Iterable<? extends GridWorker> ws,
IgniteLogger log)
Joins given collection of runnables.
|
static void |
join(@Nullable Thread t)
Joins thread.
|
static boolean |
join(@Nullable Thread t,
@Nullable IgniteLogger log)
Waits for completion of a given thread.
|
static boolean |
join(@Nullable Thread t,
@Nullable IgniteLogger log,
long timeout)
Waits for completion of a given thread.
|
static boolean |
joinThreads(Iterable<? extends Thread> workers,
@Nullable IgniteLogger log)
Waits for completion of a given threads.
|
static String |
jreName()
Gets Java Runtime name.
|
static String |
jreVersion()
Gets Java Runtime version.
|
static boolean |
jvm32Bit()
Does a best effort to detect if we a running on a 32-bit JVM.
|
static List<String> |
jvmArgs() |
static String |
jvmName()
Gets JVM implementation name.
|
static int |
jvmPid() |
static String |
jvmSpec()
Gets JVM specification name.
|
static String |
jvmVendor()
Gets JVM implementation vendor.
|
static String |
jvmVersion()
Gets JVM implementation version.
|
static @Nullable String |
lambdaEnclosingClassName(String clsName)
Extracts full name of enclosing class from JDK8 lambda class name.
|
static <K,V> Map<K,V> |
limitedMap(int limit)
Creates new map that limited by size.
|
static void |
log(@Nullable IgniteLogger log,
Object msg)
Depending on whether or not log is provided and quiet mode is enabled logs given
messages as quiet message or normal log INF0 message.
|
static void |
log(@Nullable IgniteLogger log,
Object longMsg,
Object shortMsg)
Depending on whether or not log is provided and quiet mode is enabled logs given
messages as quiet message or normal log INFO message.
|
static IgniteLogger |
logger(GridKernalContext ctx,
AtomicReference<IgniteLogger> logRef,
Class<?> cls)
Initializes logger into/from log reference passed in.
|
static IgniteLogger |
logger(GridKernalContext ctx,
AtomicReference<IgniteLogger> logRef,
Object obj)
Initializes logger into/from log reference passed in.
|
static byte[] |
longToBytes(long l)
Converts primitive
long type to byte array. |
static int |
longToBytes(long l,
byte[] bytes,
int off)
Converts primitive
long type to byte array and stores it in specified
byte array. |
static int |
majorJavaVersion(String verStr)
Get major Java version from string.
|
static ObjectName |
makeMBeanName(@Nullable String igniteInstanceName,
@Nullable String grp,
String name)
Constructs JMX object name with given properties.
|
static <K,V> Map<K,V> |
map(K k,
V v)
Create a map with single key-value pair.
|
static <K,V> Map<K,V> |
map(K k1,
V v1,
K k2,
V v2)
Create a map with two key-value pairs.
|
static <K,V> Map<K,V> |
map(K k1,
V v1,
K k2,
V v2,
K k3,
V v3)
Create a map with three key-value pairs.
|
static byte[] |
marshal(GridCacheSharedContext ctx,
Object obj)
Marshals object to byte array.
|
static byte[] |
marshal(GridKernalContext ctx,
Object obj)
Marshals object to byte array.
|
static byte[] |
marshal(Marshaller marsh,
Object obj)
Marshals object to byte array.
|
static void |
marshal(Marshaller marsh,
@Nullable Object obj,
OutputStream out)
Marshals object to byte array.
|
static String |
maskForFileName(CharSequence name)
Masks name for a valid directory path.
|
static String |
maskName(@Nullable String name)
Mask component name to make sure that it is not
null . |
static <T extends Comparable<? super T>> |
max(T t0,
T t1) |
static long |
millisSinceNanos(long nanos)
Returns number of milliseconds passed after the given nanos timestamp.
|
static long |
millisToNanos(long millis)
Convert milliseconds time interval to nanoseconds.
|
static boolean |
mkdirs(File dir) |
static long |
nanosToMillis(long nanos)
Convert nanoseconds time interval to milliseconds.
|
static int |
nearestPow2(int x) |
static int |
nearestPow2(int x,
boolean less) |
static Map<String,Collection<ClusterNode>> |
neighborhood(Iterable<ClusterNode> nodes)
Groups given nodes by the node's physical computer (host).
|
static <K,V> HashMap<K,V> |
newHashMap(int expSize)
Creates new
HashMap with expected size. |
static <T> HashSet<T> |
newHashSet(int expSize)
Creates new
HashSet with expected size. |
static <X> Set<X> |
newIdentityHashSet() |
static <T> T |
newInstance(Class<T> cls)
Creates new instance of a class only if it has an empty constructor (can be non-public).
|
static <T> T |
newInstance(String cls)
Creates new instance of a class only if it has an empty constructor (can be non-public).
|
static <K,V> LinkedHashMap<K,V> |
newLinkedHashMap(int expSize)
Creates new
LinkedHashMap with expected size. |
static <T> LinkedHashSet<T> |
newLinkedHashSet(int expSize)
Creates new
LinkedHashSet with expected size. |
static int |
nextPowerOf2(int v)
Round up the argument to the next highest power of 2;
|
static String |
nl() |
static String |
nodeIdLogFileName(UUID nodeId,
String fileName)
Attaches node ID to log file name.
|
static Collection<UUID> |
nodeIds(@Nullable Collection<? extends ClusterNode> nodes)
Converts collection of nodes to collection of node IDs.
|
static Collection<String> |
nodes2names(@Nullable Collection<? extends ClusterNode> nodes)
Converts collection of grid nodes to collection of grid names.
|
static <T> void |
notifyListeners(T t,
Collection<Consumer<T>> lsnrs,
IgniteLogger log)
Notifies provided
lsnrs with the value t . |
static void |
nullifyHomeDirectory()
Nullifies Ignite home directory.
|
static Constructor |
objectConstructor() |
static double |
offheapSize(Iterable<ClusterNode> nodes,
int precision)
Gets total offheap size in GB rounded to specified precision.
|
static ClusterNode |
oldest(Collection<ClusterNode> c,
@Nullable IgnitePredicate<ClusterNode> p)
Gets oldest node out of collection of nodes.
|
static void |
onGridStart()
Starts clock timer if grid is first.
|
static void |
onGridStop()
Stops clock timer if all nodes into JVM were stopped.
|
static String |
osArchitecture()
Gets OS CPU-architecture.
|
static String |
osJdkString()
Gets OS JDK string.
|
static String |
osName()
Gets underlying OS name.
|
static String |
osString()
Gets OS string.
|
static String |
osVersion()
Gets underlying OS version.
|
static boolean |
overridesEqualsAndHashCode(Class<?> cls) |
static boolean |
overridesEqualsAndHashCode(Object obj) |
static boolean |
p2pLoader(ClassLoader ldr)
Checks if class loader is an internal P2P class loader.
|
static boolean |
p2pLoader(Object o)
Checks if class loader is an internal P2P class loader.
|
static String |
pad(int len)
Creates space filled string of given length.
|
static GridPeerDeployAware |
peerDeployAware(Object obj)
Creates an instance of
GridPeerDeployAware for object. |
static GridPeerDeployAware |
peerDeployAware0(@Nullable Iterable<?> c)
Gets the peer deploy aware instance for the object with the widest class loader.
|
static GridPeerDeployAware |
peerDeployAware0(Object... c)
Gets the peer deploy aware instance for the object with the widest class loader.
|
static GridPeerDeployAware |
peerDeployAware0(Object obj)
Creates an instance of
GridPeerDeployAware for object. |
static <K,V> void |
printConcurrentHashMapInfo(ConcurrentHashMap<K,V> map) |
static void |
printStackTrace(long threadId,
GridStringBuilder sb) |
static IgniteProductVersion |
productVersion(ClusterNode node)
Gets node product version based on node attributes.
|
static <T> T |
property(Object obj,
String propName)
Gets property value.
|
static void |
quiet(boolean err,
Object... objs) |
static void |
quietAndInfo(IgniteLogger log,
String msg)
Prints out the message in quiet and info modes.
|
static void |
quietAndWarn(IgniteLogger log,
Object msg)
Logs warning message in both verbose and quiet modes.
|
static void |
quietAndWarn(IgniteLogger log,
Object msg,
Object shortMsg)
Logs warning message in both verbose and quiet modes.
|
static void |
quietAndWarn(IgniteLogger log,
Object msg,
@Nullable Throwable e)
Logs warning message in both verbose and quiet modes.
|
static void |
quietMultipleLines(boolean err,
String multiline) |
static ClusterNode |
randomServerNode(GridKernalContext ctx) |
static boolean |
reachable(InetAddress addr,
int reachTimeout)
Checks if address can be reached using one argument InetAddress.isReachable() version.
|
static boolean |
reachable(NetworkInterface itf,
InetAddress addr,
int reachTimeout)
Checks if address can be reached using three argument InetAddress.isReachable() version.
|
static String |
readableSize(long bytes,
boolean si) |
static @Nullable Object[] |
readArray(ObjectInput in)
Reads array from input stream.
|
static @Nullable boolean[] |
readBooleanArray(DataInput in)
Reads boolean array from input stream accounting for null values.
|
static byte[] |
readByteArray(ByteBuffer... bufs)
Reads byte array from given buffers (changing buffer positions).
|
static @Nullable byte[] |
readByteArray(DataInput in)
Reads byte array from input stream accounting for null values.
|
static @Nullable List<Byte> |
readByteList(DataInput in)
// FIXME: added for DR dataCenterIds, review if it is needed after GG-6879.
|
static List<byte[]> |
readBytesList(DataInput in)
Reads collection of byte arrays from data input.
|
static @Nullable Class<?>[] |
readClassArray(ObjectInput in)
Reads array from input stream.
|
static <E> @Nullable Collection<E> |
readCollection(ObjectInput in) |
static <E extends Enum<E>> |
readEnum(DataInput in,
Class<E> enumCls) |
static String |
readFileToString(String fileName,
String charset)
Reads file to string using specified charset.
|
static <K,V> @Nullable HashMap<K,V> |
readHashMap(ObjectInput in)
Read hash map.
|
static @Nullable IgniteUuid |
readIgniteUuid(DataInput in)
Reads
IgniteUuid from input stream. |
static @Nullable List<IgniteUuid> |
readIgniteUuids(DataInput in)
Reads Ignite UUIDs from input stream.
|
static @Nullable int[] |
readIntArray(DataInput in)
Reads int array from input stream accounting for null values.
|
static @Nullable Collection<Integer> |
readIntCollection(DataInput in) |
static @Nullable Map<Integer,Integer> |
readIntKeyIntValueMap(DataInput in) |
static <V> @Nullable Map<Integer,V> |
readIntKeyMap(ObjectInput in) |
static @Nullable List<Integer> |
readIntList(DataInput in) |
static @Nullable Set<Integer> |
readIntSet(DataInput in) |
static <K,V> @Nullable LinkedHashMap<K,V> |
readLinkedMap(ObjectInput in) |
static <E> @Nullable List<E> |
readList(ObjectInput in) |
static @Nullable String |
readLongString(DataInput in)
Reads string from input stream accounting for
null values. |
static <K,V> @Nullable Map<K,V> |
readMap(ObjectInput in) |
static <E> @Nullable Set<E> |
readSet(ObjectInput in) |
static @Nullable String |
readString(DataInput in)
Reads string from input stream accounting for
null values. |
static Map<String,String> |
readStringMap(DataInput in)
Reads string-to-string map written by
writeStringMap(DataOutput, Map) . |
static <K,V> @Nullable TreeMap<K,V> |
readTreeMap(ObjectInput in) |
static String |
readUTF(DataInput in)
Read UTF string which can be
null . |
static @Nullable UUID |
readUuid(BinaryRawReader in)
Reads UUID from binary reader.
|
static @Nullable UUID |
readUuid(DataInput in)
Reads UUID from input stream.
|
static @Nullable List<UUID> |
readUuids(DataInput in)
Reads UUIDs from input stream.
|
static <T> ObjectName |
registerMBean(MBeanServer mbeanSrv,
ObjectName name,
T impl,
Class<T> itf)
Registers MBean with the server.
|
static <T> ObjectName |
registerMBean(MBeanServer mbeanSrv,
@Nullable String igniteInstanceName,
@Nullable String grp,
String name,
T impl,
@Nullable Class<T> itf)
Registers MBean with the server.
|
static boolean |
relaxDiscoveryOrdered() |
static void |
releaseQuiet(@Nullable FileLock lock)
Quietly releases file lock ignoring all possible exceptions.
|
static void |
removeJavaNoOpLogger(Collection<Handler> rmvHnds)
Removes previously added no-op handler for root java logger.
|
static void |
removeLog4jNoOpLogger(IgniteBiTuple<Object,Object> t)
Removes previously added no-op logger via method
addLog4jNoOpLogger() . |
static Collection<InetSocketAddress> |
resolveAddresses(AddressResolver addrRslvr,
Collection<InetSocketAddress> sockAddr) |
static Collection<InetSocketAddress> |
resolveAddresses(AddressResolver addrRslvr,
Iterable<String> addrs,
int port)
Resolves all not loopback addresses and collect results.
|
static ClassLoader |
resolveClassLoader(ClassLoader ldr,
IgniteConfiguration cfg) |
static ClassLoader |
resolveClassLoader(IgniteConfiguration cfg) |
static @Nullable File |
resolveIgnitePath(String path)
Gets file associated with path.
|
static @Nullable URL |
resolveIgniteUrl(String path)
Gets URL representing the path passed in.
|
static @Nullable URL |
resolveIgniteUrl(String path,
boolean metaInf)
Gets URL representing the path passed in.
|
static IgniteBiTuple<Collection<String>,Collection<String>> |
resolveLocalAddresses(InetAddress locAddr)
Returns host names consistent with
resolveLocalHost(String) . |
static IgniteBiTuple<Collection<String>,Collection<String>> |
resolveLocalAddresses(InetAddress locAddr,
boolean allHostNames)
Returns host names consistent with
resolveLocalHost(String) . |
static InetAddress |
resolveLocalHost(@Nullable String hostName)
Tries to resolve host by name, returning local host if input is empty.
|
static URL |
resolveSpringUrl(String springCfgPath)
Resolve Spring configuration URL.
|
static File |
resolveWorkDirectory(String workDir,
String path,
boolean delIfExist)
Resolves work directory.
|
static void |
restoreDeploymentContext(GridKernalContext ctx,
IgniteUuid ldrId)
Restores a deployment context for cache deployment.
|
static void |
restoreOldIgniteName(@Nullable String oldName,
@Nullable String curName)
Restore old Ignite name.
|
static void |
rollbackConnection(@Nullable Connection rsrc,
@Nullable IgniteLogger log)
Rollbacks JDBC connection logging possible checked exception.
|
static void |
rollbackConnectionQuiet(@Nullable Connection rsrc)
Quietly rollbacks JDBC connection ignoring possible checked exception.
|
static int |
safeAbs(int i)
Gets absolute value for integer.
|
static long |
safeAbs(long i)
Gets absolute value for long.
|
static boolean |
sameMacs(ClusterNode loc,
ClusterNode rmt) |
static <E> List<E> |
sealList(Collection<E> c)
Seal collection.
|
static <E> List<E> |
sealList(E... a)
Convert array to seal list.
|
static <K,V> Map<K,V> |
sealMap(Map<K,V> m) |
static Path |
searchFileRecursively(Path path,
@NotNull String name) |
static @Nullable String |
setCurrentIgniteName(@Nullable String newName)
Set current Ignite name.
|
static void |
setIgniteHome(@Nullable String path) |
static byte[] |
shortToBytes(short s)
Converts primitive
short type to byte array. |
static int |
shortToBytes(short s,
byte[] bytes,
int off)
Converts primitive
short type to byte array and stores it in specified
byte array. |
static void |
shutdownNow(Class<?> owner,
@Nullable ExecutorService exec,
@Nullable IgniteLogger log)
Shutdowns given
ExecutorService and wait for executor service to stop. |
static int |
sizeInMegabytes(long sizeInBytes)
Converts size in bytes to human-readable size in megabytes.
|
static void |
sleep(long ms)
Sleeps for given number of milliseconds.
|
static String |
spiAttribute(IgniteSpi spi,
String attrName)
Creates SPI attribute name by adding prefix to the attribute name.
|
static String |
stackTrace() |
static void |
startLifecycleAware(Iterable<?> objs)
For each object provided by the given
Iterable checks if it implements
LifecycleAware interface and executes LifecycleAware.start() method. |
static void |
startThreads(Iterable<? extends Thread> threads)
Starts given threads.
|
static <T> T |
staticField(Class<?> cls,
String fieldName)
Gets static field value.
|
static void |
stopLifecycleAware(IgniteLogger log,
Iterable<?> objs)
For each object provided by the given
Iterable checks if it implements
LifecycleAware interface and executes LifecycleAware.stop() method. |
static int |
stripeIdx(int stripes,
int grpId,
int partId) |
static @Nullable Object |
sunReflectionFactory()
SUN JDK specific reflection factory for objects without public constructor.
|
static void |
swap(Object[] arr,
int a,
int b)
Swaps two objects in array.
|
static String |
threadName(long threadId) |
static <T> T[] |
toArray(Collection<? extends T> c,
T[] arr)
Copies all elements from collection to array and asserts that
array is big enough to hold the collection.
|
static byte[] |
toBytes(Serializable obj)
Serialize object to byte array.
|
static int |
toDigit(char ch,
int idx)
Converts a hexadecimal character to an integer.
|
static String |
toHexString(ByteBuffer buf) |
static String |
toHexString(long addr,
int len) |
static Collection<InetAddress> |
toInetAddresses(ClusterNode node)
Returns tha list of resolved inet addresses.
|
static Collection<InetAddress> |
toInetAddresses(Collection<String> addrs,
Collection<String> hostNames)
Returns tha list of resolved inet addresses.
|
static int[] |
toIntArray(@Nullable Collection<Integer> c)
Converts collection of integers into array.
|
static List<Integer> |
toIntList(@Nullable int[] arr,
IgnitePredicate<Integer>... p)
Converts array of integers into list.
|
static long[] |
toLongArray(@Nullable Collection<Long> c)
Converts collection of integers into array.
|
static List<Long> |
toLongList(@Nullable long[] arr)
Converts array of longs into list.
|
static String |
toShortString(ClusterNode n)
Short node representation.
|
static String |
toShortString(Collection<? extends ClusterNode> ns)
Short node representation.
|
static Collection<InetSocketAddress> |
toSocketAddresses(ClusterNode node,
int port)
Returns tha list of resolved socket addresses.
|
static Collection<InetSocketAddress> |
toSocketAddresses(Collection<String> addrs,
Collection<String> hostNames,
int port)
Returns tha list of resolved socket addresses.
|
static @Nullable String |
toStringSafe(@Nullable Object obj)
Get string representation of an object properly catching all exceptions.
|
static boolean |
tryAcquire(Semaphore sem,
long timeout,
TimeUnit unit)
Tries to acquire a permit from provided semaphore during
timeout . |
static long |
uncompressedSize(File zip)
Getting the total size of uncompressed data in zip.
|
static int[] |
unique(int[] a,
int aLen,
int[] b,
int bLen)
Returns array which is the union of two arrays
(array of elements contained in any of provided arrays).
|
static <T> T |
unmarshal(GridCacheSharedContext ctx,
byte[] arr,
@Nullable ClassLoader clsLdr)
Unmarshals object from the input stream using given class loader.
|
static <T> T |
unmarshal(GridKernalContext ctx,
byte[] arr,
@Nullable ClassLoader clsLdr)
Unmarshals object from the input stream using given class loader.
|
static <T> T |
unmarshal(Marshaller marsh,
byte[] arr,
@Nullable ClassLoader clsLdr)
Unmarshals object from the input stream using given class loader.
|
static <T> T |
unmarshal(Marshaller marsh,
InputStream in,
@Nullable ClassLoader clsLdr)
Unmarshals object from the input stream using given class loader.
|
static <T> T |
unmarshalZip(Marshaller marsh,
byte[] zipBytes,
@Nullable ClassLoader clsLdr) |
static String |
unquote(String s)
Unquote the given string.
|
static Exception |
unwrap(Throwable t)
Unwraps closure exceptions.
|
static byte[] |
unzip(byte[] zipBytes) |
static void |
unzip(File zipFile,
File toDir,
@Nullable IgniteLogger log)
Unzip file to folder.
|
static int |
utfBytes(char c)
Get number of bytes for
DataOutput.writeUTF(java.lang.String) ,
depending on character: One byte - If a character c is in the range
\u0001 through \u007f . |
static byte[] |
uuidToBytes(@Nullable UUID uuid)
Converts an UUID to byte array.
|
static int |
uuidToBytes(@Nullable UUID uuid,
byte[] arr,
int off)
Encodes
UUID into a sequence of bytes using the ByteBuffer ,
storing the result into a new byte array. |
static void |
wait(Object mux)
Converts
InterruptedException to IgniteCheckedException . |
static void |
warn(@Nullable IgniteLogger log,
Object msg)
Depending on whether or not log is provided and quiet mode is enabled logs given
messages as quiet message or normal log WARN message.
|
static void |
warn(@Nullable IgniteLogger log,
Object msg,
@Nullable Throwable e)
Depending on whether or not log is provided and quiet mode is enabled logs given
messages as quiet message or normal log WARN message.
|
static void |
warnDevOnly(@Nullable IgniteLogger log,
Object msg)
Depending on whether or not log is provided and quiet mode is enabled logs given
messages as quiet message or normal log WARN message with
DEV_ONLY marker. |
static <E extends Throwable> |
withCause(E e,
@Nullable Throwable cause)
Utility method that sets cause into exception and returns it.
|
static String |
workDirectory(@Nullable String userWorkDir,
@Nullable String userIgniteHome)
Get work directory for the given user-provided work directory and Ignite home.
|
static Runnable |
wrapIgniteFuture(Runnable r,
GridFutureAdapter<?> fut) |
static <R> R |
wrapThreadLoader(ClassLoader ldr,
Callable<R> c)
Sets thread context class loader to the given loader, executes the closure, and then
resets thread context class loader to its initial value.
|
static <R> R |
wrapThreadLoader(ClassLoader ldr,
IgniteOutClosure<R> c)
Sets thread context class loader to the given loader, executes the closure, and then
resets thread context class loader to its initial value.
|
static void |
wrapThreadLoader(ClassLoader ldr,
Runnable c)
Sets thread context class loader to the given loader, executes the closure, and then
resets thread context class loader to its initial value.
|
static <T> void |
writeArray(ObjectOutput out,
T[] arr)
Writes array to output stream.
|
static void |
writeBooleanArray(DataOutput out,
@Nullable boolean[] arr)
Writes boolean array to output stream accounting for null values.
|
static void |
writeByteArray(DataOutput out,
@Nullable byte[] arr)
Writes byte array to output stream accounting for null values.
|
static void |
writeByteArray(DataOutput out,
@Nullable byte[] arr,
int maxLen)
Writes byte array to output stream accounting for null values.
|
static void |
writeByteCollection(DataOutput out,
Collection<Byte> col)
// FIXME: added for DR dataCenterIds, review if it is needed after GG-6879.
|
static void |
writeBytesCollection(DataOutput out,
Collection<byte[]> bytes)
Writes collection of byte arrays to data output.
|
static void |
writeCollection(ObjectOutput out,
Collection<?> col) |
static void |
writeCutString(DataOutput out,
@Nullable String s)
Writes string to output stream accounting for
null values. |
static <E extends Enum<E>> |
writeEnum(DataOutput out,
E e)
Writes enum to output stream accounting for
null values. |
static void |
writeFully(SocketChannel sockCh,
ByteBuffer buf)
Safely write buffer fully to blocking socket channel.
|
static void |
writeIgniteUuid(DataOutput out,
IgniteUuid uid)
Writes
IgniteUuid to output stream. |
static void |
writeIgniteUuids(DataOutput out,
@Nullable Collection<IgniteUuid> col)
Writes Ignite UUIDs to output stream.
|
static void |
writeIntArray(DataOutput out,
@Nullable int[] arr)
Writes int array to output stream accounting for null values.
|
static void |
writeIntCollection(DataOutput out,
Collection<Integer> col) |
static void |
writeIntKeyIntValueMap(DataOutput out,
Map<Integer,Integer> map) |
static void |
writeIntKeyMap(ObjectOutput out,
Map<Integer,?> map) |
static void |
writeLock(ReadWriteLock lock) |
static void |
writeLongString(DataOutput out,
@Nullable String s)
Writes string to output stream accounting for
null values. |
static void |
writeMap(ObjectOutput out,
Map<?,?> map) |
static int |
writeMessageFully(Message msg,
OutputStream out,
ByteBuffer buf,
MessageWriter writer)
Fully writes communication message to provided stream.
|
static void |
writeString(DataOutput out,
String s)
Writes string to output stream accounting for
null values. |
static void |
writeStringMap(DataOutput out,
@Nullable Map<String,String> map)
Writes string-to-string map to given data output.
|
static void |
writeStringToFile(File file,
String s)
Writes string to file.
|
static void |
writeStringToFile(File file,
String s,
String charset)
Writes string to file.
|
static void |
writeStringToFile(File file,
String s,
String charset,
boolean append)
Writes string to file.
|
static void |
writeUTF(DataOutput out,
@Nullable String val)
Write UTF string which can be
null . |
static void |
writeUuid(BinaryRawWriter out,
UUID uid)
Writes UUID to binary writer.
|
static void |
writeUuid(DataOutput out,
UUID uid)
Writes UUID to output stream.
|
static void |
writeUuids(DataOutput out,
@Nullable Collection<UUID> col)
Writes UUIDs to output stream.
|
static ClusterNode |
youngest(Collection<ClusterNode> c,
@Nullable IgnitePredicate<ClusterNode> p)
Gets youngest node out of collection of nodes.
|
static byte[] |
zip(@Nullable byte[] bytes)
Zip binary payload using default compression.
|
static byte[] |
zip(@Nullable byte[] bytes,
int compressionLevel) |
public static final long KB
public static final long MB
public static final long GB
public static final int UTF_BYTE_LIMIT
DataOutput.writeUTF(java.lang.String)
and
DataInput.readUTF()
, that use "Modified UTF-8".public static final Long DFLT_MIN_CHECKPOINTING_PAGE_BUFFER_SIZE
public static final Long DFLT_MAX_CHECKPOINTING_PAGE_BUFFER_SIZE
public static final boolean DFLT_MBEAN_APPEND_CLASS_LOADER_ID
public static final int[] EMPTY_INTS
public static final long[] EMPTY_LONGS
public static final Field[] EMPTY_FIELDS
public static final String DFLT_USER_VERSION
public static final String THREAD_DUMP_MSG
public static final String JMX_DOMAIN
public static final byte[] IGNITE_HEADER
public static IgniteUtils.InterfaceSupplier INTERFACE_SUPPLIER
public static final String MAC_INVALID_ARG_MSG
public static final String IGNITE_LOG_DIR
public static final String IGNITE_WORK_DIR
public static final String LOC_IGNITE_NAME_EMPTY
public static boolean IGNITE_MBEANS_DISABLED
public static boolean IGNITE_TEST_FEATURES_ENABLED
public static C1<IgniteCheckedException,IgniteException> getExceptionConverter(Class<? extends IgniteCheckedException> clazz)
clazz
- Class.public static List<PluginProvider> allPluginProviders()
public static Exception convertExceptionNoWrap(IgniteCheckedException e)
convertException(IgniteCheckedException)
does not wrap passed in exception if none suitable converter found.e
- Ignite checked exception.public static IgniteException convertException(IgniteCheckedException e)
e
- Ignite checked exception.public static long currentTimeMillis()
public static long millisToNanos(long millis)
millis
- Original time interval.public static long nanosToMillis(long nanos)
nanos
- Original time interval.public static long millisSinceNanos(long nanos)
nanos
- Nanos timestamp.System.nanoTime()
public static int ceilPow2(int v)
v
- Value.public static boolean isPow2(int i)
i
- Value.true
If the given value is power of 2 (0 is not power of 2).@Nullable public static @Nullable Method ctorFactory()
public static Constructor objectConstructor()
@Nullable public static @Nullable Object sunReflectionFactory()
public static String gridEventName(int type)
type
- Event type.public static int[] gridEvents(int... excl)
excl
- Optional exclude events.public static boolean discoOrdered(DiscoverySpi discoSpi)
discoSpi
- Discovery SPI.True
if ordering is supported.public static boolean relaxDiscoveryOrdered()
@Deprecated public static void debug(Object msg)
msg
- Message to debug.@Deprecated public static void debugx(String msg)
msg
- Message to debug.@Deprecated public static void debug(IgniteLogger log, String msg)
log
- Logger.msg
- Message to debug.@Deprecated public static void dumpStack()
System.out
.@Deprecated public static void dumpStack(String msg)
System.out
.msg
- Message to print with the stack.public static void dumpStack(@Nullable @Nullable IgniteLogger log, String msg)
log
- Logger.msg
- Message.@Deprecated public static void dumpStack(String msg, PrintStream out)
msg
- Message to print with the stack.out
- Output to dump stack to.@Deprecated public static void debugStack(IgniteLogger log, String msg)
log
- Logger.msg
- Message to print with the stack.public static void debugHeapUsage()
public static double heapSize(ClusterNode node, int precision)
node
- Node.precision
- Precision.public static double heapSize(Iterable<ClusterNode> nodes, int precision)
nodes
- Nodes.precision
- Precision.public static double offheapSize(Iterable<ClusterNode> nodes, int precision)
nodes
- Nodes.precision
- Precision.public static double heapSize(int precision)
heapSize(ClusterNode, int)
.precision
- Precision.public static void dumpThreads(@Nullable @Nullable IgniteLogger log)
log
- Logger.public static void dumpThreads(@Nullable @Nullable IgniteLogger log, boolean isErrorLevel)
isErrorLevel
parameter.log
- Logger.isErrorLevel
- true
if thread dump must be printed with ERROR logging level,
false
if thread dump must be printed with WARN logging level.public static void printStackTrace(long threadId, GridStringBuilder sb)
threadId
- Thread ID.sb
- Builder.public static boolean deadlockPresent()
true
if there is java level deadlock.@Nullable public static @Nullable Constructor<?> forceEmptyConstructor(Class<?> cls) throws IgniteCheckedException
cls
- Class to get empty constructor for.null
otherwise.IgniteCheckedException
- If failed.@Nullable public static @Nullable Class<?> classForName(@Nullable @Nullable String cls, @Nullable @Nullable Class<?> dflt)
cls
- Class.dflt
- Default class to return.@Nullable public static @Nullable Class<?> classForName(@Nullable @Nullable String cls, @Nullable @Nullable Class<?> dflt, boolean includePrimitiveTypes)
cls
- Class.dflt
- Default class to return.includePrimitiveTypes
- Whether class resolution should include primitive types (i.e. "int" will resolve to int.class if flag is set)@Nullable public static <T> T newInstance(String cls) throws IgniteCheckedException
cls
- Class name.IgniteCheckedException
- If failed.@Nullable public static <T> T newInstance(Class<T> cls) throws IgniteCheckedException
cls
- Class to instantiate.null
if empty constructor could not be assigned.IgniteCheckedException
- If failed.public static boolean inClassPath(String clsName)
True
if in classpath.@Nullable public static <T> T forceNewInstance(Class<?> cls) throws IgniteCheckedException
cls
- Class to instantiate.null
if empty constructor could not be assigned.IgniteCheckedException
- If failed.public static String formatMins(long mins)
mins
- Minutes to format.public static String id8(UUID id)
id
- Input ID.public static String id8(IgniteUuid id)
IgniteUuid
(for terse logging).
The ID8 will be constructed as follows:
IgniteUuid.globalId()
.IgniteUuid.localId()
.id
- Input ID.IgniteUuid
.public static String filler(int len, char ch)
len
- Number of characters to fill in.ch
- Character to fill with.public static <T> void writeArray(ObjectOutput out, T[] arr) throws IOException
T
- Array type.out
- Output stream.arr
- Array to write.IOException
- If failed.@Nullable public static @Nullable Object[] readArray(ObjectInput in) throws IOException, ClassNotFoundException
in
- Input stream.IOException
- If failed.ClassNotFoundException
- If class not found.@Nullable public static @Nullable Class<?>[] readClassArray(ObjectInput in) throws IOException, ClassNotFoundException
in
- Input stream.IOException
- If failed.ClassNotFoundException
- If class not found.public static void writeCollection(ObjectOutput out, Collection<?> col) throws IOException
out
- Output.col
- Set to write.IOException
- If write failed.public static void writeIntCollection(DataOutput out, Collection<Integer> col) throws IOException
out
- Output.col
- Set to write.IOException
- If write failed.@Nullable public static <E> @Nullable Collection<E> readCollection(ObjectInput in) throws IOException, ClassNotFoundException
in
- Input.IOException
- If deserialization failed.ClassNotFoundException
- If deserialized class could not be found.@Nullable public static @Nullable Collection<Integer> readIntCollection(DataInput in) throws IOException
in
- Input.IOException
- If deserialization failed.public static <K,V> Map<K,V> copyMap(Map<K,V> m)
K
- Key type.V
- Value typem
- Map to copy.public static <K,V> Map<K,V> sealMap(Map<K,V> m)
K
- Key type.V
- Value typem
- Map to seal.public static <E> List<E> sealList(Collection<E> c)
E
- Entry typec
- Collection to seal.public static <E> List<E> sealList(E... a)
E
- Entry typea
- Array for convert to seal list.@Nullable public static @Nullable String getNetworkInterfaceName(String addr)
addr
- IP address for which to find network interface name.null
if can't be found.public static InetAddress resolveLocalHost(@Nullable @Nullable String hostName) throws IOException
IgniteConfiguration.getLocalHost()
should
be handled in most places.hostName
- Hostname or null
if local host should be returned.IOException
- If attempt to get local host failed.public static boolean isLocalHostChanged() throws IOException
true
or false
depending on whether or not local host
has changed from the cached value.IOException
- If attempt to get local host failed.public static List<InetAddress> filterReachable(Collection<InetAddress> addrs)
addrs
- Addresses.public static IgniteBiTuple<Collection<String>,Collection<String>> resolveLocalAddresses(InetAddress locAddr) throws IOException
resolveLocalHost(String)
. So when it returns
a common address this method returns single host name, and when a wildcard address passed
this method tries to collect addresses of all available interfaces.locAddr
- Local address to resolve.IOException
- If failed.public static IgniteBiTuple<Collection<String>,Collection<String>> resolveLocalAddresses(InetAddress locAddr, boolean allHostNames) throws IOException
resolveLocalHost(String)
. So when it returns
a common address this method returns single host name, and when a wildcard address passed
this method tries to collect addresses of all available interfaces.locAddr
- Local address to resolve.allHostNames
- If true
then include host names for all addresses.IOException
- If failed.public static InetAddress getLocalHost() throws IOException
Note that this method is synchronized to make sure that local host initialization happens only once.
IOException
- If attempt to get local host failed.public static boolean reachable(NetworkInterface itf, InetAddress addr, int reachTimeout)
itf
- Network interface to use for test.addr
- Address to check.reachTimeout
- Timeout for the check.True
if address is reachable.public static boolean reachable(InetAddress addr, int reachTimeout)
addr
- Address to check.reachTimeout
- Timeout for the check.True
if address is reachable.public static boolean sameMacs(ClusterNode loc, ClusterNode rmt)
loc
- Local node.rmt
- Remote node.public static Collection<String> allLocalIps()
public static boolean isLocalAddress(InetAddress addr)
addr
- Address for check.public static Collection<String> allLocalMACs()
Note that if network interface is disabled - its MAC won't be included. All local network interfaces are probed including loopbacks. Virtual interfaces (sub-interfaces) are skipped.
Note that on linux getHardwareAddress() can return null from time to time if NetworkInterface.getHardwareAddress() method is called from many threads.
public static File downloadUrl(URL url, File file) throws IOException
url
- URL to download.file
- File where downloaded resource should be stored.IOException
- If error occurred.@Nullable public static @Nullable String hidePassword(@Nullable @Nullable String uri)
Parses given URI by applying ".*://(.*:.*)@.*" regular expression pattern and than if URI matches it replaces password strings between '/' and '@' with '*'.
uri
- URI which password should be replaced.public static ClassLoader gridClassLoader()
public static ClassLoader resolveClassLoader(IgniteConfiguration cfg)
public static ClassLoader resolveClassLoader(ClassLoader ldr, IgniteConfiguration cfg)
public static boolean hasParent(@Nullable @Nullable ClassLoader parent, ClassLoader ldr)
parent
- Parent to find.ldr
- Loader to check.True
if parent found.public static void writeBytesCollection(DataOutput out, Collection<byte[]> bytes) throws IOException
out
- Output to write to.bytes
- Collection with byte arrays.IOException
- If write failed.public static List<byte[]> readBytesList(DataInput in) throws IOException
in
- Data input to read from.IOException
- If read failed.public static void writeByteArray(DataOutput out, @Nullable @Nullable byte[] arr) throws IOException
out
- Output stream to write to.arr
- Array to write, possibly null.IOException
- If write failed.public static void writeByteArray(DataOutput out, @Nullable @Nullable byte[] arr, int maxLen) throws IOException
out
- Output stream to write to.arr
- Array to write, possibly null.IOException
- If write failed.@Nullable public static @Nullable byte[] readByteArray(DataInput in) throws IOException
in
- Stream to read from.IOException
- If read failed.public static byte[] readByteArray(ByteBuffer... bufs)
bufs
- Byte buffers.public static void writeByteCollection(DataOutput out, Collection<Byte> col) throws IOException
out
- Output.col
- Set to write.IOException
- If write failed.@Nullable public static @Nullable List<Byte> readByteList(DataInput in) throws IOException
in
- Input.IOException
- If deserialization failed.public static byte[] join(byte[]... bufs)
bufs
- list of byte arrays to concatenate.public static String byteArray2String(byte[] arr, String hdrFmt, String bodyFmt)
... byte[] data = {10, 20, 30, 40, 50, 60, 70, 80, 90}; U.byteArray2String(data, "0x%02X", ",0x%02X") ...the result will be:
... 0x0A, 0x14, 0x1E, 0x28, 0x32, 0x3C, 0x46, 0x50, 0x5A ...
arr
- Array of byte.hdrFmt
- C-style string format for the first element.bodyFmt
- C-style string format for second and following elements, if any.public static byte[] hexString2ByteArray(String hex) throws IllegalArgumentException
hex
- Hexadecimal string to convert.IllegalArgumentException
- If input character differs from certain hex characters.public static String hexLong(long val)
val
- Value to convert to string.public static String hexInt(int val)
val
- Value to convert to string.public static byte[] doubleToBytes(double d)
d
- Double to convert.public static int doubleToBytes(double d, byte[] bytes, int off)
double
type to byte array and stores
it in the specified byte array.d
- Double to convert.bytes
- Array of bytes.off
- Offset.public static byte[] floatToBytes(float f)
f
- Float to convert.public static int floatToBytes(float f, byte[] bytes, int off)
f
- Float to convert.bytes
- Array of bytes.off
- Offset.public static byte[] longToBytes(long l)
long
type to byte array.l
- Long value.public static int longToBytes(long l, byte[] bytes, int off)
long
type to byte array and stores it in specified
byte array.l
- Long value.bytes
- Array of bytes.off
- Offset in bytes
array.bytes
array.public static byte[] intToBytes(int i)
int
type to byte array.i
- Integer value.public static int intToBytes(int i, byte[] bytes, int off)
int
type to byte array and stores it in specified
byte array.i
- Integer value.bytes
- Array of bytes.off
- Offset in bytes
array.bytes
array.public static byte[] shortToBytes(short s)
short
type to byte array.s
- Short value.public static int shortToBytes(short s, byte[] bytes, int off)
short
type to byte array and stores it in specified
byte array.s
- Short value.bytes
- Array of bytes.off
- Offset in bytes
array.bytes
array.public static int uuidToBytes(@Nullable @Nullable UUID uuid, byte[] arr, int off)
UUID
into a sequence of bytes using the ByteBuffer
,
storing the result into a new byte array.uuid
- Unique identifier.arr
- Byte array to fill with result.off
- Offset in arr
.bytes
array.public static byte[] uuidToBytes(@Nullable @Nullable UUID uuid)
uuid
- UUID value.UUID
.public static short bytesToShort(byte[] bytes, int off)
short
from byte array.bytes
- Array of bytes.off
- Offset in bytes
array.public static int bytesToInt(byte[] bytes, int off)
int
from byte array.bytes
- Array of bytes.off
- Offset in bytes
array.public static long bytesToLong(byte[] bytes, int off)
long
from byte array.bytes
- Array of bytes.off
- Offset in bytes
array.public static UUID bytesToUuid(byte[] bytes, int off)
UUID
form byte array.
If given array contains all 0s then null
will be returned.bytes
- array of bytes.off
- Offset in bytes
array.null
.public static double bytesToDouble(byte[] bytes, int off)
bytes
- Byte array.off
- Offset in bytes
array.public static float bytesToFloat(byte[] bytes, int off)
bytes
- Byte array.off
- Offset in bytes
array.public static boolean bytesEqual(byte[] a, int aOff, byte[] b, int bOff, int len)
a
- First array.aOff
- First array offset.b
- Second array.bOff
- Second array offset.len
- Length of fragments.true
if fragments are equal, false
otherwise.public static byte[] decodeHex(char[] data) throws IgniteCheckedException
data
- An array of characters containing hexidecimal digitsIgniteCheckedException
- Thrown if an odd number or illegal of characters is supplied.public static String readableSize(long bytes, boolean si)
bytes
- Number of bytes to display.si
- If true
, then unit base is 1000, otherwise unit base is 1024.public static String dash(int len)
'+---+'
dash line.len
- Length of the dash line to make.public static String pad(int len)
len
- Number of spaces.public static String format(long sysTime)
sysTime
- System time.public static <T> Iterable<T> asIterable(Enumeration<T> e)
foreach
construct.T
- Types of instances for iteration.e
- Enumeration to convert.public static void copy(File src, File dest, boolean overwrite) throws IOException
src
- Source file or folder.dest
- Destination file or folder.overwrite
- Whether or not overwrite existing files and folders.IOException
- Thrown if an I/O error occurs.public static void onGridStart()
public static void onGridStop() throws InterruptedException
InterruptedException
- If interrupted.public static int copy(InputStream in, OutputStream out) throws IOException
in
- Input byte stream.out
- Output byte stream.IOException
- Thrown if an I/O error occurs.public static int copy(Reader in, Writer out) throws IOException
in
- Input character stream.out
- Output character stream.IOException
- Thrown if an I/O error occurs.public static void writeStringToFile(File file, String s) throws IOException
file
- File.s
- String to write.IOException
- Thrown if an I/O error occurs.public static void writeStringToFile(File file, String s, String charset) throws IOException
file
- File.s
- String to write.charset
- Encoding.IOException
- Thrown if an I/O error occurs.public static String readFileToString(String fileName, String charset) throws IOException
fileName
- File name.charset
- File charset.IOException
- If error occurred.public static void writeStringToFile(File file, String s, String charset, boolean append) throws IOException
file
- File.s
- String to write.charset
- Encoding.append
- If true
, then specified string will be added to the end of the file.IOException
- Thrown if an I/O error occurs.public static <E extends Throwable> E withCause(E e, @Nullable @Nullable Throwable cause)
E
- Type of the exception.e
- Exception to set cause to and return.cause
- Optional cause to set (if not null
).public static boolean delete(@Nullable @Nullable File file)
file
- File or directory to delete.true
if and only if the file or directory is successfully deleted,
false
otherwisepublic static int sizeInMegabytes(long sizeInBytes)
sizeInBytes
- Size of any object (file, memory region etc) in bytes.public static boolean delete(Path path)
path
- File or directory to delete.true
if and only if the file or directory is successfully deleted,
false
otherwisepublic static boolean mkdirs(File dir)
dir
- Directory to create along with all non-existent parent directories.True
if directory exists (has been created or already existed),
false
if has not been created and does not exist.@Nullable public static @Nullable String getIgniteHome()
IGNITE_HOME
property. The property is retrieved from system
properties or from environment in that order.IGNITE_HOME
property.public static void setIgniteHome(@Nullable @Nullable String path)
path
- Ignite home. May be null
.@Nullable public static @Nullable File resolveIgnitePath(String path)
First check if path is relative to IGNITE_HOME
.
If not, check if path is absolute.
If all checks fail, then null
is returned.
See getIgniteHome()
for information on how IGNITE_HOME
is retrieved.
path
- Path to resolve.null
if path cannot be resolved.@Nullable public static @Nullable URL resolveIgniteUrl(String path)
META-INF
folder in classpath.
If not, then the check is made if path is relative to ${IGNITE_HOME}.
If all checks fail,
then null
is returned, otherwise URL representing path is returned.
See getIgniteHome()
for information on how IGNITE_HOME
is retrieved.
path
- Path to resolve.null
if path cannot be resolved.getIgniteHome()
public static URL resolveSpringUrl(String springCfgPath) throws IgniteCheckedException
springCfgPath
- Spring XML configuration file path or URL. This cannot be null
.IgniteCheckedException
- If failed.@Nullable public static @Nullable URL resolveIgniteUrl(String path, boolean metaInf)
META-INF
folder in classpath.
If not, then the check is made if path is relative to ${IGNITE_HOME}.
If all checks fail,
then null
is returned, otherwise URL representing path is returned.
See getIgniteHome()
for information on how IGNITE_HOME
is retrieved.
path
- Path to resolve.metaInf
- Flag to indicate whether META-INF folder should be checked or class path root.null
if path cannot be resolved.getIgniteHome()
public static String byteArray2HexString(byte[] arr)
arr
- Array of bytes.public static boolean containsObjectArray(@Nullable @Nullable Object[] arr, Object val, @Nullable Object... vals)
null
. Two null
s are considered equal.arr
- Array of objects.val
- Value to check for containment inside of array.vals
- Additional values.true
if contains object, false
otherwise.public static boolean containsIntArray(int[] arr, int val)
arr
- Array of objects.val
- Value to check for containment inside of array.true
if contains object, false
otherwise.public static boolean containsStringArray(String[] arr, @Nullable @Nullable String val, boolean ignoreCase)
null
. Tow null
s are considered equal.arr
- Array of strings.val
- Value to check for containment inside of array.ignoreCase
- Ignoring case if true
.true
if contains string, false
otherwise.public static boolean containsStringCollection(Iterable<String> c, @Nullable @Nullable String val, boolean ignoreCase)
null
. Tow null
s are considered equal.c
- Array of strings.val
- Value to check for containment inside of array.ignoreCase
- Ignoring case if true
.true
if contains string, false
otherwise.public static void close(@Nullable @Nullable AutoCloseable rsrc, @Nullable @Nullable IgniteLogger log)
rsrc
- Resource to close. If it's null
- it's no-op.log
- Logger to log possible checked exception with (optional).public static void closeWithSuppressingException(@Nullable @Nullable AutoCloseable rsrc, @NotNull @NotNull Exception e)
rsrc
- Resource to close. If it's null
- it's no-op.e
- Suppressor exceptionpublic static void closeQuiet(@Nullable @Nullable AutoCloseable rsrc)
rsrc
- Resource to close. If it's null
- it's no-op.public static void close(@Nullable @Nullable SelectionKey rsrc, @Nullable @Nullable IgniteLogger log)
rsrc
- Resource to close. If it's null
- it's no-op.log
- Logger to log possible checked exception with (optional).public static void closeQuiet(@Nullable @Nullable SelectionKey rsrc)
rsrc
- Resource to close. If it's null
- it's no-op.public static void close(@Nullable @Nullable DatagramSocket rsrc)
rsrc
- Resource to close. If it's null
- it's no-op.public static void close(@Nullable @Nullable Selector rsrc, @Nullable @Nullable IgniteLogger log)
rsrc
- Resource to close. If it's null
- it's no-op.log
- Logger to log possible checked exception with (optional).public static void closeQuiet(@Nullable @Nullable Selector rsrc)
rsrc
- Resource to close. If it's null
- it's no-op.public static void close(@Nullable @Nullable Context rsrc, @Nullable @Nullable IgniteLogger log)
rsrc
- Resource to close. If it's null
- it's no-op.log
- Logger to log possible checked exception with (optional).public static void closeQuiet(@Nullable @Nullable Context rsrc)
rsrc
- Resource to close. If it's null
- it's no-op.public static void close(@Nullable @Nullable URLClassLoader clsLdr, @Nullable @Nullable IgniteLogger log)
clsLdr
- Class loader. If it's null
- it's no-op.log
- Logger to log possible checked exception with (optional).public static void closeQuiet(@Nullable @Nullable Socket sock)
Socket
ignoring possible checked exception.sock
- Socket to close. If it's null
- it's no-op.public static void releaseQuiet(@Nullable @Nullable FileLock lock)
lock
- File lock. If it's null
- it's no-op.public static void rollbackConnection(@Nullable @Nullable Connection rsrc, @Nullable @Nullable IgniteLogger log)
rsrc
- JDBC connection to rollback. If connection is null
, it's no-op.log
- Logger to log possible checked exception with (optional).public static void courtesy(@Nullable @Nullable IgniteLogger log, Object msg)
org.apache.ignite.CourtesyConfigNotice
category. If log
is null
or in QUIET mode it will add (courtesy)
prefix to the message.log
- Optional logger to use when QUIET mode is not enabled.msg
- Message to log.public static void courtesy(@Nullable @Nullable IgniteLogger log, Object longMsg, Object shortMsg)
org.apache.ignite.CourtesyConfigNotice
category. If log
is null
or in QUIET mode it will add (courtesy)
prefix to the message.log
- Optional logger to use when QUIET mode is not enabled.longMsg
- Message to log using normal logger.shortMsg
- Message to log using quiet logger.public static void warn(@Nullable @Nullable IgniteLogger log, Object msg)
log
is null
or in QUIET mode it will add (wrn)
prefix to the message.log
- Optional logger to use when QUIET mode is not enabled.msg
- Message to log.public static void quietAndWarn(IgniteLogger log, Object msg)
log
- Logger to use.msg
- Message to log.public static void quietAndWarn(IgniteLogger log, Object msg, Object shortMsg)
log
- Logger to use.shortMsg
- Short message.msg
- Message to log.public static void quietAndWarn(IgniteLogger log, Object msg, @Nullable @Nullable Throwable e)
log
- Logger to use.msg
- Message to log.e
- Optional exception.public static void error(@Nullable @Nullable IgniteLogger log, Object msg)
log
is null
or in QUIET mode it will add (err)
prefix to the message.log
- Optional logger to use when QUIET mode is not enabled.msg
- Message to log.public static void warn(@Nullable @Nullable IgniteLogger log, Object msg, @Nullable @Nullable Throwable e)
log
is null
or in QUIET mode it will add (wrn)
prefix to the message.log
- Optional logger to use when QUIET mode is not enabled.msg
- Message to log using normal logger.e
- Optional exception.public static void warnDevOnly(@Nullable @Nullable IgniteLogger log, Object msg)
DEV_ONLY
marker.
If log
is null
or in QUIET mode it will add (wrn)
prefix to the message.
If property IGNITE_DEV_ONLY_LOGGING_DISABLED
is set to true, the message will not be logged.log
- Optional logger to use when QUIET mode is not enabled.msg
- Message to log.public static void log(@Nullable @Nullable IgniteLogger log, Object longMsg, Object shortMsg)
NOTE: unlike the normal logging when INFO level may not be enabled and therefore no logging will happen - using this method the log will be written always either via INFO log or quiet mode.
USE IT APPROPRIATELY.
log
- Optional logger to use when QUIET mode is not enabled.longMsg
- Message to log using normal logger.shortMsg
- Message to log using quiet logger.public static void log(@Nullable @Nullable IgniteLogger log, Object msg)
NOTE: unlike the normal logging when INFO level may not be enabled and therefore no logging will happen - using this method the log will be written always either via INFO log or quiet mode.
USE IT APPROPRIATELY.
log
- Optional logger to use when QUIET mode is not enabled.msg
- Message to log.public static void error(@Nullable @Nullable IgniteLogger log, Object longMsg, Object shortMsg, @Nullable @Nullable Throwable e)
log
is null
or in QUIET mode it will add (err)
prefix to the message.log
- Optional logger to use when QUIET mode is not enabled.longMsg
- Message to log using normal logger.shortMsg
- Message to log using quiet logger.e
- Optional exception.public static void error(@Nullable @Nullable IgniteLogger log, Object shortMsg, @Nullable @Nullable Throwable e)
log
- Optional logger.shortMsg
- Message to log using quiet logger.e
- Optional exception.public static void quiet(boolean err, Object... objs)
err
- Whether to print to System.err
.objs
- Objects to log in quiet mode.public static void quietMultipleLines(boolean err, String multiline)
err
- Whether to print to System.err
.multiline
- Multiple lines string to print.public static void quietAndInfo(IgniteLogger log, String msg)
log
- Logger.msg
- Message to print.public static void rollbackConnectionQuiet(@Nullable @Nullable Connection rsrc)
rsrc
- JDBC connection to rollback. If connection is null
, it's no-op.public static ObjectName makeMBeanName(@Nullable @Nullable String igniteInstanceName, @Nullable @Nullable String grp, String name) throws MalformedObjectNameException
groups
used for proper object name construction.igniteInstanceName
- Ignite instance name.grp
- Name of the group.name
- Name of mbean.MalformedObjectNameException
- Thrown in case of any errors.public static String maskName(@Nullable @Nullable String name)
null
.name
- Component name to mask, possibly null
.public static boolean alphanumericUnderscore(String s)
s
- String to check.true
if given string contains only alphanumeric and underscore symbols.public static <T> ObjectName registerMBean(MBeanServer mbeanSrv, @Nullable @Nullable String igniteInstanceName, @Nullable @Nullable String grp, String name, T impl, @Nullable @Nullable Class<T> itf) throws JMException
T
- Type of mbean.mbeanSrv
- MBean server.igniteInstanceName
- Ignite instance name.grp
- Name of the group.name
- Name of mbean.impl
- MBean implementation.itf
- MBean interface.MBeanRegistrationException
- if MBeans are disabled.JMException
- If MBean creation failed.public static <T> ObjectName registerMBean(MBeanServer mbeanSrv, ObjectName name, T impl, Class<T> itf) throws JMException
T
- Type of mbean.mbeanSrv
- MBean server.name
- MBean object name.impl
- MBean implementation.itf
- MBean interface.MBeanRegistrationException
- if MBeans are disabled.JMException
- If MBean creation failed.IgniteException
- If MBean creation are not allowed.public static void interrupt(@Nullable @Nullable Thread t)
null
.t
- Thread to interrupt.public static void interrupt(Iterable<? extends Thread> workers)
null
.workers
- Threads to interrupt.public static boolean join(@Nullable @Nullable Thread t, @Nullable @Nullable IgniteLogger log)
null
then
this method returns immediately returning true
t
- Thread to join.log
- Logger for logging errors.true
if thread has finished, false
otherwise.public static boolean join(@Nullable @Nullable Thread t, @Nullable @Nullable IgniteLogger log, long timeout)
null
then
this method returns immediately returning true
t
- Thread to join.log
- Logger for logging errors.timeout
- Join timeout.true
if thread has finished, false
otherwise.public static boolean joinThreads(Iterable<? extends Thread> workers, @Nullable @Nullable IgniteLogger log)
null
then
this method returns immediately returning true
workers
- Thread to join.log
- Logger for logging errors.true
if thread has finished, false
otherwise.public static void startThreads(Iterable<? extends Thread> threads)
threads
- Threads to start.public static void cancel(@Nullable @Nullable GridWorker w)
w
- Worker to cancel - it's no-op if runnable is null
.public static void cancel(Iterable<? extends GridWorker> ws)
ws
- Collection of workers - it's no-op if collection is null
.public static boolean join(@Nullable @Nullable GridWorker w, @Nullable @Nullable IgniteLogger log)
w
- Worker to join.log
- The logger to possible exception.true
if worker has not been interrupted, false
if it was interrupted.public static boolean join(Iterable<? extends GridWorker> ws, IgniteLogger log)
ws
- Collection of workers to join.log
- The logger to possible exceptions.true
if none of the worker have been interrupted,
false
if at least one was interrupted.public static void shutdownNow(Class<?> owner, @Nullable @Nullable ExecutorService exec, @Nullable @Nullable IgniteLogger log)
ExecutorService
and wait for executor service to stop.owner
- The ExecutorService owner.exec
- ExecutorService to shutdown.log
- The logger to possible exceptions and warnings.public static ClusterGroupEmptyCheckedException emptyTopologyException()
public static void writeUuids(DataOutput out, @Nullable @Nullable Collection<UUID> col) throws IOException
Externalizable
interface.out
- Output stream.col
- UUIDs to write.IOException
- If write failed.@Nullable public static @Nullable List<UUID> readUuids(DataInput in) throws IOException
Externalizable
interface.in
- Input stream.IOException
- If read failed.public static void writeIgniteUuids(DataOutput out, @Nullable @Nullable Collection<IgniteUuid> col) throws IOException
Externalizable
interface.out
- Output stream.col
- Ignite UUIDs to write.IOException
- If write failed.@Nullable public static @Nullable List<IgniteUuid> readIgniteUuids(DataInput in) throws IOException
Externalizable
interface.in
- Input stream.IOException
- If read failed.public static void writeUuid(DataOutput out, UUID uid) throws IOException
Externalizable
interface.out
- Output stream.uid
- UUID to write.IOException
- If write failed.@Nullable public static @Nullable UUID readUuid(DataInput in) throws IOException
Externalizable
interface.in
- Input stream.IOException
- If read failed.public static void writeUuid(BinaryRawWriter out, UUID uid)
out
- Output Binary writer.uid
- UUID to write.IOException
- If write failed.@Nullable public static @Nullable UUID readUuid(BinaryRawReader in)
in
- Binary reader.IOException
- If read failed.public static void writeIgniteUuid(DataOutput out, IgniteUuid uid) throws IOException
IgniteUuid
to output stream. This method is meant to be used by
implementations of Externalizable
interface.out
- Output stream.uid
- UUID to write.IOException
- If write failed.@Nullable public static @Nullable IgniteUuid readIgniteUuid(DataInput in) throws IOException
IgniteUuid
from input stream. This method is meant to be used by
implementations of Externalizable
interface.in
- Input stream.IOException
- If read failed.public static byte[] igniteUuidToBytes(IgniteUuid uuid)
IgniteUuid
to bytes.uuid
- IgniteUuid
to convert.public static void igniteUuidToBytes(IgniteUuid uuid, byte[] out, int off)
IgniteUuid
to bytes.uuid
- IgniteUuid
to convert.out
- Output array to write to.off
- Offset from which to write.public static IgniteUuid bytesToIgniteUuid(byte[] in, int off)
IgniteUuid
.in
- Input byte array.off
- Offset from which start reading.IgniteUuid
instance.public static void writeBooleanArray(DataOutput out, @Nullable @Nullable boolean[] arr) throws IOException
out
- Output stream to write to.arr
- Array to write, possibly null.IOException
- If write failed.public static void writeIntArray(DataOutput out, @Nullable @Nullable int[] arr) throws IOException
out
- Output stream to write to.arr
- Array to write, possibly null.IOException
- If write failed.@Nullable public static @Nullable boolean[] readBooleanArray(DataInput in) throws IOException
in
- Stream to read from.IOException
- If read failed.@Nullable public static @Nullable int[] readIntArray(DataInput in) throws IOException
in
- Stream to read from.IOException
- If read failed.public static int hashCode(ByteBuffer... bufs)
Arrays.hashCode(byte[])
with the same content. Does not change buffers positions.bufs
- Byte buffers.public static void writeMap(ObjectOutput out, Map<?,?> map) throws IOException
out
- Output.map
- Map to write.IOException
- If write failed.@Nullable public static <K,V> @Nullable Map<K,V> readMap(ObjectInput in) throws IOException, ClassNotFoundException
in
- Input.IOException
- If de-serialization failed.ClassNotFoundException
- If deserialized class could not be found.public static int hashCode(Object obj)
obj
- Object.@Nullable public static <K,V> @Nullable TreeMap<K,V> readTreeMap(ObjectInput in) throws IOException, ClassNotFoundException
in
- Input.IOException
- If de-serialization failed.ClassNotFoundException
- If deserialized class could not be found.@Nullable public static <K,V> @Nullable HashMap<K,V> readHashMap(ObjectInput in) throws IOException, ClassNotFoundException
in
- Input.IOException
- If de-serialization failed.ClassNotFoundException
- If deserialized class could not be found.@Nullable public static <K,V> @Nullable LinkedHashMap<K,V> readLinkedMap(ObjectInput in) throws IOException, ClassNotFoundException
in
- Input.IOException
- If de-serialization failed.ClassNotFoundException
- If deserialized class could not be found.public static void writeIntKeyMap(ObjectOutput out, Map<Integer,?> map) throws IOException
out
- Output.map
- Map to write.IOException
- If write failed.@Nullable public static <V> @Nullable Map<Integer,V> readIntKeyMap(ObjectInput in) throws IOException, ClassNotFoundException
in
- Input.IOException
- If de-serialization failed.ClassNotFoundException
- If deserialized class could not be found.public static void writeIntKeyIntValueMap(DataOutput out, Map<Integer,Integer> map) throws IOException
out
- Output.map
- Map to write.IOException
- If write failed.@Nullable public static @Nullable Map<Integer,Integer> readIntKeyIntValueMap(DataInput in) throws IOException
in
- Input.IOException
- If de-serialization failed.@Nullable public static <E> @Nullable List<E> readList(ObjectInput in) throws IOException, ClassNotFoundException
in
- Input.IOException
- If deserialization failed.ClassNotFoundException
- If deserialized class could not be found.@Nullable public static @Nullable List<Integer> readIntList(DataInput in) throws IOException
in
- Input.IOException
- If deserialization failed.@Nullable public static <E> @Nullable Set<E> readSet(ObjectInput in) throws IOException, ClassNotFoundException
in
- Input.IOException
- If deserialization failed.ClassNotFoundException
- If deserialized class could not be found.@Nullable public static @Nullable Set<Integer> readIntSet(DataInput in) throws IOException
in
- Input.IOException
- If deserialization failed.public static void writeString(DataOutput out, String s) throws IOException
null
values.
Limitation for max string lenght of UTF_BYTE_LIMIT
bytes is caused by ObjectOutputStream.writeUTF(java.lang.String)
used under the hood to perform an actual write.
If longer string is passes a UTFDataFormatException
exception will be thrown.
To write longer strings use one of two options:
writeLongString(DataOutput, String)
writes string as is converting it into binary array of UTF-8
encoded characters.
To read the value back readLongString(DataInput)
should be used.
writeCutString(DataOutput, String)
cuts passed string to UTF_BYTE_LIMIT
bytes
and then writes them without converting to byte array.
No exceptions will be thrown for string of any length; written string can be read back with regular
readString(DataInput)
method.
out
- Output stream to write to.s
- String to write, possibly null
.IOException
- If write failed.@Nullable public static @Nullable String readString(DataInput in) throws IOException
null
values.
Method enables to read strings shorter than UTF_BYTE_LIMIT
bytes in UTF-8 otherwise an exception will be thrown.
Strings written by writeString(DataOutput, String)
or writeCutString(DataOutput, String)
can be read by this method.in
- Stream to read from.null
.IOException
- If read failed.for more information about writing strings.
public static <E extends Enum<E>> void writeEnum(DataOutput out, E e) throws IOException
null
values.
Note: method writes only one byte for every enum. Therefore, this method
only for Enums with maximum count of values equals to 128.out
- Output stream to write to.e
- Enum value to write, possibly null
.IOException
- If write failed.public static <E extends Enum<E>> E readEnum(DataInput in, Class<E> enumCls) throws IOException
IOException
public static <T> T getByIndex(Collection<T> vals, int idx)
T
- Type of collection values.vals
- Collection of values.idx
- Index of value in the collection.@Nullable public static <T extends Annotation> T getAnnotation(Class<?> cls, Class<T> annCls)
T
- Type of annotation to return.cls
- Class to get annotation from.annCls
- Annotation to get.null
if not found.@Nullable public static <T extends Annotation> T getDeclaredAnnotation(Class<?> cls, Class<T> annCls)
T
- Type of annotation to return.cls
- Class to get annotation from.annCls
- Annotation to get.null
if not found.public static <T extends Annotation> boolean hasDeclaredAnnotation(Class<?> cls, Class<T> annCls)
T
- Annotation type.cls
- Class to get annotation from.annCls
- Annotation to get.true
if class has annotation or false
otherwise.public static <T extends Annotation> boolean hasDeclaredAnnotation(Object o, Class<T> annCls)
o
- Object to get annotation from.annCls
- Annotation to get.true
if class has annotation or false
otherwise.public static <T extends Annotation> boolean hasAnnotation(Class<?> cls, Class<T> annCls)
T
- Annotation type.cls
- Class to get annotation from.annCls
- Annotation to get.true
if class has annotation or false
otherwise.public static <T extends Annotation> boolean hasAnnotation(Object o, Class<T> annCls)
o
- Object to get annotation from.annCls
- Annotation to get.true
if class has annotation or false
otherwise.public static String getSimpleName(Class<?> cls)
cls
- Class to get the name for.public static boolean containsAll(Map<?,?> base, Map<?,?> map)
base
- Base map.map
- Map to check.True
if all entries within map are contained in base map,
false
otherwise.public static String getTaskName(Class<? extends ComputeTask<?,?>> taskCls)
taskCls
- Task class.ComputeTaskName
})
or task class name if there is no annotation.public static String spiAttribute(IgniteSpi spi, String attrName)
spi
- SPI.attrName
- attribute name.public static String classNameToResourceName(String clsName)
clsName
- Class name.public static RuntimeMXBean getRuntimeMx()
public static ThreadMXBean getThreadMx()
public static OperatingSystemMXBean getOsMx()
public static MemoryMXBean getMemoryMx()
public static long getTotalMemoryAvailable()
public static CompilationMXBean getCompilerMx()
public static Class<?> detectClass(Object obj)
obj
- Object.public static ClassLoader detectClassLoader(Class<?> cls)
This method will first check if Thread.getContextClassLoader()
is appropriate.
If yes, then context class loader will be returned, otherwise
the Class.getClassLoader()
will be returned.
cls
- Class to find class loader for.null
).@Nullable public static @Nullable ClassLoader detectObjectClassLoader(@Nullable @Nullable Object obj)
obj
- Object to find class loader for class of.null
).public static boolean isLoadableBy(String clsName, @Nullable @Nullable ClassLoader ldr)
clsName
- Class name to test.ldr
- Class loader to test with. If null
- we'll use system class loader instead.
If System class loader is not set - this method will return false
.True
if class is loadable, false
otherwise.public static GridPeerDeployAware peerDeployAware0(@Nullable @Nullable Iterable<?> c)
null
, empty or contains only null
s - the peer
deploy aware object based on system class loader will be returned.c
- Collection.IllegalArgumentException
- Thrown in case when common class loader for all
elements in this collection cannot be found. In such case - peer deployment
is not possible.public static GridPeerDeployAware peerDeployAware0(@Nullable Object... c)
null
, empty or contains only null
s - the peer
deploy aware object based on system class loader will be returned.c
- Objects.IllegalArgumentException
- Thrown in case when common class loader for all
elements in this array cannot be found. In such case - peer deployment
is not possible.public static GridPeerDeployAware peerDeployAware0(Object obj)
GridPeerDeployAware
for object.
Checks, if the object is an instance of collection or object
array.obj
- Object to deploy.GridPeerDeployAware
instance for given object.public static GridPeerDeployAware peerDeployAware(Object obj)
GridPeerDeployAware
for object.obj
- Object to deploy.GridPeerDeployAware
instance for given object.public static GridPeerDeployAware detectPeerDeployAware(GridPeerDeployAware obj)
obj
- Object to check.public static boolean isIgnite(Class<?> cls)
Ignite
type.cls
- Class to check.True
if given class is of Ignite
type.public static boolean isGrid(Class<?> cls)
Grid
type.cls
- Class to check.True
if given class is of Grid
type.public static String compact(String s)
org.apache.ignite.
with o.a.i.
,
org.apache.ignite.internal.
with o.a.i.i.
,
org.apache.ignite.internal.visor.
with o.a.i.i.v.
and
org.apache.ignite.scalar.
with o.a.i.s.
.s
- String to replace in.public static boolean isJdk(Class<?> cls)
cls
- Class to check.True
if object is JDK type.public static boolean isEnum(Class cls)
cls
- Class to check.True
if this is a Enum class.public static void wait(Object mux) throws IgniteInterruptedCheckedException
InterruptedException
to IgniteCheckedException
.mux
- Mux to wait on.IgniteInterruptedCheckedException
- If interrupted.public static void unzip(File zipFile, File toDir, @Nullable @Nullable IgniteLogger log) throws IOException
zipFile
- ZIP file.toDir
- Directory to unzip file content.log
- Grid logger.IOException
- In case of error.public static boolean assertionsEnabled()
True
if assertions enabled.public static String osJdkString()
public static String osString()
public static String jdkString()
public static boolean isLinux()
true
if current OS is Linux - false
otherwise.public static String jdkName()
public static String jdkVendor()
public static String jdkVersion()
public static String osArchitecture()
public static String osName()
public static String osVersion()
public static boolean isMacOs()
true
if current OS is Mac OS - false
otherwise.public static boolean isRedHat()
True
if current OS is RedHat.public static boolean isNetWare()
true
if current OS is Netware - false
otherwise.public static boolean isSolaris()
true
if current OS is Solaris (SPARC or x86) - false
otherwise.public static boolean isSolarisSparc()
true
if current OS is Solaris SPARC - false
otherwise.public static boolean isSolarisX86()
true
if current OS is Solaris x86 - false
otherwise.public static boolean isUnix()
true
if current OS is UNIX - false
otherwise.public static boolean isWindows()
true
if current OS is Windows (any versions) - false
otherwise.public static boolean isWindowsVista()
true
if current OS is Windows Vista - false
otherwise.public static boolean isWindows7()
true
if current OS is Windows 7 - false
otherwise.public static boolean isWindows8()
true
if current OS is Windows 8 - false
otherwise.public static boolean isWindows81()
true
if current OS is Windows 8.1 - false
otherwise.public static boolean isWindows2k()
true
if current OS is Windows 2000 - false
otherwise.public static boolean isWindows2003()
true
if current OS is Windows Server 2003 - false
otherwise.public static boolean isWindows2008()
true
if current OS is Windows Server 2008 - false
otherwise.public static boolean isWindows95()
true
if current OS is Windows 95 - false
otherwise.public static boolean isWindows98()
true
if current OS is Windows 98 - false
otherwise.public static boolean isWindowsNt()
true
if current OS is Windows NT - false
otherwise.public static boolean isWindowsXp()
true
if current OS is Windows XP- false
otherwise.public static String jvmSpec()
public static String jvmVersion()
public static String jvmVendor()
public static String jvmName()
public static boolean jvm32Bit()
true
if detected that we are running on a 32-bit JVM.public static int compareVersionNumbers(@Nullable @Nullable String v1, @Nullable @Nullable String v2)
v1
- - java implementation versionv2
- - java implementation version0
if v1 == v2
;
a value less than 0
if v1 < v2
; and
a value greater than 0
if v1 > v2
public static IgniteProductVersion productVersion(ClusterNode node)
node
- Node to get version from.public static boolean isJavaVersionAtLeast(String v)
v
v
- - java implementation versiontrue
if running on Java Runtime version greater than v
public static String jreName()
public static String jreVersion()
public static int majorJavaVersion(String verStr)
verStr
- Version string.public static boolean isHotSpot()
true
if current JVM implementation is a Sun HotSpot VM, false
otherwise.@Nullable public static <R> R wrapThreadLoader(ClassLoader ldr, Callable<R> c) throws IgniteCheckedException
R
- Return type.ldr
- Class loader to run the closure under.c
- Callable to run.IgniteCheckedException
- If call failed.@Nullable public static <R> R wrapThreadLoader(ClassLoader ldr, IgniteOutClosure<R> c)
R
- Return type.ldr
- Class loader to run the closure under.c
- Closure to run.public static void wrapThreadLoader(ClassLoader ldr, Runnable c)
ldr
- Class loader to run the closure under.c
- Closure to run.public static String toShortString(ClusterNode n)
n
- Grid node.public static String toShortString(Collection<? extends ClusterNode> ns)
ns
- Grid nodes.@Nullable public static @Nullable String toStringSafe(@Nullable @Nullable Object obj)
obj
- Object.null
.public static int[] toIntArray(@Nullable @Nullable Collection<Integer> c)
c
- Collection of integers.public static int[] addAll(int[] arr1, int[] arr2)
arr1
- Array 1.arr2
- Array 2.public static List<Integer> toIntList(@Nullable @Nullable int[] arr, IgnitePredicate<Integer>... p)
arr
- Array of integers.p
- Optional predicate array.public static long[] toLongArray(@Nullable @Nullable Collection<Long> c)
c
- Collection of integers.public static List<Long> toLongList(@Nullable @Nullable long[] arr)
arr
- Array of longs.public static <T> T[] toArray(Collection<? extends T> c, T[] arr)
Collection.toArray(Object[])
method.T
- Element type.c
- Collection to convert to array.arr
- Array to populate.public static void swap(Object[] arr, int a, int b)
arr
- Array.a
- Index of the first object.b
- Index of the second object.public static int[] unique(int[] a, int aLen, int[] b, int bLen)
a
- First array.aLen
- Length of prefix a
.b
- Second array.bLen
- Length of prefix b
.a
and b
.public static int[] difference(int[] a, int aLen, int[] b, int bLen)
a
- First array.aLen
- Length of prefix a
.b
- Second array.bLen
- Length of prefix b
.a
and b
.public static boolean isIncreasingArray(int[] arr, int len)
arr
- Array.len
- Prefix length.True
if arr
from 0 to (len
- 1) increases.public static boolean isNonDecreasingArray(int[] arr, int len)
arr
- Array.len
- Prefix length.True
if arr
from 0 to (len
- 1) do not decreases.public static int[] copyIfExceeded(int[] arr, int len)
arr
- Array.len
- Prefix length.arr
is equals to len
,
otherwise copy of array.public static <V,C extends Collection<? super V>> C addAll(C c, V... vals)
V
- Value type.c
- Collection to add values to.vals
- Values.public static <K,V,M extends Map<K,V>> M addAll(M m, Map.Entry<K,V>... entries)
K
- Key type.V
- Value type.M
- Map type.m
- Map to add entries to.entries
- Entries.public static <K,V,M extends Map<K,V>> M addAll(M m, IgniteBiTuple<K,V>... entries)
K
- Key type.V
- Value type.M
- Map type.m
- Map to add entries to.entries
- Entries.public static JMException jmException(Throwable e)
JMException
with given cause.e
- Cause exception.JMException
.public static Exception unwrap(Throwable t)
t
- Exception.public static IgniteCheckedException cast(Throwable t)
Throwable t
to IgniteCheckedException
.t
is a GridClosureException
, it is unwrapped and then cast to IgniteCheckedException
.
If t
is an IgniteCheckedException
, it is returned.
If t
is not a IgniteCheckedException
, a new IgniteCheckedException
caused by t
is returned.t
- Throwable to cast.t
cast to IgniteCheckedException
.public static boolean p2pLoader(Object o)
o
- Object to check.True
if P2P class loader.public static boolean p2pLoader(ClassLoader ldr)
ldr
- Class loader to check.True
if P2P class loader.public static IgniteUuid contextDeploymentClassLoaderId(GridKernalContext ctx)
null
if no context was found or Deployment is switched off.ctx
- Kernal context.null
.public static ClassLoader deploymentClassLoader(GridKernalContext ctx, IgniteUuid ldrId)
null
if the class loader was not found.ctx
- Kernal context.ldrId
- Class loader id.null
.public static void restoreDeploymentContext(GridKernalContext ctx, IgniteUuid ldrId)
ctx
- Kernal context.ldrId
- Class loader id.public static String format(Date date, String ptrn)
date
- Date to format.ptrn
- Pattern.public static IgniteClosure<UUID,ClusterNode> id2Node(GridKernalContext ctx)
ctx
- Kernal context.@Deprecated public static void dumpStack(Thread t)
t
- Thread to dump stack for.@Deprecated public static void dumpStack(Thread t, PrintStream s)
t
- Thread to dump stack for.s
- PrintStream
to use for output.public static boolean isPrimitiveArray(Object obj)
obj
- Object to check.True
if Object is primitive array.public static boolean isPrimitiveOrWrapper(Class<?> cls)
cls
- Class.True
if given class represents a primitive or a primitive wrapper class.public static void await(Condition cond) throws IgniteInterruptedCheckedException
cond
- Condition to await for.IgniteInterruptedCheckedException
- Wrapped InterruptedException
public static void awaitQuiet(Condition cond)
cond
- Condition to await for.public static boolean await(Condition cond, long time, TimeUnit unit) throws IgniteInterruptedCheckedException
cond
- Condition to await for.time
- The maximum time to wait,unit
- The unit of the time
argument.false
if the waiting time detectably elapsed before return from the method, else true
IgniteInterruptedCheckedException
- Wrapped InterruptedException
public static void await(CountDownLatch latch) throws IgniteInterruptedCheckedException
latch
- Latch to wait for.IgniteInterruptedCheckedException
- Wrapped InterruptedException
.public static boolean await(CountDownLatch latch, long timeout, TimeUnit unit) throws IgniteInterruptedCheckedException
latch
- Latch to wait for.timeout
- Maximum time to wait.unit
- Time unit for timeout.True
if the count reached zero and false
if the waiting time elapsed before the count reached zero.IgniteInterruptedCheckedException
- Wrapped InterruptedException
.public static void awaitQuiet(CountDownLatch latch)
If calling thread was interrupted, interrupted status will be recovered prior to return.
latch
- Latch to wait for.public static void awaitQuiet(CyclicBarrier barrier)
If calling thread was interrupted, interrupted status will be recovered prior to return. If the barrier is already broken, return immediately without throwing any exceptions.
barrier
- Barrier to wait for.public static URL[] classLoaderUrls(ClassLoader clsLdr)
clsLdr
- Class loader.public static void sleep(long ms) throws IgniteInterruptedCheckedException
ms
- Time to sleep.IgniteInterruptedCheckedException
- Wrapped InterruptedException
.public static void join(GridWorker w) throws IgniteInterruptedCheckedException
w
- Worker.IgniteInterruptedCheckedException
- Wrapped InterruptedException
.public static <T> T get(Future<T> fut) throws IgniteCheckedException
fut
- Future.IgniteCheckedException
- If failed.public static void join(@Nullable @Nullable Thread t) throws IgniteInterruptedCheckedException
t
- Thread.IgniteInterruptedCheckedException
- Wrapped InterruptedException
.public static void acquire(Semaphore sem) throws IgniteInterruptedCheckedException
sem
- Semaphore.IgniteInterruptedCheckedException
- Wrapped InterruptedException
.public static boolean tryAcquire(Semaphore sem, long timeout, TimeUnit unit) throws IgniteInterruptedCheckedException
timeout
.sem
- Semaphore.timeout
- The maximum time to wait.unit
- The unit of the time
argument.True
if acquires a permit, false
another.IgniteInterruptedCheckedException
- Wrapped InterruptedException
.public static GridCacheAttributes[] cacheAttributes(ClusterNode n)
n
- Node to get cache attributes for.public static boolean hasNearCache(ClusterNode n, String cacheName)
n
- Node.cacheName
- Cache name.true
if given node has near cache enabled for the
specified partitioned cache.public static void asyncLogError(IgniteInternalFuture<?> f, IgniteLogger log)
f
- Future to listen to.log
- Logger.public static Collection<UUID> nodeIds(@Nullable @Nullable Collection<? extends ClusterNode> nodes)
nodes
- Nodes.public static Collection<UUID> gridIds(@Nullable @Nullable Collection<? extends Ignite> grids)
grids
- Grids.public static Collection<String> grids2names(@Nullable @Nullable Collection<? extends Ignite> grids)
grids
- Grids.public static Collection<String> nodes2names(@Nullable @Nullable Collection<? extends ClusterNode> nodes)
nodes
- Nodes.public static boolean addLastCause(@Nullable @Nullable Throwable e, @Nullable @Nullable Throwable cause, IgniteLogger log)
e
- Error to add cause to.cause
- Cause to add.log
- Logger to log failure when cause can not be added.True
if cause was added.public static String nl()
line.separator
system property.public static IgniteLogger logger(GridKernalContext ctx, AtomicReference<IgniteLogger> logRef, Object obj)
ctx
- Context.logRef
- Log reference.obj
- Object to get logger for.public static IgniteLogger logger(GridKernalContext ctx, AtomicReference<IgniteLogger> logRef, Class<?> cls)
ctx
- Context.logRef
- Log reference.cls
- Class to get logger for.public static int concurrentMapSegment(int hash, int concurLvl)
hash
- Hash code of the object to put.concurLvl
- Concurrency level.public static <K,V> void printConcurrentHashMapInfo(ConcurrentHashMap<K,V> map)
map
- Map.public static <T> T field(Object obj, String fieldName)
obj
- Object.fieldName
- Field name.public static boolean hasField(Object obj, String fieldName)
obj
- Object.fieldName
- Field name.public static long fieldOffset(Class<?> cls, String fieldName)
cls
- Object class.fieldName
- Field name.public static boolean isFinal(Class<?> cls)
cls
- Class to check.True
if class is final.public static <T> T field(Class<?> cls, String fieldName) throws IgniteCheckedException
cls
- Class.fieldName
- Field name.IgniteCheckedException
- If static field with given name cannot be retreived.public static <T> T invoke(@Nullable @Nullable Class<?> cls, @Nullable @Nullable Object obj, String mtdName, Object... params) throws IgniteCheckedException
cls
- Object.obj
- Object.mtdName
- Field name.params
- Parameters.IgniteCheckedException
- If static field with given name cannot be retreived.public static <T> T invoke(@Nullable @Nullable Class<?> cls, @Nullable @Nullable Object obj, String mtdName, Class[] paramTypes, Object... params) throws IgniteCheckedException
cls
- Object.obj
- Object.mtdName
- Field name.paramTypes
- Parameter types.params
- Parameters.IgniteCheckedException
- If static field with given name cannot be retrieved.public static <T> T property(Object obj, String propName)
obj
- Object.propName
- Property name.public static <T> T staticField(Class<?> cls, String fieldName) throws IgniteCheckedException
cls
- Class.fieldName
- Field name.IgniteCheckedException
- If failed.public static boolean isVisorNodeStartProperty(String name)
name
- Property name to check.True
if property is Visor node startup property, false
otherwise.public static boolean isVisorRequiredProperty(String name)
name
- Property name to check.True
if property is required by Visor, false
otherwise.public static IgniteBiTuple<Object,Object> addLog4jNoOpLogger() throws IgniteCheckedException
null
if it did not found in classpath. Notice that in this case logging is not suppressed.IgniteCheckedException
- In case of failure to add no-op logger for Log4j.public static void removeLog4jNoOpLogger(IgniteBiTuple<Object,Object> t) throws IgniteCheckedException
addLog4jNoOpLogger()
.t
- Tuple with root log and null appender instances.IgniteCheckedException
- In case of failure to remove previously added no-op logger for Log4j.public static Collection<Handler> addJavaNoOpLogger()
public static void removeJavaNoOpLogger(Collection<Handler> rmvHnds)
rmvHnds
- Previously removed handlers.public static String nodeIdLogFileName(UUID nodeId, String fileName)
nodeId
- Node ID.fileName
- File name.public static String customDirectoryLogFileName(@Nullable @Nullable String dir, String fileName)
dir
- Directory.fileName
- Original path.public static String fl(String msg, Object... args)
msg
- Message to start string.args
- Even length array where the odd elements are parameter names
and even elements are parameter values.public static int nextPowerOf2(int v)
v
- Value to round up.public static int safeAbs(int i)
Integer.MIN_VALUE
, then 0
is returned.i
- Integer.public static long safeAbs(long i)
Long.MIN_VALUE
, then 0
is returned.i
- Argument.public static long ensurePositive(long i, long dflt)
long
value given is positive returns that value, otherwise returns provided default value.i
- Input value.dflt
- Default value.i
if i > 0
and dflt
otherwise.@Nullable public static @Nullable Class<?> box(@Nullable @Nullable Class<?> cls)
cls
- Class. If null
, method is no-op.public static Class<?> forName(String clsName, @Nullable @Nullable ClassLoader ldr) throws ClassNotFoundException
clsName
- Class name.ldr
- Class loader.ClassNotFoundException
- If class not found.public static Class<?> forName(String clsName, @Nullable @Nullable ClassLoader ldr, IgnitePredicate<String> clsFilter) throws ClassNotFoundException
clsName
- Class name.ldr
- Class loader.ClassNotFoundException
- If class not found.public static Class<?> forName(String clsName, @Nullable @Nullable ClassLoader ldr, IgnitePredicate<String> clsFilter, boolean useCache) throws ClassNotFoundException
clsName
- Class name.ldr
- Class loader.useCache
- If true class loader and result should be cached internally, false otherwise.ClassNotFoundException
- If class not found.public static void clearClassFromClassCache(ClassLoader ldr, String clsName)
ldr
- Class loader.clsName
- Class name of clearing class.public static void clearClassCache(ClassLoader ldr)
ldr
- Class loader.public static void clearClassCache()
public static int hash(int h)
This function has been taken from Java 8 ConcurrentHashMap with slightly modifications.
h
- Value to hash.public static int hash(Object key)
This function has been taken from Java 8 ConcurrentHashMap with slightly modifications.
key
- Value to hash.public static int hash(long key)
hash(Object)
to avoid unnecessary boxing.key
- Value to hash.public static int jvmPid()
-1
if it can't be determined.public static List<String> jvmArgs()
public static int arrayCopy(byte[] src, int off, byte[] resBuf, int resOff, int len)
src
- Buffer to copy from (length included).off
- Offset in source buffer.resBuf
- Result buffer.resOff
- Result offset.len
- Length.bytes
array.public static String consistentId(Collection<String> addrs)
addrs
- Node's addresses.ClusterNode.consistentId()
requirements.public static String consistentId(Collection<String> addrs, int port)
addrs
- Node's addresses.port
- Port discovery number.ClusterNode.consistentId()
requirements.public static String maskForFileName(CharSequence name)
name
- Name.public static boolean overridesEqualsAndHashCode(Object obj)
obj
- Object.True
if given object has overridden equals and hashCode method.public static boolean overridesEqualsAndHashCode(Class<?> cls)
cls
- Class.True
if given class has overridden equals and hashCode method.public static boolean isMacInvalidArgumentError(Exception e)
e
- Exception.True
if error is invalid argument error on MAC.@Nullable public static <T> T firstNotNull(@Nullable T... vals)
vals
- Input array.null
, if array is empty or contains
only nulls.public static void startLifecycleAware(Iterable<?> objs) throws IgniteCheckedException
Iterable
checks if it implements
LifecycleAware
interface and executes LifecycleAware.start()
method.objs
- Objects.IgniteCheckedException
- If LifecycleAware.start()
fails.public static void stopLifecycleAware(IgniteLogger log, Iterable<?> objs)
Iterable
checks if it implements
LifecycleAware
interface and executes LifecycleAware.stop()
method.log
- Logger used to log error message in case of stop failure.objs
- Object passed to Ignite configuration.public static Map<String,Collection<ClusterNode>> neighborhood(Iterable<ClusterNode> nodes)
Detection of the same physical computer (host) is based on comparing set of network interface MACs. If two nodes have the same set of MACs, Ignite considers these nodes running on the same physical computer.
nodes
- Nodes.public static Collection<InetAddress> toInetAddresses(ClusterNode node) throws IgniteCheckedException
node
- Grid node.IgniteCheckedException
- If non of addresses can be resolved.public static Collection<InetAddress> toInetAddresses(Collection<String> addrs, Collection<String> hostNames) throws IgniteCheckedException
addrs
- Addresses.hostNames
- Host names.IgniteCheckedException
- If non of addresses can be resolved.public static Collection<InetSocketAddress> toSocketAddresses(ClusterNode node, int port)
node
- Grid node.port
- Port.public static Collection<InetSocketAddress> toSocketAddresses(Collection<String> addrs, Collection<String> hostNames, int port)
addrs
- Addresses.hostNames
- Host names.port
- Port.public static Collection<InetSocketAddress> resolveAddresses(AddressResolver addrRslvr, Iterable<String> addrs, int port) throws IgniteSpiException
addrRslvr
- Address resolver.addrs
- Addresses.port
- Port.IgniteSpiException
- If failed.public static Collection<InetSocketAddress> resolveAddresses(AddressResolver addrRslvr, Collection<InetSocketAddress> sockAddr)
addrRslvr
- Address resolver.sockAddr
- Addresses.public static String addressesAsString(ClusterNode node)
node
- Grid node.public static String addressesAsString(Collection<String> addrs, Collection<String> hostNames)
addrs
- Addresses.hostNames
- Host names.public static String defaultWorkDirectory() throws IgniteCheckedException
IgniteCheckedException
public static String workDirectory(@Nullable @Nullable String userWorkDir, @Nullable @Nullable String userIgniteHome) throws IgniteCheckedException
userWorkDir
- Ignite work folder provided by user.userIgniteHome
- Ignite home folder provided by user.IgniteCheckedException
public static void nullifyHomeDirectory()
public static File resolveWorkDirectory(String workDir, String path, boolean delIfExist) throws IgniteCheckedException
workDir
- Work directory.path
- Path to resolve.delIfExist
- Flag indicating whether to delete the specify directory or not.IgniteCheckedException
- If failed.public static void ensureDirectory(File dir, String msg, IgniteLogger log) throws IgniteCheckedException
dir
- Directory to check.msg
- Directory name for the messages.log
- Optional logger to log a message that the directory has been resolved.IgniteCheckedException
- If directory does not exist and failed to create it, or if a file with
the same name already exists.public static void ensureDirectory(Path dir, String msg, IgniteLogger log) throws IgniteCheckedException
dir
- Directory to check.msg
- Directory name for the messages.log
- Optional logger to log a message that the directory has been resolved.IgniteCheckedException
- If directory does not exist and failed to create it, or if a file with
the same name already exists.public static IgniteCheckedException exceptionWithSuppressed(String msg, @Nullable @Nullable Collection<Throwable> suppressed)
IgniteCheckedException
with the collection of suppressed exceptions.msg
- Message.suppressed
- The collections of suppressed exceptions.IgniteCheckedException
.@Nullable public static @Nullable String lambdaEnclosingClassName(String clsName)
clsName
- JDK8 lambda class name.null
if passed in name is not related to lambda.public static int toDigit(char ch, int idx) throws IgniteCheckedException
ch
- A character to convert to an integer digitidx
- The index of the character in the sourceIgniteCheckedException
- Thrown if ch is an illegal hex characterpublic static ClusterNode oldest(Collection<ClusterNode> c, @Nullable @Nullable IgnitePredicate<ClusterNode> p)
c
- Collection of nodes.public static ClusterNode youngest(Collection<ClusterNode> c, @Nullable @Nullable IgnitePredicate<ClusterNode> p)
c
- Collection of nodes.public static byte[] copyMemory(long ptr, int size)
ptr
- Address.size
- Size.public static int capacity(int expSize)
expSize
- Expected size of created map.public static <K,V> HashMap<K,V> newHashMap(int expSize)
HashMap
with expected size.K
- Type of map keys.V
- Type of map values.expSize
- Expected size of created map.public static <K,V> LinkedHashMap<K,V> newLinkedHashMap(int expSize)
LinkedHashMap
with expected size.K
- Type of map keys.V
- Type of map values.expSize
- Expected size of created map.public static <T> HashSet<T> newHashSet(int expSize)
HashSet
with expected size.T
- Type of elements.expSize
- Expected size of created map.public static <T> LinkedHashSet<T> newLinkedHashSet(int expSize)
LinkedHashSet
with expected size.T
- Type of elements.expSize
- Expected size of created map.public static <K,V> Map<K,V> limitedMap(int limit)
limit
- Limit for size.public static <K,V> Map<K,V> map(K k, V v)
k
- Key.v
- Value.public static <K,V> Map<K,V> map(K k1, V v1, K k2, V v2)
k1
- Key 1.v1
- Value 1.k2
- Key 2.v2
- Value 2.public static <K,V> Map<K,V> map(K k1, V v1, K k2, V v2, K k3, V v3)
k1
- Key 1.v1
- Value 1.k2
- Key 2.v2
- Value 2.k3
- Key 3.v3
- Value 3.public static <T> Collection<T> convertToSingletonList(Collection<T> col)
col
- non-null collection with one elementpublic static Comparator<InetSocketAddress> inetAddressesComparator(boolean sameHost)
sameHost
- True
if remote node resides on the same host, false
otherwise.@Nullable public static @Nullable Method findNonPublicMethod(Class<?> cls, String name, Class<?>... paramTypes)
cls
- The class to search,name
- Name of the method.paramTypes
- Method parameters.null
.@Nullable public static @Nullable Method getNonPublicMethod(Class<?> cls, String name, Class<?>... paramTypes)
cls
- Target class.name
- Name of the method.paramTypes
- Method parameters.null
.@Nullable public static @Nullable Method findInheritableMethod(Class<?> cls, String name, Class<?>... paramTypes)
cls
- Target class.name
- Name of the method.paramTypes
- Method parameters.null
.@Nullable public static @Nullable Field findField(Class<?> cls, String name)
cls
- The class to search.name
- Name of a field to get.null
.public static <T extends R,R> List<R> arrayList(Collection<T> c, @Nullable IgnitePredicate<? super T>... p)
c
- Collection.p
- Optional filters.public static <T extends R,R> List<R> arrayList(Collection<T> c)
c
- Collection.public static <T extends R,R> List<R> arrayList(Iterator<T> c, int cap, @Nullable IgnitePredicate<? super T>... p)
c
- Collection.cap
- Initial capacity.p
- Optional filters.public static byte[] calculateMD5Digest(@NotNull @NotNull InputStream in) throws NoSuchAlgorithmException, IOException
in
- Input stream.NoSuchAlgorithmException
- If MD5 algorithm was not found.IOException
- If an I/O exception occurs.public static String calculateMD5(InputStream in) throws NoSuchAlgorithmException, IOException
in
- Input stream.NoSuchAlgorithmException
- If MD5 algorithm was not found.IOException
- If an I/O exception occurs.public static int writeMessageFully(Message msg, OutputStream out, ByteBuffer buf, MessageWriter writer) throws IOException
msg
- Message.out
- Stream to write to.buf
- Byte buffer that will be passed to Message.writeTo(ByteBuffer, MessageWriter)
method.writer
- Message writer.IOException
- In case of error.public static void assertParameter(boolean cond, String condDesc) throws IgniteException
false
.cond
- Assertion condition to check.condDesc
- Description of failed condition.IgniteException
public static boolean hasSharedMemory()
public static void writeLock(ReadWriteLock lock) throws IgniteInterruptedCheckedException
lock
- Lock.IgniteInterruptedCheckedException
- If interrupted.public static byte directProtocolVersion(GridKernalContext ctx, UUID nodeId) throws IgniteCheckedException
ctx
- Context.nodeId
- Node ID.IgniteCheckedException
- If node doesn't exist.public static boolean isHashCodeMethod(Method mtd)
Object.hashCode()
.public static boolean isEqualsMethod(Method mtd)
Object.equals(...)
.public static boolean isToStringMethod(Method mtd)
Object.toString()
.public static String threadName(long threadId)
threadId
- Thread ID.public static <T extends Comparable<? super T>> T max(T t0, T t1)
T
- Comparable type.t0
- Comparable object.t1
- Comparable object.public static <T> T unmarshal(Marshaller marsh, InputStream in, @Nullable @Nullable ClassLoader clsLdr) throws IgniteCheckedException
IgniteCheckedException
in fail case.T
- Type of unmarshalled object.in
- Input stream.clsLdr
- Class loader to use.IgniteCheckedException
- If unmarshalling failed.public static <T> T unmarshalZip(Marshaller marsh, byte[] zipBytes, @Nullable @Nullable ClassLoader clsLdr) throws IgniteCheckedException
marsh
- Marshaller.zipBytes
- Zip-compressed bytes.clsLdr
- Class loader to use.IgniteCheckedException
public static byte[] unzip(byte[] zipBytes) throws IgniteCheckedException
zipBytes
- Zipped bytes.IgniteCheckedException
- If unzip resulted in error.public static <T> T unmarshal(Marshaller marsh, byte[] arr, @Nullable @Nullable ClassLoader clsLdr) throws IgniteCheckedException
IgniteCheckedException
in fail case.T
- Type of unmarshalled object.marsh
- Marshaller.arr
- Byte array.clsLdr
- Class loader to use.IgniteCheckedException
- If unmarshalling failed.public static <T> T unmarshal(GridKernalContext ctx, byte[] arr, @Nullable @Nullable ClassLoader clsLdr) throws IgniteCheckedException
IgniteCheckedException
in fail case.T
- Type of unmarshalled object.ctx
- Kernal contex.arr
- Byte array.clsLdr
- Class loader to use.IgniteCheckedException
- If unmarshalling failed.public static <T> T unmarshal(GridCacheSharedContext ctx, byte[] arr, @Nullable @Nullable ClassLoader clsLdr) throws IgniteCheckedException
IgniteCheckedException
in fail case.T
- Type of unmarshalled object.ctx
- Kernal contex.arr
- Byte array.clsLdr
- Class loader to use.IgniteCheckedException
- If unmarshalling failed.public static byte[] marshal(Marshaller marsh, Object obj) throws IgniteCheckedException
IgniteCheckedException
in fail case.marsh
- Marshaller.obj
- Object to marshal.IgniteCheckedException
- If marshalling failed.public static void marshal(Marshaller marsh, @Nullable @Nullable Object obj, OutputStream out) throws IgniteCheckedException
IgniteCheckedException
in fail case.marsh
- Marshaller.obj
- Object to marshal.out
- Output stream.IgniteCheckedException
- If marshalling failed.public static byte[] marshal(GridKernalContext ctx, Object obj) throws IgniteCheckedException
IgniteCheckedException
in fail case.ctx
- Kernal context.obj
- Object to marshal.IgniteCheckedException
- If marshalling failed.public static byte[] marshal(GridCacheSharedContext ctx, Object obj) throws IgniteCheckedException
IgniteCheckedException
in fail case.ctx
- Cache context.obj
- Object to marshal.IgniteCheckedException
- If marshalling failed.@Nullable public static @Nullable String getCurrentIgniteName()
public static boolean isCurrentIgniteNameSet(@Nullable @Nullable String name)
name
- Name to check.True
if set.@Nullable public static @Nullable String setCurrentIgniteName(@Nullable @Nullable String newName)
newName
- New name.public static void restoreOldIgniteName(@Nullable @Nullable String oldName, @Nullable @Nullable String curName)
oldName
- Old name.curName
- Current name.public static byte[] zip(@Nullable @Nullable byte[] bytes) throws IgniteCheckedException
bytes
- Byte array to compress.IgniteCheckedException
- If failed.public static byte[] zip(@Nullable @Nullable byte[] bytes, int compressionLevel) throws IgniteCheckedException
bytes
- Byte array to compress.compressionLevel
- Level of compression to encode.IgniteCheckedException
- If failed.public static byte[] toBytes(Serializable obj)
obj
- Object.public static <T> T fromBytes(byte[] data)
data
- Serialized object.public static long checkpointBufferSize(DataRegionConfiguration regCfg)
regCfg
- Configuration.public static long adjustedWalHistorySize(DataStorageConfiguration dsCfg, @Nullable @Nullable IgniteLogger log)
DataStorageConfiguration.getMaxWalArchiveSize()
is not overridden.public static int fileCount(Path dir) throws IOException
dir
- path to directoryIOException
- sometimespublic static long dirSize(Path path) throws IgniteCheckedException
IgniteCheckedException
public static Path searchFileRecursively(Path path, @NotNull @NotNull String name) throws IgniteCheckedException
path
- Path.name
- Name.IgniteCheckedException
public static GridIntIterator forRange(int start, int cnt)
GridIntIterator
for range of primitive integers.start
- Start.cnt
- Count.public static int nearestPow2(int x)
x
- X.public static int nearestPow2(int x, boolean less)
x
- X.less
- Less.public static void enhanceThreadName(String text)
enhanceThreadName(Thread.currentThread(), text)
.
For details see enhanceThreadName(Thread, String)
.text
- Text to be set in thread name in square [] braces. Does nothing if cannot find suitable braces.public static void enhanceThreadName(@Nullable @Nullable Thread thread, String text)
enhanceThreadName(thread, "myText")
, the name of the thread will
be "my-thread-[myText]-%gridname%".thread
- Thread to be renamed, it must contain square braces in name []. Does nothing if null
.text
- Text to be set in thread name in square [] braces. Does nothing if cannot find suitable braces.public static BaselineTopology getBaselineTopology(@NotNull @NotNull GridKernalContext ctx)
ctx
- Context.public static BaselineTopology getBaselineTopology(@NotNull @NotNull GridCacheSharedContext cctx)
cctx
- Context.public static BaselineTopology getBaselineTopology(@NotNull @NotNull GridCacheContext cctx)
cctx
- Context.public static boolean isOldestNodeVersionAtLeast(IgniteProductVersion ver, Iterable<ClusterNode> nodes)
ver
- Target Ignite product version.nodes
- Cluster nodes.True
if ignite product version of all nodes is not less then ver
.public static String toHexString(long addr, int len)
addr
- pointer in memorylen
- how much byte to read (should divide 8)public static String toHexString(ByteBuffer buf)
buf
- which content should be converted to stringpublic static ClusterNode randomServerNode(GridKernalContext ctx)
ctx
- Kernel context.public static int availableThreadCount(GridKernalContext ctx, byte plc, int reserved)
ctx
- Kernal context.plc
- IO Policy.reserved
- Thread to reserve.plc
. If plc
is invalid, return 1
.public static <T,R> Collection<R> doInParallel(ExecutorService executorSvc, Collection<T> srcDatas, IgniteThrowableFunction<T,R> operation) throws IgniteCheckedException, IgniteInterruptedCheckedException
T
- Type of data.executorSvc
- Service for parallel execution.srcDatas
- List of data for parallelization.operation
- Logic for execution of on each item of data.IgniteCheckedException
- if parallel execution was failed.IgniteInterruptedCheckedException
public static <T,R> Collection<R> doInParallel(int parallelismLvl, ExecutorService executorSvc, Collection<T> srcDatas, IgniteThrowableFunction<T,R> operation) throws IgniteCheckedException, IgniteInterruptedCheckedException
T
- Type of data.R
- Type of return value.parallelismLvl
- Number of threads on which it should be executed.executorSvc
- Service for parallel execution.srcDatas
- List of data for parallelization.operation
- Logic for execution of on each item of data.IgniteCheckedException
- if parallel execution was failed.IgniteInterruptedCheckedException
public static <T,R> Collection<R> doInParallelUninterruptibly(int parallelismLvl, ExecutorService executorSvc, Collection<T> srcDatas, IgniteThrowableFunction<T,R> operation) throws IgniteCheckedException, IgniteInterruptedCheckedException
T
- Type of data.R
- Type of return value.parallelismLvl
- Number of threads on which it should be executed.executorSvc
- Service for parallel execution.srcDatas
- List of data for parallelization.operation
- Logic for execution of on each item of data.IgniteCheckedException
- if parallel execution was failed.IgniteInterruptedCheckedException
public static boolean isLocalNodeCoordinator(GridDiscoveryManager discoMgr)
true
if local node is coordinator.public static int[] calculateOptimalBatchSizes(int parallelismLvl, int size)
parallelismLvl
- Level of parallelism.size
- number of tasks to split.public static Runnable wrapIgniteFuture(Runnable r, GridFutureAdapter<?> fut)
r
- Runnable.fut
- Grid future apater.public static Cipher createCipher(Key key, int encMode)
key
- Cipher Key.encMode
- Enc mode see Cipher.ENCRYPT_MODE
, Cipher.DECRYPT_MODE
, etc.public static void writeFully(SocketChannel sockCh, ByteBuffer buf) throws IOException
sockCh
- WritableByteChannel.buf
- Buffer.IOException
- IOException.public static <X> Set<X> newIdentityHashSet()
public static int stripeIdx(int stripes, int grpId, int partId)
stripes
- Number of stripes.grpId
- Group Id.partId
- Partition Id.public static boolean isFlagSet(int flags, int flag)
flags
- Flags.flag
- Flag.True
if set.public static <T> void notifyListeners(T t, Collection<Consumer<T>> lsnrs, IgniteLogger log)
lsnrs
with the value t
.T
- Type of consumed object.t
- Consumed object.lsnrs
- Listeners.public static void awaitForWorkersStop(Collection<GridWorker> workers, boolean cancel, IgniteLogger log)
workers
- Workers collection.cancel
- Wheter should cancel workers.log
- Logger.public static String unquote(String s)
s
- String.public static void writeLongString(DataOutput out, @Nullable @Nullable String s) throws IOException
null
values. UTF_BYTE_LIMIT
limits are applied.out
- Output stream to write to.s
- String to write, possibly null
.IOException
- If write failed.@Nullable public static @Nullable String readLongString(DataInput in) throws IOException
null
values. UTF_BYTE_LIMIT
limits are applied.in
- Stream to read from.null
.IOException
- If read failed.public static void writeCutString(DataOutput out, @Nullable @Nullable String s) throws IOException
null
values.
Uses ObjectOutputStream.writeUTF(String)
to write the string under the hood
but cuts strings longer than UTF_BYTE_LIMIT
to the limit to avoid UTFDataFormatException
.
Strings written by the method can be read by readString(DataInput)
.
out
- Output stream to write to.s
- String to write, possibly null
.IOException
- If write failed.for more information.
public static int utfBytes(char c)
DataOutput.writeUTF(java.lang.String)
,
depending on character: c
is in the range
\u0001
through \u007f
.c
is \u0000
or
is in the range \u0080
through \u07ff
.
c
is in the range
\u0800
through uffff
.c
- Character.public static void broadcastToNodesSupportingFeature(GridKernalContext kctx, IgniteRunnable job, boolean srvrsOnly, IgniteFeatures feature)
kctx
- Kernal context.job
- Ignite job.srvrsOnly
- Broadcast only on server nodes.feature
- Ignite feature.public static Map<String,String> readStringMap(DataInput in) throws IOException
writeStringMap(DataOutput, Map)
.in
- Data input.IOException
- If write failed.public static void writeStringMap(DataOutput out, @Nullable @Nullable Map<String,String> map) throws IOException
out
- Data output.map
- Map.IOException
- If write failed.public static void writeUTF(DataOutput out, @Nullable @Nullable String val) throws IOException
null
.out
- Output stream.val
- Value.IOException
- If failed.public static String readUTF(DataInput in) throws IOException
null
.in
- Input stream.IOException
- If failed.public static String humanReadableByteCount(long bytes)
bytes
- Byte count.public static String humanReadableDuration(long millis)
millis
- Duration in milliseconds.public static long uncompressedSize(File zip) throws IOException
zip
- Zip file.IOException
- If failed.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.10.0 Release Date : March 10 2021