|
NASA World Wind | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectgov.nasa.worldwind.avlist.AVListImpl
gov.nasa.worldwind.util.BasicNetworkStatus
public class BasicNetworkStatus
Provides tracking of per-host network availability. Host computers that fail network requests can be logged to this class' tracking list. When a host has been logged a specified number of times, it is marked as unreachable. Users can query instances of this class to determine whether a host has been marked as unreachable.
Users are expected to invoke this class'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 this class'
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, this class will mark a host as
not unreachable after a specifiable interval of time. If the host is once more logged as unavailable, its entry will
return to the unavailable state. This cycle continues indefinitely.
Methods are also provided to determine whether the public network can be reached and whether the NASA World Wind
servers cab be reached.
| Nested Class Summary | |
|---|---|
protected static class |
BasicNetworkStatus.HostInfo
|
| Field Summary | |
|---|---|
protected static int |
DEFAULT_ATTEMPT_LIMIT
|
protected static java.lang.String[] |
DEFAULT_NETWORK_TEST_SITES
|
protected static long |
DEFAULT_TRY_AGAIN_INTERVAL
|
protected java.util.concurrent.ConcurrentHashMap<java.lang.String,BasicNetworkStatus.HostInfo> |
hostMap
|
protected java.util.concurrent.atomic.AtomicLong |
lastAvailableLogTime
|
protected java.util.concurrent.atomic.AtomicLong |
lastNetworkCheckTime
|
protected java.util.concurrent.atomic.AtomicLong |
lastNetworkStatusReportTime
|
protected java.util.concurrent.atomic.AtomicBoolean |
lastNetworkUnavailableResult
|
protected java.util.concurrent.atomic.AtomicLong |
lastUnavailableLogTime
|
protected static long |
NETWORK_STATUS_REPORT_INTERVAL
|
| Fields inherited from class gov.nasa.worldwind.avlist.AVListImpl |
|---|
changeSupport |
| Fields inherited from interface gov.nasa.worldwind.util.NetworkStatus |
|---|
HOST_AVAILABLE, HOST_UNAVAILABLE |
| Constructor Summary | |
|---|---|
BasicNetworkStatus()
|
|
| Method Summary | |
|---|---|
int |
getAttemptLimit()
Returns the number of times a host must be logged as unavailable before it is marked unavailable in this class. |
java.util.List<java.lang.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. |
protected static boolean |
isHostReachable(java.lang.String hostName)
|
boolean |
isHostUnavailable(java.net.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 |
isWorlWindServerUnavailable()
Indicates whether the NASA World Wind servers can be reached. |
void |
logAvailableHost(java.net.URL url)
Log a host as available. |
void |
logUnavailableHost(java.net.URL url)
Log a host as unavailable. |
void |
setAttemptLimit(int limit)
Set the number of times a host must be logged as unavailable before it is marked unavailable in this class. |
void |
setNetworkTestSites(java.util.List<java.lang.String> networkTestSites)
Sets the domain names, e.g., worldwind.arc.nasa.gov, of sites used to determine public network availability. |
void |
setOfflineMode(boolean offlineMode)
Indicate whether World Wind should attempt to connect to the network to retrieve data or for other reasons. |
void |
setTryAgainInterval(long interval)
Set the length of time to wait until a host is marked as not unreachable subsequent to its being marked unreachable. |
| Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl |
|---|
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 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 |
|---|
protected static final int DEFAULT_ATTEMPT_LIMIT
protected static final java.lang.String[] DEFAULT_NETWORK_TEST_SITES
protected static final long DEFAULT_TRY_AGAIN_INTERVAL
protected java.util.concurrent.ConcurrentHashMap<java.lang.String,BasicNetworkStatus.HostInfo> hostMap
protected java.util.concurrent.atomic.AtomicLong lastAvailableLogTime
protected java.util.concurrent.atomic.AtomicLong lastNetworkCheckTime
protected java.util.concurrent.atomic.AtomicLong lastNetworkStatusReportTime
protected java.util.concurrent.atomic.AtomicBoolean lastNetworkUnavailableResult
protected java.util.concurrent.atomic.AtomicLong lastUnavailableLogTime
protected static final long NETWORK_STATUS_REPORT_INTERVAL
| Constructor Detail |
|---|
public BasicNetworkStatus()
| Method Detail |
|---|
public int getAttemptLimit()
getAttemptLimit in interface NetworkStatuspublic java.util.List<java.lang.String> getNetworkTestSites()
NetworkStatus
getNetworkTestSites in interface NetworkStatuspublic long getTryAgainInterval()
getTryAgainInterval in interface NetworkStatusprotected static boolean isHostReachable(java.lang.String hostName)
public boolean isHostUnavailable(java.net.URL url)
isHostUnavailable in interface NetworkStatusurl - a url containing the host to check for availability.
public boolean isNetworkUnavailable()
isNetworkUnavailable in interface NetworkStatuspublic boolean isNetworkUnavailable(long checkInterval)
checkInterval - the number of milliseconds in the past used to determine whether the server was avaialble
recently.
public boolean isOfflineMode()
isOfflineMode in interface NetworkStatustrue if World Wind is in off-line mode, false if not.public boolean isWorlWindServerUnavailable()
isWorlWindServerUnavailable in interface NetworkStatuspublic void logAvailableHost(java.net.URL url)
logAvailableHost in interface NetworkStatusurl - a url containing the host to mark as available.public void logUnavailableHost(java.net.URL url)
logUnavailableHost in interface NetworkStatusurl - a url containing the host to mark as unavailable.public void setAttemptLimit(int limit)
setAttemptLimit in interface NetworkStatuslimit - the number of log-unavailability invocations necessary to consider the host unreachable.
java.lang.IllegalArgumentException - if the limit is less than 1.public void setNetworkTestSites(java.util.List<java.lang.String> networkTestSites)
NetworkStatus
setNetworkTestSites in interface NetworkStatusnetworkTestSites - 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.public void setOfflineMode(boolean offlineMode)
false, indicating that the network should be used.
setOfflineMode in interface NetworkStatusofflineMode - true if World Wind should use the network, false otherwisepublic void setTryAgainInterval(long interval)
setTryAgainInterval in interface NetworkStatusinterval - The length of time, in milliseconds, to wait to unmark a host as unreachable.
java.lang.IllegalArgumentException - if the interval is less than 0.
|
NASA World Wind | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||