|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.TimerTask edu.sdsc.inca.consumer.DepotQuery
public class DepotQuery
Handles the prefetching and caching of HQL queries to the depot. The HQL queries allow users to request customized data from the depot. In the event that a query takes a long time to load, this class can be used to continuously query results from the depot and store them. The advantage of this is that whenever requests are made on the consumer for the data, the latest cached data can be returned immediately rather than waiting for the lengthy query to complete. Furthermore, it will reduce the load on the consumer and depot. If a cached query has parameters, it is a template for cached queries (e.g., get latest suite results for suite X)
Field Summary | |
---|---|
static java.lang.String |
QUERYDIR
|
Constructor Summary | |
---|---|
DepotQuery(int period,
java.lang.String reloadAt,
java.lang.String tempDir,
java.lang.String name,
java.lang.String command,
java.lang.Object... params)
Create a new cache query thread for the specified query. |
Method Summary | |
---|---|
java.io.File |
getCacheFile()
Return the handle of the file used to store the query result. |
java.lang.String |
getCommand()
Return the depot command being used to fetch data from the depot. |
static java.util.Properties |
getDepotConfig()
Get the configuration for connecting to the depot. |
java.lang.String |
getFreshResult()
Query the depot and return the results (rows) as an XmlBean |
long |
getNextRefresh()
Check the age of the cached file and return the number of milliseconds before it should be refreshed again. |
java.lang.Object[] |
getParams()
Return the depot command params being used to fetch data from the depot. |
int |
getPeriod()
Returns the frequency of queries to the depot. |
java.lang.String |
getQueryName()
Returns the name of the query. |
java.lang.String |
getReloadAt()
Set the reload start time. |
java.lang.String |
getStoredResult()
Returns the latest result of the query stored in the file cache. |
java.lang.String |
query()
Send a query to the depot. |
static java.lang.String |
query(java.lang.String command,
java.lang.Object... params)
Send a query to the depot. |
void |
refresh()
Query the depot for a new result and store it in the cache |
void |
run()
Will first check to see if there is a result already stored on disk and if so, will check to see how fresh it is. |
void |
setCommand(java.lang.String command)
Set the depot query command being used to fetch data from the depot. |
static void |
setDepotConfig(java.util.Properties depotConfig)
Set the configuration for connecting to the depot. |
void |
setParams(java.lang.Object[] params)
Set the depot query command parameters being used to fetch data from the depot. |
void |
setPeriod(int period)
Set the frequency of queries to the depot. |
void |
setQueryName(java.lang.String name)
Set the name of the query. |
void |
setReloadAt(java.lang.String reloadAt)
Set the reload start time |
java.lang.String |
toString()
Return the query information as a string |
Methods inherited from class java.util.TimerTask |
---|
cancel, scheduledExecutionTime |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String QUERYDIR
Constructor Detail |
---|
public DepotQuery(int period, java.lang.String reloadAt, java.lang.String tempDir, java.lang.String name, java.lang.String command, java.lang.Object... params)
period
- The frequency of which the consumer should prefetch the
queryreloadAt
- Should be "*" if we don't care about the time the query
is started otherwise should be WW:HH:MM.tempDir
- A temporary directory where queries can be cachedname
- The name of the query (may contain whitespace)command
- The depot query commandparams
- The parameters for the query commandMethod Detail |
---|
public java.io.File getCacheFile()
public java.lang.String getCommand()
public static java.util.Properties getDepotConfig()
public long getNextRefresh()
public java.lang.Object[] getParams()
public int getPeriod()
public java.lang.String getQueryName()
public java.lang.String getReloadAt()
public java.lang.String getStoredResult()
public java.lang.String getFreshResult() throws edu.sdsc.inca.ConfigurationException, java.io.IOException, edu.sdsc.inca.protocol.ProtocolException
edu.sdsc.inca.ConfigurationException
- if complete or incorrect depot parameters
java.io.IOException
- if trouble connecting to depot
edu.sdsc.inca.protocol.ProtocolException
- if trouble talking to depotpublic java.lang.String query() throws edu.sdsc.inca.ConfigurationException, java.io.IOException
edu.sdsc.inca.ConfigurationException
- if problem with depot contact info
java.io.IOException
- iif trouble connecting to depotpublic static java.lang.String query(java.lang.String command, java.lang.Object... params) throws edu.sdsc.inca.ConfigurationException, java.io.IOException
command
- The query command to call on the depot client
(e.g., querySuite, queryHql, etc.)params
- The parameters for the query command
edu.sdsc.inca.ConfigurationException
- if problem with depot contact info
java.io.IOException
- iif trouble connecting to depotpublic void run()
run
in interface java.lang.Runnable
run
in class java.util.TimerTask
public void refresh() throws edu.sdsc.inca.ConfigurationException, java.io.IOException, edu.sdsc.inca.protocol.ProtocolException
edu.sdsc.inca.ConfigurationException
- if unable to read depot config params
java.io.IOException
- if unable to contact depot
edu.sdsc.inca.protocol.ProtocolException
- if trouble talking to depotpublic void setCommand(java.lang.String command)
command
- A string containing a depot query commandpublic static void setDepotConfig(java.util.Properties depotConfig)
depotConfig
- A properties list containing config parameters for
connecting to the depot.public void setParams(java.lang.Object[] params)
params
- A string array containing parameters for a depot query
commandpublic void setPeriod(int period)
period
- Set the number of seconds used to wait before querying the
depot again.public void setQueryName(java.lang.String name)
name
- A string containing the name of the HQL query.public void setReloadAt(java.lang.String reloadAt)
reloadAt
- Should be "*" if we don't care about the time the query
is started otherwise should be WW:HH:MM.public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |