use of org.apache.ignite.marshaller.Marshaller in project ignite by apache.
the class OptimizedMarshallerTest method testExternalizable.
/**
* Tests ability to marshal externalizable objects.
*
* @throws IgniteCheckedException If marshalling failed.
*/
public void testExternalizable() throws IgniteCheckedException {
Marshaller marsh = marshaller();
ExternalizableA outObj = marsh.unmarshal(marsh.marshal(new ExternalizableA(null, true)), null);
ExternalizableA outObj1 = marsh.unmarshal(marsh.marshal(new ExternalizableA(null, false)), null);
assertNotNull(outObj);
assertNotNull(outObj1);
}
use of org.apache.ignite.marshaller.Marshaller in project ignite by apache.
the class GridCacheEntryMemorySizeSelfTest method beforeTestsStarted.
/**
* {@inheritDoc}
*/
@Override
protected void beforeTestsStarted() throws Exception {
try {
ENTRY_OVERHEAD = U.<Integer>staticField(GridCacheMapEntry.class, "SIZE_OVERHEAD");
DHT_ENTRY_OVERHEAD = U.<Integer>staticField(GridDhtCacheEntry.class, "DHT_SIZE_OVERHEAD");
NEAR_ENTRY_OVERHEAD = U.<Integer>staticField(GridNearCacheEntry.class, "NEAR_SIZE_OVERHEAD");
REPLICATED_ENTRY_OVERHEAD = DHT_ENTRY_OVERHEAD;
Marshaller marsh = createMarshaller();
KEY_SIZE = marsh.marshal(1).length;
ONE_KB_VAL_SIZE = marsh.marshal(new Value(new byte[1024])).length;
TWO_KB_VAL_SIZE = marsh.marshal(new Value(new byte[2048])).length;
} catch (IgniteCheckedException e) {
throw new IgniteException(e);
}
startGrids(2);
}
use of org.apache.ignite.marshaller.Marshaller in project ignite by apache.
the class GridCacheEntryMemorySizeSelfTest method createMarshaller.
/**
* Creates an instance of Marshaller that is used by caches during the test run.
*
* @return Marshaller.
*/
protected Marshaller createMarshaller() throws IgniteCheckedException {
Marshaller marsh = createStandaloneBinaryMarshaller();
marsh.setContext(new MarshallerContext() {
@Override
public boolean registerClassName(byte platformId, int typeId, String clsName) {
return true;
}
@Override
public boolean registerClassNameLocally(byte platformId, int typeId, String clsName) {
return true;
}
@Override
public Class getClass(int typeId, ClassLoader ldr) {
throw new UnsupportedOperationException();
}
@Override
public String getClassName(byte platformId, int typeId) {
throw new UnsupportedOperationException();
}
@Override
public boolean isSystemType(String typeName) {
return false;
}
@Override
public IgnitePredicate<String> classNameFilter() {
return null;
}
@Override
public JdkMarshaller jdkMarshaller() {
return new JdkMarshaller();
}
});
return marsh;
}
use of org.apache.ignite.marshaller.Marshaller in project ignite by apache.
the class StandaloneGridKernalContext method prepareIgniteConfiguration.
/**
* @return Ignite configuration which allows to start requied processors for WAL reader
*/
private IgniteConfiguration prepareIgniteConfiguration() {
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setDiscoverySpi(new StandaloneNoopDiscoverySpi());
cfg.setCommunicationSpi(new StandaloneNoopCommunicationSpi());
final Marshaller marshaller = new BinaryMarshaller();
cfg.setMarshaller(marshaller);
final DataStorageConfiguration pstCfg = new DataStorageConfiguration();
final DataRegionConfiguration regCfg = new DataRegionConfiguration();
regCfg.setPersistenceEnabled(true);
pstCfg.setDefaultDataRegionConfiguration(regCfg);
cfg.setDataStorageConfiguration(pstCfg);
marshaller.setContext(marshallerCtx);
return cfg;
}
use of org.apache.ignite.marshaller.Marshaller in project ignite by apache.
the class GridTopicExternalizableSelfTest method testSerializationTopicCreatedByStringAndIntAndLong.
/**
* @throws Exception If failed.
*/
public void testSerializationTopicCreatedByStringAndIntAndLong() throws Exception {
for (Marshaller marsh : getMarshallers()) {
info("Test GridTopic externalization [marshaller=" + marsh + ']');
for (GridTopic topic : GridTopic.values()) {
Externalizable msgOut = (Externalizable) topic.topic(A_STRING, AN_INT, A_LONG);
assertEquals(msgOut, GridTestIoUtils.externalize(msgOut, marsh));
}
}
}
Aggregations