/** * @param globalIdMapper ID mapper. * @param globalSerializer Serializer. * @param typeCfgs Type configurations. * @throws BinaryObjectException In case of error. */ private void configure( BinaryIdMapper globalIdMapper, BinarySerializer globalSerializer, Collection<BinaryTypeConfiguration> typeCfgs) throws BinaryObjectException { TypeDescriptors descs = new TypeDescriptors(); Map<String, String> affFields = new HashMap<>(); if (!F.isEmpty(igniteCfg.getCacheKeyConfiguration())) { for (CacheKeyConfiguration keyCfg : igniteCfg.getCacheKeyConfiguration()) affFields.put(keyCfg.getTypeName(), keyCfg.getAffinityKeyFieldName()); } if (typeCfgs != null) { for (BinaryTypeConfiguration typeCfg : typeCfgs) { String clsName = typeCfg.getTypeName(); if (clsName == null) throw new BinaryObjectException("Class name is required for binary type configuration."); BinaryIdMapper idMapper = globalIdMapper; if (typeCfg.getIdMapper() != null) idMapper = typeCfg.getIdMapper(); idMapper = BinaryInternalIdMapper.create(idMapper); BinarySerializer serializer = globalSerializer; if (typeCfg.getSerializer() != null) serializer = typeCfg.getSerializer(); if (clsName.endsWith(".*")) { String pkgName = clsName.substring(0, clsName.length() - 2); for (String clsName0 : classesInPackage(pkgName)) descs.add( clsName0, idMapper, serializer, affFields.get(clsName0), typeCfg.isEnum(), true); } else descs.add(clsName, idMapper, serializer, affFields.get(clsName), typeCfg.isEnum(), false); } } for (TypeDescriptor desc : descs.descriptors()) registerUserType( desc.clsName, desc.idMapper, desc.serializer, desc.affKeyFieldName, desc.isEnum); BinaryInternalIdMapper dfltMapper = BinaryInternalIdMapper.create(globalIdMapper); // Put affinity field names for unconfigured types. for (Map.Entry<String, String> entry : affFields.entrySet()) { String typeName = entry.getKey(); int typeId = dfltMapper.typeId(typeName); affKeyFieldNames.putIfAbsent(typeId, entry.getValue()); } addSystemClassAffinityKey(CollocatedSetItemKey.class); addSystemClassAffinityKey(CollocatedQueueItemKey.class); }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); TcpDiscoverySpi disco = new TcpDiscoverySpi(); disco.setIpFinder(IP_FINDER); cfg.getTransactionConfiguration().setTxSerializableEnabled(true); cfg.setDiscoverySpi(disco); BasicWarmupClosure warmupClosure = new BasicWarmupClosure(); warmupClosure.setGridCount(2); warmupClosure.setIterationCount(10); warmupClosure.setKeyRange(10); cfg.setWarmupClosure(warmupClosure); CacheConfiguration<Integer, Integer> cacheCfg = new CacheConfiguration<>(); cacheCfg.setCacheMode(CacheMode.PARTITIONED); cacheCfg.setAtomicityMode(CacheAtomicityMode.ATOMIC); cacheCfg.setBackups(1); cacheCfg.setName("test"); cfg.setCacheConfiguration(cacheCfg); return cfg; }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration c = super.getConfiguration(gridName); TcpDiscoverySpi disco = new TcpDiscoverySpi(); disco.setIpFinder(ipFinder); c.setDiscoverySpi(disco); // Cache. CacheConfiguration cc = defaultCacheConfiguration(); cc.setCacheMode(CacheMode.PARTITIONED); cc.setAtomicityMode(CacheAtomicityMode.ATOMIC); cc.setNearConfiguration(null); cc.setWriteSynchronizationMode(FULL_SYNC); cc.setRebalanceMode(SYNC); cc.setSwapEnabled(false); cc.setSqlFunctionClasses(GridQueryParsingTest.class); cc.setIndexedTypes( String.class, Address.class, String.class, Person.class); c.setCacheConfiguration(cc); return c; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); assertNotNull(clientNodes); ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder); boolean client = false; for (Integer clientIdx : clientNodes) { if (getTestGridName(clientIdx).equals(gridName)) { client = true; break; } } cfg.setClientMode(client); CacheConfiguration ccfg = new CacheConfiguration(); ccfg.setBackups(0); ccfg.setRebalanceMode(SYNC); cfg.setCacheConfiguration(ccfg); return cfg; }
/** {@inheritDoc} */ @Override public void start(BenchmarkConfiguration cfg) throws Exception { IgniteBenchmarkArguments args = new IgniteBenchmarkArguments(); BenchmarkUtils.jcommander(cfg.commandLineArguments(), args, "<ignite-node>"); IgniteConfiguration c = loadConfiguration(args.configuration()); assert c != null; // Server node doesn't contains cache configuration. Driver will create dynamic cache. c.setCacheConfiguration(); TransactionConfiguration tc = c.getTransactionConfiguration(); tc.setDefaultTxConcurrency(args.txConcurrency()); tc.setDefaultTxIsolation(args.txIsolation()); TcpCommunicationSpi commSpi = (TcpCommunicationSpi) c.getCommunicationSpi(); if (commSpi == null) commSpi = new TcpCommunicationSpi(); c.setCommunicationSpi(commSpi); ignite = Ignition.start(c); }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); cfg.setCollisionSpi(new TestCollisionSpi()); return cfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); cfg.setMarshaller(new BinaryMarshaller()); return cfg; }
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration c = super.getConfiguration(gridName); c.setLifecycleBeans(bean); return c; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); return cfg; }
/** * @return Configuration. * @throws Exception If failed. */ @Override protected IgniteConfiguration getConfiguration() throws Exception { IgniteConfiguration cfg = super.getConfiguration(); cfg.setCollisionSpi(new GridTestCollision()); return cfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); cfg.setLateAffinityAssignment(false); return cfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); if (gridName.equals(getTestGridName(GRID_CNT - 1))) cfg.setClientMode(true); return cfg; }
/** * @return Expected hash code. * @param fullName Full name of type. */ private int expectedHashCode(String fullName) { BinaryIdMapper idMapper = cfg.getBinaryConfiguration().getIdMapper(); BinaryNameMapper nameMapper = cfg.getBinaryConfiguration().getNameMapper(); if (idMapper == null) idMapper = BinaryContext.defaultIdMapper(); if (nameMapper == null) nameMapper = BinaryContext.defaultNameMapper(); return idMapper.typeId(nameMapper.typeName(fullName)); }
/** @throws Exception If failed. */ public void testStopCancel() throws Exception { IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setConnectorConfiguration(null); Ignite ignite = G.start(cfg); ignite.compute().execute(TestTask.class, null); G.stop(true); }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); TcpDiscoverySpi disco = new TcpDiscoverySpi(); disco.setIpFinder(ipFinder); cfg.setDiscoverySpi(disco); return cfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setCacheMode(REPLICATED); cfg.setCacheConfiguration(cacheCfg); return cfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { Collection<String> hostNames = Arrays.asList("h_1", "h_2", "h_3"); IgniteConfiguration cfg = super.getConfiguration(gridName); TcpDiscoverySpi disco = (TcpDiscoverySpi) cfg.getDiscoverySpi(); cfg.setDiscoverySpi(new CustomHostsTcpDiscoverySpi(hostNames).setIpFinder(disco.getIpFinder())); return cfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { // Enable binary. IgniteConfiguration cfg = super.getConfiguration(gridName); BinaryConfiguration bCfg = new BinaryConfiguration(); bCfg.setClassNames(Arrays.asList(TestValue.class.getName())); cfg.setMarshaller(new BinaryMarshaller()); return cfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); CacheConfiguration ccfg = new CacheConfiguration(STATIC_CACHE_NAME); ccfg.setCacheMode(CacheMode.REPLICATED); ccfg.setRebalanceMode(CacheRebalanceMode.SYNC); cfg.setCacheConfiguration(ccfg); return cfg; }
/** * Creates new kernal context. * * @param log Logger. * @param grid Grid instance managed by kernal. * @param cfg Grid configuration. * @param gw Kernal gateway. * @param utilityCachePool Utility cache pool. * @param marshCachePool Marshaller cache pool. * @param execSvc Public executor service. * @param sysExecSvc System executor service. * @param p2pExecSvc P2P executor service. * @param mgmtExecSvc Management executor service. * @param igfsExecSvc IGFS executor service. * @param restExecSvc REST executor service. * @param affExecSvc Affinity executor service. * @param idxExecSvc Indexing executor service. * @param plugins Plugin providers. * @throws IgniteCheckedException In case of error. */ @SuppressWarnings("TypeMayBeWeakened") protected GridKernalContextImpl( GridLoggerProxy log, IgniteEx grid, IgniteConfiguration cfg, GridKernalGateway gw, ExecutorService utilityCachePool, ExecutorService marshCachePool, ExecutorService execSvc, ExecutorService sysExecSvc, ExecutorService p2pExecSvc, ExecutorService mgmtExecSvc, ExecutorService igfsExecSvc, ExecutorService restExecSvc, ExecutorService affExecSvc, @Nullable ExecutorService idxExecSvc, IgniteStripedThreadPoolExecutor callbackExecSvc, List<PluginProvider> plugins) throws IgniteCheckedException { assert grid != null; assert cfg != null; assert gw != null; this.grid = grid; this.cfg = cfg; this.gw = gw; this.utilityCachePool = utilityCachePool; this.marshCachePool = marshCachePool; this.execSvc = execSvc; this.sysExecSvc = sysExecSvc; this.p2pExecSvc = p2pExecSvc; this.mgmtExecSvc = mgmtExecSvc; this.igfsExecSvc = igfsExecSvc; this.restExecSvc = restExecSvc; this.affExecSvc = affExecSvc; this.idxExecSvc = idxExecSvc; this.callbackExecSvc = callbackExecSvc; String workDir = U.workDirectory(cfg.getWorkDirectory(), cfg.getIgniteHome()); marshCtx = new MarshallerContextImpl(workDir, plugins); try { spring = SPRING.create(false); } catch (IgniteCheckedException ignored) { if (log != null && log.isDebugEnabled()) log.debug( "Failed to load spring component, will not be able to extract userVersion from " + "META-INF/ignite.xml."); } }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration() throws Exception { IgniteConfiguration cfg = super.getConfiguration(); cfg.setPeerClassLoadingEnabled(false); TcpDiscoverySpi disco = new TcpDiscoverySpi(); disco.setIpFinder(ipFinder); cfg.setDiscoverySpi(disco); return cfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); cfg.setMarshaller(new OptimizedMarshaller(false)); cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder).setForceServerMode(true)); cfg.setCacheConfiguration(); if (gridName.equals(getTestGridName(0))) cfg.setClientMode(true); return cfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); if (gridName.equals(getTestGridName(GRID_CNT - 1))) cfg.setClientMode(true); cfg.setSwapSpaceSpi(new FileSwapSpaceSpi()); ((TcpCommunicationSpi) cfg.getCommunicationSpi()).setSharedMemoryPort(-1); return cfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); discoSpi.setIpFinder(IP_FINDER); cfg.setDiscoverySpi(discoSpi); cfg.setCacheConfiguration(cacheConfiguration()); return cfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); BinaryConfiguration binCfg = new BinaryConfiguration(); binCfg.setTypeConfigurations( Arrays.asList( new BinaryTypeConfiguration() { { setTypeName(Key.class.getName()); setIdentityResolver(BinaryArrayIdentityResolver.instance()); } }, new BinaryTypeConfiguration() { { setTypeName(Key2.class.getName()); setIdentityResolver(BinaryArrayIdentityResolver.instance()); } }, new BinaryTypeConfiguration() { { setTypeName(Key3.class.getName()); setIdentityResolver(new BinaryFieldIdentityResolver().setFieldNames("key")); } }, new BinaryTypeConfiguration() { { setTypeName(Key4.class.getName()); setIdentityResolver(new Key4Id()); } })); cfg.setBinaryConfiguration(binCfg); cfg.setPeerClassLoadingEnabled(false); TcpDiscoverySpi disco = new TcpDiscoverySpi(); disco.setIpFinder(ipFinder); cfg.setDiscoverySpi(disco); return cfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); CacheConfiguration<Integer, Person> ccfg = new CacheConfiguration<Integer, Person>(QUERY_CACHE) .setCacheMode(PARTITIONED) .setAtomicityMode(ATOMIC) .setBackups(1) .setIndexedTypes(Integer.class, Person.class); cfg.setCacheConfiguration(ccfg); return cfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); TcpDiscoverySpi spi = new TcpDiscoverySpi(); spi.setIpFinder(IP_FINDER); cfg.setDiscoverySpi(spi); cfg.setCacheConfiguration(); cfg.setMetricsUpdateFrequency(0); return cfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { assert gridName != null; IgniteConfiguration cfg = super.getConfiguration(gridName); TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); discoSpi.setIpFinder(IP_FINDER); cfg.setDiscoverySpi(discoSpi); if (gridName.contains("cache")) { String cacheName = "test-checkpoints"; CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setName(cacheName); cacheCfg.setWriteSynchronizationMode(FULL_SYNC); CacheCheckpointSpi spi = new CacheCheckpointSpi(); spi.setCacheName(cacheName); cfg.setCacheConfiguration(cacheCfg); cfg.setCheckpointSpi(spi); } else if (gridName.contains("jdbc")) { JdbcCheckpointSpi spi = new JdbcCheckpointSpi(); jdbcDataSource ds = new jdbcDataSource(); ds.setDatabase("jdbc:hsqldb:mem:gg_test_" + getClass().getSimpleName()); ds.setUser("sa"); ds.setPassword(""); spi.setDataSource(ds); spi.setCheckpointTableName("test_checkpoints"); spi.setKeyFieldName("key"); spi.setValueFieldName("value"); spi.setValueFieldType("longvarbinary"); spi.setExpireDateFieldName("expire_date"); cfg.setCheckpointSpi(spi); } return cfg; }
/** * @param fullClsName Class name. * @return Expected type name according to configuration. */ private String expectedTypeName(String fullClsName) { BinaryNameMapper mapper = cfg.getBinaryConfiguration().getNameMapper(); if (mapper == null) mapper = BinaryContext.defaultNameMapper(); return mapper.typeName(fullClsName); }
@Bean(name = "mgr") public SpringCacheManager springCacheManager() { IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setLocalHost("127.0.0.1"); cfg.setGridName("scmt"); cfg.setLifecycleBeans(bean1(), bean2()); SpringCacheManager mgr = new SpringCacheManager(); mgr.setConfiguration(cfg); return mgr; }