org.apache.ignite.internal.processors.cache.binary

## Class CacheObjectBinaryProcessorImpl

- java.lang.Object
- - org.apache.ignite.internal.processors.GridProcessorAdapter
  - - org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessorImpl
    - - org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl

All Implemented Interfaces:
  GridComponent, CacheObjectBinaryProcessor, IgniteCacheObjectProcessor, GridProcessor

    public class CacheObjectBinaryProcessorImpl
    extends IgniteCacheObjectProcessorImpl
    implements CacheObjectBinaryProcessor

Binary processor implementation.

### Nested Class Summary

### Nested classes/interfaces inherited from interface org.apache.ignite.internal.GridComponent

`GridComponent.DiscoveryDataExchangeType`

### Field Summary

### Fields inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter

`ctx, diagnosticLog, log`

### Constructor Summary

Constructors
Constructor and Description
`CacheObjectBinaryProcessorImpl(GridKernalContext ctx)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addBinaryMetadataUpdateListener(BinaryMetadataUpdatedListener lsnr)`
`void` `addMeta(int typeId, BinaryType newMeta)`
`void` `addMetaLocally(int typeId, BinaryType newMeta)` Adds metadata locally without triggering discovery exchange.
`BinaryField` `affinityKeyField(int typeId)` Get affinity key field.
`IgniteBinary` `binary()`
`BinaryContext` `binaryContext()`
`BinaryObject` `buildEnum(String typeName, int ord)`
`BinaryObject` `buildEnum(String typeName, String name)`
`BinaryObjectBuilder` `builder(BinaryObject binaryObj)` Creates builder initialized by existing binary object.
`BinaryObjectBuilder` `builder(String clsName)`
`void` `collectGridNodeData(DiscoveryDataBag dataBag)` Collects discovery data on nodes already in grid on receiving `TcpDiscoveryNodeAddedMessage`.
`void` `collectJoiningNodeData(DiscoveryDataBag dataBag)` Collects discovery data on joining node before sending `TcpDiscoveryJoinRequestMessage` request.
`CacheObjectContext` `contextForCache(CacheConfiguration cfg)`
`GridComponent.DiscoveryDataExchangeType` `discoveryDataType()` Gets unique component type to distinguish components providing discovery data.
`Object` `field(Object obj, String fieldName)`
`boolean` `hasField(Object obj, String fieldName)` Checks whether field is set in the object.
`boolean` `isBinaryEnabled(CacheConfiguration<?,?> ccfg)` Checks whether given class is binary.
`boolean` `isBinaryObject(Object obj)` Checks whether object is binary object.
`byte[]` `marshal(CacheObjectValueContext ctx, Object val)`
`byte[]` `marshal(Object obj)`
`GridBinaryMarshaller` `marshaller()`
`Object` `marshalToBinary(Object obj)`
`Collection<BinaryType>` `metadata()`
`Map<Integer,BinaryType>` `metadata(Collection<Integer> typeIds)`
`BinaryType` `metadata(int typeId)`
`BinaryType` `metadata(int typeId, int schemaId)`
`BinaryMetadata` `metadata0(int typeId)`
`void` `onDisconnected(IgniteFuture<?> reconnectFut)` Client disconnected callback.
`void` `onGridDataReceived(DiscoveryDataBag.GridDiscoveryData data)` Receives discovery data object from remote nodes (called on new node during discovery process).
`void` `onJoiningNodeDataReceived(DiscoveryDataBag.JoiningNodeDiscoveryData data)` Method is called on nodes that are already in grid (not on joining node).
`void` `onKernalStart(boolean active)` Callback that notifies that kernal has successfully started, including all managers and processors.
`BinaryType` `registerEnum(String typeName, Map<String,Integer> vals)` Register enum type
`void` `setBinaryMetadataFileStoreDir(File binaryMetadataFileStoreDir)` Sets path to binary metadata store configured by user, should include binary_meta and consistentId
`void` `start()` Starts grid component.
`void` `stop(boolean cancel)` Stops grid component.
`Object` `toBinary(Object obj)`
`KeyCacheObject` `toCacheKeyObject(CacheObjectContext ctx, GridCacheContext cctx, Object obj, boolean userObj)`
`CacheObject` `toCacheObject(CacheObjectContext ctx, byte type, byte[] bytes)`
`CacheObject` `toCacheObject(CacheObjectContext ctx, Object obj, boolean userObj)`
`KeyCacheObject` `toKeyCacheObject(CacheObjectContext ctx, byte type, byte[] bytes)`
`int` `typeId(Object obj)`
`int` `typeId(String typeName)`
`Object` `unmarshal(CacheObjectValueContext ctx, byte[] bytes, ClassLoader clsLdr)`
`Object` `unmarshal(long ptr, boolean forceHeap)`
`Object` `unwrapTemporary(GridCacheContext ctx, Object obj)` Converts temporary off-heap object to heap-based.
`void` `updateMetadata(int typeId, String typeName, String affKeyFieldName, Map<String,BinaryFieldMetadata> fieldTypeIds, boolean isEnum, Map<String,Integer> enumMap)`
`IgniteNodeValidationResult` `validateNode(ClusterNode rmtNode, DiscoveryDataBag.JoiningNodeDiscoveryData discoData)`

