info.sswap.api.servlet
Class RRGCache

java.lang.Object
  extended by info.sswap.api.servlet.RRGCache

public class RRGCache
extends java.lang.Object

Manages cached RRGs and information about them (including information about RRGs that have not yet been computed, but they already have a token (identifier) so that the clients can query/poll for them). The underlying cache implementation is currently provided by EHCache

Author:
Blazej Bulka

Field Summary
static int DEFAULT_SUGGESTED_POLLING_INTERVAL
          Default suggested polling interval (in milliseconds)
 
Method Summary
static RRGCache get()
          Accessor for the singleton instance
 info.sswap.api.servlet.RRGCache.Entry get(java.lang.String token)
          Gets an entry for a (possibly future) RRG.
 boolean isActive()
           
 void setError(java.lang.String token, java.lang.String error)
          Sets an error message, indicating that computation of the particular RRG has failed.
 void setStatus(java.lang.String token, java.lang.String status)
           
 void setSuggestedPollingInterval(java.lang.String token, int suggestedPollingInterval)
          Sets suggested polling interval for a (potentially future) RRG identified by a token.
 void shutdown()
           
 void store(java.lang.String token, RRG rrg)
          Stores a computed RRG, indicating that the computation of an RRG was successful, and allowing its future retrieval by the client.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SUGGESTED_POLLING_INTERVAL

public static final int DEFAULT_SUGGESTED_POLLING_INTERVAL
Default suggested polling interval (in milliseconds)

See Also:
Constant Field Values
Method Detail

get

public static RRGCache get()
Accessor for the singleton instance

Returns:
the singleton instance

setSuggestedPollingInterval

public void setSuggestedPollingInterval(java.lang.String token,
                                        int suggestedPollingInterval)
Sets suggested polling interval for a (potentially future) RRG identified by a token. If there is no entry in the cache for this token, it is created, otherwise the suggested polling interval is added to the existing entry.

Parameters:
token - the token identifying the (potentially future) RRG
suggestedPollingInterval - suggested polling interval in milliseconds

setError

public void setError(java.lang.String token,
                     java.lang.String error)
Sets an error message, indicating that computation of the particular RRG has failed. This call overwrites any previous contents for that token in the cache. (If there is a previous entry in the cache, it should only contain polling interval -- it is safe to overwrite such an entry, since there should be no polling anymore; an error is a terminal state for an RRG computation).

Parameters:
token - the token identifying the RRG that has been computed
error - the error message

setStatus

public void setStatus(java.lang.String token,
                      java.lang.String status)

store

public void store(java.lang.String token,
                  RRG rrg)
Stores a computed RRG, indicating that the computation of an RRG was successful, and allowing its future retrieval by the client. This call overwrites any previous contents for that token in the cache. (If there is a previous entry in the cache, it should only contain polling interval -- it is safe to overwrite such an entry, since there should be no polling anymore; storing the computed RRG is a terminal state for an RRG computation).

Parameters:
token - the token identifying the RRG that has been computed
rrg - the computed RRG

get

public info.sswap.api.servlet.RRGCache.Entry get(java.lang.String token)
Gets an entry for a (possibly future) RRG. The entry may contain RRG (if the computation has finished successfully), an error message (if the computation failed), or none of the them (in such a case, the entry is a mere indicator that the token is a valid token, and the computation is still being performed; in such a case, the useful information is in suggestedPollingInterval)

Parameters:
token - the token for which the entry should be obtained
Returns:
the entry or null (if there is no entry for this token)

isActive

public boolean isActive()

shutdown

public void shutdown()


Copyright (c) 2011, iPlant Collaborative, University of Arizona, Cold Spring Harbor Laboratories, University of Texas at Austin.