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 WorldWind servers cab be reached. The addresses used to detect public network access can be explicitly specified.

    • Method Detail

      • logUnavailableHost

        void logUnavailableHost​(java.net.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.
      • logAvailableHost

        void logAvailableHost​(java.net.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.
      • isHostUnavailable

        boolean isHostUnavailable​(java.net.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.
      • isWorldWindServerUnavailable

        boolean isWorldWindServerUnavailable()
        Indicates whether the NASA WorldWind servers can be reached.
        Returns:
        false if the servers can be reached, otherwise true.
      • 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.
      • 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.
      • isOfflineMode

        boolean isOfflineMode()
        Indicates whether WorldWind will attempt to connect to the network to retrieve data or for other reasons.
        Returns:
        true if WorldWind is in off-line mode, false if not.
      • setOfflineMode

        void setOfflineMode​(boolean offlineMode)
        Indicates whether WorldWind 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 WorldWind should use the network, false otherwise
      • 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:
        java.lang.IllegalArgumentException - if the limit is less than 1.
      • 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:
        java.lang.IllegalArgumentException - if the interval is less than 0.
      • getNetworkTestSites

        java.util.List<java.lang.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.
      • setNetworkTestSites

        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.
        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.