### Methods inherited from class org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessorImpl

`immutable, onContinuousProcessorStarted, partition, prepareForCache, toCacheKeyObject0, toCacheObject, toCacheObject, toCacheObject0, toKeyCacheObject`

### Methods inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter

`assertParameter, onKernalStop, onReconnected, printMemoryStats, toString, validateNode`

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

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

### Methods inherited from interface org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor

`immutable, onContinuousProcessorStarted, prepareForCache, toCacheObject, toCacheObject, toKeyCacheObject`

### Methods inherited from interface org.apache.ignite.internal.GridComponent

`onKernalStop, onReconnected, printMemoryStats, validateNode`

### Constructor Detail

#### CacheObjectBinaryProcessorImpl

    public CacheObjectBinaryProcessorImpl(GridKernalContext ctx)

Parameters:
  `ctx` - Kernal context.

### Method Detail

#### start

    public void start()
               throws IgniteCheckedException

Starts grid component.

Specified by:
  `start` in interface `GridComponent`
Overrides:
  `start` in class `GridProcessorAdapter`
Throws:
  `IgniteCheckedException` - Throws in case of any errors.

#### addBinaryMetadataUpdateListener

    public void addBinaryMetadataUpdateListener(BinaryMetadataUpdatedListener lsnr)

Parameters:
  `lsnr` - Listener.

#### stop

    public void stop(boolean cancel)

Stops grid component.

Specified by:
  `stop` in interface `GridComponent`
Overrides:
  `stop` in class `GridProcessorAdapter`
Parameters:
  `cancel` - If `true`, then all ongoing tasks or jobs for relevant components need to be cancelled.

#### onDisconnected

    public void onDisconnected(IgniteFuture<?> reconnectFut)
                        throws IgniteCheckedException

Client disconnected callback.

Specified by:
  `onDisconnected` in interface `GridComponent`
Overrides:
  `onDisconnected` in class `GridProcessorAdapter`
Parameters:
  `reconnectFut` - Reconnect future.
Throws:
  `IgniteCheckedException` - If failed.

#### onKernalStart

    public void onKernalStart(boolean active)
                       throws IgniteCheckedException

Callback that notifies that kernal has successfully started, including all managers and processors.

Specified by:
  `onKernalStart` in interface `GridComponent`
Overrides:
  `onKernalStart` in class `GridProcessorAdapter`
Parameters:
  `active` - Cluster active flag (note: should be used carefully since state can change concurrently).
Throws:
  `IgniteCheckedException` - Thrown in case of any errors.

#### typeId

    public int typeId(String typeName)

Specified by:
  `typeId` in interface `IgniteCacheObjectProcessor`
Overrides:
  `typeId` in class `IgniteCacheObjectProcessorImpl`
Parameters:
  `typeName` - Type name.
Returns:
  Type ID.

#### marshal

    public byte[] marshal(@Nullable
                          Object obj)
                   throws BinaryObjectException

Parameters:
  `obj` - Object.
Returns:
  Bytes.
Throws:
  `BinaryObjectException` - If failed.

#### unmarshal

    public Object unmarshal(long ptr,
                            boolean forceHeap)
                     throws BinaryObjectException

Parameters:
  `ptr` - Off-heap pointer.
  `forceHeap` - If `true` creates heap-based object.
Returns:
  Object.
Throws:
  `BinaryObjectException` - If failed.

#### marshalToBinary

    public Object marshalToBinary(@Nullable
                                  Object obj)
                           throws BinaryObjectException

Specified by:
  `marshalToBinary` in interface `CacheObjectBinaryProcessor`
Parameters:
  `obj` - Original object.
Returns:
  Binary object (in case binary marshaller is used).
Throws:
  `BinaryObjectException`

#### marshaller

    public GridBinaryMarshaller marshaller()

Returns:
  Marshaller.

#### builder

    public BinaryObjectBuilder builder(String clsName)

Specified by:
  `builder` in interface `CacheObjectBinaryProcessor`
Parameters:
  `clsName` - Class name.
Returns:
  Builder.

#### builder

    public BinaryObjectBuilder builder(BinaryObject binaryObj)

Creates builder initialized by existing binary object.

Specified by:
  `builder` in interface `CacheObjectBinaryProcessor`
Parameters:
  `binaryObj` - Binary object to edit.
Returns:
  Binary builder.

#### updateMetadata

    public void updateMetadata(int typeId,
                               String typeName,
                               @Nullable
                               String affKeyFieldName,
                               Map<String,BinaryFieldMetadata> fieldTypeIds,
                               boolean isEnum,
                               @Nullable
                               Map<String,Integer> enumMap)
                        throws BinaryObjectException

Specified by:
  `updateMetadata` in interface `CacheObjectBinaryProcessor`
Parameters:
  `typeId` - Type ID.
  `typeName` - Type name.
  `affKeyFieldName` - Affinity key field name.
  `fieldTypeIds` - Fields map.
  `isEnum` - Enum flag.
  `enumMap` - Enum name to ordinal mapping.
Throws:
  `BinaryObjectException`

#### addMeta

    public void addMeta(int typeId,
                        BinaryType newMeta)
                 throws BinaryObjectException

Specified by:
  `addMeta` in interface `CacheObjectBinaryProcessor`
Parameters:
  `typeId` - Type ID.
  `newMeta` - New meta data.
Throws:
  `BinaryObjectException`

#### addMetaLocally

    public void addMetaLocally(int typeId,
                               BinaryType newMeta)
                        throws BinaryObjectException

Adds metadata locally without triggering discovery exchange. Must be used only during startup and only if it is guaranteed that all nodes have the same copy of BinaryType.

Specified by:
  `addMetaLocally` in interface `CacheObjectBinaryProcessor`
Parameters:
  `typeId` - Type ID.
  `newMeta` - New meta data.
Throws:
  `BinaryObjectException`

#### metadata

    @Nullable
    public BinaryType metadata(int typeId)

Specified by:
  `metadata` in interface `CacheObjectBinaryProcessor`
Parameters:
  `typeId` - Type ID.
Returns:
  Meta data.

#### metadata0

    @Nullable
    public BinaryMetadata metadata0(int typeId)

Parameters:
  `typeId` - Type ID.
Returns:
  Meta data.
Throws:
  `IgniteException` - In case of error.

#### metadata

    @Nullable
    public BinaryType metadata(int typeId,
                                         int schemaId)

Specified by:
  `metadata` in interface `CacheObjectBinaryProcessor`
Parameters:
  `typeId` - Type ID.
  `schemaId` - Schema ID.
Returns:
  Meta data.

