Class BinaryMarshaller
- java.lang.Object
-
- org.apache.ignite.marshaller.AbstractMarshaller
-
- org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller
-
- org.apache.ignite.internal.binary.BinaryMarshaller
-
- All Implemented Interfaces:
Marshaller
public class BinaryMarshaller extends AbstractNodeNameAwareMarshaller
Implementation ofMarshallerthat lets to serialize and deserialize all objects in the binary format.
-
-
Field Summary
-
Fields inherited from class org.apache.ignite.marshaller.AbstractMarshaller
ctx, DFLT_BUFFER_SIZE
-
-
Constructor Summary
Constructors Constructor Description BinaryMarshaller()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleanavailable()Checks whetherBinaryMarshalleris able to work on the current JVM.GridBinaryMarshallerbinaryMarshaller()protected byte[]marshal0(@Nullable Object obj)Marshals object to byte array.protected voidmarshal0(@Nullable Object obj, OutputStream out)Marshals object to the output stream.voidonUndeploy(ClassLoader ldr)Undeployment callback invoked when class loader is being undeployed.voidsetBinaryContext(BinaryContext ctx, IgniteConfiguration cfg)SetsBinaryContext.StringtoString()protected <T> Tunmarshal0(byte[] bytes, @Nullable ClassLoader clsLdr)Unmarshals object from byte array using given class loader.protected <T> Tunmarshal0(InputStream in, @Nullable ClassLoader clsLdr)Unmarshals object from the input stream using given class loader.-
Methods inherited from class org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller
marshal, marshal, nodeName, unmarshal, unmarshal
-
Methods inherited from class org.apache.ignite.marshaller.AbstractMarshaller
getContext, setContext
-
-
-
-
Method Detail
-
available
public static boolean available()
Checks whetherBinaryMarshalleris able to work on the current JVM.As long as
BinaryMarshalleruses JVM-private API, which is not guaranteed to be available on all JVM, this method should be called to ensure marshaller could work properly.Result of this method is automatically checked in constructor.
- Returns:
trueifBinaryMarshallercan work on the current JVM orfalseif it can't.
-
setBinaryContext
public void setBinaryContext(BinaryContext ctx, IgniteConfiguration cfg)
SetsBinaryContext.- Parameters:
ctx- Binary context.
-
marshal0
protected byte[] marshal0(@Nullable @Nullable Object obj) throws IgniteCheckedExceptionMarshals object to byte array.- Specified by:
marshal0in classAbstractNodeNameAwareMarshaller- Parameters:
obj- Object to marshal.nullobject will be marshaled to binarynullrepresentation.- Returns:
- Byte array.
- Throws:
IgniteCheckedException- If marshalling failed.
-
marshal0
protected void marshal0(@Nullable @Nullable Object obj, OutputStream out) throws IgniteCheckedExceptionMarshals object to the output stream. This method should not close given output stream.- Specified by:
marshal0in classAbstractNodeNameAwareMarshaller- Parameters:
obj- Object to marshal.nullobject will be marshaled to binarynullrepresentation.out- Output stream to marshal into.- Throws:
IgniteCheckedException- If marshalling failed.
-
unmarshal0
protected <T> T unmarshal0(byte[] bytes, @Nullable @Nullable ClassLoader clsLdr)Unmarshals object from byte array using given class loader.- Specified by:
unmarshal0in classAbstractNodeNameAwareMarshaller- Type Parameters:
T- Type of unmarshalled object.- Parameters:
bytes- Byte array.clsLdr- If notnullthen given class loader will be used for unmarshal object.- Returns:
- Unmarshalled object.
-
unmarshal0
protected <T> T unmarshal0(InputStream in, @Nullable @Nullable ClassLoader clsLdr) throws IgniteCheckedException
Unmarshals object from the input stream using given class loader. This method should not close given input stream.- Specified by:
unmarshal0in classAbstractNodeNameAwareMarshaller- Type Parameters:
T- Type of unmarshalled object.- Parameters:
in- Input stream.clsLdr- If notnullthen given class loader will be used for unmarshal object.- Returns:
- Unmarshalled object.
- Throws:
IgniteCheckedException- If unmarshalling failed.
-
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.- Specified by:
onUndeployin classAbstractMarshaller- Parameters:
ldr- Class loader being undeployed.
-
binaryMarshaller
public GridBinaryMarshaller binaryMarshaller()
- Returns:
- GridBinaryMarshaller instance.
-
-