org.apache.ignite.internal.processors.platform

## Class PlatformContextImpl

- java.lang.Object
- - org.apache.ignite.internal.processors.platform.PlatformContextImpl

All Implemented Interfaces:
  PartitionsExchangeAware, PlatformContext

    public class PlatformContextImpl
    extends Object
    implements PlatformContext, PartitionsExchangeAware

Implementation of platform context.

### Constructor Summary

Constructors
Constructor and Description
`PlatformContextImpl(GridKernalContext ctx, PlatformCallbackGateway gate, PlatformMemoryManagerImpl mem, String platform)` Constructor.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addNode(ClusterNode node)` Sends node info to native platform, if necessary.
`PlatformCacheEntryFilter` `createCacheEntryFilter(Object filter, long ptr)` Create cache entry filter.
`PlatformCacheEntryProcessor` `createCacheEntryProcessor(Object proc, long ptr)` Create cache entry processor.
`PlatformJob` `createClosureJob(Object task, long ptr, Object job)` Create closure job.
`PlatformClusterNodeFilter` `createClusterNodeFilter(Object filter)` Create cluster node filter.
`PlatformContinuousQuery` `createContinuousQuery(long ptr, boolean hasFilter, @Nullable Object filter)`
`PlatformContinuousQueryFilter` `createContinuousQueryFilter(Object filter)` Create continuous query filter to be deployed on remote node.
`PlatformJob` `createJob(Object task, long ptr, @Nullable Object job)` Create job.
`PlatformEventFilterListener` `createLocalEventFilter(long hnd)` Create local event filter.
`PlatformNativeException` `createNativeException(Object cause)` Create native exception.
`PlatformEventFilterListener` `createRemoteEventFilter(Object pred, int... types)` Create remote event filter.
`PlatformMessageFilter` `createRemoteMessageFilter(Object filter, long ptr)` Create remote message filter.
`PlatformStreamReceiver` `createStreamReceiver(Object rcv, long ptr, boolean keepBinary)` Create stream receiver.
`void` `disableThreadLocalForPlatformCacheUpdate()` Disables thread-local optimization for platform cache update.
`void` `enableThreadLocalForPlatformCacheUpdate()` Enables thread-local optimization for platform cache update.
`PlatformCallbackGateway` `gateway()` Gets platform callback gateway.
`@Nullable BinaryMetadata` `getBinaryType(String typeName)` Gets platform binary type metadata.
`byte` `getMarshallerPlatformId()` Gets marshaller platform id (see `MarshallerPlatformIds`).
`boolean` `isEventTypeSupported(int evtTyp)` Check whether the given event type is supported.
`boolean` `isPlatformCacheSupported()` Gets a value indicating whether current platform supports native cache.
`GridKernalContext` `kernalContext()` Gets kernal context.
`PlatformMemoryManager` `memory()` Gets platform memory manager.
`void` `onDoneAfterTopologyUnlock(GridDhtPartitionsExchangeFuture fut)` Callback from exchange process completion; called after topology is unlocked.
`String` `platform()` Gets the current platform name.
`void` `processMetadata(BinaryRawReaderEx reader)` Process metadata from the platform.
`BinaryRawReaderEx` `reader(PlatformInputStream in)` Get memory reader.
`BinaryRawReaderEx` `reader(PlatformMemory mem)` Get memory reader.
`void` `updatePlatformCache(int cacheId, byte[] keyBytes, byte[] valBytes, int part, AffinityTopologyVersion ver)` Updates the platform cache cache.
`void` `writeAllMetadata(BinaryRawWriterEx writer)` Write all available metadata.
`void` `writeClusterMetrics(BinaryRawWriterEx writer, @Nullable ClusterMetrics metrics)` Write cluster metrics.
`void` `writeEvent(BinaryRawWriterEx writer, Event evt)` Write event.
`void` `writeMetadata(BinaryRawWriterEx writer, int typeId, boolean includeSchemas)` Write metadata for the given type ID.
`void` `writeNode(BinaryRawWriterEx writer, ClusterNode node)` Writes a node id to a stream and sends node info to native platform, if necessary.
`void` `writeNodes(BinaryRawWriterEx writer, Collection<ClusterNode> nodes)` Writes multiple node ids to a stream and sends node info to native platform, if necessary.
`BinaryRawWriterEx` `writer(PlatformMemory mem)` Get memory writer.
`BinaryRawWriterEx` `writer(PlatformOutputStream out)` Get memory writer.
`void` `writeSchema(BinaryRawWriterEx writer, int typeId, int schemaId)` Write schema for the given type ID and schema ID.

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

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

### Methods inherited from interface org.apache.ignite.internal.processors.cache.distributed.dht.preloader.PartitionsExchangeAware

`onDoneBeforeTopologyUnlock, onInitAfterTopologyLock, onInitBeforeTopologyLock`

### Constructor Detail

#### PlatformContextImpl

    public PlatformContextImpl(GridKernalContext ctx,
                               PlatformCallbackGateway gate,
                               PlatformMemoryManagerImpl mem,
                               String platform)

Constructor.

Parameters:
  `ctx` - Kernal context.
  `gate` - Callback gateway.
  `mem` - Memory manager.
  `platform` - Platform name.

### Method Detail

#### kernalContext

    public GridKernalContext kernalContext()

Gets kernal context.

Specified by:
  `kernalContext` in interface `PlatformContext`
Returns:
  Kernal context.

#### memory

    public PlatformMemoryManager memory()

Gets platform memory manager.

Specified by:
  `memory` in interface `PlatformContext`
Returns:
  Memory manager.

#### gateway

    public PlatformCallbackGateway gateway()

Gets platform callback gateway.

Specified by:
  `gateway` in interface `PlatformContext`
Returns:
  Callback gateway.

#### reader

    public BinaryRawReaderEx reader(PlatformMemory mem)

Get memory reader.

Specified by:
  `reader` in interface `PlatformContext`
Parameters:
  `mem` - Memory.
Returns:
  Reader.

#### reader

    public BinaryRawReaderEx reader(PlatformInputStream in)

Get memory reader.

Specified by:
  `reader` in interface `PlatformContext`
Parameters:
  `in` - Input.
Returns:
  Reader.

#### writer

    public BinaryRawWriterEx writer(PlatformMemory mem)

Get memory writer.

Specified by:
  `writer` in interface `PlatformContext`
Parameters:
  `mem` - Memory.
Returns:
  Writer.

#### writer

    public BinaryRawWriterEx writer(PlatformOutputStream out)

Get memory writer.

Specified by:
  `writer` in interface `PlatformContext`
Parameters:
  `out` - Output.
Returns:
  Writer.

#### addNode

    public void addNode(ClusterNode node)

Sends node info to native platform, if necessary.

Specified by:
  `addNode` in interface `PlatformContext`
Parameters:
  `node` - Node.

#### writeNode

    public void writeNode(BinaryRawWriterEx writer,
                          ClusterNode node)

Writes a node id to a stream and sends node info to native platform, if necessary.

Specified by:
  `writeNode` in interface `PlatformContext`
Parameters:
  `writer` - Writer.
  `node` - Node.

#### writeNodes

    public void writeNodes(BinaryRawWriterEx writer,
                           Collection<ClusterNode> nodes)

Writes multiple node ids to a stream and sends node info to native platform, if necessary.

Specified by:
  `writeNodes` in interface `PlatformContext`
Parameters:
  `writer` - Writer.
  `nodes` - Nodes.

#### writeClusterMetrics

    public void writeClusterMetrics(BinaryRawWriterEx writer,
                                    @Nullable
                                    @Nullable ClusterMetrics metrics)

Write cluster metrics.

Specified by:
  `writeClusterMetrics` in interface `PlatformContext`
Parameters:
  `writer` - Writer.
  `metrics` - Metrics.

#### processMetadata

    public void processMetadata(BinaryRawReaderEx reader)

Process metadata from the platform.

Specified by:
  `processMetadata` in interface `PlatformContext`
Parameters:
  `reader` - Reader.

#### writeMetadata

    public void writeMetadata(BinaryRawWriterEx writer,
                              int typeId,
                              boolean includeSchemas)

Write metadata for the given type ID.

Specified by:
  `writeMetadata` in interface `PlatformContext`
Parameters:
  `writer` - Writer.
  `typeId` - Type ID.
  `includeSchemas` - Whether to include binary object schemas into the result.

#### writeAllMetadata

    public void writeAllMetadata(BinaryRawWriterEx writer)

Write all available metadata.

Specified by:
  `writeAllMetadata` in interface `PlatformContext`
Parameters:
  `writer` - Writer.

#### writeSchema

    public void writeSchema(BinaryRawWriterEx writer,
                            int typeId,
                            int schemaId)

Write schema for the given type ID and schema ID.

Specified by:
  `writeSchema` in interface `PlatformContext`
Parameters:
  `writer` - Writer.
  `typeId` - Type ID.
  `schemaId` - Schema ID.

#### createContinuousQuery

    public PlatformContinuousQuery createContinuousQuery(long ptr,
                                                         boolean hasFilter,
                                                         @Nullable
                                                         @Nullable Object filter)

Specified by:
  `createContinuousQuery` in interface `PlatformContext`
Parameters:
  `ptr` - Pointer to continuous query deployed on the platform.
  `hasFilter` - Whether filter exists.
  `filter` - Filter.
Returns:
  Platform continuous query.

#### createContinuousQueryFilter

    public PlatformContinuousQueryFilter createContinuousQueryFilter(Object filter)

Create continuous query filter to be deployed on remote node.

Specified by:
  `createContinuousQueryFilter` in interface `PlatformContext`
Parameters:
  `filter` - Native filter.
Returns:
  Filter.

#### createRemoteMessageFilter

    public PlatformMessageFilter createRemoteMessageFilter(Object filter,
                                                           long ptr)

Create remote message filter.

Specified by:
  `createRemoteMessageFilter` in interface `PlatformContext`
Parameters:
  `filter` - Native filter.
  `ptr` - Pointer of deployed native filter.
Returns:
  Filter.

#### isEventTypeSupported

    public boolean isEventTypeSupported(int evtTyp)

Check whether the given event type is supported.

Specified by:
  `isEventTypeSupported` in interface `PlatformContext`
Parameters:
  `evtTyp` - Event type.
Returns:
  `True` if supported.

#### writeEvent

    public void writeEvent(BinaryRawWriterEx writer,
                           Event evt)

Write event.

Specified by:
  `writeEvent` in interface `PlatformContext`
Parameters:
  `writer` - Writer.
  `evt` - Event.

#### createLocalEventFilter

    public PlatformEventFilterListener createLocalEventFilter(long hnd)

Create local event filter.

Specified by:
  `createLocalEventFilter` in interface `PlatformContext`
Parameters:
  `hnd` - Native handle.
Returns:
  Filter.

#### createRemoteEventFilter

    public PlatformEventFilterListener createRemoteEventFilter(Object pred,
                                                               int... types)

Create remote event filter.

Specified by:
  `createRemoteEventFilter` in interface `PlatformContext`
Parameters:
  `pred` - Native predicate.
  `types` - Event types.
Returns:
  Filter.

#### createNativeException

    public PlatformNativeException createNativeException(Object cause)

Create native exception.

Specified by:
  `createNativeException` in interface `PlatformContext`
Parameters:
  `cause` - Native cause.
Returns:
  Exception.

#### createJob

    public PlatformJob createJob(Object task,
                                 long ptr,
                                 @Nullable
                                 @Nullable Object job)

Create job.

Specified by:
  `createJob` in interface `PlatformContext`
Parameters:
  `task` - Task.
  `ptr` - Pointer.
  `job` - Native job.
Returns:
  job.

#### createClosureJob

    public PlatformJob createClosureJob(Object task,
                                        long ptr,
                                        Object job)

Create closure job.

Specified by:
  `createClosureJob` in interface `PlatformContext`
Parameters:
  `task` - Native task.
  `ptr` - Pointer.
  `job` - Native job.
Returns:
  Closure job.

#### createCacheEntryProcessor

    public PlatformCacheEntryProcessor createCacheEntryProcessor(Object proc,
                                                                 long ptr)

Create cache entry processor.

Specified by:
  `createCacheEntryProcessor` in interface `PlatformContext`
Parameters:
  `proc` - Native processor.
  `ptr` - Pointer.
Returns:
  Entry processor.

#### createCacheEntryFilter

    public PlatformCacheEntryFilter createCacheEntryFilter(Object filter,
                                                           long ptr)

Create cache entry filter.

Specified by:
  `createCacheEntryFilter` in interface `PlatformContext`
Parameters:
  `filter` - Native filter.
  `ptr` - Pointer.
Returns:
  Entry filter.

#### createStreamReceiver

    public PlatformStreamReceiver createStreamReceiver(Object rcv,
                                                       long ptr,
                                                       boolean keepBinary)

Create stream receiver.

Specified by:
  `createStreamReceiver` in interface `PlatformContext`
Parameters:
  `rcv` - Native receiver.
  `ptr` - Pointer.
  `keepBinary` - Keep binary flag.
Returns:
  Stream receiver.

#### createClusterNodeFilter

    public PlatformClusterNodeFilter createClusterNodeFilter(Object filter)

Create cluster node filter.

Specified by:
  `createClusterNodeFilter` in interface `PlatformContext`
Parameters:
  `filter` - Native filter.
Returns:
  Cluster node filter.

#### platform

    public String platform()

Gets the current platform name.

Specified by:
  `platform` in interface `PlatformContext`
Returns:
  Current platform name.

#### isPlatformCacheSupported

    public boolean isPlatformCacheSupported()

Gets a value indicating whether current platform supports native cache.

Specified by:
  `isPlatformCacheSupported` in interface `PlatformContext`
Returns:
  True when native caching is supported; false otherwise.

#### updatePlatformCache

    public void updatePlatformCache(int cacheId,
                                    byte[] keyBytes,
                                    byte[] valBytes,
                                    int part,
                                    AffinityTopologyVersion ver)

Updates the platform cache cache.

Specified by:
  `updatePlatformCache` in interface `PlatformContext`
Parameters:
  `cacheId` - Cache id.
  `keyBytes` - Serialized key to update.
  `valBytes` - Serialized value.
  `part` - Key partition.
  `ver` - Key version.

#### enableThreadLocalForPlatformCacheUpdate

    public void enableThreadLocalForPlatformCacheUpdate()

Enables thread-local optimization for platform cache update.

Specified by:
  `enableThreadLocalForPlatformCacheUpdate` in interface `PlatformContext`

#### disableThreadLocalForPlatformCacheUpdate

    public void disableThreadLocalForPlatformCacheUpdate()

Disables thread-local optimization for platform cache update.

Specified by:
  `disableThreadLocalForPlatformCacheUpdate` in interface `PlatformContext`

#### getBinaryType

    @Nullable
    public @Nullable BinaryMetadata getBinaryType(String typeName)

Gets platform binary type metadata.

Specified by:
  `getBinaryType` in interface `PlatformContext`
Parameters:
  `typeName` - Type name.
Returns:
  Metadata when type exists; null otherwise.

#### getMarshallerPlatformId

    public byte getMarshallerPlatformId()

Gets marshaller platform id (see `MarshallerPlatformIds`).

Specified by:
  `getMarshallerPlatformId` in interface `PlatformContext`
Returns:
  Marshaller platform id.

#### onDoneAfterTopologyUnlock

    public void onDoneAfterTopologyUnlock(GridDhtPartitionsExchangeFuture fut)

Callback from exchange process completion; called after topology is unlocked.

Specified by:
  `onDoneAfterTopologyUnlock` in interface `PartitionsExchangeAware`
Parameters:
  `fut` - Partition map exchange future.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.11.1
Release Date | : December 20 2021