dods.servers.agg
Class CacheDataset

java.lang.Object
  extended by dods.servers.agg.CacheDataset

public class CacheDataset
extends Object

This keeps a cache of Datasets, up to maxCached, and closes old ones based on a simple LRU algorithm. Supposed to be thread safe. The dataset mutex lock is acquired if successful.

Version:
$Id: CacheDataset.java,v 1.3 2004/02/06 15:23:49 donm Exp $
Author:
John Caron

Constructor Summary
CacheDataset(DatasetFactory factory, String cacheName, int maxCached)
           
 
Method Summary
 Dataset acquire(String extPath, String intPath, InvCatalog.Dataset invDS)
          This finds the named dataset and gets a lock on it.
 Iterator getCache()
          FOR DEBUGUGGING ONLY
 int getCacheSize()
          get current size of the cache.
 void setCacheMax(int maxCached)
          set maximum size of cache.
 void setWaitTime(long wait)
          set maximum time to wait before opening another copy of the dataset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheDataset

public CacheDataset(DatasetFactory factory,
                    String cacheName,
                    int maxCached)
Parameters:
cacheName - name of cache (for debug messages)
maxCached - maximum number to cache (<= 0 means unlimited)
Method Detail

setCacheMax

public void setCacheMax(int maxCached)
set maximum size of cache.


setWaitTime

public void setWaitTime(long wait)
set maximum time to wait before opening another copy of the dataset.

Parameters:
wait - : time in msec

getCacheSize

public int getCacheSize()
get current size of the cache.


getCache

public Iterator getCache()
FOR DEBUGUGGING ONLY


acquire

public Dataset acquire(String extPath,
                       String intPath,
                       InvCatalog.Dataset invDS)
                throws IOException
This finds the named dataset and gets a lock on it. WARNING: you better call ds.release() when you are done or you are SOL!!!

Parameters:
extPath - : external URL of dataset
intPath - : internal URL of dataset
invDS - : InvCatalog.Dataset object
Returns:
locked dataset, or null if no room in cache for it.
Throws:
IOException