public class VisorTaskUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
VisorTaskUtils.SortableAddress
Special wrapper over address that can be sorted in following order:
IPv4, private IPv4, IPv4 local host, IPv6.
|
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 double |
MINIMAL_REBALANCE |
static int |
NOTHING_TO_REBALANCE |
static int |
REBALANCE_COMPLETE |
static int |
REBALANCE_NOT_AVAILABLE |
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 @Nullable String |
compactArray(Object[] arr)
Joins array elements to string.
|
static @Nullable String |
compactClass(Class cls)
Compact class names.
|
static @Nullable String |
compactClass(@Nullable Object obj)
Compact class names.
|
static @Nullable List<String> |
compactClasses(Class<?>[] clss)
Compact classes names.
|
static @Nullable String |
compactIterable(Iterable col)
Joins iterable collection elements to string.
|
static @Nullable 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(@Nullable Object name) |
static Integer |
evictionPolicyMaxSize(@Nullable javax.cache.configuration.Factory plc)
Extract max size from eviction policy if available.
|
static List<VisorLogFile> |
fileTree(File file,
int maxDepth,
@Nullable 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 |
isProxyCache(IgniteEx ignite,
String cacheName) |
static boolean |
isRestartingCache(IgniteEx ignite,
String cacheName)
Check whether cache restarting in progress.
|
static boolean |
joinTimedOut(String msg) |
static void |
log(@Nullable IgniteLogger log,
String msg)
Log message.
|
static long |
log(@Nullable IgniteLogger log,
String msg,
Class<?> clazz,
long start)
Log message.
|
static void |
logFinish(@Nullable IgniteLogger log,
Class<?> clazz,
long start)
Log finished.
|
static void |
logMapped(@Nullable IgniteLogger log,
Class<?> clazz,
Collection<ClusterNode> nodes)
Log task mapped.
|
static void |
logStart(@Nullable IgniteLogger log,
Class<?> clazz,
long start)
Log start.
|
static List<VisorLogFile> |
matchedFiles(File file,
String ptrn) |
static Process |
openInConsole(@Nullable File workFolder,
Map<String,String> envVars,
String... args)
Run command in separated console.
|
static Process |
openInConsole(@Nullable 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 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(@Nullable 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 NOTHING_TO_REBALANCE
public static final int REBALANCE_NOT_AVAILABLE
public static final double MINIMAL_REBALANCE
public static final int REBALANCE_COMPLETE
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 @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 @Nullable Object compactObject(Object obj)
obj
- Object to compact.@Nullable public static @Nullable String compactClass(Class cls)
cls
- Class object for compact.@Nullable public static @Nullable String compactClass(@Nullable @Nullable Object obj)
obj
- Object for compact.@Nullable public static @Nullable List<String> compactClasses(Class<?>[] clss)
clss
- Classes to compact.@Nullable public static @Nullable String compactArray(Object[] arr)
arr
- Array.@Nullable public static @Nullable 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 @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 Integer evictionPolicyMaxSize(@Nullable @Nullable javax.cache.configuration.Factory plc)
plc
- Eviction policy.public static void logStart(@Nullable @Nullable IgniteLogger log, Class<?> clazz, long start)
log
- Logger.clazz
- Class.start
- Start time.public static void logFinish(@Nullable @Nullable IgniteLogger log, Class<?> clazz, long start)
log
- Logger.clazz
- Class.start
- Start time.public static void logMapped(@Nullable @Nullable IgniteLogger log, Class<?> clazz, Collection<ClusterNode> nodes)
log
- Logger.clazz
- Task class.nodes
- Mapped nodes.public static long log(@Nullable @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 @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 @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 @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 @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.public static boolean isProxyCache(IgniteEx ignite, String cacheName)
ignite
- Ignite.cacheName
- Cache name to check.true
if cache on local node is not a data cache or near cache disabled.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.10.0 Release Date : March 10 2021