Class BinaryContext


  • public class BinaryContext
    extends Object
    Binary context.
    • 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

      • mustDeserialize

        public boolean mustDeserialize​(Class cls)
        Check whether class must be deserialized anyway.
        Parameters:
        cls - Class.
        Returns:
        True if 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 - If true, 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 - If true, 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 (see MarshallerPlatformIds).
      • 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. Other BinaryContext's "register" methods and method registerClass(Class, boolean, boolean) already call this functionality so use this method only when registering class names whose Class is unknown.
        Parameters:
        typeId - Type ID.
        clsName - Class Name.
        failIfUnregistered - If true then throw UnregisteredBinaryTypeException with org.apache.ignite.internal.processors.marshaller.MappingExchangeResult future instead of synchronously awaiting for its completion.
        onlyLocReg - Whether to register only on the current node.
        platformId - Platform ID (see MarshallerPlatformIds).
        Returns:
        True if 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.
      • 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.
      • 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 of BinaryArray.