org.apache.ignite.internal.processors.platform.utils

## Class PlatformUtils

- java.lang.Object
- - org.apache.ignite.internal.processors.platform.utils.PlatformUtils

    public class PlatformUtils
    extends Object

Platform utility methods.

### Field Summary

Fields
`static String` `ATTR_PLATFORM` Node attribute: platform.
`static int` `OP_PREPARE_DOT_NET` Operation: prepare .Net platform.
`static String` `PLATFORM_CPP` Platform: CPP.
`static String` `PLATFORM_DOTNET` Platform: .Net.

### Method Summary

Methods
`static void` `applyContinuousQueryEvents(PlatformContext ctx, long lsnrPtr, Iterable<javax.cache.event.CacheEntryEvent> evts)` Apply continuous query events to listener.
`static <T> T` `createJavaObject(String clsName)` Create Java object.
`static CachePeekMode[]` `decodeCachePeekModes(int modes)` Convert native cache peek modes to Java cache peek modes.
`static byte[]` `errorData(Throwable err)` Get error data.
`static boolean` `evaluateContinuousQueryEvent(PlatformContext ctx, long filterPtr, javax.cache.event.CacheEntryEvent evt)` Evaluate the filter.
`static String` `getFullStackTrace(Throwable throwable)` Gets the entire nested stack-trace of an throwable.
`static void` `initializeJavaObject(Object obj, String clsName, Map<String,Object> props, GridKernalContext ctx)` Initialize Java object or object factory.
`static GridBinaryMarshaller` `marshaller()` Create binary marshaller.
`static PlatformContext` `platformContext(Ignite grid)` Gets interop context for the grid.
`static PlatformProcessor` `platformProcessor(Ignite grid)` Get GridGain platform processor.
`static <T> List<T>` `readCollection(BinaryRawReaderEx reader)` Read collection.
`static <T> List<T>` `readCollection(BinaryRawReaderEx reader, PlatformReaderClosure<T> readClo)` Read collection.
`static Object` `readInvocationResult(PlatformContext ctx, BinaryRawReaderEx reader)` Reads invocation result (of a job/service/etc) using a common protocol.
`static <K,V> Map<K,V>` `readMap(BinaryRawReaderEx reader)` Read map.
`static <K,V> Map<K,V>` `readMap(BinaryRawReaderEx reader, PlatformReaderBiClosure<K,V> readClo)` Read map.
`static <T> List<T>` `readNullableCollection(BinaryRawReaderEx reader)` Read nullable collection.
`static <T> List<T>` `readNullableCollection(BinaryRawReaderEx reader, PlatformReaderClosure<T> readClo)` Read nullable collection.
`static <K,V> Map<K,V>` `readNullableMap(BinaryRawReaderEx reader)` Read nullable map.
`static <T> Set<T>` `readNullableSet(BinaryRawReaderEx reader)`
`static <T> Set<T>` `readSet(BinaryRawReaderEx reader)`
`static void` `reallocate(long memPtr, int cap)` Reallocate arbitrary memory chunk.
`static Object[]` `unwrapBinariesInArray(Object[] arr)` Unwrap array of binaries if needed.
`static IgniteCheckedException` `unwrapQueryException(Throwable err)` Unwrap query exception.
`static <T> void` `writeCollection(BinaryRawWriterEx writer, Collection<T> col)` Write collection to the writer.
`static <T> void` `writeCollection(BinaryRawWriterEx writer, Collection<T> col, PlatformWriterClosure<T> writeClo)` Write collection to the writer.
`static <T> void` `writeCollection(BinaryRawWriterEx writer, Collection<T> col, PlatformWriterClosure<T> writeClo, IgnitePredicate<T> filter)` Write collection to the writer.
`static void` `writeError(Throwable ex, BinaryRawWriterEx writer)` Writes error.
`static void` `writeErrorData(Throwable err, BinaryRawWriterEx writer)` Writer error data.
`static void` `writeErrorData(Throwable err, BinaryRawWriterEx writer, IgniteLogger log)` Write error data.
`static void` `writeIgniteUuid(BinaryRawWriterEx writer, IgniteUuid val)` Writes IgniteUuid to a writer.
`static void` `writeInvocationResult(BinaryRawWriterEx writer, Object resObj, Exception err)` Writes invocation result (of a job/service/etc) using a common protocol.
`static <K,V> void` `writeMap(BinaryRawWriterEx writer, Map<K,V> map)` Write nullable map to the writer.
`static <K,V> void` `writeMap(BinaryRawWriterEx writer, Map<K,V> map, PlatformWriterBiClosure<K,V> writeClo)` Write nullable map to the writer.
`static <T> void` `writeNullableCollection(BinaryRawWriterEx writer, Collection<T> col)` Write nullable collection to the writer.
`static <T> void` `writeNullableCollection(BinaryRawWriterEx writer, Collection<T> col, PlatformWriterClosure<T> writeClo)` Write nullable collection to the writer.
`static <T> void` `writeNullableCollection(BinaryRawWriterEx writer, Collection<T> col, PlatformWriterClosure<T> writeClo, IgnitePredicate<T> filter)` Write collection to the writer.
`static <K,V> void` `writeNullableMap(BinaryRawWriterEx writer, Map<K,V> map)` Write nullable map to the writer.

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

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

