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
`static IgniteProductVersion` `BINARY_CFG_CHECK_SINCE`

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

`ctx, log`

### Constructor Summary

Constructors
Constructor and Description
`CacheObjectBinaryProcessorImpl(GridKernalContext ctx)`

### Method Summary

Methods
`void` `addMeta(int typeId, BinaryType newMeta)`
`Object` `affinityKey(BinaryObject po)`
`IgniteBinary` `binary()`
`BinaryContext` `binaryContext()`
`BinaryObject` `buildEnum(String typeName, int ord)`
`BinaryObjectBuilder` `builder(BinaryObject binaryObj)` Creates builder initialized by existing binary object.
`BinaryObjectBuilder` `builder(String clsName)`
`CacheObjectContext` `contextForCache(CacheConfiguration cfg)`
`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(CacheObjectContext 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)`
`void` `onKernalStart()` Callback that notifies that kernal has successfully started, including all managers and processors.
`void` `onKernalStop(boolean cancel)` Callback to notify that kernal is about to stop.
`void` `onUtilityCacheStarted()`
`void` `start()` Starts grid component.
`Object` `toBinary(Object obj)`
`KeyCacheObject` `toCacheKeyObject(CacheObjectContext ctx, Object obj, boolean userObj)`
`KeyCacheObject` `toCacheKeyObject(CacheObjectContext ctx, Object obj, boolean userObj, int partition)`
`CacheObject` `toCacheObject(CacheObjectContext ctx, byte type, byte[] bytes)`
`CacheObject` `toCacheObject(CacheObjectContext ctx, Object obj, boolean userObj)`
`CacheObject` `toCacheObject(GridCacheContext ctx, long valPtr, boolean tmp)`
`int` `typeId(Object obj)`
`int` `typeId(String typeName)`
`Object` `unmarshal(CacheObjectContext 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,Integer> fieldTypeIds, boolean isEnum)`
`IgniteNodeValidationResult` `validateNode(ClusterNode rmtNode)` Validates that new node can join grid topology, this method is called on coordinator node before new node joins topology.

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

`immutable, prepareForCache, toCacheKeyObject0, toCacheObject0`

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

`assertParameter, collectDiscoveryData, discoveryDataType, onDisconnected, onDiscoveryDataReceived, onReconnected, printMemoryStats, stop, toString`

### 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, prepareForCache`

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

`collectDiscoveryData, discoveryDataType, onDisconnected, onDiscoveryDataReceived, onReconnected, printMemoryStats, stop`

### Field Detail

#### BINARY_CFG_CHECK_SINCE

    public static final IgniteProductVersion BINARY_CFG_CHECK_SINCE

### 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.

#### onUtilityCacheStarted

    public void onUtilityCacheStarted()
                               throws IgniteCheckedException

Specified by:
  `onUtilityCacheStarted` in interface `IgniteCacheObjectProcessor`
Overrides:
  `onUtilityCacheStarted` in class `IgniteCacheObjectProcessorImpl`
Throws:
  `IgniteCheckedException` - If failed.
See Also:
  `GridComponent.onKernalStart()`

#### onKernalStart

    public void onKernalStart()
                       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`
Throws:
  `IgniteCheckedException` - Thrown in case of any errors.

#### onKernalStop

    public void onKernalStop(boolean cancel)

Callback to notify that kernal is about to stop.

Specified by:
  `onKernalStop` in interface `GridComponent`
Overrides:
  `onKernalStop` in class `GridProcessorAdapter`
Parameters:
  `cancel` - Flag indicating whether jobs should be canceled.

#### 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,Integer> fieldTypeIds,
                      boolean isEnum)
                        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.
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`

#### metadata

    @Nullable
    public BinaryType metadata(int typeId)
                        throws BinaryObjectException

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

#### 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 IgniteException

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

#### 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.

#### affinityKey

    public Object affinityKey(BinaryObject po)

Parameters:
  `po` - Binary object.
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(CacheObjectContext 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(CacheObjectContext 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,
                                  Object obj,
                                  boolean userObj)

Specified by:
  `toCacheKeyObject` in interface `IgniteCacheObjectProcessor`
Overrides:
  `toCacheKeyObject` in class `IgniteCacheObjectProcessorImpl`
Parameters:
  `ctx` - Cache context.
  `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.

#### toCacheKeyObject

    public KeyCacheObject toCacheKeyObject(CacheObjectContext ctx,
                                  Object obj,
                                  boolean userObj,
                                  int partition)

Specified by:
  `toCacheKeyObject` in interface `IgniteCacheObjectProcessor`
Overrides:
  `toCacheKeyObject` in class `IgniteCacheObjectProcessorImpl`
Parameters:
  `ctx` - Cache context.
  `obj` - Key value.
  `userObj` - If `true` then given object is object provided by user and should be copied before stored in cache.
  `partition` - ID of partition this key belongs to.
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.

#### toCacheObject

    public CacheObject toCacheObject(GridCacheContext ctx,
                            long valPtr,
                            boolean tmp)
                              throws IgniteCheckedException

Specified by:
  `toCacheObject` in interface `IgniteCacheObjectProcessor`
Overrides:
  `toCacheObject` in class `IgniteCacheObjectProcessorImpl`
Parameters:
  `ctx` - Context.
  `valPtr` - Value pointer.
  `tmp` - If `true` can return temporary instance which is valid while entry lock is held.
Returns:
  Cache object.
Throws:
  `IgniteCheckedException` - If failed.

#### 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)

Validates that new node can join grid topology, this method is called on coordinator node before new node joins topology.

Specified by:
  `validateNode` in interface `GridComponent`
Overrides:
  `validateNode` in class `GridProcessorAdapter`
Parameters:
  `rmtNode` - Joining node.
Returns:
  Validation result or `null` in case of success.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.6.0
Release Date | : May 18 2016