Search in sources :

Example 11 with MarshallerContextTestImpl

use of org.apache.ignite.marshaller.MarshallerContextTestImpl in project ignite by apache.

the class GridCacheUtilsSelfTest method binaryMarshaller.

/**
 * @return Binary marshaller.
 * @throws IgniteCheckedException if failed.
 */
private BinaryMarshaller binaryMarshaller() throws IgniteCheckedException {
    IgniteConfiguration iCfg = new IgniteConfiguration();
    BinaryConfiguration bCfg = new BinaryConfiguration();
    iCfg.setBinaryConfiguration(bCfg);
    BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), iCfg, new NullLogger());
    BinaryMarshaller marsh = new BinaryMarshaller();
    marsh.setContext(new MarshallerContextTestImpl(null));
    IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", ctx, iCfg);
    return marsh;
}
Also used : NullLogger(org.apache.ignite.logger.NullLogger) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) GridBinaryMarshaller(org.apache.ignite.internal.binary.GridBinaryMarshaller) BinaryContext(org.apache.ignite.internal.binary.BinaryContext) MarshallerContextTestImpl(org.apache.ignite.marshaller.MarshallerContextTestImpl)

Example 12 with MarshallerContextTestImpl

use of org.apache.ignite.marshaller.MarshallerContextTestImpl in project ignite by apache.

the class IgfsFileInfoSelfTest method testSerialization.

/**
 * Test node info serialization.
 *
 * @throws Exception If failed.
 */
public void testSerialization() throws Exception {
    marshaller.setContext(new MarshallerContextTestImpl());
    multithreaded(new Callable<Object>() {

        private final Random rnd = new Random();

        // Suppress due to default constructor should never be used directly.
        @SuppressWarnings("deprecation")
        @Nullable
        @Override
        public Object call() throws IgniteCheckedException {
            testSerialization(IgfsUtils.createDirectory(IgniteUuid.randomUuid()));
            return null;
        }
    }, 20);
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Random(java.util.Random) MarshallerContextTestImpl(org.apache.ignite.marshaller.MarshallerContextTestImpl) Nullable(org.jetbrains.annotations.Nullable)

Example 13 with MarshallerContextTestImpl

use of org.apache.ignite.marshaller.MarshallerContextTestImpl in project ignite by apache.

the class GridAbstractTest method createStandaloneBinaryMarshaller.

/**
 * Create instance of {@link BinaryMarshaller} suitable for use
 * without starting a grid upon given {@link IgniteConfiguration}.
 * @return Binary marshaller.
 * @throws IgniteCheckedException if failed.
 */
protected BinaryMarshaller createStandaloneBinaryMarshaller(IgniteConfiguration cfg) throws IgniteCheckedException {
    BinaryMarshaller marsh = new BinaryMarshaller();
    BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), cfg, new NullLogger());
    marsh.setContext(new MarshallerContextTestImpl());
    IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", ctx, cfg);
    return marsh;
}
Also used : NullLogger(org.apache.ignite.logger.NullLogger) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) BinaryContext(org.apache.ignite.internal.binary.BinaryContext) MarshallerContextTestImpl(org.apache.ignite.marshaller.MarshallerContextTestImpl)

Example 14 with MarshallerContextTestImpl

use of org.apache.ignite.marshaller.MarshallerContextTestImpl in project ignite by apache.

the class IgniteTestResources method getMarshaller.

/**
 * @return Marshaller.
 * @throws IgniteCheckedException If failed.
 */
@SuppressWarnings("unchecked")
public static synchronized Marshaller getMarshaller() throws IgniteCheckedException {
    String marshallerName = System.getProperty(MARSH_CLASS_NAME, GridTestProperties.getProperty(GridTestProperties.MARSH_CLASS_NAME));
    Marshaller marsh;
    if (marshallerName == null)
        marsh = new BinaryMarshaller();
    else {
        try {
            Class<? extends Marshaller> cls = (Class<? extends Marshaller>) Class.forName(marshallerName);
            marsh = cls.newInstance();
        } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
            throw new IgniteCheckedException("Failed to create test marshaller [marshaller=" + marshallerName + ']', e);
        }
    }
    marsh.setContext(new MarshallerContextTestImpl());
    if (marsh instanceof BinaryMarshaller) {
        BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration(), new NullLogger());
        IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", ctx, new IgniteConfiguration());
    }
    return marsh;
}
Also used : BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) Marshaller(org.apache.ignite.marshaller.Marshaller) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) MarshallerContextTestImpl(org.apache.ignite.marshaller.MarshallerContextTestImpl) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) NullLogger(org.apache.ignite.logger.NullLogger) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryContext(org.apache.ignite.internal.binary.BinaryContext)

Aggregations

MarshallerContextTestImpl (org.apache.ignite.marshaller.MarshallerContextTestImpl)14 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)9 NullLogger (org.apache.ignite.logger.NullLogger)9 BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)6 BinaryContext (org.apache.ignite.internal.binary.BinaryContext)5 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)5 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 IgniteException (org.apache.ignite.IgniteException)2 BinaryTypeConfiguration (org.apache.ignite.binary.BinaryTypeConfiguration)2 GridDiscoveryManager (org.apache.ignite.internal.managers.discovery.GridDiscoveryManager)2 Marshaller (org.apache.ignite.marshaller.Marshaller)2 DiscoverySpiCustomMessage (org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage)2 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)2 GridTestKernalContext (org.apache.ignite.testframework.junits.GridTestKernalContext)2 Random (java.util.Random)1 BinaryObject (org.apache.ignite.binary.BinaryObject)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1 GridBinaryMarshaller (org.apache.ignite.internal.binary.GridBinaryMarshaller)1 CacheCheckpointSpi (org.apache.ignite.spi.checkpoint.cache.CacheCheckpointSpi)1 Nullable (org.jetbrains.annotations.Nullable)1