org.apache.ignite.internal

## Class MarshallerContextImpl

- java.lang.Object
- - org.apache.ignite.internal.MarshallerContextImpl

All Implemented Interfaces:
  MarshallerContext

    public class MarshallerContextImpl
    extends Object
    implements MarshallerContext

Marshaller context implementation.

### Constructor Summary

Constructors
Constructor and Description
`MarshallerContextImpl(@Nullable Collection<PluginProvider> plugins, IgnitePredicate<String> clsFilter)` Initializes context.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `checkHasClassName(String clsName, ClassLoader ldr, String fileName)`
`IgnitePredicate<String>` `classNameFilter()` Returns class name filter.
`Iterator<Map.Entry<Byte,Map<Integer,String>>>` `currentMappings()` Method collects current mappings for all platforms.
`ArrayList<Map<Integer,MappedName>>` `getCachedMappings()`
`Class` `getClass(int typeId, ClassLoader ldr)` Gets class for provided type ID.
`String` `getClassName(byte platformId, int typeId)` Gets class name for provided (platformId, typeId) pair.
`boolean` `initialized()`
`boolean` `isSystemType(String typeName)` Checks whether the given type is a system one - JDK class or Ignite class.
`JdkMarshaller` `jdkMarshaller()` Returns JDK marshaller instance.
`void` `onMappingAccepted(MarshallerMappingItem item)`
`void` `onMappingDataReceived(byte platformId, Map<Integer,MappedName> marshallerMappings)`
`MappedName` `onMappingProposed(MarshallerMappingItem item)`
`void` `onMarshallerProcessorStarted(GridKernalContext ctx, MarshallerMappingTransport transport)`
`void` `onMarshallerProcessorStop()`
`void` `onMissedMappingResolved(MarshallerMappingItem item, String resolvedClsName)`
`boolean` `registerClassName(byte platformId, int typeId, String clsName)` Same as `MarshallerContext.registerClassName(byte, int, java.lang.String, boolean)` but with shortened parameters list.
`boolean` `registerClassName(byte platformId, int typeId, String clsName, boolean failIfUnregistered)` Method to register typeId->class name mapping in marshaller context cluster-wide.
`boolean` `registerClassNameLocally(byte platformId, int typeId, String clsName)` Method to register typeId->class name mapping in marshaller context on local node only.
`String` `resolveMissedMapping(byte platformId, int typeId)`
`void` `setMarshallerMappingFileStoreDir(@Nullable File marshallerMappingFileStoreDir)` Sets custom marshaller mapping files directory.

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

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

### Constructor Detail

#### MarshallerContextImpl

    public MarshallerContextImpl(@Nullable
                                 @Nullable Collection<PluginProvider> plugins,
                                 IgnitePredicate<String> clsFilter)

Initializes context.

Parameters:
  `plugins` - Plugins.

### Method Detail

#### getCachedMappings

    public ArrayList<Map<Integer,MappedName>> getCachedMappings()

#### onMappingDataReceived

    public void onMappingDataReceived(byte platformId,
                                      Map<Integer,MappedName> marshallerMappings)
                               throws IgniteCheckedException

Parameters:
  `platformId` - Platform id.
  `marshallerMappings` - All marshaller mappings for given platformId.
Throws:
  `IgniteCheckedException` - In case of failure to process incoming marshaller mappings.

#### checkHasClassName

    public void checkHasClassName(String clsName,
                                  ClassLoader ldr,
                                  String fileName)

Parameters:
  `clsName` - Class name.
  `ldr` - Class loader used to get properties file.
  `fileName` - File name.

#### registerClassName

    public boolean registerClassName(byte platformId,
                                     int typeId,
                                     String clsName,
                                     boolean failIfUnregistered)
                              throws IgniteCheckedException

Method to register typeId->class name mapping in marshaller context cluster-wide. This method guarantees that mapping is delivered to all nodes in cluster and blocks caller thread until then.

Specified by:
  `registerClassName` in interface `MarshallerContext`
Parameters:
  `platformId` - Id of a platform (java, .NET, etc.) to register mapping for.
  `typeId` - Type ID.
  `clsName` - Class name.
  `failIfUnregistered` - If `true` then throw `UnregisteredBinaryTypeException` with registration future instead of synchronously awaiting for its completion.
Returns:
  `True` if mapping was registered successfully.
Throws:
  `IgniteCheckedException` - In case of error.

#### registerClassName

    public boolean registerClassName(byte platformId,
                                     int typeId,
                                     String clsName)
                              throws IgniteCheckedException

