use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project ignite by apache.
the class TcpClientDiscoverySpiSelfTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
cfg.setClientFailureDetectionTimeout(clientFailureDetectionTimeout());
TcpDiscoverySpi disco = getDiscoverySpi();
if (igniteInstanceName.startsWith("server"))
disco.setIpFinder(IP_FINDER);
else if (igniteInstanceName.startsWith("client")) {
cfg.setClientMode(true);
TcpDiscoveryVmIpFinder ipFinder;
if (clientIpFinder != null)
ipFinder = clientIpFinder;
else {
ipFinder = new TcpDiscoveryVmIpFinder();
String addr = new ArrayList<>(IP_FINDER.getRegisteredAddresses()).get((clientIdx.get() - 1) / clientsPerSrv).toString();
if (addr.startsWith("/"))
addr = addr.substring(1);
ipFinder.setAddresses(Collections.singletonList(addr));
}
disco.setIpFinder(ipFinder);
String nodeId = cfg.getNodeId().toString();
nodeId = "cc" + nodeId.substring(2);
cfg.setNodeId(UUID.fromString(nodeId));
} else
throw new IllegalArgumentException();
if (useFailureDetectionTimeout())
cfg.setFailureDetectionTimeout(failureDetectionTimeout());
else {
if (longSockTimeouts) {
disco.setAckTimeout(2000);
disco.setSocketTimeout(2000);
} else {
disco.setAckTimeout(igniteInstanceName.startsWith("client") ? TcpDiscoverySpi.DFLT_ACK_TIMEOUT_CLIENT : TcpDiscoverySpi.DFLT_ACK_TIMEOUT);
disco.setSocketTimeout(igniteInstanceName.startsWith("client") ? TcpDiscoverySpi.DFLT_SOCK_TIMEOUT_CLIENT : TcpDiscoverySpi.DFLT_SOCK_TIMEOUT);
}
}
disco.setJoinTimeout(joinTimeout);
disco.setNetworkTimeout(netTimeout);
if (reconnectCnt != null)
disco.setReconnectCount(reconnectCnt);
disco.setClientReconnectDisabled(reconnectDisabled);
if (disco instanceof TestTcpDiscoverySpi)
((TestTcpDiscoverySpi) disco).afterWrite(afterWrite);
cfg.setDiscoverySpi(disco);
if (nodeId != null)
cfg.setNodeId(nodeId);
return cfg;
}
use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project ignite by apache.
the class TcpDiscoveryWithWrongServerTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
ipFinder.setAddresses(Collections.singleton("127.0.0.1:" + Integer.toString(SERVER_PORT) + ".." + Integer.toString(LAST_SERVER_PORT)));
cfg.setDiscoverySpi(new TcpDiscoverySpiWithOrderedIps().setIpFinder(ipFinder));
if (igniteInstanceName.startsWith("client"))
cfg.setClientMode(true);
return cfg;
}
use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project ignite by apache.
the class IgniteClientConnectTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
TestTcpDiscoverySpi disco = new TestTcpDiscoverySpi();
if (igniteInstanceName.equals("client")) {
TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
ipFinder.registerAddresses(Collections.singleton(new InetSocketAddress(InetAddress.getLoopbackAddress(), 47501)));
disco.setIpFinder(ipFinder);
} else
disco.setIpFinder(ipFinder);
disco.setJoinTimeout(2 * 60_000);
disco.setSocketTimeout(1000);
disco.setNetworkTimeout(2000);
cfg.setDiscoverySpi(disco);
CacheConfiguration cacheConfiguration = new CacheConfiguration().setName(DEFAULT_CACHE_NAME).setCacheMode(CacheMode.PARTITIONED).setAffinity(new RendezvousAffinityFunction(false, 8)).setBackups(0);
cfg.setCacheConfiguration(cacheConfiguration);
return cfg;
}
use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project cas by apereo.
the class IgniteTicketRegistryConfiguration method igniteConfiguration.
/**
* Ignite configuration ignite configuration.
*
* @return the ignite configuration
*/
@RefreshScope
@Bean
public IgniteConfiguration igniteConfiguration() {
final IgniteProperties ignite = casProperties.getTicket().getRegistry().getIgnite();
final IgniteConfiguration config = new IgniteConfiguration();
final TcpDiscoverySpi spi = new TcpDiscoverySpi();
spi.setHeartbeatFrequency(ignite.getHeartbeatFrequency());
spi.setJoinTimeout(ignite.getJoinTimeout());
if (!StringUtils.isEmpty(ignite.getLocalAddress())) {
spi.setLocalAddress(ignite.getLocalAddress());
}
if (ignite.getLocalPort() != -1) {
spi.setLocalPort(ignite.getLocalPort());
}
spi.setNetworkTimeout(ignite.getNetworkTimeout());
spi.setSocketTimeout(ignite.getSocketTimeout());
spi.setThreadPriority(ignite.getThreadPriority());
spi.setForceServerMode(ignite.isForceServerMode());
final TcpDiscoveryVmIpFinder finder = new TcpDiscoveryVmIpFinder();
finder.setAddresses(StringUtils.commaDelimitedListToSet(ignite.getIgniteAddresses()));
spi.setIpFinder(finder);
config.setDiscoverySpi(spi);
final List<CacheConfiguration> configurations = new ArrayList<>();
final CacheConfiguration ticketsCache = new CacheConfiguration();
ticketsCache.setName(ignite.getTicketsCache().getCacheName());
ticketsCache.setCacheMode(CacheMode.valueOf(ignite.getTicketsCache().getCacheMode()));
ticketsCache.setAtomicityMode(CacheAtomicityMode.valueOf(ignite.getTicketsCache().getAtomicityMode()));
ticketsCache.setWriteSynchronizationMode(CacheWriteSynchronizationMode.valueOf(ignite.getTicketsCache().getWriteSynchronizationMode()));
ticketsCache.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, casProperties.getTicket().getTgt().getMaxTimeToLiveInSeconds())));
configurations.add(ticketsCache);
config.setCacheConfiguration(configurations.toArray(new CacheConfiguration[] {}));
return config;
}
use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project zeppelin by apache.
the class IgniteInterpreter method getIgnite.
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;
}
Aggregations