|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface GuardedDataset
A GuardedDataset allows us to handle multithreaded stateful processing.
In a multi-threaded environment such as a Servlet, multiple requests for the same dataset may happen at the same time. This is a problem only when there is some state that is being maintained. Caching strategies (eg the netcdf server caches open netcdf files) may need to maintain state information in order to manage resources efficiently. All accesses to the DDS and DAS are made through the GuardedDataset. Typically the server puts a mutex lock on the resource when getDDS() or getDAS() is called. When the dataset processing is complete, release() is called, and the server releases the mutex. Example use:
public void doGetDAS(HttpServletRequest request,
HttpServletResponse response,
ReqState rs)
throws IOException, ServletException {
response.setContentType("text/plain");
response.setHeader("XDODS-Server", getServerVersion() );
response.setHeader("Content-Description", "dods-dds");
OutputStream Out = new BufferedOutputStream(response.getOutputStream());
GuardedDataset ds = null;
try {
ds = getDataset(rs);
DAS myDAS = ds.getDAS(); // server would lock here
myDAS.print(Out);
response.setStatus(response.SC_OK);
}
catch (DAP2Exception de){
dap2ExceptionHandler(de,response);
}
catch (ParseException pe) {
parseExceptionHandler(pe,response);
}
finally { // release lock if needed
if (ds != null) ds.release();
}
}
Its important that the DDS or DAS not be used after release() is called.
See opendap.servers.netcdf.NcDataset for example of implementing a locking
GuardedDataset.
If a server is not keeping state, it can simply pass the DDS and DAS without locking,
and implement a dummy release() method.
Method Summary | |
---|---|
DAS |
getDAS()
Get the DAS for this Dataset. |
ServerDDS |
getDDS()
Get the DDS for this Dataset. |
void |
release()
Release the lock, if any, on this dataset. |
Method Detail |
---|
ServerDDS getDDS() throws DAP2Exception, ParseException
DAP2Exception
ParseException
DAS getDAS() throws DAP2Exception, ParseException
DAP2Exception
ParseException
void release()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |