Search in sources :

Example 6 with NullLogger

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

the class BinaryFooterOffsetsAbstractSelfTest method beforeTest.

/**
 * {@inheritDoc}
 */
@Override
protected void beforeTest() throws Exception {
    super.beforeTest();
    ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration(), new NullLogger());
    marsh = new BinaryMarshaller();
    IgniteConfiguration iCfg = new IgniteConfiguration();
    BinaryConfiguration bCfg = new BinaryConfiguration();
    bCfg.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(TestObject.class.getName())));
    bCfg.setCompactFooter(compactFooter());
    iCfg.setBinaryConfiguration(bCfg);
    marsh.setContext(new MarshallerContextTestImpl(null));
    marsh.setBinaryContext(ctx, iCfg);
}
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 7 with NullLogger

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

the class GridBinaryWildcardsSelfTest method binaryMarshaller.

/**
 */
protected BinaryMarshaller binaryMarshaller(BinaryNameMapper nameMapper, BinaryIdMapper mapper, BinarySerializer serializer, Collection<BinaryTypeConfiguration> cfgs) throws IgniteCheckedException {
    IgniteConfiguration iCfg = new IgniteConfiguration();
    BinaryConfiguration bCfg = new BinaryConfiguration();
    bCfg.setNameMapper(nameMapper);
    bCfg.setIdMapper(mapper);
    bCfg.setSerializer(serializer);
    bCfg.setTypeConfigurations(cfgs);
    iCfg.setBinaryConfiguration(bCfg);
    BinaryContext ctx = new BinaryContext(BinaryNoopMetadataHandler.instance(), iCfg, new NullLogger());
    BinaryMarshaller marsh = new BinaryMarshaller();
    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) MarshallerContextTestImpl(org.apache.ignite.marshaller.MarshallerContextTestImpl)

Example 8 with NullLogger

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

the class GridBinaryCacheEntryMemorySizeSelfTest method createMarshaller.

/**
 * {@inheritDoc}
 */
@Override
protected Marshaller createMarshaller() throws IgniteCheckedException {
    BinaryMarshaller marsh = new BinaryMarshaller();
    IgniteConfiguration iCfg = new IgniteConfiguration();
    iCfg.setDiscoverySpi(new TcpDiscoverySpi() {

        @Override
        public void sendCustomEvent(DiscoverySpiCustomMessage msg) throws IgniteException {
        // No-op.
        }
    });
    iCfg.setClientMode(false);
    iCfg.setSystemViewExporterSpi(new JmxSystemViewExporterSpi() {

        @Override
        protected void register(SystemView<?> sysView) {
        // No-op.
        }
    });
    GridTestKernalContext kernCtx = new GridTestKernalContext(log, iCfg);
    kernCtx.add(new GridSystemViewManager(kernCtx));
    kernCtx.add(new GridDiscoveryManager(kernCtx));
    MarshallerContextTestImpl marshCtx = new MarshallerContextTestImpl(null);
    marshCtx.onMarshallerProcessorStarted(kernCtx, null);
    marsh.setContext(marshCtx);
    BinaryContext pCtx = new BinaryContext(BinaryNoopMetadataHandler.instance(), iCfg, new NullLogger());
    marsh.setBinaryContext(pCtx, iCfg);
    return marsh;
}
Also used : BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) JmxSystemViewExporterSpi(org.apache.ignite.internal.managers.systemview.JmxSystemViewExporterSpi) MarshallerContextTestImpl(org.apache.ignite.marshaller.MarshallerContextTestImpl) DiscoverySpiCustomMessage(org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage) GridDiscoveryManager(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager) NullLogger(org.apache.ignite.logger.NullLogger) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridSystemViewManager(org.apache.ignite.internal.managers.systemview.GridSystemViewManager) IgniteException(org.apache.ignite.IgniteException) BinaryContext(org.apache.ignite.internal.binary.BinaryContext) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 9 with NullLogger

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

the class GridSessionCheckpointSelfTest method testCacheCheckpoint.

/**
 * @throws Exception If failed.
 */
