Interface Machines

All Superinterfaces:
AdminAware, Iterable<Machine>
All Known Subinterfaces:
InternalMachines
All Known Implementing Classes:
DefaultMachines

public interface Machines extends AdminAware, Iterable<Machine>
Machines hold all the different Machines that are currently discovered.

Provides simple means to get all the current machines, as well as as registering for machine lifecycle (added and removed) events.

Author:
kimchy
  • Method Details

    • getMachines

      Machine[] getMachines()
      Returns all currently discovered machines.
    • getMachineByHostAddress

      Machine getMachineByHostAddress(String hostAddress)
      Returns the machine by the host address.
      Parameters:
      hostAddress - The host address to lookup the machine by
      Returns:
      The machine correlated to the specified host address, null if there is no one
    • getMachineByHostName

      Machine getMachineByHostName(String hostName)
      Returns the machine by the host name.
    • getUids

      Map<String,Machine> getUids()
      Returns a map of machines with the key as the uid.
    • getHostsByAddress

      Map<String,Machine> getHostsByAddress()
      Returns a map of machines by host address.
    • getHostsByName

      Map<String,Machine> getHostsByName()
      Returns a map of machines by host names.
    • getSize

      int getSize()
      Returns the number of machines current discovered.
    • isEmpty

      boolean isEmpty()
      Returns true if there are no machines, false otherwise.
    • waitFor

      boolean waitFor(int numberOfMachines)
      Waits indefinitely till the provided number of machines are up.
      Parameters:
      numberOfMachines - The number of containers to wait for
    • waitFor

      boolean waitFor(int numberOfMachines, long timeout, TimeUnit timeUnit)
      Waits for the given timeout (in time unit) till the provided number of machines are up. Returns true if the required number of machines were discovered, false if the timeout expired.
      Parameters:
      numberOfMachines - The number of containers to wait for
    • waitFor

      Machine waitFor(String host)
      Waits indefinitely till the machine with the given host (name/address) is discovered.
      Parameters:
      host - The machine host name or address
      Returns:
      The machine discovered
    • waitFor

      Machine waitFor(String host, long timeout, TimeUnit timeUnit)
      Waits for the given timeout (in time unit) till the machien with the given host (name/address) is discovered. Returns the machine if it was discovered within the provided timeout, or null if the machine was not discovered.
      Parameters:
      host - The machine host name or address
      timeout - The timeout value to wait
      timeUnit - The time unit of the timeout value
      Returns:
      The machien discovered, or null if it was not discovered within the provided timeout
    • getMachineAdded

      MachineAddedEventManager getMachineAdded()
      Returns the machines added event manager allowing to add and remove MachineAddedEventListeners.
    • getMachineRemoved

      MachineRemovedEventManager getMachineRemoved()
      Returns the grid service container added event manager allowing to add and remove MachineRemovedEventListeners.
    • addLifecycleListener

      void addLifecycleListener(MachineLifecycleEventListener eventListener)
    • removeLifeycleListener

      void removeLifeycleListener(MachineLifecycleEventListener eventListener)
      Allows to remove a MachineLifecycleEventListener.