Package org.apache.ignite.internal
Class MarshallerContextImpl
- java.lang.Object
-
- org.apache.ignite.internal.MarshallerContextImpl
-
- All Implemented Interfaces:
MarshallerContext
public class MarshallerContextImpl extends Object implements MarshallerContext
Marshaller context implementation.
-
-
Constructor Summary
Constructors Constructor Description MarshallerContextImpl(@Nullable Collection<PluginProvider> plugins, IgnitePredicate<String> clsFilter)Initializes context.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckHasClassName(String clsName, ClassLoader ldr, String fileName)IgnitePredicate<String>classNameFilter()Returns class name filter.Iterator<Map.Entry<Byte,Map<Integer,String>>>currentMappings()Method collects current mappings for all platforms.ArrayList<Map<Integer,MappedName>>getCachedMappings()ClassgetClass(int typeId, ClassLoader ldr)Gets class for provided type ID.StringgetClassName(byte platformId, int typeId)Gets class name for provided (platformId, typeId) pair.booleaninitialized()booleanisSystemType(String typeName)Checks whether the given type is a system one - JDK class or Ignite class.JdkMarshallerjdkMarshaller()static FilemappingFileStoreWorkDir(String igniteWorkDir)voidonMappingAccepted(MarshallerMappingItem item)voidonMappingDataReceived(IgniteLogger log, List<Map<Integer,MappedName>> mappings)MappedNameonMappingProposed(MarshallerMappingItem item)voidonMarshallerProcessorStarted(GridKernalContext ctx, MarshallerMappingTransport transport)voidonMarshallerProcessorStop()booleanregisterClassName(byte platformId, int typeId, String clsName)Same asMarshallerContext.registerClassName(byte, int, java.lang.String, boolean)but with shortened parameters list.booleanregisterClassName(byte platformId, int typeId, String clsName, boolean failIfUnregistered)Method to register typeId->class name mapping in marshaller context <b>cluster-wide</b>.booleanregisterClassNameLocally(byte platformId, int typeId, String clsName)Method to register typeId->class name mapping in marshaller context <b>on local node only</b>.static FileresolveMappingFileStoreWorkDir(String igniteWorkDir)StringresolveMissedMapping(byte platformId, int typeId)static voidsaveMappings(GridKernalContext ctx, List<Map<Integer,MappedName>> mappings, File dir)voidsetMarshallerMappingFileStoreDir(@Nullable File marshallerMappingFileStoreDir)Sets custom marshaller mapping files directory.voidunregisterClassNameLocally(int typeId)Remove mapping for appropriate type locally.
-
-
-
Constructor Detail
-
MarshallerContextImpl
public MarshallerContextImpl(@Nullable @Nullable Collection<PluginProvider> plugins, IgnitePredicate<String> clsFilter)Initializes context.- Parameters:
plugins- Plugins.
-
-
Method Detail
-
getCachedMappings
public ArrayList<Map<Integer,MappedName>> getCachedMappings()
-
onMappingDataReceived
public void onMappingDataReceived(IgniteLogger log, List<Map<Integer,MappedName>> mappings)
- Parameters:
log- Ignite logger.mappings- All marshaller mappings to write.
-
saveMappings
public static void saveMappings(GridKernalContext ctx, List<Map<Integer,MappedName>> mappings, File dir) throws IgniteCheckedException
- Parameters:
ctx- Kernal context.mappings- Marshaller mappings to save.dir- Directory to save given mappings to.- Throws:
IgniteCheckedException
-
checkHasClassName
public void checkHasClassName(String clsName, ClassLoader ldr, String fileName)
- Parameters:
clsName- Class name.ldr- Class loader used to get properties file.fileName- File name.
-
registerClassName
public boolean registerClassName(byte platformId, int typeId, String clsName, boolean failIfUnregistered) throws IgniteCheckedExceptionMethod to register typeId->class name mapping in marshaller context <b>cluster-wide</b>. This method guarantees that mapping is delivered to all nodes in cluster and blocks caller thread until then.- Specified by:
registerClassNamein interfaceMarshallerContext- Parameters:
platformId- Id of a platform (java, .NET, etc.) to register mapping for.typeId- Type ID.clsName- Class name.failIfUnregistered- Iftruethen throwUnregisteredBinaryTypeExceptionwith registration future instead of synchronously awaiting for its completion.- Returns:
Trueif mapping was registered successfully.- Throws:
IgniteCheckedException- In case of error.
-
registerClassName
public boolean registerClassName(byte platformId, int typeId, String clsName) throws IgniteCheckedExceptionSame asMarshallerContext.registerClassName(byte, int, java.lang.String, boolean)but with shortened parameters list.- Specified by:
registerClassNamein interfaceMarshallerContext- Parameters:
platformId- ID of a platform (java, .NET, etc.) to register mapping for.typeId- Type ID.clsName- Class name.- Returns:
Trueif mapping was registered successfully.- Throws:
IgniteCheckedException
-
registerClassNameLocally
public boolean registerClassNameLocally(byte platformId, int typeId, String clsName) throws IgniteCheckedExceptionMethod to register typeId->class name mapping in marshaller context <b>on local node only</b>. No guarantees that the mapping is presented on other nodes are provided. This method is safe to use if there is another source of mappings like metadata persisted on disk and this source is known to be solid and free of conflicts beforehand.- Specified by:
registerClassNameLocallyin interfaceMarshallerContext- Parameters:
platformId- Id of a platform (java, .NET, etc.) to register mapping for.typeId- Type id.clsName- Class name.- Returns:
Trueif class mapping was registered successfully.- Throws:
IgniteCheckedException- In case of error.
-
unregisterClassNameLocally
public void unregisterClassNameLocally(int typeId)
Remove mapping for appropriate type locally.
-
onMappingProposed
public MappedName onMappingProposed(MarshallerMappingItem item)
- Parameters:
item- type mapping to propose- Returns:
- null if cache doesn't contain any mappings for given (platformId, typeId) pair,
previous
mapped nameotherwise.
-
onMappingAccepted
public void onMappingAccepted(MarshallerMappingItem item)
- Parameters:
item- Item.
-
getClass
public Class getClass(int typeId, ClassLoader ldr) throws ClassNotFoundException, IgniteCheckedException
Gets class for provided type ID.- Specified by:
getClassin interfaceMarshallerContext- Parameters:
typeId- Type ID.ldr- Class loader.- Returns:
- Class.
- Throws:
ClassNotFoundException- If class was not found.IgniteCheckedException- In case of any other error.
-
getClassName
public String getClassName(byte platformId, int typeId) throws ClassNotFoundException, IgniteCheckedException
Gets class name for provided (platformId, typeId) pair.- Specified by:
getClassNamein interfaceMarshallerContext- Parameters:
platformId- id of a platform the class was registered for.typeId- Type ID.- Returns:
- Class name
- Throws:
ClassNotFoundException- If class was not found.IgniteCheckedException- In case of any other error.
-
classNameFilter
public IgnitePredicate<String> classNameFilter()
Returns class name filter.- Specified by:
classNameFilterin interfaceMarshallerContext- Returns:
- Class name filter.
-
jdkMarshaller
public JdkMarshaller jdkMarshaller()
- Specified by:
jdkMarshallerin interfaceMarshallerContext- Returns:
- JDK marshaller instance.
-
resolveMissedMapping
public String resolveMissedMapping(byte platformId, int typeId)
- Parameters:
platformId- Platform id.typeId- Type id.
-
isSystemType
public boolean isSystemType(String typeName)
Checks whether the given type is a system one - JDK class or Ignite class.- Specified by:
isSystemTypein interfaceMarshallerContext- Parameters:
typeName- Type name.- Returns:
trueif the type is a system one,falseotherwise.
-
onMarshallerProcessorStarted
public void onMarshallerProcessorStarted(GridKernalContext ctx, MarshallerMappingTransport transport) throws IgniteCheckedException
- Parameters:
ctx- Context.transport- Transport.- Throws:
IgniteCheckedException
-
resolveMappingFileStoreWorkDir
public static File resolveMappingFileStoreWorkDir(String igniteWorkDir)
- Parameters:
igniteWorkDir- Base ignite working directory.- Returns:
- Resolved directory.
-
mappingFileStoreWorkDir
public static File mappingFileStoreWorkDir(String igniteWorkDir)
- Parameters:
igniteWorkDir- Base ignite working directory.- Returns:
- Work directory for marshaller mappings.
-
onMarshallerProcessorStop
public void onMarshallerProcessorStop()
-
currentMappings
public Iterator<Map.Entry<Byte,Map<Integer,String>>> currentMappings()
Method collects current mappings for all platforms.- Returns:
- current mappings.
-
initialized
public boolean initialized()
- Returns:
Trueif marshaller context is initialized.
-
setMarshallerMappingFileStoreDir
public void setMarshallerMappingFileStoreDir(@Nullable @Nullable File marshallerMappingFileStoreDir)Sets custom marshaller mapping files directory. Used for standalone WAL iteration- Parameters:
marshallerMappingFileStoreDir- directory with type name mappings
-
-