uk.ac.ic.doc.automed.p2p.protocol
Class QEP

java.lang.Object
  extended by uk.ac.ic.doc.automed.p2p.protocol.QEP

public class QEP
extends java.lang.Object


Field Summary
private  AutoMedPeer _mainPeer
           
private  ObjectCache _qcache
           
private static QEP _qep
           
private  java.util.concurrent.ExecutorService brokerService
           
 
Constructor Summary
private QEP(AutoMedPeer mainPeer)
          Creates a new instance of QEP
 
Method Summary
private  void cacheQuery(java.lang.String msgID, java.lang.String qID)
           
static java.util.Properties convertQiToCommProps(java.util.Properties props, RuntimeParameters params)
          Convert selected quality indicator parameters into communication properties
 AbstractMessage executeQuery(AbstractMessage request)
          Execute query and return result (server-side).
 java.util.Map executeQuery(java.lang.String query, java.lang.String schema, QueryProcessorConfiguration qpc)
          This method should be used as the first invocation by the user application.
It is a controller method in that it reads the application parameters to decide a suitable course of action for the query.
 AbstractMessage executeQuery(java.lang.String query, java.lang.String schema, QueryProcessorConfiguration qpc, PeerProcessDescription destPeer)
          Send a query to the network for execution (client-side).
static QEP getQEPInstance(AutoMedPeer mainPeer)
          Return a single QEP instance per JVM
private  boolean isInCache(java.lang.String msgID, java.lang.String qID)
           
private  void registerPeerHandlers()
          Peer: Register message handlers on the peer
protected  AbstractMessage sendGroupQuery(AbstractMessage request, java.lang.String query, java.lang.String schema, RuntimeParameters params, java.util.Collection brokerPeers)
          Send a query to a set of peers
private  AbstractMessage sendQuery(AbstractMessage request, java.lang.String query, java.lang.String schema, RuntimeParameters params, PeerProcessDescription destPeer)
          Process a query message and forward it on to the next target peer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_qep

private static QEP _qep

_mainPeer

private AutoMedPeer _mainPeer

brokerService

private java.util.concurrent.ExecutorService brokerService

_qcache

private ObjectCache _qcache
Constructor Detail

QEP

private QEP(AutoMedPeer mainPeer)
Creates a new instance of QEP

Method Detail

getQEPInstance

public static QEP getQEPInstance(AutoMedPeer mainPeer)
Return a single QEP instance per JVM


sendGroupQuery

protected AbstractMessage sendGroupQuery(AbstractMessage request,
                                         java.lang.String query,
                                         java.lang.String schema,
                                         RuntimeParameters params,
                                         java.util.Collection brokerPeers)
                                  throws CommunicationException,
                                         AutoMedException
Send a query to a set of peers

Parameters:
queryDesc -
destPeer -
Returns:
Throws:
CommunicationException
AutoMedException

sendQuery

private AbstractMessage sendQuery(AbstractMessage request,
                                  java.lang.String query,
                                  java.lang.String schema,
                                  RuntimeParameters params,
                                  PeerProcessDescription destPeer)
                           throws CommunicationException,
                                  AutoMedException
Process a query message and forward it on to the next target peer.

Parameters:
request -
query -
schema -
params -
destPeer -
Returns:
Throws:
CommunicationException
AutoMedException

executeQuery

public AbstractMessage executeQuery(java.lang.String query,
                                    java.lang.String schema,
                                    QueryProcessorConfiguration qpc,
                                    PeerProcessDescription destPeer)
                             throws CommunicationException,
                                    AutoMedException
Send a query to the network for execution (client-side).
This method is used by the application to invoke the process of executing a query message over a specific target peer.

Parameters:
qpc - a QueryProcessorConfiguration object of the query to be sent
destPeer - a PeerProcessDescription object of the destination peer to which the query is sent
Returns:
AbstractMessage result of query execution
Throws:
CommunicationException
AutoMedException

convertQiToCommProps

public static java.util.Properties convertQiToCommProps(java.util.Properties props,
                                                        RuntimeParameters params)
Convert selected quality indicator parameters into communication properties


executeQuery

public java.util.Map executeQuery(java.lang.String query,
                                  java.lang.String schema,
                                  QueryProcessorConfiguration qpc)
                           throws CommunicationException,
                                  AutoMedException
This method should be used as the first invocation by the user application.
It is a controller method in that it reads the application parameters to decide a suitable course of action for the query.

Parameters:
query - the use query
schema - the public schema on which the query is to be evaluated
qpc - a query processor configuration object
targetPeers - a set of peers on which the query will be evaluated
Returns:
Map of peer to ASG result
Throws:
CommunicationException
AutoMedException

executeQuery

public AbstractMessage executeQuery(AbstractMessage request)
Execute query and return result (server-side). This method is invoked by intermediate peers as part of the query execution process.

Parameters:
request - AbstractMessage received from the network
Returns:
AbstractMessage the message to send back to client

cacheQuery

private void cacheQuery(java.lang.String msgID,
                        java.lang.String qID)

isInCache

private boolean isInCache(java.lang.String msgID,
                          java.lang.String qID)

registerPeerHandlers

private void registerPeerHandlers()
Peer: Register message handlers on the peer