Same as `MarshallerContext.registerClassName(byte, int, java.lang.String, boolean)` but with shortened parameters list.

Specified by:
  `registerClassName` in interface `MarshallerContext`
Throws:
  `IgniteCheckedException`

#### registerClassNameLocally

    public boolean registerClassNameLocally(byte platformId,
                                            int typeId,
                                            String clsName)
                                     throws IgniteCheckedException

Method to register typeId->class name mapping in marshaller context on local node only. No guarantees that the mapping is presented on other nodes are provided. This method is safe to use if there is another source of mappings like metadata persisted on disk and this source is known to be solid and free of conflicts beforehand.

Specified by:
  `registerClassNameLocally` in interface `MarshallerContext`
Parameters:
  `platformId` - Id of a platform (java, .NET, etc.) to register mapping for.
  `typeId` - Type id.
  `clsName` - Class name.
Returns:
  `True` if class mapping was registered successfully.
Throws:
  `IgniteCheckedException` - In case of error.

#### onMappingProposed

    public MappedName onMappingProposed(MarshallerMappingItem item)

Parameters:
  `item` - type mapping to propose
Returns:
  null if cache doesn't contain any mappings for given (platformId, typeId) pair, previous `mapped name` otherwise.

#### onMappingAccepted

    public void onMappingAccepted(MarshallerMappingItem item)

Parameters:
  `item` - Item.

#### getClass

    public Class getClass(int typeId,
                          ClassLoader ldr)
                   throws ClassNotFoundException,
                          IgniteCheckedException

Gets class for provided type ID.

Specified by:
  `getClass` in interface `MarshallerContext`
Parameters:
  `typeId` - Type ID.
  `ldr` - Class loader.
Returns:
  Class.
Throws:
  `ClassNotFoundException` - If class was not found.
  `IgniteCheckedException` - In case of any other error.

#### getClassName

    public String getClassName(byte platformId,
                               int typeId)
                        throws ClassNotFoundException,
                               IgniteCheckedException

Gets class name for provided (platformId, typeId) pair.

Specified by:
  `getClassName` in interface `MarshallerContext`
Parameters:
  `platformId` - id of a platform the class was registered for.
  `typeId` - Type ID.
Returns:
  Class name
Throws:
  `ClassNotFoundException` - If class was not found.
  `IgniteCheckedException` - In case of any other error.

#### classNameFilter

    public IgnitePredicate<String> classNameFilter()

Returns class name filter.

Specified by:
  `classNameFilter` in interface `MarshallerContext`
Returns:
  Class name filter.

#### jdkMarshaller

    public JdkMarshaller jdkMarshaller()

Returns JDK marshaller instance.

Specified by:
  `jdkMarshaller` in interface `MarshallerContext`

#### resolveMissedMapping

    public String resolveMissedMapping(byte platformId,
                                       int typeId)

Parameters:
  `platformId` - Platform id.
  `typeId` - Type id.

#### onMissedMappingResolved

    public void onMissedMappingResolved(MarshallerMappingItem item,
                                        String resolvedClsName)

Parameters:
  `item` - Item.
  `resolvedClsName` - Resolved class name.

#### isSystemType

    public boolean isSystemType(String typeName)

Checks whether the given type is a system one - JDK class or Ignite class.

Specified by:
  `isSystemType` in interface `MarshallerContext`
Parameters:
  `typeName` - Type name.
Returns:
  `true` if the type is a system one, `false` otherwise.

#### onMarshallerProcessorStarted

    public void onMarshallerProcessorStarted(GridKernalContext ctx,
                                             MarshallerMappingTransport transport)
                                      throws IgniteCheckedException

Parameters:
  `ctx` - Context.
  `transport` - Transport.
Throws:
  `IgniteCheckedException`

#### onMarshallerProcessorStop

    public void onMarshallerProcessorStop()

#### currentMappings

    public Iterator<Map.Entry<Byte,Map<Integer,String>>> currentMappings()

Method collects current mappings for all platforms.

Returns:
  current mappings.

#### initialized

    public boolean initialized()

Returns:
  `True` if marshaller context is initialized.

#### setMarshallerMappingFileStoreDir

    public void setMarshallerMappingFileStoreDir(@Nullable
                                                 @Nullable File marshallerMappingFileStoreDir)

Sets custom marshaller mapping files directory. Used for standalone WAL iteration

Parameters:
  `marshallerMappingFileStoreDir` - directory with type name mappings

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.8.1
Release Date | : May 21 2020