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;
}
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();
}
}
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;
}
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;
}
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;
}
Aggregations