Java Code Examples for org.apache.ignite.configuration.IgniteConfiguration#setClientMode()
The following examples show how to use
org.apache.ignite.configuration.IgniteConfiguration#setClientMode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IgniteModuleMemberRegistrationIT.java From hibernate-ogm-ignite with GNU Lesser General Public License v2.1 | 6 votes |
private IgniteConfiguration createConfig() { IgniteConfiguration config = new IgniteConfiguration(); config.setIgniteInstanceName( "OgmTestGrid" ); config.setClientMode( false ); BinaryConfiguration binaryConfiguration = new BinaryConfiguration(); binaryConfiguration.setNameMapper( new BinaryBasicNameMapper( true ) ); binaryConfiguration.setCompactFooter( false ); // it is necessary only for embedded collections (@ElementCollection) config.setBinaryConfiguration( binaryConfiguration ); TransactionConfiguration transactionConfiguration = new TransactionConfiguration(); // I'm going to use PESSIMISTIC here because some people had problem with it and it would be nice if tests // can highlight the issue. Ideally, we would want to test the different concurrency and isolation level. transactionConfiguration.setDefaultTxConcurrency( TransactionConcurrency.PESSIMISTIC ); transactionConfiguration.setDefaultTxIsolation( TransactionIsolation.READ_COMMITTED ); config.setTransactionConfiguration( transactionConfiguration ); return config; }
Example 2
Source File: OptimizedMarshallerNodeFailoverTest.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setMarshaller(new OptimizedMarshaller()); cfg.setWorkDirectory(workDir); if (cache) { CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg.setCacheMode(PARTITIONED); ccfg.setBackups(1); ccfg.setWriteSynchronizationMode(FULL_SYNC); cfg.setCacheConfiguration(ccfg); } else cfg.setClientMode(true); return cfg; }
Example 3
Source File: CacheContinuousBatchAckTest.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); if (igniteInstanceName.endsWith(CLIENT)) { cfg.setClientMode(true); cfg.setCommunicationSpi(new FailedTcpCommunicationSpi(true, false)); } else if (igniteInstanceName.endsWith(SERVER2)) cfg.setCommunicationSpi(new FailedTcpCommunicationSpi(false, true)); else cfg.setCommunicationSpi(new FailedTcpCommunicationSpi(false, false)); return cfg; }
Example 4
Source File: IgniteClusterIdTagTest.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); if (igniteInstanceName.contains("client")) cfg.setClientMode(true); else { DataStorageConfiguration dsCfg = new DataStorageConfiguration() .setDefaultDataRegionConfiguration( new DataRegionConfiguration() .setInitialSize(128 * 1024 * 1024) .setMaxSize(128 * 1024 * 1024) .setPersistenceEnabled(isPersistenceEnabled) ); cfg.setDataStorageConfiguration(dsCfg); } return cfg; }
Example 5
Source File: JdbcConnection.java From ignite with Apache License 2.0 | 6 votes |
/** * @param cfgUrl Config URL. * @param jdbcName Appended to instance name or used as default. * @return Ignite config and Spring context. */ private IgniteBiTuple<IgniteConfiguration, ? extends GridSpringResourceContext> loadConfiguration(String cfgUrl, String jdbcName) { try { IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> cfgMap = IgnitionEx.loadConfigurations(cfgUrl); IgniteConfiguration cfg = F.first(cfgMap.get1()); if (cfg.getIgniteInstanceName() == null) cfg.setIgniteInstanceName(jdbcName); else cfg.setIgniteInstanceName(cfg.getIgniteInstanceName() + "-" + jdbcName); cfg.setClientMode(true); // Force client mode. return new IgniteBiTuple<>(cfg, cfgMap.getValue()); } catch (IgniteCheckedException e) { throw new IgniteException(e); } }
Example 6
Source File: IgniteCacheClientNearCacheExpiryTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); if (igniteInstanceName.equals(getTestIgniteInstanceName(NODES - 1))) cfg.setClientMode(true); return cfg; }
Example 7
Source File: GridBinaryCacheEntryMemorySizeSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected Marshaller createMarshaller() throws IgniteCheckedException { BinaryMarshaller marsh = new BinaryMarshaller(); IgniteConfiguration iCfg = new IgniteConfiguration(); iCfg.setDiscoverySpi(new TcpDiscoverySpi() { @Override public void sendCustomEvent(DiscoverySpiCustomMessage msg) throws IgniteException { // No-op. } }); iCfg.setClientMode(false); iCfg.setSystemViewExporterSpi(new JmxSystemViewExporterSpi() { @Override protected void register(SystemView<?> sysView) { // No-op. } }); GridTestKernalContext kernCtx = new GridTestKernalContext(log, iCfg); kernCtx.add(new GridSystemViewManager(kernCtx)); kernCtx.add(new GridDiscoveryManager(kernCtx)); MarshallerContextTestImpl marshCtx = new MarshallerContextTestImpl(null); marshCtx.onMarshallerProcessorStarted(kernCtx, null); marsh.setContext(marshCtx); BinaryContext pCtx = new BinaryContext(BinaryNoopMetadataHandler.instance(), iCfg, new NullLogger()); IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", pCtx, iCfg); return marsh; }
Example 8
Source File: AuthenticationConfigurationClusterTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @param idx Node index. * @param authEnabled Authentication enabled. * @param client Client node flag. * @return Ignite configuration. * @throws Exception On error. */ private IgniteConfiguration configuration(int idx, boolean authEnabled, boolean client) throws Exception { IgniteConfiguration cfg = getConfiguration(getTestIgniteInstanceName(idx)); cfg.setClientMode(client); cfg.setAuthenticationEnabled(authEnabled); cfg.setDataStorageConfiguration(new DataStorageConfiguration() .setDefaultDataRegionConfiguration(new DataRegionConfiguration() .setMaxSize(200L * 1024 * 1024) .setPersistenceEnabled(true))); return cfg; }
Example 9
Source File: TxRecoveryWithConcurrentRollbackTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String name) throws Exception { final IgniteConfiguration cfg = super.getConfiguration(name); cfg.setConsistentId(name); if (persistence) { cfg.setDataStorageConfiguration( new DataStorageConfiguration(). setWalSegmentSize(4 * 1024 * 1024). setWalHistorySize(1000). setCheckpointFrequency(Integer.MAX_VALUE). setDefaultDataRegionConfiguration( new DataRegionConfiguration().setPersistenceEnabled(true).setMaxSize(50 * 1024 * 1024))); } cfg.setActiveOnStart(false); cfg.setClientMode("client".equals(name)); cfg.setCommunicationSpi(new TestRecordingCommunicationSpi()); cfg.setCacheConfiguration(new CacheConfiguration(DEFAULT_CACHE_NAME). setCacheMode(PARTITIONED). setBackups(backups). setAtomicityMode(TRANSACTIONAL). setWriteSynchronizationMode(syncMode)); return cfg; }
Example 10
Source File: IgniteSourceConnectorTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { IgniteConfiguration cfg = loadConfiguration("modules/kafka/src/test/resources/example-ignite.xml"); cfg.setClientMode(false); grid = startGrid("igniteServerNode", cfg); }
Example 11
Source File: H2ConnectionLeaksSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { CacheConfiguration<Long, String> ccfg = new CacheConfiguration<Long, String>().setName(CACHE_NAME) .setIndexedTypes(Long.class, String.class); IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setCacheConfiguration(ccfg); if (getTestIgniteInstanceIndex(igniteInstanceName) != 0) cfg.setClientMode(true); return cfg; }
Example 12
Source File: GridAbstractTest.java From ignite with Apache License 2.0 | 5 votes |
/** * Starts new grid with given name. * * @param gridName Grid name. * @param client Client mode. * @param cfgUrl Config URL. * @return Started grid. * @throws Exception If failed. */ protected Ignite startGridWithSpringCtx(String gridName, boolean client, String cfgUrl) throws Exception { IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext> cfgMap = IgnitionEx.loadConfigurations(cfgUrl); IgniteConfiguration cfg = F.first(cfgMap.get1()); cfg.setIgniteInstanceName(gridName); cfg.setClientMode(client); return IgnitionEx.start(cfg, cfgMap.getValue()); }
Example 13
Source File: CacheStopAndDestroySelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration iCfg = super.getConfiguration(igniteInstanceName); if (getTestIgniteInstanceName(2).equals(igniteInstanceName)) { iCfg.setClientMode(true); iCfg.setDataStorageConfiguration(memCfg); } ((TcpDiscoverySpi)iCfg.getDiscoverySpi()).setForceServerMode(true); iCfg.setCacheConfiguration(); TcpCommunicationSpi commSpi = new CountingTxRequestsToClientNodeTcpCommunicationSpi(); commSpi.setLocalPort(GridTestUtils.getNextCommPort(getClass())); commSpi.setTcpNoDelay(true); iCfg.setCommunicationSpi(commSpi); return iCfg; }
Example 14
Source File: TcpDiscoverySslSecuredUnsecuredTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(final String gridName) throws Exception { final IgniteConfiguration cfg = super.getConfiguration(gridName); cfg.setClientMode(gridName.contains("client")); if (gridName.contains("ssl")) cfg.setSslContextFactory(GridTestUtils.sslFactory()); if (spi != null) { final TcpDiscoveryIpFinder finder = ((TcpDiscoverySpi)cfg.getDiscoverySpi()).getIpFinder(); spi.setIpFinder(finder); cfg.setDiscoverySpi(spi); } return cfg; }
Example 15
Source File: GridCommandHandlerAbstractTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); if (atomicConfiguration != null) cfg.setAtomicConfiguration(atomicConfiguration); cfg.setCommunicationSpi(new TestRecordingCommunicationSpi()); cfg.setConnectorConfiguration(new ConnectorConfiguration().setSslEnabled(sslEnabled())); if (sslEnabled()) cfg.setSslContextFactory(GridTestUtils.sslFactory()); DataStorageConfiguration dsCfg = new DataStorageConfiguration() .setWalMode(WALMode.LOG_ONLY) .setCheckpointFrequency(checkpointFreq) .setDefaultDataRegionConfiguration( new DataRegionConfiguration().setMaxSize(50L * 1024 * 1024).setPersistenceEnabled(persistent) ); if (dataRegionConfiguration != null) dsCfg.setDataRegionConfigurations(dataRegionConfiguration); cfg.setDataStorageConfiguration(dsCfg); cfg.setConsistentId(igniteInstanceName); cfg.setClientMode(igniteInstanceName.startsWith(CLIENT_NODE_NAME_PREFIX)); if (encriptionEnabled) { KeystoreEncryptionSpi encSpi = new KeystoreEncryptionSpi(); encSpi.setKeyStorePath(KEYSTORE_PATH); encSpi.setKeyStorePassword(KEYSTORE_PASSWORD.toCharArray()); cfg.setEncryptionSpi(encSpi); } return cfg; }
Example 16
Source File: IgniteCacheGetRestartTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); Boolean clientMode = client.get(); if (clientMode != null) { cfg.setClientMode(clientMode); client.remove(); } cfg.setConsistentId(igniteInstanceName); return cfg; }
Example 17
Source File: DataStreamProcessorSelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @SuppressWarnings({"unchecked"}) @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setPeerClassLoadingEnabled(false); cfg.setIncludeProperties(); if (useCache) { CacheConfiguration cc = defaultCacheConfiguration(); cc.setCacheMode(mode); cc.setAtomicityMode(getCacheAtomicityMode()); if (nearEnabled) { NearCacheConfiguration nearCfg = new NearCacheConfiguration(); cc.setNearConfiguration(nearCfg); } cc.setWriteSynchronizationMode(FULL_SYNC); if (store != null) { cc.setCacheStoreFactory(new IgniteReflectionFactory<CacheStore>(TestStore.class)); cc.setReadThrough(true); cc.setWriteThrough(true); } cfg.setCacheConfiguration(cc); if (persistenceEnabled()) cfg.setDataStorageConfiguration(new DataStorageConfiguration() .setDefaultDataRegionConfiguration(new DataRegionConfiguration() .setPersistenceEnabled(true)) .setWalMode(WALMode.LOG_ONLY)); } else { cfg.setCacheConfiguration(); cfg.setClientMode(true); } cfg.setIncludeEventTypes(EventType.EVTS_ALL); return cfg; }
Example 18
Source File: GridCacheAbstractRemoveFailureTest.java From ignite with Apache License 2.0 | 3 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true); if (testClientNode() && getTestIgniteInstanceName(0).equals(igniteInstanceName)) cfg.setClientMode(true); ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1); return cfg; }
Example 19
Source File: ClusterStateNoRebalanceAbstractTest.java From ignite with Apache License 2.0 | 3 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); cfg.setActiveOnStart(false); cfg.setCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME)); cfg.setClientMode(gridName.startsWith("client")); cfg.setCommunicationSpi(new TestCommunicationSpi()); return cfg; }
Example 20
Source File: AgentClusterDemo.java From ignite with Apache License 2.0 | 2 votes |
/** * Configure node. * * @param basePort Base port. * @param gridIdx Ignite instance name index. * @param client If {@code true} then start client node. * @return IgniteConfiguration */ private static IgniteConfiguration igniteConfiguration(int basePort, int gridIdx, boolean client) throws IgniteCheckedException { IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setGridLogger(new Slf4jLogger()); cfg.setIgniteInstanceName((client ? CLN_NODE_NAME : SRV_NODE_NAME) + gridIdx); cfg.setLocalHost("127.0.0.1"); cfg.setEventStorageSpi(new MemoryEventStorageSpi()); cfg.setConsistentId(cfg.getIgniteInstanceName()); File workDir = new File(U.workDirectory(null, null), "demo-work"); cfg.setWorkDirectory(workDir.getAbsolutePath()); int[] evts = new int[EVTS_DISCOVERY.length + VISOR_TASK_EVTS.length]; System.arraycopy(EVTS_DISCOVERY, 0, evts, 0, EVTS_DISCOVERY.length); System.arraycopy(VISOR_TASK_EVTS, 0, evts, EVTS_DISCOVERY.length, VISOR_TASK_EVTS.length); cfg.setIncludeEventTypes(evts); cfg.getConnectorConfiguration().setPort(basePort); System.setProperty(IGNITE_JETTY_PORT, String.valueOf(basePort + 10)); TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(); int discoPort = basePort + 20; ipFinder.setAddresses(Collections.singletonList("127.0.0.1:" + discoPort + ".." + (discoPort + NODE_CNT - 1))); // Configure discovery SPI. TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); discoSpi.setLocalPort(discoPort); discoSpi.setIpFinder(ipFinder); cfg.setDiscoverySpi(discoSpi); TcpCommunicationSpi commSpi = new TcpCommunicationSpi(); commSpi.setSharedMemoryPort(-1); commSpi.setMessageQueueLimit(10); int commPort = basePort + 30; commSpi.setLocalPort(commPort); cfg.setCommunicationSpi(commSpi); cfg.setGridLogger(new Slf4jLogger(log)); cfg.setMetricsLogFrequency(0); DataRegionConfiguration dataRegCfg = new DataRegionConfiguration(); dataRegCfg.setName("demo"); dataRegCfg.setMetricsEnabled(true); dataRegCfg.setMaxSize(DFLT_DATA_REGION_INITIAL_SIZE); dataRegCfg.setPersistenceEnabled(true); DataStorageConfiguration dataStorageCfg = new DataStorageConfiguration(); dataStorageCfg.setMetricsEnabled(true); dataStorageCfg.setStoragePath(PdsConsistentIdProcessor.DB_DEFAULT_FOLDER); dataStorageCfg.setDefaultDataRegionConfiguration(dataRegCfg); dataStorageCfg.setSystemRegionMaxSize(DFLT_DATA_REGION_INITIAL_SIZE); dataStorageCfg.setWalMode(LOG_ONLY); dataStorageCfg.setWalSegments(WAL_SEGMENTS); dataStorageCfg.setWalSegmentSize(WAL_SEGMENT_SZ); cfg.setDataStorageConfiguration(dataStorageCfg); cfg.setClientMode(client); return cfg; }