Class PlatformUtils
- java.lang.Object
-
- org.apache.ignite.internal.processors.platform.utils.PlatformUtils
-
public class PlatformUtils extends Object
Platform utility methods.
-
-
Field Summary
Fields Modifier and Type Field Description static StringATTR_PLATFORMNode attribute: platform.static intOP_PREPARE_DOT_NETOperation: prepare .Net platform.static StringPLATFORM_CPPPlatform: CPP.static StringPLATFORM_DOTNETPlatform: .Net.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidapplyContinuousQueryEvents(PlatformContext ctx, long lsnrPtr, Iterable<javax.cache.event.CacheEntryEvent> evts)Apply continuous query events to listener.static <T> TcreateJavaObject(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 booleanevaluateContinuousQueryEvent(PlatformContext ctx, long filterPtr, javax.cache.event.CacheEntryEvent evt)Evaluate the filter.static StringgetFullStackTrace(Throwable throwable)Gets the entire nested stack-trace of an throwable.static int[]getSchema(CacheObjectBinaryProcessorImpl cacheObjProc, int typeId, int schemaId)Gets the schema.static voidinitializeJavaObject(Object obj, String clsName, @Nullable Map<String,Object> props, @Nullable GridKernalContext ctx)Initialize Java object or object factory.static GridBinaryMarshallermarshaller()Create binary marshaller.static PlatformContextplatformContext(Ignite grid)Gets interop context for the grid.static PlatformProcessorplatformProcessor(Ignite grid)Get platform processor.static BinaryMetadatareadBinaryMetadata(BinaryRawReaderEx reader)Reads the binary metadata.static Collection<BinaryMetadata>readBinaryMetadataCollection(BinaryRawReaderEx reader)Reads the binary metadata.static <T extends CacheObject>
TreadCacheObject(BinaryReaderExImpl reader, boolean isKey)Read cache object from the stream as raw bytes to avoid marshalling.static <T> List<T>readCollection(BinaryRawReaderEx reader)Read collection.static <T> List<T>readCollection(BinaryRawReaderEx reader, @Nullable PlatformReaderClosure<T> readClo)Read collection.static ObjectreadInvocationResult(PlatformContext ctx, BinaryRawReaderEx reader)Reads invocation result (of a job/service/etc) using a common protocol.static ObjectreadInvocationResult(PlatformContext ctx, BinaryRawReaderEx reader, boolean deserialize)Reads invocation result (of a job/service/etc) using a common protocol.static <K,V>
Map<K,V>readLinkedMap(BinaryRawReaderEx reader, @Nullable PlatformReaderBiClosure<K,V> readClo)Read linked map.static <K,V>
Map<K,V>readMap(BinaryRawReaderEx reader)Read map.static <K,V>
Map<K,V>readMap(BinaryRawReaderEx reader, @Nullable PlatformReaderBiClosure<K,V> readClo)Read map.static Map<String,Object>readNodeAttributes(BinaryRawReaderEx reader)Reads node attributes.static <T> List<T>readNullableCollection(BinaryRawReaderEx reader)Read nullable collection.static <T> List<T>readNullableCollection(BinaryRawReaderEx reader, @Nullable 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 Collection<String>readStrings(BinaryRawReader reader)Reads collection of strings.static voidreallocate(long memPtr, int cap)Reallocate arbitrary memory chunk.static StringservicePlatform(ServiceConfiguration svcCfg)Get service platform.static Object[]unwrapBinariesInArray(Object[] arr)Unwrap array of binaries if needed.static IgniteCheckedExceptionunwrapQueryException(Throwable err)Unwrap query exception.static voidwriteBinaryMetadata(BinaryRawWriter writer, BinaryMetadata meta, boolean includeSchemas)Writes the binary metadata to a writer.static <T> voidwriteCollection(BinaryRawWriterEx writer, Collection<T> col)Write collection to the writer.static <T> voidwriteCollection(BinaryRawWriterEx writer, Collection<T> col, @Nullable PlatformWriterClosure<T> writeClo)Write collection to the writer.static <T> voidwriteCollection(BinaryRawWriterEx writer, Collection<T> col, @Nullable PlatformWriterClosure<T> writeClo, @Nullable IgnitePredicate<T> filter)Write collection to the writer.static voidwriteError(Throwable ex, BinaryRawWriterEx writer)Writes error.static voidwriteErrorData(Throwable err, BinaryRawWriterEx writer)Writer error data.static voidwriteErrorData(Throwable err, BinaryRawWriterEx writer, @Nullable IgniteLogger log)Write error data.static voidwriteIgniteUuid(BinaryRawWriterEx writer, IgniteUuid val)Writes IgniteUuid to a writer.static voidwriteInvocationResult(BinaryRawWriterEx writer, Object resObj, Throwable err)Writes invocation result (of a job/service/etc) using a common protocol.static <K,V>
voidwriteMap(BinaryRawWriterEx writer, Map<K,V> map)Write nullable map to the writer.static <K,V>
voidwriteMap(BinaryRawWriterEx writer, Map<K,V> map, @Nullable PlatformWriterBiClosure<K,V> writeClo)Write nullable map to the writer.static voidwriteNodeAttributes(BinaryRawWriterEx writer, Map<String,Object> attrs)Writes node attributes.static voidwriteNodeVersion(BinaryRawWriterEx out, IgniteProductVersion productVersion)Write binary productVersion.static <T> voidwriteNullableCollection(BinaryRawWriterEx writer, @Nullable Collection<T> col)Write nullable collection to the writer.static <T> voidwriteNullableCollection(BinaryRawWriterEx writer, @Nullable Collection<T> col, @Nullable PlatformWriterClosure<T> writeClo)Write nullable collection to the writer.static <T> voidwriteNullableCollection(BinaryRawWriterEx writer, @Nullable Collection<T> col, @Nullable PlatformWriterClosure<T> writeClo, @Nullable IgnitePredicate<T> filter)Write collection to the writer.static <K,V>
voidwriteNullableMap(BinaryRawWriterEx writer, @Nullable Map<K,V> map)Write nullable map to the writer.
-
-
-
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 @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 @Nullable Collection<T> col, @Nullable @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 @Nullable Collection<T> col, @Nullable @Nullable PlatformWriterClosure<T> writeClo, @Nullable @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 @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 @Nullable PlatformWriterClosure<T> writeClo, @Nullable @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 @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 @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 @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 @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 @Nullable PlatformReaderBiClosure<K,V> readClo)
Read map.- Parameters:
reader- Reader.readClo- Reader closure.- Returns:
- Map.
-
readLinkedMap
public static <K,V> Map<K,V> readLinkedMap(BinaryRawReaderEx reader, @Nullable @Nullable PlatformReaderBiClosure<K,V> readClo)
Read linked 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 @Nullable IgniteLogger log)
Write error data.- Parameters:
err- Error.writer- Writer.log- Optional logger.
-
platformProcessor
public static PlatformProcessor platformProcessor(Ignite grid)
Get 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, Throwable 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.
-
readInvocationResult
public static Object readInvocationResult(PlatformContext ctx, BinaryRawReaderEx reader, boolean deserialize) throws IgniteCheckedException
Reads invocation result (of a job/service/etc) using a common protocol.- Parameters:
ctx- Platform context.reader- Reader.deserialize- Iftruedeserialize invocation result.- 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 @Nullable Map<String,Object> props, @Nullable @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- TheThrowableto be examined.- Returns:
- The nested stack trace, with the root cause first.
-
getSchema
public static int[] getSchema(CacheObjectBinaryProcessorImpl cacheObjProc, int typeId, int schemaId)
Gets the schema.- Parameters:
cacheObjProc- Cache object processor.typeId- Type id.schemaId- Schema id.
-
writeBinaryMetadata
public static void writeBinaryMetadata(BinaryRawWriter writer, BinaryMetadata meta, boolean includeSchemas)
Writes the binary metadata to a writer.- Parameters:
writer- Writer.meta- Meta.
-
readBinaryMetadataCollection
public static Collection<BinaryMetadata> readBinaryMetadataCollection(BinaryRawReaderEx reader)
Reads the binary metadata.- Parameters:
reader- Reader.- Returns:
- Collection of metas.
-
readBinaryMetadata
public static BinaryMetadata readBinaryMetadata(BinaryRawReaderEx reader)
Reads the binary metadata.- Parameters:
reader- Reader.- Returns:
- Binary type metadata.
-
writeNodeAttributes
public static void writeNodeAttributes(BinaryRawWriterEx writer, Map<String,Object> attrs)
Writes node attributes.- Parameters:
writer- Writer.attrs- Attributes.
-
readNodeAttributes
public static Map<String,Object> readNodeAttributes(BinaryRawReaderEx reader)
Reads node attributes.- Parameters:
reader- Reader.- Returns:
- Attributes.
-
writeNodeVersion
public static void writeNodeVersion(BinaryRawWriterEx out, IgniteProductVersion productVersion)
Write binary productVersion.- Parameters:
out- Writer.productVersion- IgniteProductVersion.
-
readStrings
public static Collection<String> readStrings(BinaryRawReader reader)
Reads collection of strings.- Parameters:
reader- Reader.
-
servicePlatform
public static String servicePlatform(ServiceConfiguration svcCfg)
Get service platform.- Parameters:
svcCfg- Service configuration.- Returns:
- Service platform or empty string if this is a java service.
-
readCacheObject
public static <T extends CacheObject> T readCacheObject(BinaryReaderExImpl reader, boolean isKey)
Read cache object from the stream as raw bytes to avoid marshalling.- Parameters:
reader- Reader.isKey-Trueif object is a key.
-
-