NASA World Wind

gov.nasa.worldwind.util
Interface NetworkStatus

All Superinterfaces:
AVList
All Known Implementing Classes:
BasicNetworkStatus

public interface NetworkStatus
extends AVList

Provides tracking of per-host network availability. Host computers that fail network requests can be logged to the implementing object's tracking list. When a host has been logged a specified number of times, it is marked as unreachable. Users can query instances of classes implementing this interface to determine whether a host has been marked as unreachable.

Users are expected to invoke the logUnavailableHost(java.net.URL) method when an attempt to contact a host fails. Each invocation increments the failure count by one. When the count exceeds the attempt limit, the host is marked as unreachable. When attempts to contact the host are successful, users should invoke logAvailableHost(java.net.URL) method to clear its status.

A host may become reachable at a time subsequent to its being logged. To detect this, the implementation marks a host as not unreachable after a specifiable interval of time. If the host is once more logged as unavailable, its entry returns to the unavailable state. This cycle continues indefinitely.

Methods are provided to determine whether the public network can be reached and whether the NASA World Wind servers cab be reached. The addresses used to detect public network access can be explicitly specified.


Field Summary
static String HOST_AVAILABLE
           
static String HOST_UNAVAILABLE
           
 
Method Summary
 int getAttemptLimit()
          Returns the number of times a host must be logged as unavailable before it is marked unavailable in this class.
 List<String> getNetworkTestSites()
          Returns the server domain names of the sites used to test public network availability.
 long getTryAgainInterval()
          Returns the length of time to wait until a host is marked as not unreachable subsequent to its being marked unreachable.
 boolean isHostUnavailable(URL url)
          Indicates whether the host has been marked as unavailable.
 boolean isNetworkUnavailable()
          Indicates whether a public network can be reached or has been reached in the previous five seconds.
 boolean isNetworkUnavailable(long checkInterval)
          Indicates whether a public network can be reached or has been reached in a specified previous amount of time.
 boolean isOfflineMode()
          Indicates whether World Wind will attempt to connect to the network to retrieve data or for other reasons.
 boolean isWorldWindServerUnavailable()
          Indicates whether the NASA World Wind servers can be reached.
 void logAvailableHost(URL url)
          Log a host as available.
 void logUnavailableHost(URL url)
          Log a host as unavailable.
 void setAttemptLimit(int limit)
          Sets the number of times a host must be logged as unavailable before it is marked unavailable in this class.
 void setNetworkTestSites(List<String> networkTestSites)
          Sets the domain names, e.g., worldwind.arc.nasa.gov, of sites used to determine public network availability.
 void setOfflineMode(boolean offlineMode)
          Indicates whether World Wind should attempt to connect to the network to retrieve data or for other reasons.
 void setTryAgainInterval(long interval)
          Sets the length of time to wait until a host is marked as not unreachable subsequent to its being marked unreachable.
 
Methods inherited from interface gov.nasa.worldwind.avlist.AVList
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 

Field Detail

HOST_AVAILABLE

static final String HOST_AVAILABLE
See Also:
Constant Field Values

HOST_UNAVAILABLE

static final String HOST_UNAVAILABLE
See Also:
Constant Field Values
Method Detail

getAttemptLimit

int getAttemptLimit()
Returns the number of times a host must be logged as unavailable before it is marked unavailable in this class.

Returns:
the limit.

getNetworkTestSites

List<String> getNetworkTestSites()
Returns the server domain names of the sites used to test public network availability.

Returns:
the list of sites used to check network status. The list is a copy of the internal list, so changes to it do not affect instances of this class.

getTryAgainInterval

long getTryAgainInterval()
Returns the length of time to wait until a host is marked as not unreachable subsequent to its being marked unreachable.

Returns:
the interval, in milliseconds.

isHostUnavailable

boolean isHostUnavailable(URL url)
Indicates whether the host has been marked as unavailable. To be marked unavailable a host's attempt count must exceed the specified attempt limit.

Parameters:
url - a url containing the host to check for availability.
Returns:
true if the host is marked as unavailable, otherwise false.

isNetworkUnavailable

boolean isNetworkUnavailable()
Indicates whether a public network can be reached or has been reached in the previous five seconds.

Returns:
false if the network can be reached or has been reached in the previous five seconds, otherwise true.

isNetworkUnavailable

boolean isNetworkUnavailable(long checkInterval)
Indicates whether a public network can be reached or has been reached in a specified previous amount of time.

Parameters:
checkInterval - the number of milliseconds in the past used to determine whether the server was avaialble recently.
Returns:
false if the network can be reached or has been reached in a specified time, otherwise true.

isOfflineMode

boolean isOfflineMode()
Indicates whether World Wind will attempt to connect to the network to retrieve data or for other reasons.

Returns:
true if World Wind is in off-line mode, false if not.

isWorldWindServerUnavailable

boolean isWorldWindServerUnavailable()
Indicates whether the NASA World Wind servers can be reached.

Returns:
false if the servers can be reached, otherwise true.

logAvailableHost

void logAvailableHost(URL url)
Log a host as available. Each invocation causes the host to no longer be marked as unavailable. Its unavailability count is effectively set to 0.

Parameters:
url - a url containing the host to mark as available.

logUnavailableHost

void logUnavailableHost(URL url)
Log a host as unavailable. Each invocation increments the host's attempt count. When the count equals or exceeds the attempt limit, the host is marked as unavailable.

Parameters:
url - a url containing the host to mark as unavailable.

setAttemptLimit

void setAttemptLimit(int limit)
Sets the number of times a host must be logged as unavailable before it is marked unavailable in this class.

Parameters:
limit - the number of log-unavailability invocations necessary to consider the host unreachable.
Throws:
IllegalArgumentException - if the limit is less than 1.

setNetworkTestSites

void setNetworkTestSites(List<String> networkTestSites)
Sets the domain names, e.g., worldwind.arc.nasa.gov, of sites used to determine public network availability.

Parameters:
networkTestSites - the list of desired test sites. The list is copied internally, so changes made to the submitted list do not affect instances of this class. May be null, in which case no sites are consulted.

setOfflineMode

void setOfflineMode(boolean offlineMode)
Indicates whether World Wind should attempt to connect to the network to retrieve data or for other reasons. The default value for this attribute is false, indicating that the network should be used.

Parameters:
offlineMode - true if World Wind should use the network, false otherwise

setTryAgainInterval

void setTryAgainInterval(long interval)
Sets the length of time to wait until a host is marked as not unreachable subsequent to its being marked unreachable.

Parameters:
interval - The length of time, in milliseconds, to wait to unmark a host as unreachable.
Throws:
IllegalArgumentException - if the interval is less than 0.

NASA World Wind