Search in sources :

Example 21 with BinaryMarshaller

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

the class GridSessionCheckpointSelfTest method testCacheCheckpoint.

/**
     * @throws Exception If failed.
     */
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) {
        BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), cfg, new NullLogger());
        Marshaller marsh = cfg.getMarshaller();
        marsh.setContext(new MarshallerContextTestImpl(null));
        IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", ctx, cfg);
    }
    GridSessionCheckpointSelfTest.spi = spi;
    checkCheckpoints(cfg);
}
Also used : BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) Marshaller(org.apache.ignite.marshaller.Marshaller) 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)

Example 22 with BinaryMarshaller

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

the class CacheEntryProcessorCopySelfTest method doTestMutableEntry.

/**
     *
     */
private void doTestMutableEntry(boolean p2pEnabled) throws Exception {
    this.p2pEnabled = p2pEnabled;
    Ignite grid = startGrid();
    assertEquals(p2pEnabled, grid.configuration().isPeerClassLoadingEnabled());
    try {
        // One deserialization due to copyOnRead == true.
        doTest(true, false, OLD_VAL, 1);
        // One deserialization due to copyOnRead == true.
        // Additional deserialization in case p2p enabled and not BinaryMarshaller due to storeValue == true on update entry.
        doTest(true, true, NEW_VAL, p2pEnabled && !(grid.configuration().getMarshaller() instanceof BinaryMarshaller) ? 2 : 1);
        // No deserialization.
        doTest(false, false, NEW_VAL, 0);
        // One deserialization due to storeValue == true.
        doTest(false, true, NEW_VAL, 1);
    } finally {
        stopAllGrids();
    }
}
Also used : BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) Ignite(org.apache.ignite.Ignite)

Example 23 with BinaryMarshaller

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

the class GridMarshallerPerformanceTest method testGridMarshaller.

/**
     * @throws Exception If failed.
     */
public void testGridMarshaller() throws Exception {
    final GridTuple<byte[]> tuple = new GridTuple<>();
    final BinaryMarshaller marsh = createStandaloneBinaryMarshaller();
    IgniteInClosure<TestObject> writer = new CIX1<TestObject>() {

        @Override
        public void applyx(TestObject obj) throws IgniteCheckedException {
            tuple.set(marsh.marshal(obj));
        }
    };
    IgniteOutClosure<TestObject> reader = new COX<TestObject>() {

        @Override
        public TestObject applyx() throws IgniteCheckedException {
            return marsh.unmarshal(tuple.get(), null);
        }
    };
    runTest("GridMarshaller", writer, reader);
}
Also used : CIX1(org.apache.ignite.internal.util.typedef.CIX1) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) GridTuple(org.apache.ignite.internal.util.lang.GridTuple) COX(org.apache.ignite.internal.util.typedef.COX)

Example 24 with BinaryMarshaller

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

the class ClientReconnectAfterClusterRestartTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setMarshaller(new BinaryMarshaller());
    cfg.setIncludeEventTypes(EventType.EVTS_CACHE);
    if (getTestIgniteInstanceName(CLIENT_ID).equals(igniteInstanceName))
        cfg.setClientMode(true);
    else {
        CacheConfiguration ccfg = getCacheConfiguration();
        cfg.setCacheConfiguration(ccfg);
    }
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 25 with BinaryMarshaller

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

the class QueryEntityCaseMismatchTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);
    cfg.setLocalHost("127.0.0.1");
    cfg.setPeerClassLoadingEnabled(true);
    TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    ipFinder.setAddresses(Collections.singletonList("127.0.0.1:47500..47509"));
    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
    discoSpi.setIpFinder(ipFinder);
    cfg.setDiscoverySpi(discoSpi);
    CacheConfiguration<Object, Integer> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
    cfg.setMarshaller(new BinaryMarshaller());
    QueryEntity queryEntity = new QueryEntity("KeyType", Integer.class.getName());
    LinkedHashMap<String, String> fields = new LinkedHashMap<>();
    fields.put("a", "TypeA");
    fields.put("b", "TypeB");
    queryEntity.setFields(fields);
    //Specify key fields in upper register
    HashSet<String> keyFields = new HashSet<>();
    keyFields.add("a");
    keyFields.add("B");
    queryEntity.setKeyFields(keyFields);
    ccfg.setQueryEntities(F.asList(queryEntity));
    cfg.setCacheConfiguration(ccfg);
    return cfg;
}
Also used : TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) QueryEntity(org.apache.ignite.cache.QueryEntity) LinkedHashMap(java.util.LinkedHashMap) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) HashSet(java.util.HashSet)

Aggregations

BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)87 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)56 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)30 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)21 BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)12 Ignite (org.apache.ignite.Ignite)9 ArrayList (java.util.ArrayList)8 BinaryTypeConfiguration (org.apache.ignite.binary.BinaryTypeConfiguration)8 GridBinaryMarshaller (org.apache.ignite.internal.binary.GridBinaryMarshaller)8 BinaryContext (org.apache.ignite.internal.binary.BinaryContext)7 BinaryObject (org.apache.ignite.binary.BinaryObject)6 NullLogger (org.apache.ignite.logger.NullLogger)6 Marshaller (org.apache.ignite.marshaller.Marshaller)6 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)5 MarshallerContextTestImpl (org.apache.ignite.marshaller.MarshallerContextTestImpl)5 Connection (java.sql.Connection)4 ResultSet (java.sql.ResultSet)4 HashMap (java.util.HashMap)4 IgniteException (org.apache.ignite.IgniteException)4 CacheKeyConfiguration (org.apache.ignite.cache.CacheKeyConfiguration)4