jpl.mipl.mdms.FileService.komodo.services.query.client
Class QueryClient

java.lang.Object
  extended by jpl.mipl.mdms.FileService.komodo.services.query.client.QueryClient
All Implemented Interfaces:
Closable

public class QueryClient
extends Object
implements Closable

Client-end to the FeiQ web service

Version:
$Id: QueryClient.java,v 1.6 2007/09/26 00:06:50 ntt Exp $
Author:
Nicholas Toole (Nicholas.T.Toole@jpl.nasa.gov)

Field Summary
protected  Random _random
           
protected  int max_size
           
 
Constructor Summary
QueryClient(QLoginInfo loginInfo, Map options)
           
QueryClient(String serviceUrl, QLoginInfo loginInfo, Map options)
          Constructor
 
Method Summary
protected  Map<String,ClientRestartCache> attemptLoadCrcMap(boolean forceLoad)
          Will attempt to load the map of CRC's based on whether the RESTART option appears in the options map.
 int close()
          Method to close this admin channel.
protected  void completeSystemQuery(Map<String,ClientRestartCache> crcMap)
          Called prior to a query creation.
protected  Date getDateFromCacheMap(String filetype, Map<String,ClientRestartCache> restartCacheMap)
          Extracts the Date associated with a filetype from the map if found.
 QLoginInfo getLoginInfo()
           
 String getServerGroup()
           
 String getServiceUrlString()
          Accessor method to get the service URL as string
 int getTransactionCount()
           
 int getTransactionId()
          Get new transaction id.
protected  void init()
           
protected  void initSystemQuery()
           
 boolean isAlive()
           
 boolean isQueryActive()
           
 Result result()
          Read next result from this client.
 int sendQuery()
          Sends single query.
 void setUserQuery(QueryList query)
           
 int subscribeQuery()
          Subscribes a query.
 int unsubscribeQuery()
          Kills a query subscription.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

max_size

protected int max_size

_random

protected Random _random
Constructor Detail

QueryClient

public QueryClient(QLoginInfo loginInfo,
                   Map options)
            throws SessionException
Throws:
SessionException

QueryClient

public QueryClient(String serviceUrl,
                   QLoginInfo loginInfo,
                   Map options)
            throws SessionException
Constructor

Parameters:
serviceUrl - The query service URL
loginInfo - Session login information for service
options - Map of options, can contain output, restart, date filters, date format, file expressions
Throws:
SessionException - when failed to initialize
Method Detail

init

protected void init()
             throws SessionException
Throws:
SessionException

initSystemQuery

protected void initSystemQuery()
                        throws SessionException
Throws:
SessionException

getServiceUrlString

public final String getServiceUrlString()
Accessor method to get the service URL as string

Returns:
the service URL

getServerGroup

public final String getServerGroup()

getLoginInfo

public final QLoginInfo getLoginInfo()

setUserQuery

public void setUserQuery(QueryList query)

sendQuery

public int sendQuery()
              throws SessionException
Sends single query.

Returns:
proxy transaction id
Throws:
SessionException - if error occurs

subscribeQuery

public int subscribeQuery()
                   throws SessionException
Subscribes a query.

Returns:
proxy transaction id
Throws:
SessionException - if error occurs

unsubscribeQuery

public int unsubscribeQuery()
                     throws SessionException
Kills a query subscription.

Returns:
proxy transaction id
Throws:
SessionException - if error occurs

result

public Result result()
              throws SessionException
Read next result from this client. Can block until result is available. Return value may be null, so caller should quit when getTransactionCount() returns 0.

Returns:
Next Result instance
Throws:
SessionException - if error occurs

isQueryActive

public boolean isQueryActive()

close

public final int close()
Method to close this admin channel. Do this by appending the close command at the head of the requests queue. The ServerProxy will then remove any admin requests for from the request queue. If all referneces, file types and admin for this server have been closed, then the connection to the server will be gracefully closed.

Specified by:
close in interface Closable
Returns:
the transaction id for tracking this command.

getTransactionId

public int getTransactionId()
Get new transaction id. Also increments the transaction count.

Returns:
the transaction id

getTransactionCount

public int getTransactionCount()

isAlive

public boolean isAlive()

attemptLoadCrcMap

protected Map<String,ClientRestartCache> attemptLoadCrcMap(boolean forceLoad)
                                                    throws SessionException
Will attempt to load the map of CRC's based on whether the RESTART option appears in the options map. Caller can force loading by passing true as the parameter.

Parameters:
forceLoad - Forces caches to be loaded
Throws:
SessionException - if error occurs

getDateFromCacheMap

protected Date getDateFromCacheMap(String filetype,
                                   Map<String,ClientRestartCache> restartCacheMap)
                            throws SessionException
Extracts the Date associated with a filetype from the map if found. Otherwise null will be returned.

Parameters:
filetype - Name of the file type for which a date is requested
restartCacheMap - Map of ClientRestartCache instances that contain restart info
Returns:
Date of last query, if defined for filetype
Throws:
SessionException - if error occurs

completeSystemQuery

protected void completeSystemQuery(Map<String,ClientRestartCache> crcMap)
                            throws SessionException
Called prior to a query creation. This method examines any filetype specific filters, such as last mod times for subscriptions.

Parameters:
crcMap - Map of client restart caches for filetypes
Throws:
SessionException - if error occurs