Search in sources :

Example 1 with BinaryContext

use of org.apache.ignite.internal.binary.BinaryContext 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 2 with BinaryContext

use of org.apache.ignite.internal.binary.BinaryContext in project ignite by apache.

the class ClientBinaryMarshaller method createImpl.

/**
 * Create new marshaller implementation.
 */
private GridBinaryMarshaller createImpl(BinaryConfiguration binCfg) {
    IgniteConfiguration igniteCfg = new IgniteConfiguration();
    if (binCfg == null) {
        binCfg = new BinaryConfiguration();
        binCfg.setCompactFooter(false);
    }
    igniteCfg.setBinaryConfiguration(binCfg);
    BinaryContext ctx = new BinaryContext(metaHnd, igniteCfg, new NullLogger());
    BinaryMarshaller marsh = new BinaryMarshaller();
    marsh.setContext(marshCtx);
    ctx.configure(marsh, binCfg);
    ctx.registerUserTypesSchema();
    return new GridBinaryMarshaller(ctx);
}
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) GridBinaryMarshaller(org.apache.ignite.internal.binary.GridBinaryMarshaller) BinaryContext(org.apache.ignite.internal.binary.BinaryContext)

Example 3 with BinaryContext

use of org.apache.ignite.internal.binary.BinaryContext in project ignite by apache.

the class JdbcThinConnectionSelfTest method getBinaryContext.

/**
 * Returns new binary context.
 *
 * @return New binary context.
 */
private BinaryContext getBinaryContext() {
    BinaryMarshaller marsh = new BinaryMarshaller();
    marsh.setContext(getFakeMarshallerCtx());
    BinaryContext ctx = new BinaryContext(BinaryNoopMetadataHandler.instance(), new IgniteConfiguration(), new NullLogger());
    ctx.configure(marsh);
    ctx.registerUserTypesSchema();
    return ctx;
}
Also used : 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)

Example 4 with BinaryContext

use of org.apache.ignite.internal.binary.BinaryContext in project ignite by apache.

the class GridCacheProcessor method withBinaryContext.

/**
 * @param c Closure.
 * @return Closure result.
 * @throws IgniteCheckedException If failed.
 */
private <T> T withBinaryContext(IgniteOutClosureX<T> c) throws IgniteCheckedException {
    IgniteCacheObjectProcessor objProc = ctx.cacheObjects();
    BinaryContext oldCtx = null;
    if (objProc instanceof CacheObjectBinaryProcessorImpl) {
        GridBinaryMarshaller binMarsh = ((CacheObjectBinaryProcessorImpl) objProc).marshaller();
        oldCtx = binMarsh == null ? null : binMarsh.pushContext();
    }
    try {
        return c.applyx();
    } finally {
        if (objProc instanceof CacheObjectBinaryProcessorImpl)
            GridBinaryMarshaller.popContext(oldCtx);
    }
}
Also used : CacheObjectBinaryProcessorImpl(org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl) IgniteCacheObjectProcessor(org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor) GridBinaryMarshaller(org.apache.ignite.internal.binary.GridBinaryMarshaller) BinaryContext(org.apache.ignite.internal.binary.BinaryContext)

Example 5 with BinaryContext

use of org.apache.ignite.internal.binary.BinaryContext in project ignite by apache.

the class PlatformUtils method marshaller.

/**
 * Create binary marshaller.
 *
 * @return Marshaller.
 */
public static GridBinaryMarshaller marshaller() {
    BinaryContext ctx = new BinaryContext(BinaryNoopMetadataHandler.instance(), new IgniteConfiguration(), new NullLogger());
    BinaryMarshaller marsh = new BinaryMarshaller();
    marsh.setContext(new MarshallerContextImpl(null, null));
    ctx.configure(marsh);
    return new GridBinaryMarshaller(ctx);
}
Also used : MarshallerContextImpl(org.apache.ignite.internal.MarshallerContextImpl) NullLogger(org.apache.ignite.logger.NullLogger) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) GridBinaryMarshaller(org.apache.ignite.internal.binary.GridBinaryMarshaller) GridBinaryMarshaller(org.apache.ignite.internal.binary.GridBinaryMarshaller) BinaryContext(org.apache.ignite.internal.binary.BinaryContext)

Aggregations

BinaryContext (org.apache.ignite.internal.binary.BinaryContext)22 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)14 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)12 NullLogger (org.apache.ignite.logger.NullLogger)10 GridBinaryMarshaller (org.apache.ignite.internal.binary.GridBinaryMarshaller)7 BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)6 MarshallerContextTestImpl (org.apache.ignite.marshaller.MarshallerContextTestImpl)6 BinaryMetadata (org.apache.ignite.internal.binary.BinaryMetadata)5 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)3 IgniteException (org.apache.ignite.IgniteException)3 MarshallerContextImpl (org.apache.ignite.internal.MarshallerContextImpl)3 BinaryWriterExImpl (org.apache.ignite.internal.binary.BinaryWriterExImpl)3 BinaryHeapOutputStream (org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream)3 CacheObjectBinaryProcessorImpl (org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl)3 HashMap (java.util.HashMap)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 BinaryObject (org.apache.ignite.binary.BinaryObject)2 BinaryType (org.apache.ignite.binary.BinaryType)2 BinaryTypeConfiguration (org.apache.ignite.binary.BinaryTypeConfiguration)2 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2