Search in sources :

Example 16 with NullLogger

use of org.apache.ignite.logger.NullLogger in project ignite by apache.

the class BinaryFieldsAbstractSelfTest method createMarshaller.

/**
 * Create marshaller.
 *
 * @return Binary marshaller.
 * @throws Exception If failed.
 */
protected BinaryMarshaller createMarshaller() throws Exception {
    BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration(), new NullLogger());
    BinaryMarshaller marsh = new BinaryMarshaller();
    BinaryConfiguration bCfg = new BinaryConfiguration();
    bCfg.setCompactFooter(compactFooter());
    bCfg.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(TestObject.class.getName()), new BinaryTypeConfiguration(TestOuterObject.class.getName()), new BinaryTypeConfiguration(TestInnerObject.class.getName())));
    IgniteConfiguration iCfg = new IgniteConfiguration();
    iCfg.setBinaryConfiguration(bCfg);
    marsh.setContext(new MarshallerContextTestImpl(null));
    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) BinaryTypeConfiguration(org.apache.ignite.binary.BinaryTypeConfiguration) MarshallerContextTestImpl(org.apache.ignite.marshaller.MarshallerContextTestImpl)

Example 17 with NullLogger

use of org.apache.ignite.logger.NullLogger in project ignite by apache.

the class GridBinaryMarshallerCtxDisabledSelfTest method testObjectExchange.

/**
 * @throws Exception If failed.
 */
@Test
public void testObjectExchange() throws Exception {
    BinaryMarshaller marsh = new BinaryMarshaller();
    marsh.setContext(new MarshallerContextWithNoStorage());
    IgniteConfiguration cfg = new IgniteConfiguration();
    BinaryContext context = new BinaryContext(BinaryCachingMetadataHandler.create(), cfg, new NullLogger());
    marsh.setBinaryContext(context, cfg);
    SimpleObject simpleObj = new SimpleObject();
    simpleObj.b = 2;
    simpleObj.bArr = new byte[] { 2, 3, 4, 5, 5 };
    simpleObj.c = 'A';
    simpleObj.enumVal = TestEnum.D;
    simpleObj.objArr = new Object[] { "hello", "world", "from", "me" };
    simpleObj.enumArr = new TestEnum[] { TestEnum.C, TestEnum.B };
    SimpleObject otherObj = new SimpleObject();
    otherObj.b = 3;
    otherObj.bArr = new byte[] { 5, 3, 4 };
    simpleObj.otherObj = otherObj;
    assertEquals(simpleObj, marsh.unmarshal(marsh.marshal(simpleObj), null));
    SimpleBinary simpleBinary = new SimpleBinary();
    simpleBinary.str = "binary";
    simpleBinary.arr = new long[] { 100, 200, 300 };
    assertEquals(simpleBinary, marsh.unmarshal(marsh.marshal(simpleBinary), null));
    SimpleExternalizable simpleExtr = new SimpleExternalizable();
    simpleExtr.str = "externalizable";
    simpleExtr.arr = new long[] { 20000, 300000, 400000 };
    assertEquals(simpleExtr, marsh.unmarshal(marsh.marshal(simpleExtr), null));
}
Also used : NullLogger(org.apache.ignite.logger.NullLogger) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 18 with NullLogger

use of org.apache.ignite.logger.NullLogger 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());
    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 19 with NullLogger

use of org.apache.ignite.logger.NullLogger in project ignite by apache.

the class GridTestBinaryMarshaller method createBinaryMarshaller.

/**
 * @param log Logger.
 */
private BinaryMarshaller createBinaryMarshaller(IgniteLogger log) throws IgniteCheckedException {
    IgniteConfiguration iCfg = new IgniteConfiguration().setBinaryConfiguration(new BinaryConfiguration().setCompactFooter(true)).setClientMode(false).setDiscoverySpi(new TcpDiscoverySpi() {

        @Override
        public void sendCustomEvent(DiscoverySpiCustomMessage msg) throws IgniteException {
        // No-op.
        }
    });
    BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), iCfg, new NullLogger());
    MarshallerContextTestImpl marshCtx = new MarshallerContextTestImpl();
    marshCtx.onMarshallerProcessorStarted(new GridTestKernalContext(log, iCfg), null);
    BinaryMarshaller marsh = new BinaryMarshaller();
    marsh.setContext(marshCtx);
    marsh.setBinaryContext(ctx, iCfg);
    return marsh;
}
Also used : DiscoverySpiCustomMessage(org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage) 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) IgniteException(org.apache.ignite.IgniteException) BinaryContext(org.apache.ignite.internal.binary.BinaryContext) MarshallerContextTestImpl(org.apache.ignite.marshaller.MarshallerContextTestImpl) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 20 with NullLogger

use of org.apache.ignite.logger.NullLogger in project ignite by apache.

the class IgniteTestResources method getMarshaller.

/**
 * @return Marshaller.
 * @throws IgniteCheckedException If failed.
 */
public static synchronized Marshaller getMarshaller() throws IgniteCheckedException {
    String marshallerName = System.getProperty(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) {
        BinaryMarshaller binaryMarsh = (BinaryMarshaller) marsh;
        BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration(), new NullLogger());
        binaryMarsh.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

NullLogger (org.apache.ignite.logger.NullLogger)23 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)17 BinaryContext (org.apache.ignite.internal.binary.BinaryContext)10 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)10 MarshallerContextTestImpl (org.apache.ignite.marshaller.MarshallerContextTestImpl)10 BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)8 Test (org.junit.Test)6 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 IgniteException (org.apache.ignite.IgniteException)4 GridBinaryMarshaller (org.apache.ignite.internal.binary.GridBinaryMarshaller)4 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)4 Ignite (org.apache.ignite.Ignite)3 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)3 File (java.io.File)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 BinaryTypeConfiguration (org.apache.ignite.binary.BinaryTypeConfiguration)2 GridDiscoveryManager (org.apache.ignite.internal.managers.discovery.GridDiscoveryManager)2 GridSystemViewManager (org.apache.ignite.internal.managers.systemview.GridSystemViewManager)2 JmxSystemViewExporterSpi (org.apache.ignite.internal.managers.systemview.JmxSystemViewExporterSpi)2 WALIterator (org.apache.ignite.internal.pagemem.wal.WALIterator)2