Package uk.ac.starlink.ttools.cone
Class ConeErrorPolicy
java.lang.Object
uk.ac.starlink.ttools.cone.ConeErrorPolicy
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
FieldsModifier and TypeFieldDescriptionstatic final ConeErrorPolicy
An error during a cone search results in a failure of the task.static final ConeErrorPolicy
Errors during cone searches are treated as if the search had returned with no results.static final ConeErrorPolicy
If an error occurs during a cone search it is retried until a non-error result is obtained. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ConeErrorPolicy
createAdviceAbortPolicy
(String name, String extraAdvice) Returns a policy likeABORT
, except that if an error occurs, the IOException thrown is populated with some custom text.static ConeErrorPolicy
createRetryPolicy
(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.toString()
Returns this object's name.
-
Field Details
-
ABORT
An error during a cone search results in a failure of the task. -
IGNORE
Errors during cone searches are treated as if the search had returned with no results. -
RETRY
If an error occurs during a cone search it is retried until a non-error result is obtained. Use with care.
-
-
Constructor Details
-
ConeErrorPolicy
Constructor.- Parameters:
name
- policy name
-
-
Method Details
-
toString
Returns this object's name. -
performConeSearch
public abstract uk.ac.starlink.table.StarTable performConeSearch(ConeSearcher cs, double ra, double dec, double sr) throws IOException, 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'sperformSearch
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 capabilitiesra
- right ascension in degrees of search region centredec
- declination in degrees of search region centresr
- search radius in degrees- Returns:
- table containing records in the given cone, or possibly null if no records are found
- Throws:
IOException
- if an IO error occursInterruptedException
- if the thread was interrupted- See Also:
-
createRetryPolicy
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 namenTry
- maximum number of attempts; if <=0 will retry indefinitely- Returns:
- new error policy
-
createAdviceAbortPolicy
Returns a policy likeABORT
, except that if an error occurs, the IOException thrown is populated with some custom text.- Parameters:
name
- policy nameextraAdvice
- advice to user in case of cone search failure- Returns:
- new abort-like policy
-