at.ac.tuwien.infosys.rnue.interfaces
Interface IHostList


public interface IHostList

The IHostList interface specifies the functionality to manage the list of known and online peers. It specifies methods to add, remove, and retrieve peers (hosts).

Classes implementing this interface are also responsible to remove hosts (garbage collection) that seem to be no longer alive (no IAmAlive message within IConstants.LIFETIME_OF_HOSTINFOS). This should be implemented as a thread that can be stopped using the stopGarbageCollector method.


Method Summary
 boolean contains(IHostInfo info)
          Returns whether a given host identified by a IHostInfo object is contained in the host list.
 java.util.Enumeration elements()
          Returns an enumeration with all the elements stored in the host list.
 IHostInfo get(java.lang.String hostId)
          Retrieve a IHostInfo object from the host list.
 java.util.Enumeration keys()
          Returns an enumeration with all the keys stored in the host list.
 IHostInfo put(IHostInfo info)
          Insert a new IHostInfo object into this host list.
 IHostInfo remove(java.lang.String hostId)
          Remove a host from the host list.
 void stopGarbageCollector()
          Stop the garbage collector thread that removes inactive hosts from the host list.
 

Method Detail

get

public IHostInfo get(java.lang.String hostId)
Retrieve a IHostInfo object from the host list.

Parameters:
hostId - identifies the host to be retrieved. The format of this identifier is registryHost:registryPort.
Returns:
the value to which the key is mapped in this IHostList; null if the key is not mapped to any value in this IHostList.

put

public IHostInfo put(IHostInfo info)
Insert a new IHostInfo object into this host list.

Parameters:
info - New IHostInfo object to be inserted.
Returns:
the previous value of the specified key in this IHostList, or null if it did not have one.

remove

public IHostInfo remove(java.lang.String hostId)
Remove a host from the host list.

Parameters:
hostId - identifies the host to be retrieved. The format of this identifier is registryHost:registryPort.
Returns:
the value to which the key had been mapped in this IHostList, or null if the key did not have a mapping.

contains

public boolean contains(IHostInfo info)
Returns whether a given host identified by a IHostInfo object is contained in the host list.

Parameters:
info - the IHostInfo objecct identifying the host.
Returns:
true if this map maps one or more keys to the specified value.

keys

public java.util.Enumeration keys()
Returns an enumeration with all the keys stored in the host list.

Returns:
an enumeration of the keys in this IHostList.

elements

public java.util.Enumeration elements()
Returns an enumeration with all the elements stored in the host list.

Returns:
an enumeration of the values in this IHostList.

stopGarbageCollector

public void stopGarbageCollector()
Stop the garbage collector thread that removes inactive hosts from the host list.