Java Code Examples for org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi#setLocalPort()
The following examples show how to use
org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi#setLocalPort() .
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: IgniteTopologyValidatorGridSplitCacheTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); int idx = getTestIgniteInstanceIndex(gridName); Map<String, Object> userAttrs = new HashMap<>(4); int segment = idx % 2; userAttrs.put(DC_NODE_ATTR, segment); TcpDiscoverySpi disco = (TcpDiscoverySpi)cfg.getDiscoverySpi(); disco.setLocalPort(getDiscoPort(idx)); disco.setIpFinder(new TcpDiscoveryVmIpFinder().setAddresses(segmented() ? (segment == 0 ? SEG_FINDER_0 : SEG_FINDER_1) : SEG_FINDER_ALL)); if (idx != CONFIGLESS_GRID_IDX) { if (idx == RESOLVER_GRID_IDX) { userAttrs.put(ACTIVATOR_NODE_ATTR, "true"); } else cfg.setActiveOnStart(false); } cfg.setUserAttributes(userAttrs); cfg.setMemoryConfiguration(new MemoryConfiguration(). setDefaultMemoryPolicySize((50L << 20) + (100L << 20) * CACHES_CNT / GRID_CNT)); return cfg; }
Example 2
Source File: IgniteHadoopFileSystemAbstractSelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** * Starts the nodes for this test. * * @throws Exception If failed. */ protected void startNodes() throws Exception { if (mode != PRIMARY) { // Start secondary IGFS. FileSystemConfiguration igfsCfg = new FileSystemConfiguration(); igfsCfg.setName("igfs_secondary"); igfsCfg.setIpcEndpointConfiguration(SECONDARY_ENDPOINT_CFG); 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.setLocalPort(47510); TcpDiscoveryVmIpFinder finder = new TcpDiscoveryVmIpFinder(true); discoSpi.setIpFinder(finder); cfg.setDiscoverySpi(discoSpi); cfg.setFileSystemConfiguration(igfsCfg); cfg.setIncludeEventTypes(EVT_TASK_FAILED, EVT_TASK_FINISHED, EVT_JOB_MAPPED); G.start(cfg); } for (int i = 1; i < GRID_COUNT; ++i) startGrid(i); startGrid(0); }
Example 3
Source File: BasicWarmupClosure.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override public void apply(IgniteConfiguration gridCfg) { // Remove cache duplicates, clean up the rest, etc. IgniteConfiguration cfg = prepareConfiguration(gridCfg); // Do nothing if no caches found. if (cfg == null) return; out("Starting grids to warmup caches [gridCnt=" + gridCnt + ", caches=" + cfg.getCacheConfiguration().length + ']'); Collection<Ignite> ignites = new LinkedList<>(); String old = System.getProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER); try { System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, "false"); TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); for (int i = 0; i < gridCnt; i++) { IgniteConfiguration cfg0 = new IgniteConfiguration(cfg); TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); discoSpi.setIpFinder(ipFinder); discoSpi.setLocalPort(discoveryPort); cfg0.setDiscoverySpi(discoSpi); cfg0.setGridLogger(new NullLogger()); cfg0.setIgniteInstanceName("ignite-warmup-grid-" + i); ignites.add(Ignition.start(cfg0)); } doWarmup(ignites); } catch (Exception e) { throw new IgniteException(e); } finally { for (Ignite ignite : ignites) Ignition.stop(ignite.name(), false); out("Stopped warmup grids."); if (old == null) old = "false"; System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, old); } }
Example 4
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 5
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 6
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; }