### Field Detail

#### ATTR_PLATFORM

    public static final String ATTR_PLATFORM

Node attribute: platform.

See Also:
  Constant Field Values

#### PLATFORM_CPP

    public static final String PLATFORM_CPP

Platform: CPP.

See Also:
  Constant Field Values

#### PLATFORM_DOTNET

    public static final String PLATFORM_DOTNET

Platform: .Net.

See Also:
  Constant Field Values

#### OP_PREPARE_DOT_NET

    public static final int OP_PREPARE_DOT_NET

Operation: prepare .Net platform.

See Also:
  Constant Field Values

### Method Detail

#### writeNullableCollection

    public static <T> void writeNullableCollection(BinaryRawWriterEx writer,
                                   @Nullable
                                   Collection<T> col)

Write nullable collection to the writer.

Parameters:
  `writer` - Writer.
  `col` - Collection to write.

#### writeNullableCollection

    public static <T> void writeNullableCollection(BinaryRawWriterEx writer,
                                   @Nullable
                                   Collection<T> col,
                                   @Nullable
                                   PlatformWriterClosure<T> writeClo)

Write nullable collection to the writer.

Parameters:
  `writer` - Writer.
  `col` - Collection to write.
  `writeClo` - Writer closure.

#### writeNullableCollection

    public static <T> void writeNullableCollection(BinaryRawWriterEx writer,
                                   @Nullable
                                   Collection<T> col,
                                   @Nullable
                                   PlatformWriterClosure<T> writeClo,
                                   @Nullable
                                   IgnitePredicate<T> filter)

Write collection to the writer.

Parameters:
  `writer` - Writer.
  `col` - Collection to write.
  `writeClo` - Optional writer closure.
  `filter` - Optional filter.

#### writeCollection

    public static <T> void writeCollection(BinaryRawWriterEx writer,
                           Collection<T> col)

Write collection to the writer.

Parameters:
  `writer` - Writer.
  `col` - Collection to write.

#### writeCollection

    public static <T> void writeCollection(BinaryRawWriterEx writer,
                           Collection<T> col,
                           @Nullable
                           PlatformWriterClosure<T> writeClo)

Write collection to the writer.

Parameters:
  `writer` - Writer.
  `col` - Collection to write.
  `writeClo` - Writer closure.

#### writeCollection

    public static <T> void writeCollection(BinaryRawWriterEx writer,
                           Collection<T> col,
                           @Nullable
                           PlatformWriterClosure<T> writeClo,
                           @Nullable
                           IgnitePredicate<T> filter)

Write collection to the writer.

