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 Description PlatformContextImpl(GridKernalContext ctx, PlatformCallbackGateway gate, PlatformMemoryManagerImpl mem, String platform)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddNode(ClusterNode node)Sends node info to native platform, if necessary.PlatformCacheEntryFiltercreateCacheEntryFilter(Object filter, long ptr)Create cache entry filter.PlatformCacheEntryProcessorcreateCacheEntryProcessor(Object proc, long ptr)Create cache entry processor.PlatformJobcreateClosureJob(Object task, long ptr, Object job, String jobName)Create closure job.PlatformClusterNodeFiltercreateClusterNodeFilter(Object filter)Create cluster node filter.PlatformContinuousQuerycreateContinuousQuery(long ptr, boolean hasFilter, @Nullable Object filter)PlatformContinuousQueryFiltercreateContinuousQueryFilter(Object filter)Create continuous query filter to be deployed on remote node.PlatformJobcreateJob(Object task, long ptr, @Nullable Object job, String jobName)Create job.PlatformEventFilterListenercreateLocalEventFilter(long hnd)Create local event filter.PlatformNativeExceptioncreateNativeException(Object cause)Create native exception.PlatformEventFilterListenercreateRemoteEventFilter(Object pred, int... types)Create remote event filter.PlatformMessageFiltercreateRemoteMessageFilter(Object filter, long ptr)Create remote message filter.PlatformStreamReceivercreateStreamReceiver(Object rcv, long ptr, boolean keepBinary)Create stream receiver.voiddisableThreadLocalForPlatformCacheUpdate()Disables thread-local optimization for platform cache update.voidenableThreadLocalForPlatformCacheUpdate()Enables thread-local optimization for platform cache update.PlatformCallbackGatewaygateway()Gets platform callback gateway.@Nullable BinaryMetadatagetBinaryType(String typeName)Gets platform binary type metadata.bytegetMarshallerPlatformId()Gets marshaller platform id (seeMarshallerPlatformIds).booleanisEventTypeSupported(int evtTyp)Check whether the given event type is supported.booleanisPlatformCacheSupported()Gets a value indicating whether current platform supports native cache.GridKernalContextkernalContext()Gets kernal context.PlatformMemoryManagermemory()Gets platform memory manager.voidonDoneBeforeTopologyUnlock(GridDhtPartitionsExchangeFuture fut)Callback from exchange process completion; called before topology is unlocked.Stringplatform()Gets the current platform name.voidprocessMetadata(BinaryRawReaderEx reader)Process metadata from the platform.BinaryRawReaderExreader(PlatformInputStream in)Get memory reader.BinaryRawReaderExreader(PlatformMemory mem)Get memory reader.voidupdatePlatformCache(int cacheId, byte[] keyBytes, byte[] valBytes, int part, AffinityTopologyVersion ver)Updates the platform cache cache.voidwriteAllMetadata(BinaryRawWriterEx writer)Write all available metadata.voidwriteClusterMetrics(BinaryRawWriterEx writer, @Nullable ClusterMetrics metrics)Write cluster metrics.voidwriteEvent(BinaryRawWriterEx writer, Event evt)Write event.voidwriteMetadata(BinaryRawWriterEx writer, int typeId, boolean includeSchemas)Write metadata for the given type ID.voidwriteNode(BinaryRawWriterEx writer, ClusterNode node)Writes a node id to a stream and sends node info to native platform, if necessary.voidwriteNodes(BinaryRawWriterEx writer, Collection<ClusterNode> nodes)Writes multiple node ids to a stream and sends node info to native platform, if necessary.BinaryRawWriterExwriter(PlatformMemory mem)Get memory writer.BinaryRawWriterExwriter(PlatformOutputStream out)Get memory writer.voidwriteSchema(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
onDoneAfterTopologyUnlock, 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:
kernalContextin interfacePlatformContext- Returns:
- Kernal context.
-
memory
public PlatformMemoryManager memory()
Gets platform memory manager.- Specified by:
memoryin interfacePlatformContext- Returns:
- Memory manager.
-
gateway
public PlatformCallbackGateway gateway()
Gets platform callback gateway.- Specified by:
gatewayin interfacePlatformContext- Returns:
- Callback gateway.
-
reader
public BinaryRawReaderEx reader(PlatformMemory mem)
Get memory reader.- Specified by:
readerin interfacePlatformContext- Parameters:
mem- Memory.- Returns:
- Reader.
-
reader
public BinaryRawReaderEx reader(PlatformInputStream in)
Get memory reader.- Specified by:
readerin interfacePlatformContext- Parameters:
in- Input.- Returns:
- Reader.
-
writer
public BinaryRawWriterEx writer(PlatformMemory mem)
Get memory writer.- Specified by:
writerin interfacePlatformContext- Parameters:
mem- Memory.- Returns:
- Writer.
-
writer
public BinaryRawWriterEx writer(PlatformOutputStream out)
Get memory writer.- Specified by:
writerin interfacePlatformContext- Parameters:
out- Output.- Returns:
- Writer.
-
addNode
public void addNode(ClusterNode node)
Sends node info to native platform, if necessary.- Specified by:
addNodein interfacePlatformContext- 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:
writeNodein interfacePlatformContext- 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:
writeNodesin interfacePlatformContext- Parameters:
writer- Writer.nodes- Nodes.
-
writeClusterMetrics
public void writeClusterMetrics(BinaryRawWriterEx writer, @Nullable @Nullable ClusterMetrics metrics)
Write cluster metrics.- Specified by:
writeClusterMetricsin interfacePlatformContext- Parameters:
writer- Writer.metrics- Metrics.
-
processMetadata
public void processMetadata(BinaryRawReaderEx reader)
Process metadata from the platform.- Specified by:
processMetadatain interfacePlatformContext- Parameters:
reader- Reader.
-
writeMetadata
public void writeMetadata(BinaryRawWriterEx writer, int typeId, boolean includeSchemas)
Write metadata for the given type ID.- Specified by:
writeMetadatain interfacePlatformContext- 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:
writeAllMetadatain interfacePlatformContext- 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:
writeSchemain interfacePlatformContext- Parameters:
writer- Writer.typeId- Type ID.schemaId- Schema ID.
-
createContinuousQuery
public PlatformContinuousQuery createContinuousQuery(long ptr, boolean hasFilter, @Nullable @Nullable Object filter)
- Specified by:
createContinuousQueryin interfacePlatformContext- 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:
createContinuousQueryFilterin interfacePlatformContext- Parameters:
filter- Native filter.- Returns:
- Filter.
-
createRemoteMessageFilter
public PlatformMessageFilter createRemoteMessageFilter(Object filter, long ptr)
Create remote message filter.- Specified by:
createRemoteMessageFilterin interfacePlatformContext- 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:
isEventTypeSupportedin interfacePlatformContext- Parameters:
evtTyp- Event type.- Returns:
Trueif supported.
-
writeEvent
public void writeEvent(BinaryRawWriterEx writer, Event evt)
Write event.- Specified by:
writeEventin interfacePlatformContext- Parameters:
writer- Writer.evt- Event.
-
createLocalEventFilter
public PlatformEventFilterListener createLocalEventFilter(long hnd)
Create local event filter.- Specified by:
createLocalEventFilterin interfacePlatformContext- Parameters:
hnd- Native handle.- Returns:
- Filter.
-
createRemoteEventFilter
public PlatformEventFilterListener createRemoteEventFilter(Object pred, int... types)
Create remote event filter.- Specified by:
createRemoteEventFilterin interfacePlatformContext- Parameters:
pred- Native predicate.types- Event types.- Returns:
- Filter.
-
createNativeException
public PlatformNativeException createNativeException(Object cause)
Create native exception.- Specified by:
createNativeExceptionin interfacePlatformContext- Parameters:
cause- Native cause.- Returns:
- Exception.
-
createJob
public PlatformJob createJob(Object task, long ptr, @Nullable @Nullable Object job, String jobName)
Create job.- Specified by:
createJobin interfacePlatformContext- Parameters:
task- Task.ptr- Pointer.job- Native job.jobName- Native job name.- Returns:
- job.
-
createClosureJob
public PlatformJob createClosureJob(Object task, long ptr, Object job, String jobName)
Create closure job.- Specified by:
createClosureJobin interfacePlatformContext- Parameters:
task- Native task.ptr- Pointer.job- Native job.jobName- Closure name.- Returns:
- Closure job.
-
createCacheEntryProcessor
public PlatformCacheEntryProcessor createCacheEntryProcessor(Object proc, long ptr)
Create cache entry processor.- Specified by:
createCacheEntryProcessorin interfacePlatformContext- Parameters:
proc- Native processor.ptr- Pointer.- Returns:
- Entry processor.
-
createCacheEntryFilter
public PlatformCacheEntryFilter createCacheEntryFilter(Object filter, long ptr)
Create cache entry filter.- Specified by:
createCacheEntryFilterin interfacePlatformContext- Parameters:
filter- Native filter.ptr- Pointer.- Returns:
- Entry filter.
-
createStreamReceiver
public PlatformStreamReceiver createStreamReceiver(Object rcv, long ptr, boolean keepBinary)
Create stream receiver.- Specified by:
createStreamReceiverin interfacePlatformContext- 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:
createClusterNodeFilterin interfacePlatformContext- Parameters:
filter- Native filter.- Returns:
- Cluster node filter.
-
platform
public String platform()
Gets the current platform name.- Specified by:
platformin interfacePlatformContext- Returns:
- Current platform name.
-
isPlatformCacheSupported
public boolean isPlatformCacheSupported()
Gets a value indicating whether current platform supports native cache.- Specified by:
isPlatformCacheSupportedin interfacePlatformContext- 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:
updatePlatformCachein interfacePlatformContext- 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:
enableThreadLocalForPlatformCacheUpdatein interfacePlatformContext
-
disableThreadLocalForPlatformCacheUpdate
public void disableThreadLocalForPlatformCacheUpdate()
Disables thread-local optimization for platform cache update.- Specified by:
disableThreadLocalForPlatformCacheUpdatein interfacePlatformContext
-
getBinaryType
@Nullable public @Nullable BinaryMetadata getBinaryType(String typeName)
Gets platform binary type metadata.- Specified by:
getBinaryTypein interfacePlatformContext- Parameters:
typeName- Type name.- Returns:
- Metadata when type exists; null otherwise.
-
getMarshallerPlatformId
public byte getMarshallerPlatformId()
Gets marshaller platform id (seeMarshallerPlatformIds).- Specified by:
getMarshallerPlatformIdin interfacePlatformContext- Returns:
- Marshaller platform id.
-
onDoneBeforeTopologyUnlock
public void onDoneBeforeTopologyUnlock(GridDhtPartitionsExchangeFuture fut)
Callback from exchange process completion; called before topology is unlocked. Guarantees that no updates were performed on local node since exchange process started.- Specified by:
onDoneBeforeTopologyUnlockin interfacePartitionsExchangeAware- Parameters:
fut- Partition map exchange future.
-
-