Java Code Examples for org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi#setIpFinder()
The following examples show how to use
org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi#setIpFinder() .
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: GridCacheNearReaderPreloadSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** * Create configuration for data node. * * @param ipFinder IP finder. * @param igniteInstanceName Ignite instance name. * @return Configuration for data node. * @throws IgniteCheckedException If failed. */ private IgniteConfiguration dataNode(TcpDiscoveryIpFinder ipFinder, String igniteInstanceName) throws Exception { CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg.setName(CACHE_NAME); ccfg.setCacheMode(PARTITIONED); ccfg.setAtomicityMode(TRANSACTIONAL); ccfg.setNearConfiguration(new NearCacheConfiguration()); ccfg.setWriteSynchronizationMode(FULL_SYNC); ccfg.setBackups(1); IgniteConfiguration cfg = getConfiguration(igniteInstanceName); TcpDiscoverySpi spi = new TcpDiscoverySpi(); spi.setIpFinder(ipFinder); cfg.setLocalHost("127.0.0.1"); cfg.setDiscoverySpi(spi); cfg.setCacheConfiguration(ccfg); cfg.setIncludeProperties(); cfg.setConnectorConfiguration(null); return cfg; }
Example 2
Source File: GridAddressResolverSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(final String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); discoSpi.setIpFinder(IP_FINDER); cfg.setDiscoverySpi(discoSpi); cfg.setAddressResolver(new AddressResolver() { @Override public Collection<InetSocketAddress> getExternalAddresses( InetSocketAddress addr) throws IgniteCheckedException { Set<InetSocketAddress> set = new HashSet<>(); set.add(addr); set.add(igniteInstanceName.contains("0") ? addr0 : addr1); return set; } }); return cfg; }
Example 3
Source File: AbstractSnapshotSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); TcpDiscoverySpi discoSpi = new BlockingCustomMessageDiscoverySpi(); discoSpi.setIpFinder(((TcpDiscoverySpi)cfg.getDiscoverySpi()).getIpFinder()); return cfg.setConsistentId(igniteInstanceName) .setCommunicationSpi(new TestRecordingCommunicationSpi()) .setDataStorageConfiguration(new DataStorageConfiguration() .setDefaultDataRegionConfiguration(new DataRegionConfiguration() .setMaxSize(100L * 1024 * 1024) .setPersistenceEnabled(persistence)) .setCheckpointFrequency(3000) .setPageSize(4096)) .setCacheConfiguration(dfltCacheCfg) .setClusterStateOnStart(INACTIVE) .setDiscoverySpi(discoSpi); }
Example 4
Source File: GridCacheNearOneNodeSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override protected IgniteConfiguration getConfiguration() throws Exception { MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); IgniteConfiguration cfg = super.getConfiguration(); TcpDiscoverySpi disco = new TcpDiscoverySpi(); disco.setIpFinder(new TcpDiscoveryVmIpFinder(true)); cfg.setDiscoverySpi(disco); CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setCacheMode(PARTITIONED); cacheCfg.setBackups(1); cacheCfg.setAtomicityMode(TRANSACTIONAL); cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); cacheCfg.setNearConfiguration(new NearCacheConfiguration()); cacheCfg.setCacheStoreFactory(singletonFactory(store)); cacheCfg.setReadThrough(true); cacheCfg.setWriteThrough(true); cacheCfg.setLoadPreviousValue(true); cfg.setCacheConfiguration(cacheCfg); return cfg; }
Example 5
Source File: IgniteInterpreter.java From zeppelin with Apache License 2.0 | 5 votes |
private Ignite getIgnite() { if (ignite == null) { try { String cfgUrl = getProperty(IGNITE_CFG_URL); if (cfgUrl != null && !cfgUrl.isEmpty()) { ignite = Ignition.start(new URL(cfgUrl)); } else { IgniteConfiguration conf = new IgniteConfiguration(); conf.setClientMode(Boolean.parseBoolean(getProperty(IGNITE_CLIENT_MODE))); TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(); ipFinder.setAddresses(getAddresses()); TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); discoSpi.setIpFinder(ipFinder); conf.setDiscoverySpi(discoSpi); conf.setPeerClassLoadingEnabled( Boolean.parseBoolean(getProperty(IGNITE_PEER_CLASS_LOADING_ENABLED))); ignite = Ignition.start(conf); } initEx = null; } catch (Exception e) { logger.error("Error in IgniteInterpreter while getIgnite: " , e); initEx = e; } } return ignite; }
Example 6
Source File: HelloIgnite.java From ignite-book-code-samples with GNU General Public License v3.0 | 5 votes |
public static void main(String[] args) { System.out.println("Hello Ignite"); // create a new instance of TCP Discovery SPI TcpDiscoverySpi spi = new TcpDiscoverySpi(); // create a new instance of tcp discovery multicast ip finder TcpDiscoveryMulticastIpFinder tcMp = new TcpDiscoveryMulticastIpFinder(); tcMp.setAddresses(Arrays.asList("localhost")); // change your IP address here // set the multi cast ip finder for spi spi.setIpFinder(tcMp); // create new ignite configuration IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setClientMode(false); // set the discovery spi to ignite configuration cfg.setDiscoverySpi(spi); // Start ignite Ignite ignite = Ignition.start(cfg); // get or create cache IgniteCache<Integer, String> cache = ignite.getOrCreateCache("testCache"); // put some cache elements for(int i = 1; i <= 100; i++){ cache.put(i, Integer.toString(i)); } // get them from the cache and write to the console for(int i =1; i<= 100; i++){ System.out.println("Cache get:"+ cache.get(i)); } ignite.close(); }
Example 7
Source File: Log4j2LoggerSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** * Creates grid configuration. * * @param igniteInstanceName Ignite instance name. * @param logPath Logger configuration path. * @return Grid configuration. * @throws Exception If error occurred. */ private static IgniteConfiguration getConfiguration(String igniteInstanceName, String logPath) throws Exception { TcpDiscoverySpi disco = new TcpDiscoverySpi(); disco.setIpFinder(new TcpDiscoveryVmIpFinder(false) {{ setAddresses(Collections.singleton("127.0.0.1:47500..47509")); }}); return new IgniteConfiguration() .setIgniteInstanceName(igniteInstanceName) .setGridLogger(new Log4J2Logger(logPath)) .setConnectorConfiguration(null) .setDiscoverySpi(disco); }
Example 8
Source File: HibernateL2CacheConfigurationSelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true)); cfg.setDiscoverySpi(discoSpi); cfg.setCacheConfiguration(cacheConfiguration(ENTITY3_NAME), cacheConfiguration(ENTITY4_NAME), cacheConfiguration("cache1"), cacheConfiguration("cache2"), cacheConfiguration("cache3"), cacheConfiguration(TIMESTAMP_CACHE), cacheConfiguration(QUERY_CACHE)); return cfg; }
Example 9
Source File: ApplicationConfiguration.java From ignite with Apache License 2.0 | 4 votes |
/** * Ignite instance bean with not default name */ @Bean public Ignite igniteInstanceTWO() { IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setIgniteInstanceName(IGNITE_INSTANCE_TWO); CacheConfiguration ccfg = new CacheConfiguration("PersonCache"); ccfg.setIndexedTypes(Integer.class, Person.class); cfg.setCacheConfiguration(ccfg); TcpDiscoverySpi spi = new TcpDiscoverySpi(); spi.setIpFinder(new TcpDiscoveryVmIpFinder(true)); cfg.setDiscoverySpi(spi); return Ignition.start(cfg); }
Example 10
Source File: GridCacheAbstractSelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); TcpDiscoverySpi disco = new TcpDiscoverySpi(); disco.setIpFinder(ipFinder); if (isDebug()) disco.setAckTimeout(Integer.MAX_VALUE); cfg.setDiscoverySpi(disco); cfg.setCacheConfiguration(cacheConfiguration(igniteInstanceName)); TcpCommunicationSpi comm = new TcpCommunicationSpi(); comm.setSharedMemoryPort(-1); cfg.setCommunicationSpi(comm); return cfg; }
Example 11
Source File: IgfsBlockMessageSystemPoolStarvationSelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** * Create node configuration. * * @param name Node name. * @param ipFinder IpFinder. * @return Configuration. * @throws Exception If failed. */ private IgniteConfiguration config(String name, TcpDiscoveryVmIpFinder ipFinder) throws Exception { // Data cache configuration. CacheConfiguration dataCcfg = new CacheConfiguration(DEFAULT_CACHE_NAME); dataCcfg.setCacheMode(CacheMode.REPLICATED); dataCcfg.setAtomicityMode(TRANSACTIONAL); dataCcfg.setWriteSynchronizationMode(FULL_SYNC); dataCcfg.setAffinityMapper(new DummyAffinityMapper(1)); dataCcfg.setMaxConcurrentAsyncOperations(1); // Meta cache configuration. CacheConfiguration metaCcfg = new CacheConfiguration(DEFAULT_CACHE_NAME); metaCcfg.setCacheMode(CacheMode.REPLICATED); metaCcfg.setAtomicityMode(TRANSACTIONAL); metaCcfg.setWriteSynchronizationMode(FULL_SYNC); // File system configuration. FileSystemConfiguration igfsCfg = new FileSystemConfiguration(); igfsCfg.setDefaultMode(IgfsMode.PRIMARY); igfsCfg.setFragmentizerEnabled(false); igfsCfg.setBlockSize(1024); igfsCfg.setDataCacheConfiguration(dataCcfg); igfsCfg.setMetaCacheConfiguration(metaCcfg); igfsCfg.setName(IGFS_NAME); // Ignite configuration. IgniteConfiguration cfg = getConfiguration(name); TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); discoSpi.setIpFinder(ipFinder); cfg.setDiscoverySpi(discoSpi); cfg.setFileSystemConfiguration(igfsCfg); cfg.setLocalHost("127.0.0.1"); cfg.setConnectorConfiguration(null); cfg.setStripedPoolSize(2); cfg.setSystemThreadPoolSize(2); cfg.setRebalanceThreadPoolSize(1); cfg.setPublicThreadPoolSize(1); return cfg; }
Example 12
Source File: IgniteConfigurationAdapter.java From sakai with Educational Community License v2.0 | 4 votes |
@Override protected IgniteConfiguration createInstance() { if (!configured) { address = serverConfigurationService.getString("ignite.address"); home = serverConfigurationService.getString("ignite.home"); remoteAddresses = serverConfigurationService.getStrings("ignite.addresses"); port = serverConfigurationService.getInt("ignite.port", 0); range = serverConfigurationService.getInt("ignite.range", 10); mode = serverConfigurationService.getString("ignite.mode", "worker"); name = serverConfigurationService.getServerName(); node = serverConfigurationService.getServerId(); // disable banner System.setProperty("IGNITE_NO_ASCII", "true"); System.setProperty("IGNITE_QUIET", "true"); System.setProperty("IGNITE_PERFORMANCE_SUGGESTIONS_DISABLED", "true"); configureName(); configureHome(); configurePort(); igniteConfiguration.setIgniteHome(home); igniteConfiguration.setConsistentId(node); igniteConfiguration.setIgniteInstanceName(name); if (StringUtils.equalsIgnoreCase("client", mode)) { igniteConfiguration.setClientMode(true); } else { igniteConfiguration.setClientMode(false); } igniteConfiguration.setDeploymentMode(DeploymentMode.CONTINUOUS); igniteConfiguration.setGridLogger(new Slf4jLogger()); igniteConfiguration.setCacheConfiguration(cacheConfiguration); // local node network configuration TcpCommunicationSpi tcpCommunication = new TcpCommunicationSpi(); TcpDiscoverySpi tcpDiscovery = new TcpDiscoverySpi(); TcpDiscoveryVmIpFinder finder = new TcpDiscoveryVmIpFinder(); List<String> discoveryAddresses = new ArrayList<>(); if (StringUtils.isNotBlank(address)) { tcpCommunication.setLocalAddress(address); tcpDiscovery.setLocalAddress(address); discoveryAddresses.add(address + ":" + (port + range) + ".." + (port + range + range - 1)); } else { discoveryAddresses.add("127.0.0.1:" + (port + range) + ".." + (port + range + range - 1)); } tcpCommunication.setLocalPort(port); tcpCommunication.setLocalPortRange(range - 1); tcpDiscovery.setLocalPort(port + range); tcpDiscovery.setLocalPortRange(range - 1); // remote node network configuration, 1.2.3.5:49000..49009 if (remoteAddresses != null && remoteAddresses.length > 0) { discoveryAddresses.addAll(Arrays.asList(remoteAddresses)); } finder.setAddresses(discoveryAddresses); tcpDiscovery.setIpFinder(finder); igniteConfiguration.setDiscoverySpi(tcpDiscovery); igniteConfiguration.setCommunicationSpi(tcpCommunication); log.info("Ignite configured with home=[{}], node=[{}], name=[{}], client mode=[{}], tcp ports=[{}..{}], discovery ports=[{}..{}]", igniteConfiguration.getIgniteHome(), igniteConfiguration.getConsistentId(), igniteConfiguration.getIgniteInstanceName(), igniteConfiguration.isClientMode(), tcpCommunication.getLocalPort(), tcpCommunication.getLocalPort() + tcpCommunication.getLocalPortRange(), tcpDiscovery.getLocalPort(), tcpDiscovery.getLocalPort() + tcpDiscovery.getLocalPortRange()); configured = Boolean.TRUE; } return igniteConfiguration; }
Example 13
Source File: KillQueryOnClientDisconnectTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); CacheConfiguration<?, ?> cache = GridAbstractTest.defaultCacheConfiguration(); cache.setCacheMode(PARTITIONED); cache.setBackups(1); cache.setWriteSynchronizationMode(FULL_SYNC); cache.setSqlFunctionClasses(TestSQLFunctions.class); cache.setIndexedTypes(Integer.class, Integer.class); cfg.setCacheConfiguration(cache); TcpDiscoverySpi disco = new TcpDiscoverySpi(); disco.setIpFinder(IP_FINDER); cfg.setDiscoverySpi(disco); cfg.setCommunicationSpi(new TcpCommunicationSpi() { /** {@inheritDoc} */ @Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackC) { if (GridIoMessage.class.isAssignableFrom(msg.getClass())) { Message gridMsg = ((GridIoMessage)msg).message(); //Don't send Kill response and disconnect client node. if (GridQueryKillResponse.class.isAssignableFrom(gridMsg.getClass())) { grid(0).configuration().getDiscoverySpi().failNode(clientNode().cluster().localNode().id(), null); return; } } super.sendMessage(node, msg, ackC); } }); return cfg; }
Example 14
Source File: HadoopIgfs20FileSystemAbstractSelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** * Starts the nodes for this test. * * @throws Exception If failed. */ private void startNodes() throws Exception { if (mode != PRIMARY) { // Start secondary IGFS. FileSystemConfiguration igfsCfg = new FileSystemConfiguration(); igfsCfg.setName("igfs_secondary"); igfsCfg.setIpcEndpointConfiguration(secondaryIpcEndpointConfiguration()); igfsCfg.setManagementPort(-1); igfsCfg.setBlockSize(512 * 1024); igfsCfg.setPrefetchBlocks(1); CacheConfiguration dataCacheCfg = defaultCacheConfiguration(); dataCacheCfg.setName("partitioned"); dataCacheCfg.setCacheMode(PARTITIONED); dataCacheCfg.setNearConfiguration(null); dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(GRP_SIZE)); dataCacheCfg.setBackups(0); dataCacheCfg.setAtomicityMode(TRANSACTIONAL); CacheConfiguration metaCacheCfg = defaultCacheConfiguration(); metaCacheCfg.setName("replicated"); metaCacheCfg.setCacheMode(REPLICATED); metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); metaCacheCfg.setAtomicityMode(TRANSACTIONAL); igfsCfg.setDataCacheConfiguration(dataCacheCfg); igfsCfg.setMetaCacheConfiguration(metaCacheCfg); IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setIgniteInstanceName("grid_secondary"); TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true)); cfg.setDiscoverySpi(discoSpi); cfg.setCacheConfiguration(metaCacheCfg, dataCacheCfg); cfg.setFileSystemConfiguration(igfsCfg); cfg.setIncludeEventTypes(EVT_TASK_FAILED, EVT_TASK_FINISHED, EVT_JOB_MAPPED); cfg.setLocalHost(U.getLocalHost().getHostAddress()); cfg.setCommunicationSpi(communicationSpi()); G.start(cfg); } startGrids(4); awaitPartitionMapExchange(); }
Example 15
Source File: IgniteNoClassOnServerAbstractTest.java From ignite with Apache License 2.0 | 4 votes |
/** * @return Configuration. */ private IgniteConfiguration createConfiguration() { IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setPeerClassLoadingEnabled(false); cfg.setLocalHost("127.0.0.1"); TcpDiscoverySpi disco = new TcpDiscoverySpi(); disco.setIpFinderCleanFrequency(1000); TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(); ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500..47509")); disco.setIpFinder(ipFinder); cfg.setDiscoverySpi(disco); return cfg; }
Example 16
Source File: IgnitionEx.java From ignite with Apache License 2.0 | 4 votes |
/** * Initialize default SPI implementations. * * @param cfg Ignite configuration. */ private void initializeDefaultSpi(IgniteConfiguration cfg) { if (cfg.getDiscoverySpi() == null) cfg.setDiscoverySpi(new TcpDiscoverySpi()); if (cfg.getDiscoverySpi() instanceof TcpDiscoverySpi) { TcpDiscoverySpi tcpDisco = (TcpDiscoverySpi)cfg.getDiscoverySpi(); if (tcpDisco.getIpFinder() == null) tcpDisco.setIpFinder(new TcpDiscoveryMulticastIpFinder()); } if (cfg.getCommunicationSpi() == null) cfg.setCommunicationSpi(new TcpCommunicationSpi()); if (cfg.getDeploymentSpi() == null) cfg.setDeploymentSpi(new LocalDeploymentSpi()); if (cfg.getEventStorageSpi() == null) cfg.setEventStorageSpi(new NoopEventStorageSpi()); if (cfg.getCheckpointSpi() == null) cfg.setCheckpointSpi(new NoopCheckpointSpi()); if (cfg.getCollisionSpi() == null) cfg.setCollisionSpi(new NoopCollisionSpi()); if (cfg.getFailoverSpi() == null) cfg.setFailoverSpi(new AlwaysFailoverSpi()); if (cfg.getLoadBalancingSpi() == null) cfg.setLoadBalancingSpi(new RoundRobinLoadBalancingSpi()); else { Collection<LoadBalancingSpi> spis = new ArrayList<>(); boolean dfltLoadBalancingSpi = false; for (LoadBalancingSpi spi : cfg.getLoadBalancingSpi()) { spis.add(spi); if (!dfltLoadBalancingSpi && spi instanceof RoundRobinLoadBalancingSpi) dfltLoadBalancingSpi = true; } // Add default load balancing SPI for internal tasks. if (!dfltLoadBalancingSpi) spis.add(new RoundRobinLoadBalancingSpi()); cfg.setLoadBalancingSpi(spis.toArray(new LoadBalancingSpi[spis.size()])); } if (cfg.getIndexingSpi() == null) cfg.setIndexingSpi(new NoopIndexingSpi()); if (cfg.getEncryptionSpi() == null) cfg.setEncryptionSpi(new NoopEncryptionSpi()); if (F.isEmpty(cfg.getMetricExporterSpi())) cfg.setMetricExporterSpi(new NoopMetricExporterSpi()); if (F.isEmpty(cfg.getSystemViewExporterSpi())) { if (IgniteComponentType.INDEXING.inClassPath()) { try { cfg.setSystemViewExporterSpi(new JmxSystemViewExporterSpi(), U.newInstance(SYSTEM_VIEW_SQL_SPI)); } catch (IgniteCheckedException e) { throw new IgniteException(e); } } else cfg.setSystemViewExporterSpi(new JmxSystemViewExporterSpi()); } }
Example 17
Source File: GridSessionWaitAttributeSelfTest.java From ignite with Apache License 2.0 | 3 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true)); c.setDiscoverySpi(discoSpi); c.setPublicThreadPoolSize(JOB_NUM * 2); return c; }
Example 18
Source File: FilterDataForClientNodeDiscoveryTest.java From ignite with Apache License 2.0 | 3 votes |
/** * @param nodeIdx Node index. * @return Ignite configuration. * @throws Exception On error. */ private IgniteConfiguration configuration(int nodeIdx) throws Exception { IgniteConfiguration cfg = getConfiguration(getTestIgniteInstanceName(nodeIdx)); TcpDiscoverySpi testSpi = new TestDiscoverySpi(); testSpi.setIpFinder(sharedStaticIpFinder); cfg.setDiscoverySpi(testSpi); return cfg; }
Example 19
Source File: IgniteHadoopFileSystemClientSelfTest.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 discoSpi = new TcpDiscoverySpi(); discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true)); cfg.setDiscoverySpi(discoSpi); FileSystemConfiguration igfsCfg = new FileSystemConfiguration(); igfsCfg.setDataCacheConfiguration(dataCacheConfiguration()); igfsCfg.setMetaCacheConfiguration(metaCacheConfiguration()); igfsCfg.setName("igfs"); igfsCfg.setBlockSize(512 * 1024); IgfsIpcEndpointConfiguration endpointCfg = new IgfsIpcEndpointConfiguration(); endpointCfg.setType(IgfsIpcEndpointType.TCP); endpointCfg.setPort(DFLT_IPC_PORT); igfsCfg.setIpcEndpointConfiguration(endpointCfg); cfg.setFileSystemConfiguration(igfsCfg); return cfg; }
Example 20
Source File: IgniteHadoopFileSystemLoggerStateSelfTest.java From ignite with Apache License 2.0 | 2 votes |
/** * Startup the grid and instantiate the file system. * * @throws Exception If failed. */ private void startUp() throws Exception { FileSystemConfiguration igfsCfg = new FileSystemConfiguration(); igfsCfg.setName("igfs"); igfsCfg.setBlockSize(512 * 1024); igfsCfg.setDefaultMode(PRIMARY); IgfsIpcEndpointConfiguration endpointCfg = new IgfsIpcEndpointConfiguration(); endpointCfg.setType(IgfsIpcEndpointType.TCP); endpointCfg.setPort(10500); igfsCfg.setIpcEndpointConfiguration(endpointCfg); CacheConfiguration dataCacheCfg = defaultCacheConfiguration(); dataCacheCfg.setName("partitioned"); dataCacheCfg.setCacheMode(PARTITIONED); dataCacheCfg.setNearConfiguration(null); dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128)); dataCacheCfg.setBackups(0); dataCacheCfg.setAtomicityMode(TRANSACTIONAL); CacheConfiguration metaCacheCfg = defaultCacheConfiguration(); metaCacheCfg.setName("replicated"); metaCacheCfg.setCacheMode(REPLICATED); metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); metaCacheCfg.setAtomicityMode(TRANSACTIONAL); igfsCfg.setDataCacheConfiguration(dataCacheCfg); igfsCfg.setMetaCacheConfiguration(metaCacheCfg); IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setIgniteInstanceName("igfs-grid"); TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true)); cfg.setDiscoverySpi(discoSpi); cfg.setFileSystemConfiguration(igfsCfg); cfg.setLocalHost("127.0.0.1"); cfg.setConnectorConfiguration(null); Ignite g = G.start(cfg); igfs = (IgfsEx)g.fileSystem("igfs"); igfs.globalSampling(sampling); fs = fileSystem(); }