Class GridClientUtils
- java.lang.Object
-
- org.apache.ignite.internal.client.util.GridClientUtils
-
public abstract class GridClientUtils extends Object
Java client utils.
-
-
Constructor Summary
Constructors Constructor Description GridClientUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Collection<T>applyFilter(Iterable<? extends T> elements, GridClientPredicate<? super T>... filters)Applies filter and returns filtered collection of nodes.static voidcloseQuiet(@Nullable Closeable closeable)Closes resource without reporting any error.static <T> GridClientPredicate<T>contains(Collection<T> c)Creates a predicates that checks if given value is contained in collection c.static <T> Tfirst(@Nullable Iterable<? extends T> c)Gets first element from given collection or returnsnullif the collection is empty.static StringgetSimpleName(Class<?> cls)Gets simple class name taking care of empty names.static booleanrestAvailable(GridClientNode node, GridClientProtocol p)Checks if given REST protocol available for given node.static intsafeAbs(int i)Gets absolute value for integer.static voidshutdownNow(Class<?> owner, ExecutorService exec, Logger log)Shutdowns givenExecutorServiceand wait for executor service to stop.
-
-
-
Method Detail
-
closeQuiet
public static void closeQuiet(@Nullable @Nullable Closeable closeable)Closes resource without reporting any error.- Parameters:
closeable- Resource to close.
-
contains
public static <T> GridClientPredicate<T> contains(Collection<T> c)
Creates a predicates that checks if given value is contained in collection c.- Type Parameters:
T- Type of elements in collection.- Parameters:
c- Collection to check.- Returns:
- Predicate.
-
first
@Nullable public static <T> T first(@Nullable @Nullable Iterable<? extends T> c)Gets first element from given collection or returnsnullif the collection is empty.- Type Parameters:
T- Type of the collection.- Parameters:
c- A collection.- Returns:
- Collections' first element or
nullin case if the collection is empty.
-
applyFilter
public static <T> Collection<T> applyFilter(Iterable<? extends T> elements, GridClientPredicate<? super T>... filters)
Applies filter and returns filtered collection of nodes.- Parameters:
elements- Nodes to be filtered.filters- Filters to apply. Elements of this array are allowed to benull.- Returns:
- Filtered collection.
-
restAvailable
public static boolean restAvailable(GridClientNode node, GridClientProtocol p)
Checks if given REST protocol available for given node.- Parameters:
node- Node.p- Protocol.- Returns:
trueif protocolpavailable fornode,falseotherwise.
-
shutdownNow
public static void shutdownNow(Class<?> owner, ExecutorService exec, Logger log)
Shutdowns givenExecutorServiceand wait for executor service to stop.- Parameters:
owner- The ExecutorService owner.exec- ExecutorService to shutdown.log- The logger to possible exceptions and warnings.
-
getSimpleName
public static String getSimpleName(Class<?> cls)
Gets simple class name taking care of empty names.- Parameters:
cls- Class to get the name for.- Returns:
- Simple class name.
-
safeAbs
public static int safeAbs(int i)
Gets absolute value for integer. If integer isInteger.MIN_VALUE, then0is returned.- Parameters:
i- Integer.- Returns:
- Absolute value.
-
-