#### metadata

    public Map<Integer,BinaryType> metadata(Collection<Integer> typeIds)
                                     throws BinaryObjectException

Specified by:
  `metadata` in interface `CacheObjectBinaryProcessor`
Parameters:
  `typeIds` - Type ID.
Returns:
  Meta data.
Throws:
  `BinaryObjectException`

#### metadata

    public Collection<BinaryType> metadata()
                                    throws BinaryObjectException

Specified by:
  `metadata` in interface `CacheObjectBinaryProcessor`
Returns:
  Metadata for all types.
Throws:
  `BinaryObjectException`

#### buildEnum

    public BinaryObject buildEnum(String typeName,
                                  int ord)
                           throws BinaryObjectException

Specified by:
  `buildEnum` in interface `CacheObjectBinaryProcessor`
Parameters:
  `typeName` - Type name.
  `ord` - ordinal.
Returns:
  Enum object.
Throws:
  `BinaryObjectException`

#### buildEnum

    public BinaryObject buildEnum(String typeName,
                                  String name)
                           throws BinaryObjectException

Specified by:
  `buildEnum` in interface `CacheObjectBinaryProcessor`
Parameters:
  `typeName` - Type name.
  `name` - Name.
Returns:
  Enum object.
Throws:
  `BinaryObjectException`

#### registerEnum

    public BinaryType registerEnum(String typeName,
                                   Map<String,Integer> vals)
                            throws BinaryObjectException

Register enum type

Specified by:
  `registerEnum` in interface `CacheObjectBinaryProcessor`
Parameters:
  `typeName` - Type name.
  `vals` - Mapping of enum constant names to ordinals.
Returns:
  Binary Type for registered enum.
Throws:
  `BinaryObjectException`

#### binary

    public IgniteBinary binary()
                        throws IgniteException

Specified by:
  `binary` in interface `CacheObjectBinaryProcessor`
Specified by:
  `binary` in interface `IgniteCacheObjectProcessor`
Overrides:
  `binary` in class `IgniteCacheObjectProcessorImpl`
Returns:
  Ignite binary interface.
Throws:
  `IgniteException` - If failed.

#### isBinaryObject

    public boolean isBinaryObject(Object obj)

Checks whether object is binary object.

Specified by:
  `isBinaryObject` in interface `IgniteCacheObjectProcessor`
Overrides:
  `isBinaryObject` in class `IgniteCacheObjectProcessorImpl`
Parameters:
  `obj` - Object to check.
Returns:
  `True` if object is already a binary object, `false` otherwise.

#### isBinaryEnabled

    public boolean isBinaryEnabled(CacheConfiguration<?,?> ccfg)

Checks whether given class is binary.

Specified by:
  `isBinaryEnabled` in interface `IgniteCacheObjectProcessor`
Overrides:
  `isBinaryEnabled` in class `IgniteCacheObjectProcessorImpl`
Returns:
  `true` If binary objects are enabled.

#### affinityKeyField

    public BinaryField affinityKeyField(int typeId)

Get affinity key field.

Parameters:
  `typeId` - Binary object type ID.
Returns:
  Affinity key.

#### typeId

    public int typeId(Object obj)

Specified by:
  `typeId` in interface `IgniteCacheObjectProcessor`
Overrides:
  `typeId` in class `IgniteCacheObjectProcessorImpl`
Parameters:
  `obj` - Object to get type ID for.
Returns:
  Type ID.

#### field

    public Object field(Object obj,
                        String fieldName)

Specified by:
  `field` in interface `IgniteCacheObjectProcessor`
Overrides:
  `field` in class `IgniteCacheObjectProcessorImpl`
Parameters:
  `obj` - Binary object to get field from.
  `fieldName` - Field name.
Returns:
  Field value.

#### hasField

    public boolean hasField(Object obj,
                            String fieldName)

Checks whether field is set in the object.

Specified by:
  `hasField` in interface `IgniteCacheObjectProcessor`
