Class ConeErrorPolicy


  • public abstract class ConeErrorPolicy
    extends java.lang.Object
    Defines how errors are treated during a multiple cone search operation. It also makes sure that interruptions are checked for, which is important to stop threads continuing to submit requests to remote services after the client no longer has any need for them.
    Since:
    24 Jan 2007
    Author:
    Mark Taylor
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static ConeErrorPolicy ABORT
      An error during a cone search results in a failure of the task.
      static ConeErrorPolicy IGNORE
      Errors during cone searches are treated as if the search had returned with no results.
      static ConeErrorPolicy RETRY
      If an error occurs during a cone search it is retried until a non-error result is obtained.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected ConeErrorPolicy​(java.lang.String name)
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      static ConeErrorPolicy createAdviceAbortPolicy​(java.lang.String name, java.lang.String extraAdvice)
      Returns a policy like ABORT, except that if an error occurs, the IOException thrown is populated with some custom text.
      static ConeErrorPolicy createRetryPolicy​(java.lang.String name, int nTry)
      Constructs an error policy which will retry the search a fixed number of times.
      abstract uk.ac.starlink.table.StarTable performConeSearch​(ConeSearcher cs, double ra, double dec, double sr)
      Uses the given cone searcher object to perform an actual cone search.
      java.lang.String toString()
      Returns this object's name.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • ABORT

        public static final ConeErrorPolicy ABORT
        An error during a cone search results in a failure of the task.
      • IGNORE

        public static final ConeErrorPolicy IGNORE
        Errors during cone searches are treated as if the search had returned with no results.
      • RETRY

        public static final ConeErrorPolicy RETRY
        If an error occurs during a cone search it is retried until a non-error result is obtained. Use with care.
    • Constructor Detail

      • ConeErrorPolicy

        protected ConeErrorPolicy​(java.lang.String name)
        Constructor.
        Parameters:
        name - policy name
    • Method Detail

      • toString

        public java.lang.String toString()
        Returns this object's name.
        Overrides:
        toString in class java.lang.Object
      • performConeSearch

        public abstract uk.ac.starlink.table.StarTable performConeSearch​(ConeSearcher cs,
                                                                         double ra,
                                                                         double dec,
                                                                         double sr)
                                                                  throws java.io.IOException,
                                                                         java.lang.InterruptedException
        Uses the given cone searcher object to perform an actual cone search. This may result in more than one call to the given cone searcher's performSearch method.

        Implementations are expected to check for thread interruption status and throw an InterruptedException if interruption has happened. They should do this in such a way that the cone search query is not performed (especially multiple times) following an interruption.

        Parameters:
        cs - cone searcher providing basic cone search capabilities
        ra - right ascension in degrees of search region centre
        dec - declination in degrees of search region centre
        sr - search radius in degrees
        Returns:
        table containing records in the given cone, or possibly null if no records are found
        Throws:
        java.io.IOException - if an IO error occurs
        java.lang.InterruptedException - if the thread was interrupted
        See Also:
        ConeSearcher.performSearch(double, double, double)
      • createRetryPolicy

        public static ConeErrorPolicy createRetryPolicy​(java.lang.String name,
                                                        int nTry)
        Constructs an error policy which will retry the search a fixed number of times. A backing-off policy applies so that progressively longer delays are introduced between successive attempts following failure.
        Parameters:
        name - policy name
        nTry - maximum number of attempts; if <=0 will retry indefinitely
        Returns:
        new error policy
      • createAdviceAbortPolicy

        public static ConeErrorPolicy createAdviceAbortPolicy​(java.lang.String name,
                                                              java.lang.String extraAdvice)
        Returns a policy like ABORT, except that if an error occurs, the IOException thrown is populated with some custom text.
        Parameters:
        name - policy name
        extraAdvice - advice to user in case of cone search failure
        Returns:
        new abort-like policy