@Test
public void testCacheCheckpoint() throws Exception {
    IgniteConfiguration cfg = getConfiguration();
    String cacheName = "test-checkpoints";
    CacheConfiguration cacheCfg = defaultCacheConfiguration();
    cacheCfg.setName(cacheName);
    CacheCheckpointSpi spi = new CacheCheckpointSpi();
    spi.setCacheName(cacheName);
    cfg.setCacheConfiguration(cacheCfg);
    cfg.setCheckpointSpi(spi);
    if (cfg.getMarshaller() instanceof BinaryMarshaller) {
        BinaryMarshaller marsh = (BinaryMarshaller) cfg.getMarshaller();
        BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), cfg, new NullLogger());
        marsh.setContext(new MarshallerContextTestImpl(null));
        marsh.setBinaryContext(ctx, cfg);
    }
    GridSessionCheckpointSelfTest.spi = spi;
    checkCheckpoints(cfg);
}
Also used : CacheCheckpointSpi(org.apache.ignite.spi.checkpoint.cache.CacheCheckpointSpi) NullLogger(org.apache.ignite.logger.NullLogger) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) BinaryContext(org.apache.ignite.internal.binary.BinaryContext) MarshallerContextTestImpl(org.apache.ignite.marshaller.MarshallerContextTestImpl) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) Test(org.junit.Test) GridCommonTest(org.apache.ignite.testframework.junits.common.GridCommonTest)

Example 10 with NullLogger

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

the class GridTcpCommunicationSpiConfigSelfTest method testSendToNonInitializedTcpCommSpi.

/**
 * Verifies that TcpCommunicationSpi starts messaging protocol only when fully initialized.
 *
 * @see <a href="https://issues.apache.org/jira/browse/IGNITE-12982">IGNITE-12982</a>
 *
 * @throws Exception If failed.
 */
@Test
@WithSystemProperty(key = "IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK", value = "true")
public void testSendToNonInitializedTcpCommSpi() throws Exception {
    ListeningTestLogger listeningLogger = new ListeningTestLogger(log);
    LogListener npeLsnr = LogListener.matches("NullPointerException").andMatches("InboundConnectionHandler.onMessageSent").build();
    listeningLogger.registerListener(npeLsnr);
    GridTestNode sendingNode = new GridTestNode();
    sendingNode.order(0);
    GridSpiTestContext sendingCtx = initSpiContext();
    TcpCommunicationSpi sendingSpi = initializeSpi(sendingCtx, sendingNode, listeningLogger, false);
    spisToStop.add(sendingSpi);
    sendingSpi.onContextInitialized(sendingCtx);
    GridTestNode receiverNode = new GridTestNode();
    receiverNode.order(1);
    GridSpiTestContext receiverCtx = initSpiContext();
    /*
         * This is a dirty hack to intervene into TcpCommunicationSpi#onContextInitialized0 method
         * and add a delay before injecting metrics listener into its clients (like InboundConnectionHandler).
         * The purpose of the delay is to make race between sending a message and initializing TcpCommSpi visible.
         *
         * This solution heavily depends on current code structure of onContextInitialized0 method.
         * If any modifications are made to it, this logic could break and the test starts failing.
         *
         * In that case try to rewrite the test or delete it as this race is really hard to test.
         */
    receiverCtx.metricsRegistryProducer((name) -> {
        try {
            Thread.sleep(100);
        } catch (Exception ignored) {
        // No-op.
        }
        return new MetricRegistry(name, null, null, new NullLogger());
    });
    TcpCommunicationSpi receiverSpi = initializeSpi(receiverCtx, receiverNode, listeningLogger, true);
    spisToStop.add(receiverSpi);
    receiverCtx.remoteNodes().add(sendingNode);
    sendingCtx.remoteNodes().add(receiverNode);
    IgniteInternalFuture sendFut = GridTestUtils.runAsync(() -> {
        Message msg = new GridTestMessage(sendingNode.id(), 0, 0);
        sendingSpi.sendMessage(receiverNode, msg);
    });
    IgniteInternalFuture initFut = GridTestUtils.runAsync(() -> {
        try {
            receiverSpi.onContextInitialized(receiverCtx);
        } catch (Exception ignored) {
        // No-op.
        }
    });
    assertFalse("Check test logs, NPE was found", GridTestUtils.waitForCondition(npeLsnr::check, 3_000));
    initFut.get();
    sendFut.get();
}
Also used : GridSpiTestContext(org.apache.ignite.testframework.GridSpiTestContext) GridTestMessage(org.apache.ignite.spi.communication.GridTestMessage) NullLogger(org.apache.ignite.logger.NullLogger) LogListener(org.apache.ignite.testframework.LogListener) GridTestMessage(org.apache.ignite.spi.communication.GridTestMessage) Message(org.apache.ignite.plugin.extensions.communication.Message) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) GridTestNode(org.apache.ignite.testframework.GridTestNode) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridSpiTest(org.apache.ignite.testframework.junits.spi.GridSpiTest) GridAbstractTest(org.apache.ignite.testframework.junits.GridAbstractTest) Test(org.junit.Test) GridSpiAbstractConfigTest(org.apache.ignite.testframework.junits.spi.GridSpiAbstractConfigTest) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

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