public class CacheObjectBinaryProcessorImpl extends GridProcessorAdapter implements IgniteCacheObjectProcessor
Modifier and Type | Class and Description |
---|---|
static class |
CacheObjectBinaryProcessorImpl.TestBinaryContext |
GridComponent.DiscoveryDataExchangeType
Modifier and Type | Field and Description |
---|---|
static String |
BINARY_METADATA_DESC |
static String |
BINARY_METADATA_VIEW |
static int |
DFLT_WAIT_SCHEMA_UPDATE |
static boolean |
useTestBinaryCtx
For tests.
|
ctx, diagnosticLog, log
Constructor and Description |
---|
CacheObjectBinaryProcessorImpl(GridKernalContext ctx) |
Modifier and Type | Method and Description |
---|---|
void |
addBinaryMetadataUpdateListener(BinaryMetadataUpdatedListener lsnr) |
void |
addMeta(int typeId,
BinaryType newMeta,
boolean failIfUnregistered) |
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() |
Collection<BinaryMetadata> |
binaryMetadata() |
BinaryMetadata |
binaryMetadata(int typeId) |
static File |
binaryWorkDir(String igniteWorkDir,
String consId) |
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 ccfg) |
@Nullable 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 |
immutable(Object obj) |
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(@Nullable Object obj) |
GridBinaryMarshaller |
marshaller() |
Object |
marshalToBinary(@Nullable Object obj,
boolean failIfUnregistered) |
Collection<BinaryType> |
metadata() |
Map<Integer,BinaryType> |
metadata(Collection<Integer> typeIds) |
@Nullable BinaryType |
metadata(int typeId) |
@Nullable BinaryType |
metadata(int typeId,
int schemaId) |
@Nullable BinaryMetadata |
metadata0(int typeId) |
void |
onContinuousProcessorStarted(GridKernalContext ctx) |
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.
|
IgniteInternalFuture<?> |
onReconnected(boolean clusterRestarted)
Client reconnected callback.
|
@Nullable CacheObject |
prepareForCache(@Nullable CacheObject obj,
GridCacheContext cctx)
Prepares cache object for cache (e.g. copies user-provided object if needed).
|
BinaryType |
registerEnum(String typeName,
Map<String,Integer> vals)
Register enum type
|
void |
removeType(int typeId)
Remove registered binary type from grid.
|
static File |
resolveBinaryWorkDir(String igniteWorkDir,
String consId) |
void |
saveMetadata(Collection<BinaryType> types,
File dir) |
void |
setBinaryMetadataFileStoreDir(@Nullable 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.
|
@Nullable Object |
toBinary(@Nullable Object obj,
boolean failIfUnregistered) |
KeyCacheObject |
toCacheKeyObject(CacheObjectContext ctx,
@Nullable GridCacheContext cctx,
Object obj,
boolean userObj) |
protected KeyCacheObject |
toCacheKeyObject0(CacheObjectContext ctx,
@Nullable GridCacheContext cctx,
Object obj,
boolean userObj) |
CacheObject |
toCacheObject(CacheObjectContext ctx,
ByteBuffer buf) |
IncompleteCacheObject |
toCacheObject(CacheObjectContext ctx,
ByteBuffer buf,
@Nullable IncompleteCacheObject incompleteObj) |
CacheObject |
toCacheObject(CacheObjectContext ctx,
byte type,
byte[] bytes) |
@Nullable CacheObject |
toCacheObject(CacheObjectContext ctx,
@Nullable Object obj,
boolean userObj) |
@Nullable CacheObject |
toCacheObject(CacheObjectContext ctx,
@Nullable Object obj,
boolean userObj,
boolean failIfUnregistered) |
IncompleteCacheObject |
toKeyCacheObject(CacheObjectContext ctx,
ByteBuffer buf,
@Nullable IncompleteCacheObject incompleteObj) |
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,
@Nullable String affKeyFieldName,
Map<String,BinaryFieldMetadata> fieldTypeIds,
boolean isEnum,
@Nullable Map<String,Integer> enumMap) |
@Nullable IgniteNodeValidationResult |
validateNode(ClusterNode rmtNode,
DiscoveryDataBag.JoiningNodeDiscoveryData discoData)
Validates that new node can join grid topology, this method is called on coordinator
node before new node joins topology.
|
void |
waitMetadataWriteIfNeeded(int typeId)
Forces caller thread to wait for binary metadata write operation for given type ID.
|
assertParameter, onKernalStop, printMemoryStats, toString, validateNode
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
onKernalStop, printMemoryStats, validateNode
public static final int DFLT_WAIT_SCHEMA_UPDATE
public static final String BINARY_METADATA_VIEW
BinaryMetadataView
public static final String BINARY_METADATA_DESC
BinaryMetadataView
,
Constant Field Valuespublic static boolean useTestBinaryCtx
public CacheObjectBinaryProcessorImpl(GridKernalContext ctx)
ctx
- Kernal context.public static File resolveBinaryWorkDir(String igniteWorkDir, String consId)
igniteWorkDir
- Basic ignite working directory.consId
- Node consistent id.public static File binaryWorkDir(String igniteWorkDir, String consId)
igniteWorkDir
- Basic ignite working directory.consId
- Node consistent id.public void start() throws IgniteCheckedException
start
in interface GridComponent
start
in class GridProcessorAdapter
IgniteCheckedException
- Throws in case of any errors.public void addBinaryMetadataUpdateListener(BinaryMetadataUpdatedListener lsnr)
lsnr
- Listener.public void stop(boolean cancel)
stop
in interface GridComponent
stop
in class GridProcessorAdapter
cancel
- If true
, then all ongoing tasks or jobs for relevant
components need to be cancelled.public void onDisconnected(IgniteFuture<?> reconnectFut)
onDisconnected
in interface GridComponent
onDisconnected
in class GridProcessorAdapter
reconnectFut
- Reconnect future.public IgniteInternalFuture<?> onReconnected(boolean clusterRestarted) throws IgniteCheckedException
onReconnected
in interface GridComponent
onReconnected
in class GridProcessorAdapter
clusterRestarted
- Cluster restarted flag.IgniteCheckedException
- If failed.public void onKernalStart(boolean active) throws IgniteCheckedException
onKernalStart
in interface GridComponent
onKernalStart
in class GridProcessorAdapter
active
- Cluster active flag (note: should be used carefully since state can
change concurrently).IgniteCheckedException
- Thrown in case of any errors.@Nullable public @Nullable CacheObject prepareForCache(@Nullable @Nullable CacheObject obj, GridCacheContext cctx)
prepareForCache
in interface IgniteCacheObjectProcessor
obj
- Cache object.cctx
- Cache context.public int typeId(String typeName)
typeId
in interface IgniteCacheObjectProcessor
typeName
- Type name.public boolean immutable(Object obj)
immutable
in interface IgniteCacheObjectProcessor
obj
- Value.True
if object is of known immutable type.public void onContinuousProcessorStarted(GridKernalContext ctx)
onContinuousProcessorStarted
in interface IgniteCacheObjectProcessor
ctx
- Context.public byte[] marshal(@Nullable @Nullable Object obj) throws BinaryObjectException
obj
- Object.BinaryObjectException
- If failed.public Object unmarshal(long ptr, boolean forceHeap) throws BinaryObjectException
ptr
- Off-heap pointer.forceHeap
- If true
creates heap-based object.BinaryObjectException
- If failed.public Object marshalToBinary(@Nullable @Nullable Object obj, boolean failIfUnregistered) throws BinaryObjectException
marshalToBinary
in interface IgniteCacheObjectProcessor
obj
- Original object.failIfUnregistered
- Throw exception if class isn't registered.BinaryObjectException
public GridBinaryMarshaller marshaller()
public BinaryObjectBuilder builder(String clsName)
builder
in interface IgniteCacheObjectProcessor
clsName
- Class name.public BinaryObjectBuilder builder(BinaryObject binaryObj)
builder
in interface IgniteCacheObjectProcessor
binaryObj
- Binary object to edit.public void updateMetadata(int typeId, String typeName, @Nullable @Nullable String affKeyFieldName, Map<String,BinaryFieldMetadata> fieldTypeIds, boolean isEnum, @Nullable @Nullable Map<String,Integer> enumMap) throws BinaryObjectException
updateMetadata
in interface IgniteCacheObjectProcessor
typeId
- Type ID.typeName
- Type name.affKeyFieldName
- Affinity key field name.fieldTypeIds
- Fields map.isEnum
- Enum flag.enumMap
- Enum name to ordinal mapping.BinaryObjectException
public void addMeta(int typeId, BinaryType newMeta, boolean failIfUnregistered) throws BinaryObjectException
addMeta
in interface IgniteCacheObjectProcessor
typeId
- Type ID.newMeta
- New metadata.failIfUnregistered
- Fail if unregistered.BinaryObjectException
public void addMetaLocally(int typeId, BinaryType newMeta) throws BinaryObjectException
addMetaLocally
in interface IgniteCacheObjectProcessor
typeId
- Type ID.newMeta
- New metadata.BinaryObjectException
@Nullable public @Nullable BinaryType metadata(int typeId)
metadata
in interface IgniteCacheObjectProcessor
typeId
- Type ID.public void waitMetadataWriteIfNeeded(int typeId)
typeId
- ID of binary type to wait for metadata write operation.@Nullable public @Nullable BinaryMetadata metadata0(int typeId)
typeId
- Type ID.IgniteException
- In case of error.@Nullable public @Nullable BinaryType metadata(int typeId, int schemaId)
metadata
in interface IgniteCacheObjectProcessor
typeId
- Type ID.schemaId
- Schema ID.public Map<Integer,BinaryType> metadata(Collection<Integer> typeIds) throws BinaryObjectException
metadata
in interface IgniteCacheObjectProcessor
typeIds
- Type ID.BinaryObjectException
public Collection<BinaryType> metadata() throws BinaryObjectException
metadata
in interface IgniteCacheObjectProcessor
BinaryObjectException
public Collection<BinaryMetadata> binaryMetadata() throws BinaryObjectException
BinaryObjectException
- on error.public BinaryMetadata binaryMetadata(int typeId) throws BinaryObjectException
BinaryObjectException
- on error.public void saveMetadata(Collection<BinaryType> types, File dir)
saveMetadata
in interface IgniteCacheObjectProcessor
types
- Collection of binary types to write to.dir
- Destination directory.public BinaryObject buildEnum(String typeName, int ord) throws BinaryObjectException
buildEnum
in interface IgniteCacheObjectProcessor
typeName
- Type name.ord
- ordinal.BinaryObjectException
public BinaryObject buildEnum(String typeName, String name) throws BinaryObjectException
buildEnum
in interface IgniteCacheObjectProcessor
typeName
- Type name.name
- Name.BinaryObjectException
public BinaryType registerEnum(String typeName, Map<String,Integer> vals) throws BinaryObjectException
registerEnum
in interface IgniteCacheObjectProcessor
typeName
- Type name.vals
- Mapping of enum constant names to ordinals.BinaryObjectException
public IgniteBinary binary() throws IgniteException
binary
in interface IgniteCacheObjectProcessor
IgniteException
- If failed.public boolean isBinaryObject(Object obj)
isBinaryObject
in interface IgniteCacheObjectProcessor
obj
- Object to check.True
if object is already a binary object, false
otherwise.public boolean isBinaryEnabled(CacheConfiguration<?,?> ccfg)
isBinaryEnabled
in interface IgniteCacheObjectProcessor
true
If binary objects are enabled.public BinaryField affinityKeyField(int typeId)
typeId
- Binary object type ID.public int typeId(Object obj)
typeId
in interface IgniteCacheObjectProcessor
obj
- Object to get type ID for.public Object field(Object obj, String fieldName)
field
in interface IgniteCacheObjectProcessor
obj
- Binary object to get field from.fieldName
- Field name.public boolean hasField(Object obj, String fieldName)
hasField
in interface IgniteCacheObjectProcessor
obj
- Object.fieldName
- Field name.true
if field is set.public BinaryContext binaryContext()
public CacheObjectContext contextForCache(CacheConfiguration ccfg) throws IgniteCheckedException
contextForCache
in interface IgniteCacheObjectProcessor
ccfg
- Cache configuration.IgniteCheckedException
- If failed.public byte[] marshal(CacheObjectValueContext ctx, Object val) throws IgniteCheckedException
marshal
in interface IgniteCacheObjectProcessor
ctx
- Cache object context.val
- Value.IgniteCheckedException
- If failed.public Object unmarshal(CacheObjectValueContext ctx, byte[] bytes, ClassLoader clsLdr) throws IgniteCheckedException
unmarshal
in interface IgniteCacheObjectProcessor
ctx
- Context.bytes
- Bytes.clsLdr
- Class loader.IgniteCheckedException
- If failed.public KeyCacheObject toCacheKeyObject(CacheObjectContext ctx, @Nullable @Nullable GridCacheContext cctx, Object obj, boolean userObj)
toCacheKeyObject
in interface IgniteCacheObjectProcessor
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.protected KeyCacheObject toCacheKeyObject0(CacheObjectContext ctx, @Nullable @Nullable GridCacheContext cctx, Object obj, boolean userObj)
obj
- Object.userObj
- If true
then given object is object provided by user and should be copied
before stored in cache.@Nullable public @Nullable CacheObject toCacheObject(CacheObjectContext ctx, @Nullable @Nullable Object obj, boolean userObj, boolean failIfUnregistered)
toCacheObject
in interface IgniteCacheObjectProcessor
ctx
- Cache context.obj
- Object.userObj
- If true
then given object is object provided by user and should be copied
before stored in cache.failIfUnregistered
- Throw exception if class isn't registered.public CacheObject toCacheObject(CacheObjectContext ctx, byte type, byte[] bytes)
toCacheObject
in interface IgniteCacheObjectProcessor
ctx
- Cache context.type
- Object type.bytes
- Object bytes.public KeyCacheObject toKeyCacheObject(CacheObjectContext ctx, byte type, byte[] bytes) throws IgniteCheckedException
toKeyCacheObject
in interface IgniteCacheObjectProcessor
ctx
- Cache context.type
- Object type.bytes
- Object bytes.IgniteCheckedException
public CacheObject toCacheObject(CacheObjectContext ctx, ByteBuffer buf)
toCacheObject
in interface IgniteCacheObjectProcessor
ctx
- Cache context.buf
- Buffer to read from.public IncompleteCacheObject toCacheObject(CacheObjectContext ctx, ByteBuffer buf, @Nullable @Nullable IncompleteCacheObject incompleteObj)
toCacheObject
in interface IgniteCacheObjectProcessor
ctx
- Cache object context.buf
- Buffer.incompleteObj
- Incomplete cache object or null
if it's a first read.public IncompleteCacheObject toKeyCacheObject(CacheObjectContext ctx, ByteBuffer buf, @Nullable @Nullable IncompleteCacheObject incompleteObj) throws IgniteCheckedException
toKeyCacheObject
in interface IgniteCacheObjectProcessor
ctx
- Cache object context.buf
- Buffer.incompleteObj
- Incomplete cache object or null
if it's a first read.IgniteCheckedException
- If fail.@Nullable public @Nullable CacheObject toCacheObject(CacheObjectContext ctx, @Nullable @Nullable Object obj, boolean userObj)
toCacheObject
in interface IgniteCacheObjectProcessor
ctx
- Cache context.obj
- Object.userObj
- If true
then given object is object provided by user and should be copied
before stored in cache.public Object unwrapTemporary(GridCacheContext ctx, Object obj) throws BinaryObjectException
unwrapTemporary
in interface IgniteCacheObjectProcessor
ctx
- Context.obj
- Object.BinaryObjectException
@Nullable public @Nullable Object toBinary(@Nullable @Nullable Object obj, boolean failIfUnregistered) throws IgniteException
obj
- Object.IgniteException
- In case of error.@Nullable public @Nullable IgniteNodeValidationResult validateNode(ClusterNode rmtNode, DiscoveryDataBag.JoiningNodeDiscoveryData discoData)
validateNode
in interface GridComponent
validateNode
in class GridProcessorAdapter
rmtNode
- Joining node.discoData
- Joining node discovery data.null
in case of success.@Nullable public @Nullable GridComponent.DiscoveryDataExchangeType discoveryDataType()
GridComponent.collectJoiningNodeData(DiscoveryDataBag)
or GridComponent.collectGridNodeData(DiscoveryDataBag)
.discoveryDataType
in interface GridComponent
discoveryDataType
in class GridProcessorAdapter
public void collectGridNodeData(DiscoveryDataBag dataBag)
TcpDiscoveryNodeAddedMessage
.collectGridNodeData
in interface GridComponent
collectGridNodeData
in class GridProcessorAdapter
dataBag
- container object to store discovery data in.public void collectJoiningNodeData(DiscoveryDataBag dataBag)
TcpDiscoveryJoinRequestMessage
request.collectJoiningNodeData
in interface GridComponent
collectJoiningNodeData
in class GridProcessorAdapter
dataBag
- container object to store discovery data in.public void onJoiningNodeDataReceived(DiscoveryDataBag.JoiningNodeDiscoveryData data)
onJoiningNodeDataReceived
in interface GridComponent
onJoiningNodeDataReceived
in class GridProcessorAdapter
data
- DiscoveryDataBag.JoiningNodeDiscoveryData
interface to retrieve discovery data of joining node.public void onGridDataReceived(DiscoveryDataBag.GridDiscoveryData data)
onGridDataReceived
in interface GridComponent
onGridDataReceived
in class GridProcessorAdapter
data
- DiscoveryDataBag.GridDiscoveryData
interface to retrieve discovery data collected on remote nodes
(data common for all nodes in grid and specific for each node).public void setBinaryMetadataFileStoreDir(@Nullable @Nullable File binaryMetadataFileStoreDir)
binaryMetadataFileStoreDir
- path to binary_metapublic void removeType(int typeId)
removeType
in interface IgniteCacheObjectProcessor
typeId
- Type ID.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.10.0 Release Date : March 10 2021