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 and Description
    --- | ---
    `static class` | `MachineList.InetAddressFactory` InetAddressFactory is used to obtain InetAddress from host.

  - ### Field Summary

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

  - ### Constructor Summary

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

  - ### Method Summary

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

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

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

- - ### Field Detail

    - #### LOG

          public static final org.slf4j.Logger LOG

    - #### WILDCARD_VALUE

          public static final String WILDCARD_VALUE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### 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` -
        `addressFactory` - addressFactory to convert host to InetAddress

  - ### Method Detail

    - #### 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` -
      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` -
      Returns:
        true if address is part of the list

    - #### getCollection

          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.

Copyright © 2008–2022 Apache Software Foundation. All rights reserved.