gov.bnl.star.offline.scheduler
Class CatalogQuery

java.lang.Object
  extended by gov.bnl.star.offline.scheduler.CatalogQuery
All Implemented Interfaces:
java.io.Serializable

public class CatalogQuery
extends java.lang.Object
implements java.io.Serializable

Encapsulate a query to the file catalog. This class is a wrapper around a URI that describes a file catalog query. The syntax of the URI is:

catalog:catalogName?query

catalogName is the name that identifies the catalog that should resolve the query. If can be directly a machine name, or a more abstract name that can be resolved to a specific machine at a later time.

query is the actual query to pass to the catalog. The syntax of the query is the one defined by the perl interface.

Different counting methods can be used. By counting methods, we mean the method used by the query resolver to decide how many and which records to return. Right now, two methods are supported:

START-LIMIT, which maps directly to the SQL START LIMIT definition. One can think the result returned as a view on the total result. Basically, only the records between start and start+limit are returned. By executing the same query with a different start, one can view all the result a chunk at a time.

NFILES, which returns a given number of files (that is of records) in no particular order. The query resolver is allowed to return whatever files it decides. This allows the query resolver to perform optimizations.

Version:
$Revision: 1.28 $ $Date: 2006/11/21 00:41:32 $
Author:
Gabriele Carcassi
See Also:
Serialized Form

Field Summary
static int NFILES_COUNTING
          The method to specify how many records to return is by returning the specified number of valid records.
static int NO_COUNTING
          No method for determine how long the result should be was specified.
static int START_LIMIT_COUNTING
          The method to specify how many records to return is the SQL START and LIMIT model.
 
Constructor Summary
CatalogQuery()
           
CatalogQuery(CatalogQuery query)
          Creates a copy of a given query.
CatalogQuery(java.lang.String uri)
          Creates a query to the file catalog.
 
Method Summary
 void addToEventsReturned(int eventsReturned)
           
 void filesReturned()
           
 java.util.List getAttributes()
          Getter for property attributes.
 java.lang.String getCatalogName()
          Returns the catalog to which the query should be sent.
 int getCountingType()
          Returns the counting method used to decide how many records the query should return.
 int getEventsReturned()
           
 int getFilesReturned()
           
 java.lang.Integer getLimit()
          Returns the number of records this query should return.
 java.lang.Integer getNFiles()
          Returns the number of files the query should return.
 java.lang.String getPreferStorage()
          Tells which copy is preferred in case more than one copy for the same file is found.
 java.lang.String getQuery()
          Returns the query to be passed to the file catalog.
 java.lang.Integer getStart()
          Returns the first element to be returned.
 boolean isSingleCopy()
          Tells whether single copy or multiple copies for the same file should be returned.
 void setAttributes(java.util.List attributes)
          Setter for property attributes.
 void setEventsReturned(int eventsReturned)
           
 void setFilesReturned(int filesReturned)
           
 void setLimit(java.lang.Integer limit)
          Sets the number of records this query should return.
 void setNFiles(java.lang.Integer nFiles)
          Sets the number of files the query should return.
 void setPreferStorage(java.lang.String preferStorage)
          Sets which copy is preferred in case of more than one copy for the same file is found.
 void setSingleCopy(boolean singleCopy)
          Sets whether single copy or multiple copies for the same file should be returned.
 void setStart(java.lang.Integer start)
          Sets the first element to be returned.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_COUNTING

public static final int NO_COUNTING
No method for determine how long the result should be was specified.

See Also:
Constant Field Values

START_LIMIT_COUNTING

public static final int START_LIMIT_COUNTING
The method to specify how many records to return is the SQL START and LIMIT model.

See Also:
Constant Field Values

NFILES_COUNTING

public static final int NFILES_COUNTING
The method to specify how many records to return is by returning the specified number of valid records. Any records in any order can be returned.

See Also:
Constant Field Values
Constructor Detail

CatalogQuery

public CatalogQuery(java.lang.String uri)
Creates a query to the file catalog. The query is specified by a URI in this form: catalog:catalogName?query

catalogName defines which catalog to look. For example, star.bnl.gov specifies the STAR catalog.

query is the query that will be used to search for the entry. The exact syntax is specified by the catalog itself. For STAR, it is a series of comma separated assignments between keywords and values.

Parameters:
uri - specifies the full uri: ex. catalog:star.bnl.gov:collision=AuAu200,storage=local

CatalogQuery

public CatalogQuery(CatalogQuery query)
Creates a copy of a given query. The new query has the same URI and optional parameters, except the counting method, which is not set.

Parameters:
query - the query to be copied

CatalogQuery

public CatalogQuery()
Method Detail

getEventsReturned

public int getEventsReturned()

setEventsReturned

public void setEventsReturned(int eventsReturned)

addToEventsReturned

public void addToEventsReturned(int eventsReturned)

getFilesReturned

public int getFilesReturned()

setFilesReturned

public void setFilesReturned(int filesReturned)

filesReturned

public void filesReturned()

getCatalogName

public java.lang.String getCatalogName()
Returns the catalog to which the query should be sent.

This method is provided for forward compatibility and is not actually used

Returns:
the name of a machine

getQuery

public java.lang.String getQuery()
Returns the query to be passed to the file catalog.

Returns:
the query as specified by the file catalog.

getLimit

public java.lang.Integer getLimit()
Returns the number of records this query should return.

Returns:
number of files the query will return

setLimit

public void setLimit(java.lang.Integer limit)
Sets the number of records this query should return.

Parameters:
limit - number of files returned by the query

getStart

public java.lang.Integer getStart()
Returns the first element to be returned. In conjuction with limit you can scroll all the list.

Returns:
row of the first element to be returned

setStart

public void setStart(java.lang.Integer start)
Sets the first element to be returned. In conjuction with limit you can scroll all the list.

Parameters:
start - row of the first element to be returned

isSingleCopy

public boolean isSingleCopy()
Tells whether single copy or multiple copies for the same file should be returned.

Returns:
true if the query should return only one copy for each file in the catalog

getPreferStorage

public java.lang.String getPreferStorage()
Tells which copy is preferred in case more than one copy for the same file is found.

Returns:
a String representing a storage (es. "local", "NFS", ... )

setPreferStorage

public void setPreferStorage(java.lang.String preferStorage)
Sets which copy is preferred in case of more than one copy for the same file is found.

Parameters:
preferStorage - a String representing a storage (es. "local", "NFS", ... )

setSingleCopy

public void setSingleCopy(boolean singleCopy)
Sets whether single copy or multiple copies for the same file should be returned.

Parameters:
singleCopy - true if the query should return only one copy for each file in the catalog

getNFiles

public java.lang.Integer getNFiles()
Returns the number of files the query should return. The files returned by the query if this counting method is used.

Returns:
the number of files returned by the query, or null if this counting method is not used

setNFiles

public void setNFiles(java.lang.Integer nFiles)
Sets the number of files the query should return. Files are returned in no particular order.

Parameters:
nFiles - the number of files to be returned by the query.

getCountingType

public int getCountingType()
Returns the counting method used to decide how many records the query should return.

Returns:
NO_COUNTING, START_LIMIT_COUNTING or NFILES_COUNTING depending on the counting method defined on the query

getAttributes

public java.util.List getAttributes()
Getter for property attributes.

Returns:
Value of property attributes.

setAttributes

public void setAttributes(java.util.List attributes)
Setter for property attributes.

Parameters:
attributes - New value of property attributes.


Copyright © 2002-2004 STAR collaboration - Brookhaven National Laboratory. All Rights Reserved.