public class VisorTaskUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static VisorEventMapper |
EVT_MAPPER
Mapper from grid event to Visor data transfer object.
|
static int |
LOG_FILES_COUNT_LIMIT
Log files count limit
|
static int |
MAX_FOLDER_DEPTH
Maximum folder depth.
|
static int[] |
VISOR_ALL_EVTS
Only non task event types that Visor should collect.
|
static int[] |
VISOR_NON_TASK_EVTS
Only non task event types that Visor should collect.
|
static int[] |
VISOR_TASK_EVTS
Only task event types that Visor should collect.
|
| Constructor and Description |
|---|
VisorTaskUtils() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
boolValue(String propName,
boolean dflt)
Returns boolean value from system property or provided function.
|
static boolean |
checkExplicitTaskMonitoring(Ignite ignite)
Checks for explicit events configuration.
|
static Collection<VisorGridEvent> |
collectEvents(Ignite ignite,
String evtOrderKey,
String evtThrottleCntrKey,
boolean all,
IgniteClosure<Event,VisorGridEvent> evtMapper)
Grabs local events and detects if events was lost since last poll.
|
static List<VisorGridEvent> |
collectEvents(Ignite ignite,
String evtOrderKey,
String evtThrottleCntrKey,
int[] evtTypes,
IgniteClosure<Event,VisorGridEvent> evtMapper)
Grabs local events and detects if events was lost since last poll.
|
static String |
compactArray(Object[] arr)
Joins array elements to string.
|
static String |
compactClass(Class cls)
Compact class names.
|
static String |
compactClass(Object obj)
Compact class names.
|
static List<String> |
compactClasses(Class<?>[] clss)
Compact classes names.
|
static String |
compactIterable(Iterable col)
Joins iterable collection elements to string.
|
static Object |
compactObject(Object obj)
Returns compact class host.
|
static int[] |
concat(int[]... arrays)
Concat arrays in one.
|
static Charset |
decode(File f)
Decode file charset.
|
static String |
escapeName(Object name) |
static Integer |
evictionPolicyMaxSize(javax.cache.configuration.Factory plc)
Extract max size from eviction policy if available.
|
static List<VisorLogFile> |
fileTree(File file,
int maxDepth,
FileFilter filter)
Finds all files in folder and in it's sub-tree of specified depth.
|
static <K,V> V |
getOrElse(Map<K,V> map,
K key,
V ifNull)
Helper function to get value from map.
|
static Integer |
intValue(String propName,
Integer dflt)
Returns boolean value from system property or provided function.
|
static boolean |
joinTimedOut(String msg) |
static void |
log(IgniteLogger log,
String msg)
Log message.
|
static long |
log(IgniteLogger log,
String msg,
Class<?> clazz,
long start)
Log message.
|
static void |
logFinish(IgniteLogger log,
Class<?> clazz,
long start)
Log finished.
|
static void |
logMapped(IgniteLogger log,
Class<?> clazz,
Collection<ClusterNode> nodes)
Log task mapped.
|
static void |
logStart(IgniteLogger log,
Class<?> clazz,
long start)
Log start.
|
static List<VisorLogFile> |
matchedFiles(File file,
String ptrn) |
static Process |
openInConsole(File workFolder,
Map<String,String> envVars,
String... args)
Run command in separated console.
|
static Process |
openInConsole(File workFolder,
String... args)
Run command in separated console.
|
static Process |
openInConsole(String... args)
Run command in separated console.
|
static boolean |
reachableByPing(InetAddress addr,
int reachTimeout)
Checks if address can be reached using one argument InetAddress.isReachable() version or ping command if failed.
|
static VisorFileBlock |
readBlock(File file,
long off,
int blockSz,
long lastModified)
Read block from file.
|
static Path |
resolveIgfsProfilerLogsDir(IgniteFileSystem igfs)
Resolve IGFS profiler logs directory.
|
static File |
resolveIgnitePath(String path) |
static File |
resolveSymbolicLink(File file) |
static Collection<String> |
sortAddresses(Collection<String> addrs)
Sort addresses: IPv4 & real addresses first.
|
static Collection<String> |
splitAddresses(String s)
Split addresses.
|
static List<Process> |
startLocalNode(IgniteLogger log,
String cfgPath,
int nodesToStart,
boolean quite,
Map<String,String> envVars)
Start local node in terminal.
|
static boolean |
textFile(File f,
boolean emptyOk)
Check is text file.
|
static String |
unescapeName(String name) |
static byte[] |
zipBytes(byte[] input)
Zips byte array.
|
static byte[] |
zipBytes(byte[] input,
int initBufSize)
Zips byte array.
|
public static final int LOG_FILES_COUNT_LIMIT
public static final int[] VISOR_TASK_EVTS
public static final int[] VISOR_NON_TASK_EVTS
public static final int[] VISOR_ALL_EVTS
public static final int MAX_FOLDER_DEPTH
public static final VisorEventMapper EVT_MAPPER
public static String escapeName(@Nullable Object name)
name - Grid-style nullable name.null replaced to <default>.public static String unescapeName(String name)
name - Escaped name.null for default name.public static int[] concat(int[]... arrays)
arrays - Arrays.@Nullable public static Object compactObject(Object obj)
obj - Object to compact.@Nullable public static String compactClass(Class cls)
cls - Class object for compact.@Nullable public static String compactClass(@Nullable Object obj)
obj - Object for compact.@Nullable public static List<String> compactClasses(Class<?>[] clss)
clss - Classes to compact.@Nullable public static String compactArray(Object[] arr)
arr - Array.@Nullable public static String compactIterable(Iterable col)
col - Iterable collection.public static Integer intValue(String propName, Integer dflt)
propName - System property name.dflt - Function that returns Integer.Integer valuepublic static boolean boolValue(String propName, boolean dflt)
propName - System property host.dflt - Function that returns Boolean.Boolean valuepublic static <K,V> V getOrElse(Map<K,V> map, K key, V ifNull)
K - Key type.V - Value type.map - Map to take value from.key - Key to search in map.ifNull - Default value if null was returned by map.null.public static boolean checkExplicitTaskMonitoring(Ignite ignite)
ignite - Grid instance.true if all task events explicitly specified in configuration.public static Collection<VisorGridEvent> collectEvents(Ignite ignite, String evtOrderKey, String evtThrottleCntrKey, boolean all, IgniteClosure<Event,VisorGridEvent> evtMapper)
ignite - Target grid.evtOrderKey - Unique key to take last order key from node local map.evtThrottleCntrKey - Unique key to take throttle count from node local map.all - If true then collect all events otherwise collect only non task events.evtMapper - Closure to map grid events to Visor data transfer objects.public static List<VisorGridEvent> collectEvents(Ignite ignite, String evtOrderKey, String evtThrottleCntrKey, int[] evtTypes, IgniteClosure<Event,VisorGridEvent> evtMapper)
ignite - Target grid.evtOrderKey - Unique key to take last order key from node local map.evtThrottleCntrKey - Unique key to take throttle count from node local map.evtTypes - Event types to collect.evtMapper - Closure to map grid events to Visor data transfer objects.public static File resolveIgnitePath(String path) throws IOException
path - Path to resolve only relative to IGNITE_HOME.null if path cannot be resolved.IOException - If failed to resolve path.public static File resolveSymbolicLink(File file) throws IOException
file - File to resolve.IOException - If failed to resolve symlink.public static List<VisorLogFile> fileTree(File file, int maxDepth, @Nullable FileFilter filter) throws IOException
file - Starting foldermaxDepth - Depth of the tree. If 1 - just look in the folder, no sub-folders.filter - file filter.IOException - If failed to list files.public static List<VisorLogFile> matchedFiles(File file, String ptrn) throws IOException
file - Folder with files to match.ptrn - Pattern to match against file name.IOException - If failed to filter files.public static boolean textFile(File f, boolean emptyOk)
f - file reference.emptyOk - default value if empty file.public static Charset decode(File f) throws IOException
f - File to process.IOException - in case of error.public static VisorFileBlock readBlock(File file, long off, int blockSz, long lastModified) throws IOException
file - - File to read.off - - Marker position in file to start read from if -1 read last blockSz bytes.blockSz - - Maximum number of chars to read.lastModified - - File last modification time.IOException - In case of error.public static Path resolveIgfsProfilerLogsDir(IgniteFileSystem igfs) throws IgniteCheckedException
igfs - IGFS instance to resolve logs dir for.Path to log dir or null if not found.IgniteCheckedException - if failed to resolve.public static Integer evictionPolicyMaxSize(@Nullable javax.cache.configuration.Factory plc)
plc - Eviction policy.public static void logStart(@Nullable
IgniteLogger log,
Class<?> clazz,
long start)
log - Logger.clazz - Class.start - Start time.public static void logFinish(@Nullable
IgniteLogger log,
Class<?> clazz,
long start)
log - Logger.clazz - Class.start - Start time.public static void logMapped(@Nullable
IgniteLogger log,
Class<?> clazz,
Collection<ClusterNode> nodes)
log - Logger.clazz - Task class.nodes - Mapped nodes.public static long log(@Nullable
IgniteLogger log,
String msg,
Class<?> clazz,
long start)
log - Logger.msg - Message to log.clazz - class.start - start time.public static void log(@Nullable
IgniteLogger log,
String msg)
log - Logger.msg - Message.public static boolean reachableByPing(InetAddress addr, int reachTimeout)
addr - Address to check.reachTimeout - Timeout for the check.True if address is reachable.public static List<Process> startLocalNode(@Nullable IgniteLogger log, String cfgPath, int nodesToStart, boolean quite, Map<String,String> envVars) throws IOException
log - Logger.cfgPath - Path to node configuration to start with.nodesToStart - Number of nodes to start.quite - If true then start node in quiet mode.envVars - Optional map with environment variables.IOException - If failed to start.public static Process openInConsole(String... args) throws IOException
args - A string array containing the program and its arguments.IOException - in case of error.public static Process openInConsole(@Nullable File workFolder, String... args) throws IOException
workFolder - Work folder for command.args - A string array containing the program and its arguments.IOException - in case of error.public static Process openInConsole(@Nullable File workFolder, Map<String,String> envVars, String... args) throws IOException
workFolder - Work folder for command.envVars - Optional map with environment variables.args - A string array containing the program and its arguments.IOException - If failed to start process.public static byte[] zipBytes(byte[] input)
throws IOException
input - Input bytes.IOException - If failed.public static byte[] zipBytes(byte[] input,
int initBufSize)
throws IOException
input - Input bytes.initBufSize - Initial buffer size.IOException - If failed.public static boolean joinTimedOut(String msg)
msg - Exception message.true if node failed to join grid.public static Collection<String> sortAddresses(Collection<String> addrs)
addrs - Addresses to sort.public static Collection<String> splitAddresses(String s)
s - String with comma separted addresses.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.7.5 Release Date : June 4 2019