Overrides:
  `hasField` in class `IgniteCacheObjectProcessorImpl`
Parameters:
  `obj` - Object.
  `fieldName` - Field name.
Returns:
  `true` if field is set.

#### binaryContext

    public BinaryContext binaryContext()

Returns:
  Binary context.

#### contextForCache

    public CacheObjectContext contextForCache(CacheConfiguration cfg)
                                       throws IgniteCheckedException

Specified by:
  `contextForCache` in interface `IgniteCacheObjectProcessor`
Overrides:
  `contextForCache` in class `IgniteCacheObjectProcessorImpl`
Parameters:
  `cfg` - Cache configuration.
Returns:
  Cache object context.
Throws:
  `IgniteCheckedException` - If failed.

#### marshal

    public byte[] marshal(CacheObjectValueContext ctx,
                          Object val)
                   throws IgniteCheckedException

Specified by:
  `marshal` in interface `IgniteCacheObjectProcessor`
Overrides:
  `marshal` in class `IgniteCacheObjectProcessorImpl`
Parameters:
  `ctx` - Cache object context.
  `val` - Value.
Returns:
  Value bytes.
Throws:
  `IgniteCheckedException` - If failed.

#### unmarshal

    public Object unmarshal(CacheObjectValueContext ctx,
                            byte[] bytes,
                            ClassLoader clsLdr)
                     throws IgniteCheckedException

Specified by:
  `unmarshal` in interface `IgniteCacheObjectProcessor`
Overrides:
  `unmarshal` in class `IgniteCacheObjectProcessorImpl`
Parameters:
  `ctx` - Context.
  `bytes` - Bytes.
  `clsLdr` - Class loader.
Returns:
  Unmarshalled object.
Throws:
  `IgniteCheckedException` - If failed.

#### toCacheKeyObject

    public KeyCacheObject toCacheKeyObject(CacheObjectContext ctx,
                                           @Nullable
                                           GridCacheContext cctx,
                                           Object obj,
                                           boolean userObj)

Specified by:
  `toCacheKeyObject` in interface `IgniteCacheObjectProcessor`
Overrides:
  `toCacheKeyObject` in class `IgniteCacheObjectProcessorImpl`
Parameters:
  `ctx` - Cache objects context.
  `cctx` - Cache context if cache is available.
  `obj` - Key value.
  `userObj` - If `true` then given object is object provided by user and should be copied before stored in cache.
Returns:
  Cache key object.

#### toCacheObject

    @Nullable
    public CacheObject toCacheObject(CacheObjectContext ctx,
                                               @Nullable
                                               Object obj,
                                               boolean userObj)

Specified by:
  `toCacheObject` in interface `IgniteCacheObjectProcessor`
Overrides:
  `toCacheObject` in class `IgniteCacheObjectProcessorImpl`
Parameters:
  `ctx` - Cache context.
  `obj` - Object.
  `userObj` - If `true` then given object is object provided by user and should be copied before stored in cache.
Returns:
  Cache object.

#### toCacheObject

    public CacheObject toCacheObject(CacheObjectContext ctx,
                                     byte type,
                                     byte[] bytes)

Specified by:
  `toCacheObject` in interface `IgniteCacheObjectProcessor`
Overrides:
  `toCacheObject` in class `IgniteCacheObjectProcessorImpl`
Parameters:
  `ctx` - Cache context.
  `type` - Object type.
  `bytes` - Object bytes.
Returns:
  Cache object.

#### toKeyCacheObject

    public KeyCacheObject toKeyCacheObject(CacheObjectContext ctx,
                                           byte type,
                                           byte[] bytes)
                                    throws IgniteCheckedException

Specified by:
  `toKeyCacheObject` in interface `IgniteCacheObjectProcessor`
Overrides:
  `toKeyCacheObject` in class `IgniteCacheObjectProcessorImpl`
Parameters:
  `ctx` - Cache context.
  `type` - Object type.
  `bytes` - Object bytes.
Returns:
  Cache object.
