org.apache.ignite.internal.client.util

## 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 and Description
`GridClientUtils()`

### Method Summary

All Methods Static Methods Concrete Methods
`static <T> Collection<T>` `applyFilter(Iterable<? extends T> elements, GridClientPredicate<? super T>... filters)` Applies filter and returns filtered collection of nodes.
`static UUID` `checkFeatureSupportedByCluster(GridClient client, IgniteFeatures feature, boolean validateClientNodes, boolean failIfUnsupportedFound)` Checks that all cluster nodes support specified feature.
`static void` `closeQuiet(@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> T` `first(@Nullable Iterable<? extends T> c)` Gets first element from given collection or returns `null` if the collection is empty.
`static String` `getSimpleName(Class<?> cls)` Gets simple class name taking care of empty names.
`static boolean` `restAvailable(GridClientNode node, GridClientProtocol p)` Checks if given REST protocol available for given node.
`static int` `safeAbs(int i)` Gets absolute value for integer.
`static void` `shutdownNow(Class<?> owner, ExecutorService exec, Logger log)` Shutdowns given `ExecutorService` and wait for executor service to stop.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### GridClientUtils

    public GridClientUtils()

### 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 returns `null` if the collection is empty.

Type Parameters:
  `T` - Type of the collection.
Parameters:
  `c` - A collection.
Returns:
  Collections' first element or `null` in 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 be `null`.
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:
  `true` if protocol `p` available for `node`, `false` otherwise.

#### shutdownNow

    public static void shutdownNow(Class<?> owner,
                                   ExecutorService exec,
                                   Logger log)

Shutdowns given `ExecutorService` and 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 is `Integer.MIN_VALUE`, then `0` is returned.

Parameters:
  `i` - Integer.
Returns:
  Absolute value.

#### checkFeatureSupportedByCluster

    public static UUID checkFeatureSupportedByCluster(GridClient client,
                                                      IgniteFeatures feature,
                                                      boolean validateClientNodes,
                                                      boolean failIfUnsupportedFound)
                                               throws GridClientException

Checks that all cluster nodes support specified feature.

Parameters:
  `client` - Client.
  `feature` - Feature.
  `validateClientNodes` - Whether client nodes should be checked as well.
  `failIfUnsupportedFound` - If `true`, fails when found a node unsupporting `feature`. unsupporting `feature`.
Returns:
  Id of node unsupporting `feature`. `Null` if all nodes support `feature`.
Throws:
  `GridClientException`

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.15.0
Release Date | : April 25 2023