|
GridGain 3.6.0e
Enterprise Edition |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.gridgain.grid.marshaller.optimized.GridOptimizedMarshaller
public class GridOptimizedMarshaller
Optimized implementation of GridMarshaller. Unlike GridJdkMarshaller,
which is based on standard ObjectOutputStream, this marshaller does not
enforce that all serialized objects implement Serializable interface. It is also
generally much faster as it removes lots of serialization overhead that exists in
default JDK implementation.
GridOptimizedMarshaller is the default marshaler and will be used if no other
marshaller was explicitly configured.
GridOptimizedMarshaller marshaller = new GridOptimizedMarshaller(); // Enforce Serializable interface. marshaller.setRequireSerializable(true); GridConfigurationAdapter cfg = new GridConfigurationAdapter(); // Override marshaller. cfg.setMarshaller(marshaller); // Starts grid. G.start(cfg);
<bean id="grid.custom.cfg" class="org.gridgain.grid.GridConfigurationAdapter" singleton="true">
...
<property name="marshaller">
<bean class="org.gridgain.grid.marshaller.optimized.GridOptimizedMarshaller">
<property name="requireSerializable">true</property>
</bean>
</property>
...
</bean>
For information about Spring framework visit www.springframework.org
public class MyGridJob implements GridJob {
...
@GridMarshallerResource
private GridMarshaller marshaller;
...
}
or
public class MyGridJob implements GridJob {
...
private GridMarshaller marshaller;
...
@GridMarshallerResource
public void setMarshaller(GridMarshaller marshaller) {
this.marshaller = marshaller;
}
...
}
| Wiki | |
| Forum |
![]() |
![]() |
| Constructor Summary | |
|---|---|
GridOptimizedMarshaller()
Initializes marshaller not to enforce Serializable interface. |
|
GridOptimizedMarshaller(boolean requireSer,
Collection<String> clsNames,
String clsNamesPath)
Initializes marshaller with given serialization flag. |
|
| Method Summary | ||
|---|---|---|
boolean |
isRequireSerializable()
|
|
void |
marshal(Object obj,
OutputStream out)
Marshals object to the output stream. |
|
void |
setClassNames(Collection<String> clsNames)
Adds provides class names. |
|
void |
setClassNamesPath(String path)
Specifies a name of the file which lists all class names to be optimized. |
|
void |
setRequireSerializable(boolean requireSer)
Sets flag to enforce Serializable interface or not. |
|
|
unmarshal(InputStream in,
ClassLoader clsLdr)
Unmarshalls object from the output stream using given class loader. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public GridOptimizedMarshaller()
Serializable interface.
public GridOptimizedMarshaller(boolean requireSer,
Collection<String> clsNames,
String clsNamesPath)
throws GridException
true,
then objects will be required to implement Serializable in order
to be serialize.
GridException - If an I/O error occurs while writing stream header.requireSer - Flag to enforce Serializable interface or not. If true,
then objects will be required to implement Serializable in order to be
marshalled, if false, then such requirement will be relaxed.clsNames - User preregistered class names.clsNamesPath - Path to a file with user preregistered class names.| Method Detail |
|---|
public void setClassNames(Collection<String> clsNames)
clsNames - User preregistered class names to add.
public void setClassNamesPath(String path)
throws GridException
GRIDGAIN_HOME,
or specify a resource file on the class path.
The format of the file is class name per line, like this:
... com.example.Class1 com.example.Class2 ...
GridException - If an error occurs while writing stream header.path - Path to a file with user preregistered class names.public boolean isRequireSerializable()
Serializable interface.
public void setRequireSerializable(boolean requireSer)
throws IllegalArgumentException
Serializable interface or not.
IllegalArgumentException - If requireSer is false while marshalling of
non-serializable classes is not available in the current JVM implementation.requireSer - Flag to enforce Serializable interface or not. If true,
then objects will be required to implement Serializable in order to be
marshalled, if false, then such requirement will be relaxed.
public void marshal(@Nullable
Object obj,
OutputStream out)
throws GridException
marshal in interface GridMarshallerGridException - If marshalling failed.obj - Object to marshal.out - Output stream to marshal into.public <T> T unmarshal(InputStream in, @Nullable ClassLoader clsLdr) throws GridException
unmarshal in interface GridMarshallerGridException - If unmarshalling failed.T - Type of unmarshalled object.in - Input stream.clsLdr - Class loader to use.
|
GridGain 3.6.0e
Enterprise Edition |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
|
GridGain - Real Time Big Data
|
|
|