Parameters:
  `writer` - Writer.
  `col` - Collection to write.
  `writeClo` - Optional writer closure.
  `filter` - Optional filter.

#### writeNullableMap

    public static <K,V> void writeNullableMap(BinaryRawWriterEx writer,
                              @Nullable
                              Map<K,V> map)

Write nullable map to the writer.

Parameters:
  `writer` - Writer.
  `map` - Map to write.

#### writeMap

    public static <K,V> void writeMap(BinaryRawWriterEx writer,
                      Map<K,V> map)

Write nullable map to the writer.

Parameters:
  `writer` - Writer.
  `map` - Map to write.

#### writeMap

    public static <K,V> void writeMap(BinaryRawWriterEx writer,
                      Map<K,V> map,
                      @Nullable
                      PlatformWriterBiClosure<K,V> writeClo)

Write nullable map to the writer.

Parameters:
  `writer` - Writer.
  `map` - Map to write.
  `writeClo` - Writer closure.

#### readCollection

    public static <T> List<T> readCollection(BinaryRawReaderEx reader)

Read collection.

Parameters:
  `reader` - Reader.
Returns:
  List.

#### readCollection

    public static <T> List<T> readCollection(BinaryRawReaderEx reader,
                             @Nullable
                             PlatformReaderClosure<T> readClo)

Read collection.

Parameters:
  `reader` - Reader.
  `readClo` - Optional reader closure.
Returns:
  List.

#### readNullableCollection

    public static <T> List<T> readNullableCollection(BinaryRawReaderEx reader)

Read nullable collection.

Parameters:
  `reader` - Reader.
Returns:
  List.

#### readNullableCollection

    public static <T> List<T> readNullableCollection(BinaryRawReaderEx reader,
                                     @Nullable
                                     PlatformReaderClosure<T> readClo)

Read nullable collection.

Parameters:
  `reader` - Reader.
Returns:
  List.

#### readSet

    public static <T> Set<T> readSet(BinaryRawReaderEx reader)

Parameters:
  `reader` - Reader.
Returns:
  Set.

#### readNullableSet

    public static <T> Set<T> readNullableSet(BinaryRawReaderEx reader)

Parameters:
  `reader` - Reader.
Returns:
  Set.

#### readMap

    public static <K,V> Map<K,V> readMap(BinaryRawReaderEx reader)

Read map.

Parameters:
  `reader` - Reader.
Returns:
  Map.

#### readMap

    public static <K,V> Map<K,V> readMap(BinaryRawReaderEx reader,
                         @Nullable
                         PlatformReaderBiClosure<K,V> readClo)

Read map.

Parameters:
  `reader` - Reader.
  `readClo` - Reader closure.
Returns:
  Map.

#### readNullableMap

    public static <K,V> Map<K,V> readNullableMap(BinaryRawReaderEx reader)

Read nullable map.

Parameters:
  `reader` - Reader.
Returns:
  Map.

#### writeIgniteUuid

    public static void writeIgniteUuid(BinaryRawWriterEx writer,
                       IgniteUuid val)

Writes IgniteUuid to a writer.

Parameters:
  `writer` - Writer.
  `val` - Values.

#### decodeCachePeekModes

    public static CachePeekMode[] decodeCachePeekModes(int modes)

Convert native cache peek modes to Java cache peek modes.

Parameters:
  `modes` - Encoded peek modes.
Returns:
  Cache peek modes.

#### unwrapQueryException

    public static IgniteCheckedException unwrapQueryException(Throwable err)

Unwrap query exception.

Parameters:
  `err` - Initial error.
Returns:
  Unwrapped error.

#### applyContinuousQueryEvents

    public static void applyContinuousQueryEvents(PlatformContext ctx,
                                  long lsnrPtr,
                                  Iterable<javax.cache.event.CacheEntryEvent> evts)
                                           throws javax.cache.event.CacheEntryListenerException

Apply continuous query events to listener.

