MachineList (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.util, class: MachineList

Package org.apache.hadoop.util

# Class MachineList

java.lang.Object
org.apache.hadoop.util.MachineList

public class MachineList extends Object
Container class which holds a list of ip/host addresses and answers membership queries. Accepts list of ip addresses, ip addreses in CIDR format and/or host addresses.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `MachineList.InetAddressFactory`
  InetAddressFactory is used to obtain InetAddress from host.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final org.slf4j.Logger`
  `LOG`
  `static final String`
  `WILDCARD_VALUE`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MachineList(String hostEntries)`
  `MachineList(String hostEntries, MachineList.InetAddressFactory addressFactory)`
  `MachineList(Collection<String> hostEntries)`
  `MachineList(Collection<String> hostEntries, MachineList.InetAddressFactory addressFactory)`
  Accepts a collection of ip/cidr/host addresses

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Collection<String>`
  `getCollection()`
  returns the contents of the MachineList as a Collection<String> .
  `boolean`
  `includes(String ipAddress)`
  Accepts an ip address and return true if ipAddress is in the list.
  `boolean`
  `includes(InetAddress address)`
  Accepts an inet address and return true if address is in the list.

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

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

- ## Field Details

  - ### LOG

    public static final org.slf4j.Logger LOG

  - ### WILDCARD_VALUE

    public static final String WILDCARD_VALUE
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### MachineList

    public MachineList(String hostEntries)
    Parameters:
      `hostEntries` - comma separated ip/cidr/host addresses

  - ### MachineList

    public MachineList(String hostEntries, MachineList.InetAddressFactory addressFactory)

  - ### MachineList

    public MachineList(Collection<String> hostEntries)
    Parameters:
      `hostEntries` - collection of separated ip/cidr/host addresses

  - ### MachineList

    public MachineList(Collection<String> hostEntries, MachineList.InetAddressFactory addressFactory)
    Accepts a collection of ip/cidr/host addresses
    Parameters:
      `hostEntries` - hostEntries.
      `addressFactory` - addressFactory to convert host to InetAddress

- ## Method Details

  - ### includes

    public boolean includes(String ipAddress)
    Accepts an ip address and return true if ipAddress is in the list. `includes(InetAddress)` should be preferred to avoid possibly re-resolving the ip address.
    Parameters:
      `ipAddress` - ipAddress.
    Returns:
      true if ipAddress is part of the list

  - ### includes

    public boolean includes(InetAddress address)
    Accepts an inet address and return true if address is in the list.
    Parameters:
      `address` - address.
    Returns:
      true if address is part of the list

  - ### getCollection

    @VisibleForTesting public Collection<String> getCollection()
    returns the contents of the MachineList as a Collection<String> . This can be used for testing .
    Returns:
      contents of the MachineList.