org.apache.ignite.spi.discovery.tcp.ipfinder.cloud

## Class TcpDiscoveryCloudIpFinder

- java.lang.Object
- - org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinderAdapter
  - - org.apache.ignite.spi.discovery.tcp.ipfinder.cloud.TcpDiscoveryCloudIpFinder

- All Implemented Interfaces:
    TcpDiscoveryIpFinder

      public class TcpDiscoveryCloudIpFinder
      extends TcpDiscoveryIpFinderAdapter

  IP finder for automatic lookup of nodes running in a cloud.

  Implementation is based on Apache jclouds multi-cloud toolkit. For information about jclouds visit jclouds.apache.org.

  # Configuration

  ## Mandatory

  - Cloud provider (see `setProvider(String)`)
  - Identity (see `setIdentity(String)`)

  ## Optional

  - Credential (see `setCredential(String)`)
  - Credential path (see `setCredentialPath(String)`
  - Regions (see `setRegions(Collection)`)
  - Zones (see `setZones(Collection)`

  The finder forms nodes addresses, that possibly running Ignite, by getting private and public IPs of all VMs in a cloud and adding a port number to them. The port is either the one that is set with `TcpDiscoverySpi.setLocalPort(int)` or `TcpDiscoverySpi.DFLT_PORT`. Make sure that all VMs start Ignite instances on the same port, otherwise they will not be able to discover each other using this IP finder.

  Both `registerAddresses(Collection)` and `unregisterAddresses(Collection)` has no effect.

  Note, this finder is only workable when it used directly by cloud VM. Choose another implementation of `TcpDiscoveryIpFinder` for local or home network tests.

  ## Java Example

       String accountId = "your_account_id";
       String accountKey = "your_account_key";

       TcpDiscoveryCloudIpFinder ipFinder = new TcpDiscoveryCloudIpFinder();

       ipFinder.setProvider("aws-ec2");
       ipFinder.setIdentity(accountId);
       ipFinder.setCredential(accountKey);
       ipFinder.setRegions(Collections.emptyList().add("us-east-1"));
       ipFinder.setZones(Arrays.asList("us-east-1b", "us-east-1e"));

  ## Spring Example

  TcpDiscoveryCloudIpFinder can be configured from Spring XML configuration file:

       <bean id="grid.custom.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" singleton="true">
               ...
               <property name="discoverySpi">
                   <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                       <property name="ipFinder">
                           <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.cloud.TcpDiscoveryCloudIpFinder"/>
                               <property name="provider" value="google-compute-engine"/>
                               <property name="identity" value="your_service_account_email"/>
                               <property name="credentialPath" value="path_to_json_key"/>
                               <property name="zones">
                                   <list>
                                       <value>us-central1-a</value>
                                       <value>asia-east1-a</value>
                                   </list>
                               </property>
                           </bean>
                       </property>

                       <property name="socketTimeout" value="400"/>
                   </bean>
               </property>
               ...
       </bean>

  For information about Spring framework visit www.springframework.org

- - ### Field Summary

    - ### Fields inherited from class org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinderAdapter

      `ignite`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TcpDiscoveryCloudIpFinder()` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Collection<InetSocketAddress>` | `getRegisteredAddresses()` Gets all addresses registered in this finder.
    `void` | `registerAddresses(Collection<InetSocketAddress> addrs)` Registers new addresses.
    `TcpDiscoveryCloudIpFinder` | `setCredential(String credential)` Sets credential that is used during authentication on the cloud.
    `TcpDiscoveryCloudIpFinder` | `setCredentialPath(String credentialPath)` Sets the path to a credential that is used during authentication on the cloud.
    `TcpDiscoveryCloudIpFinder` | `setIdentity(String identity)` Sets the identity that is used as a user name during a connection to the cloud.
    `TcpDiscoveryCloudIpFinder` | `setProvider(String provider)` Sets the cloud provider to use.
    `TcpDiscoveryCloudIpFinder` | `setRegions(Collection<String> regions)` Sets list of regions where VMs are located.
    `TcpDiscoveryCloudIpFinder` | `setShared(boolean shared)` Sets shared flag.
    `TcpDiscoveryCloudIpFinder` | `setZones(Collection<String> zones)` Sets list of zones where VMs are located.
    `String` | `toString()`
    `void` | `unregisterAddresses(Collection<InetSocketAddress> addrs)` Unregisters provided addresses.

    - ### Methods inherited from class org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinderAdapter

      `close, discoveryClientMode, initializeLocalAddresses, isShared, onSpiContextDestroyed, onSpiContextInitialized, spiContext`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### TcpDiscoveryCloudIpFinder

          public TcpDiscoveryCloudIpFinder()

      Constructor.

  - ### Method Detail

    - #### getRegisteredAddresses

          public Collection<InetSocketAddress> getRegisteredAddresses()
                                                               throws IgniteSpiException

      Gets all addresses registered in this finder.
      Returns:
        All known addresses, potentially empty, but never `null`.
      Throws:
        `IgniteSpiException` - In case of error.

    - #### registerAddresses

          public void registerAddresses(Collection<InetSocketAddress> addrs)
                                 throws IgniteSpiException

      Registers new addresses.

      Implementation should accept duplicates quietly, but should not register address if it is already registered.

      Parameters:
        `addrs` - Addresses to register. Not `null` and not empty.
      Throws:
        `IgniteSpiException` - In case of error.

    - #### unregisterAddresses

          public void unregisterAddresses(Collection<InetSocketAddress> addrs)
                                   throws IgniteSpiException

      Unregisters provided addresses.

      Implementation should accept addresses that are currently not registered quietly (just no-op).

      Parameters:
        `addrs` - Addresses to unregister. Not `null` and not empty.
      Throws:
        `IgniteSpiException` - In case of error.

    - #### setProvider

          @IgniteSpiConfiguration(optional=false)
          public TcpDiscoveryCloudIpFinder setProvider(String provider)

      Sets the cloud provider to use. Apache jclouds providers list from ComputeService section contains names of all supported providers.
      Parameters:
        `provider` - Provider name.
      Returns:
        `this` for chaining.

    - #### setIdentity

          @IgniteSpiConfiguration(optional=false)
          public TcpDiscoveryCloudIpFinder setIdentity(String identity)

      Sets the identity that is used as a user name during a connection to the cloud. Depending on a cloud platform it can be an email address, user name, etc. Refer to Apache jclouds guide to get concrete information on what is used as an identity for a particular cloud platform.
      Parameters:
        `identity` - Identity to use during authentication on the cloud.
      Returns:
        `this` for chaining.

    - #### setCredential

          @IgniteSpiConfiguration(optional=true)
          public TcpDiscoveryCloudIpFinder setCredential(String credential)

      Sets credential that is used during authentication on the cloud. Depending on a cloud platform it can be a password or access key. Refer to Apache jclouds guide to get concrete information on what is used as an credential for a particular cloud platform.
      Parameters:
        `credential` - Credential to use during authentication on the cloud.
      Returns:
        `this` for chaining.

    - #### setCredentialPath

          @IgniteSpiConfiguration(optional=true)
          public TcpDiscoveryCloudIpFinder setCredentialPath(String credentialPath)

      Sets the path to a credential that is used during authentication on the cloud. This method should be used when an access key or private key is stored in a file. Content of the file, referred by @{code credentialPath}, is fully read and used as a access key or private key during authentication. Refer to Apache jclouds guide to get concrete information on what is used as an credential for a particular cloud platform.
      Parameters:
        `credentialPath` - Path to the credential to use during authentication on the cloud.
      Returns:
        `this` for chaining.

    - #### setZones

          @IgniteSpiConfiguration(optional=true)
          public TcpDiscoveryCloudIpFinder setZones(Collection<String> zones)

      Sets list of zones where VMs are located. If the zones are not set then every zone from regions, set by `setRegions(Collection)`}, will be taken into account. Note, that some cloud providers, like Rackspace, doesn't have a notion of a zone. For such providers a call to this method is redundant.
      Parameters:
        `zones` - Zones where VMs are located or null if to take every zone into account.
      Returns:
        `this` for chaining.

    - #### setRegions

          @IgniteSpiConfiguration(optional=true)
          public TcpDiscoveryCloudIpFinder setRegions(Collection<String> regions)

      Sets list of regions where VMs are located. If the regions are not set then every region, that a cloud provider has, will be investigated. This could lead to significant performance degradation. Note, that some cloud providers, like Google Compute Engine, doesn't have a notion of a region. For such providers a call to this method is redundant.
      Parameters:
        `regions` - Regions where VMs are located or null if to check every region a provider has.
      Returns:
        `this` for chaining.

    - #### setShared

          public TcpDiscoveryCloudIpFinder setShared(boolean shared)

      Sets shared flag. If `true` then it is expected that IP addresses registered with IP finder will be seen by IP finders on all other nodes.
      Overrides:
        `setShared` in class `TcpDiscoveryIpFinderAdapter`
      Parameters:
        `shared` - `true` if this IP finder is shared.
      Returns:
        `this` for chaining.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `TcpDiscoveryIpFinderAdapter`

2020 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.9.0
Release Date | : October 15 2020