Interface IgniteCacheObjectProcessor
-
- All Superinterfaces:
GridComponent,GridProcessor
- All Known Implementing Classes:
CacheObjectBinaryProcessorImpl
public interface IgniteCacheObjectProcessor extends GridProcessor
Cache objects processor.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.ignite.internal.GridComponent
GridComponent.DiscoveryDataExchangeType
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddBinaryMetadataUpdateListener(BinaryMetadataUpdatedListener lsnr)Add binary metadata update listener.voidaddMeta(int typeId, BinaryType newMeta, boolean failIfUnregistered)voidaddMetaLocally(int typeId, BinaryType newMeta)Adds metadata locally without triggering discovery exchange.IgniteBinarybinary()BinaryObjectbuildEnum(String typeName, int ord)BinaryObjectbuildEnum(String typeName, String name)BinaryObjectBuilderbuilder(String clsName)BinaryObjectBuilderbuilder(BinaryObject binaryObj)Creates builder initialized by existing binary object.voidcacheMetadataLocally(File metadataDir, int typeId)Merge the binary metadata file stored in the specified directory.CacheObjectContextcontextForCache(CacheConfiguration ccfg)Objectfield(Object obj, String fieldName)booleanhasField(Object obj, String fieldName)Checks whether field is set in the object.booleanimmutable(Object obj)booleanisBinaryEnabled(CacheConfiguration<?,?> ccfg)Checks whether given class is binary.booleanisBinaryObject(Object obj)Checks whether object is binary object.byte[]marshal(CacheObjectValueContext ctx, Object val)ObjectmarshalToBinary(Object obj, boolean failIfUnregistered)Collection<BinaryType>metadata()@Nullable BinaryTypemetadata(int typeId)@Nullable BinaryTypemetadata(int typeId, int schemaId)Map<Integer,BinaryType>metadata(Collection<Integer> typeIds)voidonContinuousProcessorStarted(GridKernalContext ctx)@Nullable CacheObjectprepareForCache(@Nullable CacheObject obj, GridCacheContext cctx)Prepares cache object for cache (e.g. copies user-provided object if needed).BinaryTyperegisterClass(Class<?> cls)Register binary type for specified class.BinaryTyperegisterEnum(String typeName, Map<String,Integer> vals)Register enum typevoidremoveType(int typeId)Remove registered binary type from grid.voidsaveMetadata(Collection<BinaryType> types, File dir)KeyCacheObjecttoCacheKeyObject(CacheObjectContext ctx, @Nullable GridCacheContext cctx, Object obj, boolean userObj)CacheObjecttoCacheObject(CacheObjectContext ctx, byte type, byte[] bytes)@Nullable CacheObjecttoCacheObject(CacheObjectContext ctx, @Nullable Object obj, boolean userObj)@Nullable CacheObjecttoCacheObject(CacheObjectContext ctx, @Nullable Object obj, boolean userObj, boolean failIfUnregistered)CacheObjecttoCacheObject(CacheObjectContext ctx, ByteBuffer buf)IncompleteCacheObjecttoCacheObject(CacheObjectContext ctx, ByteBuffer buf, @Nullable IncompleteCacheObject incompleteObj)KeyCacheObjecttoKeyCacheObject(CacheObjectContext ctx, byte type, byte[] bytes)IncompleteCacheObjecttoKeyCacheObject(CacheObjectContext ctx, ByteBuffer buf, @Nullable IncompleteCacheObject incompleteObj)inttypeId(Object obj)inttypeId(String typeName)Objectunmarshal(CacheObjectValueContext ctx, byte[] bytes, ClassLoader clsLdr)@Nullable ObjectunwrapTemporary(GridCacheContext ctx, @Nullable Object obj)Converts temporary off-heap object to heap-based.voidupdateMetadata(int typeId, String typeName, @Nullable String affKeyFieldName, Map<String,BinaryFieldMetadata> fieldTypeIds, boolean isEnum, @Nullable Map<String,Integer> enumMap)voidupdateMetadata(File metadataDir, BooleanSupplier stopChecker)Merge the binary metadata files stored in the specified directory.-
Methods inherited from interface org.apache.ignite.internal.GridComponent
collectGridNodeData, collectJoiningNodeData, discoveryDataType, onDisconnected, onGridDataReceived, onJoiningNodeDataReceived, onKernalStart, onKernalStop, onReconnected, printMemoryStats, start, stop, validateNode, validateNode
-
-
-
-
Method Detail
-
onContinuousProcessorStarted
void onContinuousProcessorStarted(GridKernalContext ctx) throws IgniteCheckedException
- Parameters:
ctx- Context.- Throws:
IgniteCheckedException- If failed.
-
typeId
int typeId(String typeName)
- Parameters:
typeName- Type name.- Returns:
- Type ID.
-
typeId
int typeId(Object obj)
- Parameters:
obj- Object to get type ID for.- Returns:
- Type ID.
-
unwrapTemporary
@Nullable @Nullable Object unwrapTemporary(GridCacheContext ctx, @Nullable @Nullable Object obj) throws IgniteException
Converts temporary off-heap object to heap-based.- Parameters:
ctx- Context.obj- Object.- Returns:
- Heap-based object.
- Throws:
IgniteException- In case of error.
-
prepareForCache
@Nullable @Nullable CacheObject prepareForCache(@Nullable @Nullable CacheObject obj, GridCacheContext cctx)
Prepares cache object for cache (e.g. copies user-provided object if needed).- Parameters:
obj- Cache object.cctx- Cache context.- Returns:
- Object to be store in cache.
-
isBinaryObject
boolean isBinaryObject(Object obj)
Checks whether object is binary object.- Parameters:
obj- Object to check.- Returns:
Trueif object is already a binary object,falseotherwise.
-
isBinaryEnabled
boolean isBinaryEnabled(CacheConfiguration<?,?> ccfg)
Checks whether given class is binary.- Returns:
trueIf binary objects are enabled.
-
field
Object field(Object obj, String fieldName)
- Parameters:
obj- Binary object to get field from.fieldName- Field name.- Returns:
- Field value.
-
hasField
boolean hasField(Object obj, String fieldName)
Checks whether field is set in the object.- Parameters:
obj- Object.fieldName- Field name.- Returns:
trueif field is set.
-
marshal
byte[] marshal(CacheObjectValueContext ctx, Object val) throws IgniteCheckedException
- Parameters:
ctx- Cache object context.val- Value.- Returns:
- Value bytes.
- Throws:
IgniteCheckedException- If failed.
-
unmarshal
Object unmarshal(CacheObjectValueContext ctx, byte[] bytes, ClassLoader clsLdr) throws IgniteCheckedException
- Parameters:
ctx- Context.bytes- Bytes.clsLdr- Class loader.- Returns:
- Unmarshalled object.
- Throws:
IgniteCheckedException- If failed.
-
contextForCache
CacheObjectContext contextForCache(CacheConfiguration ccfg) throws IgniteCheckedException
- Parameters:
ccfg- Cache configuration.- Returns:
- Cache object context.
- Throws:
IgniteCheckedException- If failed.
-
toCacheKeyObject
KeyCacheObject toCacheKeyObject(CacheObjectContext ctx, @Nullable @Nullable GridCacheContext cctx, Object obj, boolean userObj)
- Parameters:
ctx- Cache objects context.cctx- Cache context if cache is available.obj- Key value.userObj- Iftruethen given object is object provided by user and should be copied before stored in cache.- Returns:
- Cache key object.
-
toCacheObject
@Nullable @Nullable CacheObject toCacheObject(CacheObjectContext ctx, @Nullable @Nullable Object obj, boolean userObj)
- Parameters:
ctx- Cache context.obj- Object.userObj- Iftruethen given object is object provided by user and should be copied before stored in cache.- Returns:
- Cache object.
-
toCacheObject
@Nullable @Nullable CacheObject toCacheObject(CacheObjectContext ctx, @Nullable @Nullable Object obj, boolean userObj, boolean failIfUnregistered)
- Parameters:
ctx- Cache context.obj- Object.userObj- Iftruethen given object is object provided by user and should be copied before stored in cache.failIfUnregistered- Throw exception if class isn't registered.- Returns:
- Cache object.
-
toCacheObject
CacheObject toCacheObject(CacheObjectContext ctx, byte type, byte[] bytes)
- Parameters:
ctx- Cache context.type- Object type.bytes- Object bytes.- Returns:
- Cache object.
-
toKeyCacheObject
KeyCacheObject toKeyCacheObject(CacheObjectContext ctx, byte type, byte[] bytes) throws IgniteCheckedException
- Parameters:
ctx- Cache context.type- Object type.bytes- Object bytes.- Returns:
- Cache object.
- Throws:
IgniteCheckedException
-
toCacheObject
CacheObject toCacheObject(CacheObjectContext ctx, ByteBuffer buf)
- Parameters:
ctx- Cache context.buf- Buffer to read from.- Returns:
- Cache object.
-
toCacheObject
IncompleteCacheObject toCacheObject(CacheObjectContext ctx, ByteBuffer buf, @Nullable @Nullable IncompleteCacheObject incompleteObj) throws IgniteCheckedException
- Parameters:
ctx- Cache object context.buf- Buffer.incompleteObj- Incomplete cache object ornullif it's a first read.- Returns:
- Incomplete cache object.
- Throws:
IgniteCheckedException- If fail.
-
toKeyCacheObject
IncompleteCacheObject toKeyCacheObject(CacheObjectContext ctx, ByteBuffer buf, @Nullable @Nullable IncompleteCacheObject incompleteObj) throws IgniteCheckedException
- Parameters:
ctx- Cache object context.buf- Buffer.incompleteObj- Incomplete cache object ornullif it's a first read.- Returns:
- Incomplete cache object.
- Throws:
IgniteCheckedException- If fail.
-
immutable
boolean immutable(Object obj)
- Parameters:
obj- Value.- Returns:
Trueif object is of known immutable type.
-
binary
IgniteBinary binary() throws IgniteException
- Returns:
- Ignite binary interface.
- Throws:
IgniteException- If failed.
-
builder
BinaryObjectBuilder builder(String clsName)
- Parameters:
clsName- Class name.- Returns:
- Builder.
-
builder
BinaryObjectBuilder builder(BinaryObject binaryObj)
Creates builder initialized by existing binary object.- Parameters:
binaryObj- Binary object to edit.- Returns:
- Binary builder.
-
addMeta
void addMeta(int typeId, BinaryType newMeta, boolean failIfUnregistered) throws IgniteException- Parameters:
typeId- Type ID.newMeta- New metadata.failIfUnregistered- Fail if unregistered.- Throws:
IgniteException- In case of error.
-
addMetaLocally
void addMetaLocally(int typeId, BinaryType newMeta) throws IgniteExceptionAdds 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.- Parameters:
typeId- Type ID.newMeta- New metadata.- Throws:
IgniteException- In case of error.
-
updateMetadata
void updateMetadata(int typeId, String typeName, @Nullable @Nullable String affKeyFieldName, Map<String,BinaryFieldMetadata> fieldTypeIds, boolean isEnum, @Nullable @Nullable Map<String,Integer> enumMap) throws IgniteException- 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:
IgniteException- In case of error.
-
metadata
@Nullable @Nullable BinaryType metadata(int typeId) throws IgniteException
- Parameters:
typeId- Type ID.- Returns:
- Metadata.
- Throws:
IgniteException- In case of error.
-
metadata
@Nullable @Nullable BinaryType metadata(int typeId, int schemaId) throws IgniteException
- Parameters:
typeId- Type ID.schemaId- Schema ID.- Returns:
- Metadata.
- Throws:
IgniteException- In case of error.
-
metadata
Map<Integer,BinaryType> metadata(Collection<Integer> typeIds) throws IgniteException
- Parameters:
typeIds- Type ID.- Returns:
- Metadata.
- Throws:
IgniteException- In case of error.
-
metadata
Collection<BinaryType> metadata() throws IgniteException
- Returns:
- Metadata for all types.
- Throws:
IgniteException- In case of error.
-
saveMetadata
void saveMetadata(Collection<BinaryType> types, File dir)
- Parameters:
types- Collection of binary types to write to.dir- Destination directory.
-
updateMetadata
void updateMetadata(File metadataDir, BooleanSupplier stopChecker) throws IgniteCheckedException
Merge the binary metadata files stored in the specified directory.- Parameters:
metadataDir- Directory containing binary metadata files.stopChecker- Process interrupt checker.- Throws:
IgniteCheckedException- If failed.
-
cacheMetadataLocally
void cacheMetadataLocally(File metadataDir, int typeId) throws IgniteCheckedException
Merge the binary metadata file stored in the specified directory.- Parameters:
metadataDir- Directory containing binary metadata files.typeId- Type id to update.- Throws:
IgniteCheckedException- If failed.
-
buildEnum
BinaryObject buildEnum(String typeName, int ord) throws IgniteException
- Parameters:
typeName- Type name.ord- ordinal.- Returns:
- Enum object.
- Throws:
IgniteException- If failed.
-
buildEnum
BinaryObject buildEnum(String typeName, String name) throws IgniteException
- Parameters:
typeName- Type name.name- Name.- Returns:
- Enum object.
- Throws:
IgniteException- If failed.
-
registerEnum
BinaryType registerEnum(String typeName, Map<String,Integer> vals) throws IgniteException
Register enum type- Parameters:
typeName- Type name.vals- Mapping of enum constant names to ordinals.- Returns:
- Binary Type for registered enum.
- Throws:
IgniteException
-
marshalToBinary
Object marshalToBinary(Object obj, boolean failIfUnregistered) throws IgniteException
- Parameters:
obj- Original object.failIfUnregistered- Throw exception if class isn't registered.- Returns:
- Binary object (in case binary marshaller is used).
- Throws:
IgniteException- If failed.
-
removeType
void removeType(int typeId)
Remove registered binary type from grid. Attention: this is not safe feature, the grid must not contain binary objects with specified type, operations with specified type must not be processed on the cluster.- Parameters:
typeId- Type ID.
-
registerClass
BinaryType registerClass(Class<?> cls) throws BinaryObjectException
Register binary type for specified class.- Parameters:
cls- Class.- Returns:
- Metadata.
- Throws:
BinaryObjectException- In case of error.
-
addBinaryMetadataUpdateListener
void addBinaryMetadataUpdateListener(BinaryMetadataUpdatedListener lsnr)
Add binary metadata update listener.- Parameters:
lsnr- Listener.
-
-