Throws:
  `IgniteCheckedException`

#### unwrapTemporary

    public Object unwrapTemporary(GridCacheContext ctx,
                                  Object obj)
                           throws BinaryObjectException

Converts temporary off-heap object to heap-based.

Specified by:
  `unwrapTemporary` in interface `IgniteCacheObjectProcessor`
Overrides:
  `unwrapTemporary` in class `IgniteCacheObjectProcessorImpl`
Parameters:
  `ctx` - Context.
  `obj` - Object.
Returns:
  Heap-based object.
Throws:
  `BinaryObjectException`

#### toBinary

    @Nullable
    public Object toBinary(@Nullable
                                     Object obj)
                              throws IgniteException

Parameters:
  `obj` - Object.
Returns:
  Binary object.
Throws:
  `IgniteException` - In case of error.

#### validateNode

    @Nullable
    public IgniteNodeValidationResult validateNode(ClusterNode rmtNode,
                                                             DiscoveryDataBag.JoiningNodeDiscoveryData discoData)

Specified by:
  `validateNode` in interface `GridComponent`
Overrides:
  `validateNode` in class `GridProcessorAdapter`

#### discoveryDataType

    @Nullable
    public GridComponent.DiscoveryDataExchangeType discoveryDataType()

Gets unique component type to distinguish components providing discovery data. Must return non-null value if component implements any of methods `GridComponent.collectJoiningNodeData(DiscoveryDataBag)` or `GridComponent.collectGridNodeData(DiscoveryDataBag)`.

Specified by:
  `discoveryDataType` in interface `GridComponent`
Overrides:
  `discoveryDataType` in class `GridProcessorAdapter`
Returns:
  Unique component type for discovery data exchange.

#### collectGridNodeData

    public void collectGridNodeData(DiscoveryDataBag dataBag)

Collects discovery data on nodes already in grid on receiving `TcpDiscoveryNodeAddedMessage`.

Specified by:
  `collectGridNodeData` in interface `GridComponent`
Overrides:
  `collectGridNodeData` in class `GridProcessorAdapter`
Parameters:
  `dataBag` - container object to store discovery data in.

#### collectJoiningNodeData

    public void collectJoiningNodeData(DiscoveryDataBag dataBag)

Collects discovery data on joining node before sending `TcpDiscoveryJoinRequestMessage` request.

Specified by:
  `collectJoiningNodeData` in interface `GridComponent`
Overrides:
  `collectJoiningNodeData` in class `GridProcessorAdapter`
Parameters:
  `dataBag` - container object to store discovery data in.

#### onJoiningNodeDataReceived

    public void onJoiningNodeDataReceived(DiscoveryDataBag.JoiningNodeDiscoveryData data)

Method is called on nodes that are already in grid (not on joining node). It receives discovery data from joining node.

Specified by:
  `onJoiningNodeDataReceived` in interface `GridComponent`
Overrides:
  `onJoiningNodeDataReceived` in class `GridProcessorAdapter`
Parameters:
  `data` - `DiscoveryDataBag.JoiningNodeDiscoveryData` interface to retrieve discovery data of joining node.

#### onGridDataReceived

    public void onGridDataReceived(DiscoveryDataBag.GridDiscoveryData data)

Receives discovery data object from remote nodes (called on new node during discovery process).

Specified by:
  `onGridDataReceived` in interface `GridComponent`
Overrides:
  `onGridDataReceived` in class `GridProcessorAdapter`
Parameters:
  `data` - `DiscoveryDataBag.GridDiscoveryData` interface to retrieve discovery data collected on remote nodes (data common for all nodes in grid and specific for each node).

#### setBinaryMetadataFileStoreDir

    public void setBinaryMetadataFileStoreDir(@Nullable
                                              File binaryMetadataFileStoreDir)

Sets path to binary metadata store configured by user, should include binary_meta and consistentId

Parameters:
  `binaryMetadataFileStoreDir` - path to binary_meta

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.6.0
Release Date | : July 10 2018