use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project zeppelin by apache.
the class IgniteSqlInterpreterTest method setUp.
@Before
public void setUp() {
TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
ipFinder.setAddresses(Collections.singletonList(HOST));
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
discoSpi.setIpFinder(ipFinder);
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setDiscoverySpi(discoSpi);
cfg.setPeerClassLoadingEnabled(true);
cfg.setGridName("test");
ignite = Ignition.start(cfg);
Properties props = new Properties();
props.setProperty(IgniteSqlInterpreter.IGNITE_JDBC_URL, "jdbc:ignite:cfg://cache=person@default-ignite-jdbc.xml");
intp = new IgniteSqlInterpreter(props);
CacheConfiguration<Integer, Person> cacheConf = new CacheConfiguration<>();
cacheConf.setIndexedTypes(Integer.class, Person.class);
cacheConf.setName("person");
IgniteCache<Integer, Person> cache = ignite.createCache(cacheConf);
cache.put(1, new Person("sun", 100));
cache.put(2, new Person("moon", 50));
assertEquals("moon", cache.get(2).getName());
intp.open();
}
use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project ignite by apache.
the class ComputeFailoverNodeStartup method configuration.
/**
* Create Ignite configuration with configured checkpoints.
*
* @return Ignite configuration.
* @throws IgniteException If configuration creation failed.
*/
public static IgniteConfiguration configuration() throws IgniteException {
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setLocalHost("127.0.0.1");
cfg.setPeerClassLoadingEnabled(true);
// Configure checkpoint SPI.
SharedFsCheckpointSpi checkpointSpi = new SharedFsCheckpointSpi();
checkpointSpi.setDirectoryPaths(Collections.singletonList("work/checkpoint/sharedfs"));
cfg.setCheckpointSpi(checkpointSpi);
// Configure discovery SPI.
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500..47509"));
discoSpi.setIpFinder(ipFinder);
cfg.setDiscoverySpi(discoSpi);
return cfg;
}
use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project ignite by apache.
the class JdbcStreamingSelfTest method getConfiguration0.
/**
* @param gridName Grid name.
* @return Grid configuration used for starting the grid.
* @throws Exception If failed.
*/
private IgniteConfiguration getConfiguration0(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
CacheConfiguration<?, ?> cache = defaultCacheConfiguration();
cache.setCacheMode(PARTITIONED);
cache.setBackups(1);
cache.setWriteSynchronizationMode(FULL_SYNC);
cache.setIndexedTypes(Integer.class, Integer.class);
cfg.setCacheConfiguration(cache);
cfg.setLocalHost("127.0.0.1");
TcpDiscoverySpi disco = new TcpDiscoverySpi();
TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
ipFinder.setAddresses(Collections.singleton("127.0.0.1:47500..47501"));
disco.setIpFinder(ipFinder);
cfg.setDiscoverySpi(disco);
cfg.setConnectorConfiguration(new ConnectorConfiguration());
return cfg;
}
use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project ignite by apache.
the class RestProcessorTest method cacheTestConfiguration.
/**
* @param cfg Initial configuration.
* @return Final configuration.
*/
@SuppressWarnings({ "unchecked" })
private IgniteConfiguration cacheTestConfiguration(IgniteConfiguration cfg) {
TcpDiscoverySpi disco = new TcpDiscoverySpi();
TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
ipFinder.setShared(true);
disco.setIpFinder(ipFinder);
cfg.setDiscoverySpi(disco);
assert cfg.getConnectorConfiguration() == null;
ConnectorConfiguration clientCfg = new ConnectorConfiguration();
// Ensure - no authentication.
clientCfg.setSecretKey(null);
cfg.setConnectorConfiguration(clientCfg);
cfg.setCacheConfiguration(defaultCacheConfiguration());
return cfg;
}
use of org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder in project ignite by apache.
the class PlatformConfigurationUtils method readDiscoveryConfiguration.
/**
* Reads discovery configuration from a stream and updates provided IgniteConfiguration.
*
* @param cfg IgniteConfiguration to update.
* @param in Reader.
*/
private static void readDiscoveryConfiguration(BinaryRawReader in, IgniteConfiguration cfg) {
boolean hasConfig = in.readBoolean();
if (!hasConfig)
return;
TcpDiscoverySpi disco = new TcpDiscoverySpi();
boolean hasIpFinder = in.readBoolean();
if (hasIpFinder) {
byte ipFinderType = in.readByte();
int addrCount = in.readInt();
ArrayList<String> addrs = null;
if (addrCount > 0) {
addrs = new ArrayList<>(addrCount);
for (int i = 0; i < addrCount; i++) addrs.add(in.readString());
}
TcpDiscoveryVmIpFinder finder = null;
if (ipFinderType == 1) {
finder = new TcpDiscoveryVmIpFinder();
} else if (ipFinderType == 2) {
TcpDiscoveryMulticastIpFinder finder0 = new TcpDiscoveryMulticastIpFinder();
finder0.setLocalAddress(in.readString());
finder0.setMulticastGroup(in.readString());
finder0.setMulticastPort(in.readInt());
finder0.setAddressRequestAttempts(in.readInt());
finder0.setResponseWaitTime(in.readInt());
boolean hasTtl = in.readBoolean();
if (hasTtl)
finder0.setTimeToLive(in.readInt());
finder = finder0;
} else {
assert false;
}
finder.setAddresses(addrs);
disco.setIpFinder(finder);
}
disco.setSocketTimeout(in.readLong());
disco.setAckTimeout(in.readLong());
disco.setMaxAckTimeout(in.readLong());
disco.setNetworkTimeout(in.readLong());
disco.setJoinTimeout(in.readLong());
disco.setForceServerMode(in.readBoolean());
disco.setClientReconnectDisabled(in.readBoolean());
disco.setLocalAddress(in.readString());
disco.setReconnectCount(in.readInt());
disco.setLocalPort(in.readInt());
disco.setLocalPortRange(in.readInt());
disco.setStatisticsPrintFrequency(in.readLong());
disco.setIpFinderCleanFrequency(in.readLong());
disco.setThreadPriority(in.readInt());
disco.setTopHistorySize(in.readInt());
cfg.setDiscoverySpi(disco);
}
Aggregations