Class BinaryContext
- java.lang.Object
-
- org.apache.ignite.internal.binary.BinaryContext
-
public class BinaryContext extends Object
Binary context.
-
-
Constructor Summary
Constructors Constructor Description BinaryContext(BinaryMetadataHandler metaHnd, @Nullable BinaryMarshaller marsh, @Nullable String igniteInstanceName, @Nullable ClassLoader clsLdr, @Nullable BinarySerializer dfltSerializer, @Nullable BinaryIdMapper idMapper, @Nullable BinaryNameMapper nameMapper, @Nullable Collection<BinaryTypeConfiguration> typeCfgs, Map<String,String> affFlds, boolean compactFooter, Function<Class<?>,String> affFldNameProvider, IgniteLogger log)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringaffinityKeyFieldName(int typeId)Get affinity key field name for type.ClassLoaderclassLoader()bytecollectionType(Class<? extends Collection> cls)BinaryObjectcreateBinaryArray(Class<?> compCls, Object[] pArr)Creates instance ofBinaryArray.BinaryFieldcreateField(int typeId, String fieldName)Create binary field.static BinaryIdMapperdefaultIdMapper()static org.apache.ignite.internal.binary.BinaryInternalMapperdefaultMapper()static BinaryNameMapperdefaultNameMapper()intfieldId(int typeId, String fieldName)org.apache.ignite.internal.binary.BinaryIdentityResolveridentity(int typeId)StringigniteInstanceName()booleanisCompactFooter()IgniteLoggerlog()bytemapType(Class<? extends Map> cls)BinaryMarshallermarshaller()Collection<BinaryType>metadata()@Nullable BinaryTypemetadata(int typeId)BinaryTypemetadata(int typeId, int schemaId)@Nullable BinaryMetadatametadata0(int typeId)booleanmustDeserialize(Class cls)Check whether class must be deserialized anyway.voidonUndeploy(ClassLoader ldr)Undeployment callback invoked when class loader is being undeployed.voidregisterBinarilizableSystemClass(Class<?> cls)Register system class that should be marshalled with BinaryMarshaller.voidregisterClassLocally(BinaryType binaryType, boolean failIfUnregistered, byte platformId)Registers binary type locally.voidregisterPredefinedType(Class<?> cls, int id)voidregisterPredefinedType(Class<?> cls, int id, String affFieldName, boolean registered)intregisterType(Class<?> cls, boolean registerMeta, boolean failIfUnregistered)Attempts registration of the provided class.intregisterTypeLocally(Class<?> cls, boolean registerMeta, boolean failIfUnregistered)booleanregisterUserClassName(int typeId, String clsName, boolean failIfUnregistered, boolean onlyLocReg, byte platformId)Register "type ID to class name" mapping on all nodes to allow for mapping requests resolution form client.voidregisterUserType(String clsName, org.apache.ignite.internal.binary.BinaryInternalMapper mapper, @Nullable BinarySerializer serializer, @Nullable org.apache.ignite.internal.binary.BinaryIdentityResolver identity, @Nullable String affKeyFieldName, boolean isEnum, @Nullable Map<String,Integer> enumMap)voidregisterUserTypesSchema()Register user types schemas.voidremoveType(int typeId)inttypeId(String typeName)voidunregisterBinarySchemas()Unregister all binary schemas.voidunregisterUserTypeDescriptors()Unregisters the user types descriptors.voidupdateMetadata(int typeId, BinaryMetadata meta, boolean failIfUnregistered)voidupdateMetaIfNeeded(BinaryWriterEx writer, BinaryType meta, int typeId, String typeName, String affFieldName, Map<String,BinaryFieldMetadata> fieldsMeta)StringuserTypeName(String clsName)
-
-
-
Constructor Detail
-
BinaryContext
public BinaryContext(BinaryMetadataHandler metaHnd, @Nullable @Nullable BinaryMarshaller marsh, @Nullable @Nullable String igniteInstanceName, @Nullable @Nullable ClassLoader clsLdr, @Nullable @Nullable BinarySerializer dfltSerializer, @Nullable @Nullable BinaryIdMapper idMapper, @Nullable @Nullable BinaryNameMapper nameMapper, @Nullable @Nullable Collection<BinaryTypeConfiguration> typeCfgs, Map<String,String> affFlds, boolean compactFooter, Function<Class<?>,String> affFldNameProvider, IgniteLogger log)
- Parameters:
metaHnd- Meta data handler.marsh- Binary marshaller.igniteInstanceName- Ignite instance name.clsLdr- Class loader.dfltSerializer- Binary serializer.idMapper- Binary id mapper.nameMapper- Binary name mapper.affFlds- Affinity fields.compactFooter- Compact footer flag.affFldNameProvider- Affinity field name provider function.log- Logger.
-
-
Method Detail
-
log
public IgniteLogger log()
- Returns:
- Logger.
-
marshaller
public BinaryMarshaller marshaller()
- Returns:
- Marshaller.
-
mustDeserialize
public boolean mustDeserialize(Class cls)
Check whether class must be deserialized anyway.- Parameters:
cls- Class.- Returns:
Trueif must be deserialized.
-
igniteInstanceName
public String igniteInstanceName()
- Returns:
- Ignite instance name.
-
classLoader
public ClassLoader classLoader()
- Returns:
- Class loader.
-
defaultMapper
public static org.apache.ignite.internal.binary.BinaryInternalMapper defaultMapper()
- Returns:
- Internal mapper used as default.
-
defaultIdMapper
public static BinaryIdMapper defaultIdMapper()
- Returns:
- ID mapper used as default.
-
defaultNameMapper
public static BinaryNameMapper defaultNameMapper()
- Returns:
- Name mapper used as default.
-
registerType
public int registerType(Class<?> cls, boolean registerMeta, boolean failIfUnregistered) throws BinaryObjectException
Attempts registration of the provided class. If the type is already registered, then an existing descriptor is returned.- Parameters:
cls- Class to register.registerMeta- Iftrue, then metadata will be registered along with the class descriptor.failIfUnregistered- Throw exception if class isn't registered.- Returns:
- Class descriptor ID.
- Throws:
BinaryObjectException- In case of error.
-
registerTypeLocally
public int registerTypeLocally(Class<?> cls, boolean registerMeta, boolean failIfUnregistered) throws BinaryObjectException
- Parameters:
cls- Class.failIfUnregistered- Throw exception if class isn't registered.registerMeta- Iftrue, then metadata will be registered along with the class descriptor.- Returns:
- Class descriptor ID.
- Throws:
BinaryObjectException- In case of error.
-
registerBinarilizableSystemClass
public void registerBinarilizableSystemClass(Class<?> cls)
Register system class that should be marshalled with BinaryMarshaller.- Parameters:
cls- Class to register.
-
registerClassLocally
public void registerClassLocally(BinaryType binaryType, boolean failIfUnregistered, byte platformId)
Registers binary type locally.- Parameters:
binaryType- Binary type to register.failIfUnregistered- Whether to fail when not registered.platformId- Platform ID (seeMarshallerPlatformIds).
-
collectionType
public byte collectionType(Class<? extends Collection> cls)
- Parameters:
cls- Collection class.- Returns:
- Collection type ID.
-
mapType
public byte mapType(Class<? extends Map> cls)
- Parameters:
cls- Map class.- Returns:
- Map type ID.
-
typeId
public int typeId(String typeName)
- Parameters:
typeName- Type name.- Returns:
- Type ID.
-
fieldId
public int fieldId(int typeId, String fieldName)- Parameters:
typeId- Type ID.fieldName- Field name.- Returns:
- Field ID.
-
userTypeName
public String userTypeName(String clsName)
- Parameters:
clsName- Class name.- Returns:
- Type name.
-
registerPredefinedType
public void registerPredefinedType(Class<?> cls, int id)
- Parameters:
cls- Class.id- Type ID.
-
registerPredefinedType
public void registerPredefinedType(Class<?> cls, int id, String affFieldName, boolean registered)
- Parameters:
cls- Class.id- Type ID.affFieldName- Affinity field name.
-
registerUserType
public void registerUserType(String clsName, org.apache.ignite.internal.binary.BinaryInternalMapper mapper, @Nullable @Nullable BinarySerializer serializer, @Nullable @Nullable org.apache.ignite.internal.binary.BinaryIdentityResolver identity, @Nullable @Nullable String affKeyFieldName, boolean isEnum, @Nullable @Nullable Map<String,Integer> enumMap) throws BinaryObjectException
- Parameters:
clsName- Class name.mapper- ID mapper.serializer- Serializer.identity- Type identity.affKeyFieldName- Affinity key field name.isEnum- If enum.enumMap- Enum name to ordinal mapping.- Throws:
BinaryObjectException- In case of error.
-
registerUserTypesSchema
public void registerUserTypesSchema()
Register user types schemas.
-
registerUserClassName
public boolean registerUserClassName(int typeId, String clsName, boolean failIfUnregistered, boolean onlyLocReg, byte platformId)Register "type ID to class name" mapping on all nodes to allow for mapping requests resolution form client. OtherBinaryContext's "register" methods and methodregisterClass(Class, boolean, boolean)already call this functionality so use this method only when registering class names whoseClassis unknown.- Parameters:
typeId- Type ID.clsName- Class Name.failIfUnregistered- Iftruethen throwUnregisteredBinaryTypeExceptionwithorg.apache.ignite.internal.processors.marshaller.MappingExchangeResultfuture instead of synchronously awaiting for its completion.onlyLocReg- Whether to register only on the current node.platformId- Platform ID (seeMarshallerPlatformIds).- Returns:
Trueif the mapping was registered successfully.
-
createField
public BinaryField createField(int typeId, String fieldName)
Create binary field.- Parameters:
typeId- Type ID.fieldName- Field name.- Returns:
- Binary field.
-
metadata
@Nullable public @Nullable BinaryType metadata(int typeId) throws BinaryObjectException
- Parameters:
typeId- Type ID.- Returns:
- Meta data.
- Throws:
BinaryObjectException- In case of error.
-
metadata0
@Nullable public @Nullable BinaryMetadata metadata0(int typeId) throws BinaryObjectException
- Parameters:
typeId- Type ID- Returns:
- Meta data.
- Throws:
BinaryObjectException- In case of error.
-
metadata
public Collection<BinaryType> metadata() throws BinaryObjectException
- Returns:
- All metadata known to this node.
- Throws:
BinaryObjectException
-
metadata
public BinaryType metadata(int typeId, int schemaId) throws BinaryObjectException
- Parameters:
typeId- Type ID.schemaId- Schema ID.- Returns:
- Meta data.
- Throws:
BinaryObjectException- In case of error.
-
affinityKeyFieldName
public String affinityKeyFieldName(int typeId)
Get affinity key field name for type. First consult to predefined configuration, then delegate to metadata.- Parameters:
typeId- Type ID.- Returns:
- Affinity key field name.
-
identity
public org.apache.ignite.internal.binary.BinaryIdentityResolver identity(int typeId)
- Parameters:
typeId- Type ID.- Returns:
- Type identity.
-
updateMetadata
public void updateMetadata(int typeId, BinaryMetadata meta, boolean failIfUnregistered) throws BinaryObjectException- Parameters:
typeId- Type ID.meta- Meta data.failIfUnregistered- Fail if unregistered.- Throws:
BinaryObjectException- In case of error.
-
isCompactFooter
public boolean isCompactFooter()
- Returns:
- Whether field IDs should be skipped in footer or not.
-
updateMetaIfNeeded
public void updateMetaIfNeeded(BinaryWriterEx writer, BinaryType meta, int typeId, String typeName, String affFieldName, Map<String,BinaryFieldMetadata> fieldsMeta)
-
unregisterBinarySchemas
public void unregisterBinarySchemas()
Unregister all binary schemas.
-
unregisterUserTypeDescriptors
public void unregisterUserTypeDescriptors()
Unregisters the user types descriptors.
-
onUndeploy
public void onUndeploy(ClassLoader ldr)
Undeployment callback invoked when class loader is being undeployed. Some marshallers may want to clean their internal state that uses the undeployed class loader somehow.- Parameters:
ldr- Class loader being undeployed.
-
removeType
public void removeType(int typeId)
- Parameters:
typeId- Type ID.
-
createBinaryArray
public BinaryObject createBinaryArray(Class<?> compCls, Object[] pArr)
Creates instance ofBinaryArray.
-
-