Search in sources :

Example 1 with TcpDiscoveryVmIpFinder

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();
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) Properties(java.util.Properties) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) Before(org.junit.Before)

Example 2 with TcpDiscoveryVmIpFinder

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;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) SharedFsCheckpointSpi(org.apache.ignite.spi.checkpoint.sharedfs.SharedFsCheckpointSpi) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 3 with TcpDiscoveryVmIpFinder

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;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) ConnectorConfiguration(org.apache.ignite.configuration.ConnectorConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 4 with TcpDiscoveryVmIpFinder

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;
}
Also used : TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) ConnectorConfiguration(org.apache.ignite.configuration.ConnectorConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 5 with TcpDiscoveryVmIpFinder

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);
}
Also used : TcpDiscoveryMulticastIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Aggregations

TcpDiscoveryVmIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder)81 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)69 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)69 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)32 FileSystemConfiguration (org.apache.ignite.configuration.FileSystemConfiguration)16 Ignite (org.apache.ignite.Ignite)12 IgfsGroupDataBlocksKeyMapper (org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper)12 ArrayList (java.util.ArrayList)5 IgfsIpcEndpointConfiguration (org.apache.ignite.igfs.IgfsIpcEndpointConfiguration)5 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 ConnectorConfiguration (org.apache.ignite.configuration.ConnectorConfiguration)4 TcpDiscoveryNode (org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode)4 TcpDiscoveryIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder)4 HashMap (java.util.HashMap)3 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)3 TcpCommunicationSpi (org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)3 TcpDiscoveryMulticastIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder)3 IOException (java.io.IOException)2 InetSocketAddress (java.net.InetSocketAddress)2 Properties (java.util.Properties)2