|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.harvard.cfa.vo.tapclient.vosi.Availability
public class Availability
The operability and reliability of a service for extended and scheduled requests.
edu.harvard.cfa.vo.tapclient.tap.TapService tapService = new edu.harvard.cfa.vo.tapclient.tap.TapService(baseURL);
Availability availability = tapService.getAvailability();
if (! availability.isAvailable()) {
System.out.println("Service is unavailable.");
Calendar backAt = availability.getBackAt();
if (availability.getBackAt() != null) {
Calendar now = Calendar.getInstance();
if (backAt.compareTo(now) >= 0) {
System.out.println("Sleeping...");
long delay = (backAt.getTimeInMillis()-now.getTimeInMillis())+5000;
Thread.sleep(delay);
}
// Update the availability
availability.update();
System.out.println("Service is "+(availability.isAvailable() ? "available." : " not available."));
} else {
System.out.println("Service did not specify when it would be back.");
}
} else {
System.out.println("Service is available");
}
for (String note: availability.getNotes()) {
System.out.println("TAP service note: "+note);
}
Constructor Summary | |
---|---|
Availability(java.lang.String fullURL)
Construct an Availability for the given Vosi. |
Method Summary | |
---|---|
java.util.Calendar |
getBackAt()
Returns the instant at which the service is scheduled to become available. |
java.util.Calendar |
getDownAt()
Returns the instant at which the service is scheduled to be unavailable. |
java.util.List<java.lang.String> |
getNotes()
Returns a list of notes, for example explaining the reason for unavailability. |
java.util.Calendar |
getUpSince()
Returns the instant since which the service has been continuously available. |
boolean |
isAvailable()
Returns true if the service is accepting requests. |
void |
list(java.io.PrintStream output)
|
void |
list(java.io.PrintStream output,
java.lang.String indent)
|
void |
update()
Updates this Availability object with the latest response from the service. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Availability(java.lang.String fullURL)
fullURL
- the full URL associated with this availabilityMethod Detail |
---|
public boolean isAvailable()
update
.
update()
public java.util.Calendar getUpSince()
update()
public java.util.Calendar getDownAt()
update()
public java.util.Calendar getBackAt()
update()
public java.util.List<java.lang.String> getNotes()
update()
public void update() throws HttpException, ResponseFormatException, java.io.IOException
HttpException
- if the service responses to the VOSI Availability request with an unexpected HTTP status.
ResponseFormatException
- if an error occurs parsing the service response into an VOSI Availability document.
java.io.IOException
- if an error occurs creating an input stream.public void list(java.io.PrintStream output)
public void list(java.io.PrintStream output, java.lang.String indent)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |