Search in sources :

Example 81 with BinaryMarshaller

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

the class JdbcThinAbstractDmlStatementSelfTest method getBinaryConfiguration.

/**
 * @param igniteInstanceName Ignite instance name.
 * @return Grid configuration used for starting the grid ready for manipulating binary objects.
 * @throws Exception If failed.
 */
IgniteConfiguration getBinaryConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = getConfiguration0(igniteInstanceName);
    cfg.setMarshaller(new BinaryMarshaller());
    CacheConfiguration ccfg = cfg.getCacheConfiguration()[0];
    ccfg.getQueryEntities().clear();
    QueryEntity e = new QueryEntity();
    e.setKeyType(String.class.getName());
    e.setValueType("Person");
    e.addQueryField("id", Integer.class.getName(), null);
    e.addQueryField("age", Integer.class.getName(), null);
    e.addQueryField("firstName", String.class.getName(), null);
    e.addQueryField("lastName", String.class.getName(), null);
    ccfg.setQueryEntities(Collections.singletonList(e));
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) QueryEntity(org.apache.ignite.cache.QueryEntity) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 82 with BinaryMarshaller

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

the class CacheAbstractJdbcStore method getOrCreateCacheMappings.

/**
 * @param cacheName Cache name to check mappings for.
 * @return Type mappings for specified cache name.
 * @throws CacheException If failed to initialize cache mappings.
 */
private Map<Object, EntryMapping> getOrCreateCacheMappings(@Nullable String cacheName) throws CacheException {
    Map<Object, EntryMapping> entryMappings = cacheMappings.get(cacheName);
    if (entryMappings != null)
        return entryMappings;
    cacheMappingsLock.lock();
    try {
        entryMappings = cacheMappings.get(cacheName);
        if (entryMappings != null)
            return entryMappings;
        List<JdbcType> cacheTypes = new ArrayList<>(types.length);
        for (JdbcType type : types) if ((cacheName != null && cacheName.equals(type.getCacheName())) || (cacheName == null && type.getCacheName() == null))
            cacheTypes.add(type);
        entryMappings = U.newHashMap(cacheTypes.size());
        if (!cacheTypes.isEmpty()) {
            boolean binarySupported = ignite.configuration().getMarshaller() instanceof BinaryMarshaller;
            for (JdbcType type : cacheTypes) {
                String keyType = type.getKeyType();
                String valType = type.getValueType();
                TypeKind keyKind = kindForName(keyType, binarySupported);
                checkTypeConfiguration(cacheName, keyKind, keyType, type.getKeyFields());
                Object keyTypeId = typeIdForTypeName(keyKind, keyType);
                if (entryMappings.containsKey(keyTypeId))
                    throw new CacheException("Key type must be unique in type metadata [cache=" + U.maskName(cacheName) + ", type=" + keyType + "]");
                TypeKind valKind = kindForName(valType, binarySupported);
                checkTypeConfiguration(cacheName, valKind, valType, type.getValueFields());
                entryMappings.put(keyTypeId, new EntryMapping(cacheName, dialect, type, keyKind, valKind, sqlEscapeAll));
            }
            Map<String, Map<Object, EntryMapping>> mappings = new HashMap<>(cacheMappings);
            mappings.put(cacheName, entryMappings);
            prepareBuilders(cacheName, cacheTypes);
            cacheMappings = mappings;
        }
        return entryMappings;
    } finally {
        cacheMappingsLock.unlock();
    }
}
Also used : BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) CacheException(javax.cache.CacheException) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap)

Example 83 with BinaryMarshaller

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

the class WithKeepBinaryCacheConfigVariationsFullApiTestSuite method suite.

/**
 * @return Cache API test suite.
 * @throws Exception If failed.
 */
@SuppressWarnings("serial")
public static TestSuite suite() throws Exception {
    TestSuite suite = new TestSuite("With Keep Binary Cache Config Variations Full API Test Suite");
    suite.addTest(new ConfigVariationsTestSuiteBuilder("With Keep Binary Cache Test Suite", WithKeepBinaryCacheFullApiTest.class).withBasicCacheParams().withIgniteConfigFilters(new IgnitePredicate<IgniteConfiguration>() {

        @Override
        public boolean apply(IgniteConfiguration cfg) {
            return cfg.getMarshaller() instanceof BinaryMarshaller;
        }
    }).gridsCount(5).backups(1).testedNodesCount(3).withClients().build());
    suite.addTest(new ConfigVariationsTestSuiteBuilder("With Keep Binary Cache with Interceptor Test Suite", WithKeepBinaryCacheFullApiTest.class).withBasicCacheParams().withIgniteConfigFilters(new IgnitePredicate<IgniteConfiguration>() {

        @Override
        public boolean apply(IgniteConfiguration cfg) {
            return cfg.getMarshaller() instanceof BinaryMarshaller;
        }
    }).gridsCount(5).backups(1).testedNodesCount(3).withClients().build());
    return suite;
}
Also used : ConfigVariationsTestSuiteBuilder(org.apache.ignite.testframework.configvariations.ConfigVariationsTestSuiteBuilder) TestSuite(junit.framework.TestSuite) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller)

Example 84 with BinaryMarshaller

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

the class ServicePredicateAccessCacheTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
    cfg.setMarshaller(new BinaryMarshaller());
    cfg.setPeerClassLoadingEnabled(false);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 85 with BinaryMarshaller

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

the class CacheAffinityEarlyTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
    discoSpi.setIpFinder(ipFinder);
    cfg.setDiscoverySpi(discoSpi);
    cfg.setMarshaller(new BinaryMarshaller());
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Aggregations

BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)93 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)61 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)34 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)22 BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)14 Ignite (org.apache.ignite.Ignite)9 BinaryTypeConfiguration (org.apache.ignite.binary.BinaryTypeConfiguration)9 GridBinaryMarshaller (org.apache.ignite.internal.binary.GridBinaryMarshaller)9 BinaryContext (org.apache.ignite.internal.binary.BinaryContext)8 ArrayList (java.util.ArrayList)7 BinaryObject (org.apache.ignite.binary.BinaryObject)7 Marshaller (org.apache.ignite.marshaller.Marshaller)7 IgniteException (org.apache.ignite.IgniteException)6 NullLogger (org.apache.ignite.logger.NullLogger)6 TcpDiscoveryVmIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder)6 HashMap (java.util.HashMap)5 CacheKeyConfiguration (org.apache.ignite.cache.CacheKeyConfiguration)5 MarshallerContextTestImpl (org.apache.ignite.marshaller.MarshallerContextTestImpl)5 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)4 JdkMarshaller (org.apache.ignite.marshaller.jdk.JdkMarshaller)4