Parameters:
  `ctx` - Context.
  `lsnrPtr` - Listener pointer.
  `evts` - Events.
Throws:
  `javax.cache.event.CacheEntryListenerException` - In case of failure.

#### evaluateContinuousQueryEvent

    public static boolean evaluateContinuousQueryEvent(PlatformContext ctx,
                                       long filterPtr,
                                       javax.cache.event.CacheEntryEvent evt)
                                                throws javax.cache.event.CacheEntryListenerException

Evaluate the filter.

Parameters:
  `ctx` - Context.
  `filterPtr` - Native filter pointer.
  `evt` - Event.
Returns:
  Result.
Throws:
  `javax.cache.event.CacheEntryListenerException` - In case of failure.

#### writeError

    public static void writeError(Throwable ex,
                  BinaryRawWriterEx writer)

Writes error.

Parameters:
  `ex` - Error.
  `writer` - Writer.

#### writeErrorData

    public static void writeErrorData(Throwable err,
                      BinaryRawWriterEx writer)

Writer error data.

Parameters:
  `err` - Error.
  `writer` - Writer.

#### writeErrorData

    public static void writeErrorData(Throwable err,
                      BinaryRawWriterEx writer,
                      @Nullable
                      IgniteLogger log)

Write error data.

Parameters:
  `err` - Error.
  `writer` - Writer.
  `log` - Optional logger.

#### platformProcessor

    public static PlatformProcessor platformProcessor(Ignite grid)

Get GridGain platform processor.

Parameters:
  `grid` - Ignite instance.
Returns:
  Platform processor.

#### platformContext

    public static PlatformContext platformContext(Ignite grid)

Gets interop context for the grid.

Parameters:
  `grid` - Grid
Returns:
  Context.

#### reallocate

    public static void reallocate(long memPtr,
                  int cap)

Reallocate arbitrary memory chunk.

Parameters:
  `memPtr` - Memory pointer.
  `cap` - Capacity.

#### errorData

    public static byte[] errorData(Throwable err)

Get error data.

Parameters:
  `err` - Error.
Returns:
  Error data.

#### writeInvocationResult

    public static void writeInvocationResult(BinaryRawWriterEx writer,
                             Object resObj,
                             Exception err)

Writes invocation result (of a job/service/etc) using a common protocol.

Parameters:
  `writer` - Writer.
  `resObj` - Result.
  `err` - Error.

#### readInvocationResult

    public static Object readInvocationResult(PlatformContext ctx,
                              BinaryRawReaderEx reader)
                                       throws IgniteCheckedException

Reads invocation result (of a job/service/etc) using a common protocol.

Parameters:
  `ctx` - Platform context.
  `reader` - Reader.
Returns:
  Result.
Throws:
  `IgniteCheckedException` - When invocation result is an error.

#### marshaller

    public static GridBinaryMarshaller marshaller()

Create binary marshaller.

Returns:
  Marshaller.

#### unwrapBinariesInArray

    public static Object[] unwrapBinariesInArray(Object[] arr)

Unwrap array of binaries if needed.

Parameters:
  `arr` - Array.
Returns:
  Result.

#### createJavaObject

    public static <T> T createJavaObject(String clsName)

Create Java object.

Parameters:
  `clsName` - Class name.
Returns:
  Instance.

#### initializeJavaObject

    public static void initializeJavaObject(Object obj,
                            String clsName,
                            @Nullable
                            Map<String,Object> props,
                            @Nullable
                            GridKernalContext ctx)

Initialize Java object or object factory.

Parameters:
  `obj` - Object.
  `clsName` - Class name.
  `props` - Properties (optional).
  `ctx` - Kernal context (optional).

#### getFullStackTrace

    public static String getFullStackTrace(Throwable throwable)

Gets the entire nested stack-trace of an throwable.

Parameters:
  `throwable` - The `Throwable` to be examined.
Returns:
  The nested stack trace, with the root cause first.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.8.0
Release Date | : December 5 2016