uk.ac.ic.doc.automed.p2p.qproc.planner
Class QPlannerMain

java.lang.Object
  extended by uk.ac.ic.doc.automed.p2p.qproc.planner.QPlannerMain
All Implemented Interfaces:
QPlannerAlgorithmRecursive

public class QPlannerMain
extends java.lang.Object
implements QPlannerAlgorithmRecursive


Nested Class Summary
(package private)  class QPlannerMain.Timer
          Timer for each peer to time-out its processing
 
Field Summary
private static java.lang.String BANNER_END
           
private static java.lang.String BANNER_START
           
private  AppContext cxt
           
protected  boolean debug
           
protected  boolean debugAll
           
protected  boolean debugDetailed
           
protected static java.util.List eventHandlers
           
private  Indexer indexer
           
private static long instanceCount
           
protected  long instanceID
           
private static java.lang.String line
           
private  java.util.Map lookUpCache
           
private  Match matcher
           
private  java.lang.Object myMsgID
           
protected  QueryPlannerResult myQPlannerResult
           
protected  ObjectCache objCache
           
private  Match objMatcher
           
protected static int section
           
protected  java.util.concurrent.ExecutorService threadPool
           
protected  QPlannerMain.Timer timer
           
private  java.util.Map timers
           
 
Constructor Summary
QPlannerMain(AppContext cxt)
           
 
Method Summary
 void addEventHandler(P2PListener listener)
           
private  void addFetchMappingHandler()
          Prepare a protocol handler for handling top-k mapping request
private  void addGetCoverageStatsHandler()
          Prepare a handler for top-k mapping request
private  void addKQueryResultHandler()
          Add a handler to handle the event of receiving the k-query result
private  void addLookUpWithFilterHandler()
          Add a handler to handle look-up with filter function
 void clear()
           
private  void execute(QueryPlannerResult qpresult)
          Execution performed by each internal peer or root peer.
private  void executeInit(RuntimeParameters params)
          Invoked by the query peer to plan the processing of the query
 java.lang.Object fetchMappings(java.lang.Object dhtIDAndAddress, RuntimeParameters params)
          This method is used by a user-application wanting to request the next top-k mapppings
private  java.util.Map fetchMappings(RuntimeParameters params)
          Method to process top-k mapping message
 void fireEvent(int event, java.lang.Object data)
           
private  java.util.Map getCoverageSetStats(RuntimeParameters params)
          Method to process get-coverageset message.
Obtain statistics about all the coverage sets of a given k-edge
 java.lang.Object getCoverageSetStats(RuntimeParameters params, java.lang.Object dhtIDAddress)
          This method is used by a user-application the coverage set statistics
static java.lang.String getName()
           
protected  void gmatch(Node n, java.util.Collection kedges, Graph qgraph)
          perform local matching of the schema graphs matching a given k-edge
protected  java.io.Serializable handle_LUP_WFILTER(ow.id.ID key, QueryPlannerResult qpresult, RuntimeParameters params, boolean forward)
           
 java.lang.Object[] handleResult(java.lang.Object result)
          Handle the search results returned by peers.
private  void init(RuntimeParameters params)
          Initialise caching based on the handler object of the query planner result that this planner has received
protected  void initDebug(RuntimeParameters params)
           
 boolean isIConfigBPF(RuntimeParameters params)
           
private  boolean isMyMessage(RuntimeParameters params)
          Return true if a DHT message has the same id as the message id of this object
protected  boolean match(Node n, java.util.Collection ngraphs, Node nj, java.util.Collection njgraphs, RuntimeParameters params, QueryPlannerResult qpresult)
          Match a pair of k-nodes using the corresponding HDM graphs that are mapped to them.
 QueryPlannerResult plan(ow.id.ID key, Graph query, RuntimeParameters params)
          The main method to execute the matchgraphtopkp2p() algorithm.
private  QueryPlannerResult plan(ow.id.ID key, RuntimeParameters params)
          invoked by methods that are involved in processing the current query of this object
protected  void postExecute(Node knode)
          Invoked to perform post-processing.
protected  void preExecute(Node knode)
          Invoked by internal or root peer to match its k-node with the leaf child k-node (of its sub-tree), from which this call was initiated.
In other words, this method is invoked each time a leaf child k-node has completed its processing and forwarded the result to this node (its parent).
private  void prematching()
          Ensures that necessary resources are available for matching.
private  void updateResult(QueryPlannerResult source, QueryPlannerResult target, int topK, boolean memOnly)
          Update the query planner result with information from the query planner result of this object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myQPlannerResult

protected QueryPlannerResult myQPlannerResult

instanceID

protected long instanceID

section

protected static final transient int section
See Also:
Constant Field Values

debug

protected transient boolean debug

debugDetailed

protected transient boolean debugDetailed

debugAll

protected transient boolean debugAll

eventHandlers

protected static java.util.List eventHandlers

objCache

protected transient ObjectCache objCache

instanceCount

private static transient long instanceCount

objMatcher

private transient Match objMatcher

matcher

private transient Match matcher

timer

protected transient QPlannerMain.Timer timer

timers

private transient java.util.Map timers

lookUpCache

private transient java.util.Map lookUpCache

threadPool

protected transient java.util.concurrent.ExecutorService threadPool

BANNER_START

private static final transient java.lang.String BANNER_START
See Also:
Constant Field Values

BANNER_END

private static final transient java.lang.String BANNER_END
See Also:
Constant Field Values

line

private static final transient java.lang.String line
See Also:
Constant Field Values

cxt

private AppContext cxt

indexer

private Indexer indexer

myMsgID

private java.lang.Object myMsgID
Constructor Detail

QPlannerMain

public QPlannerMain(AppContext cxt)
Method Detail

getName

public static java.lang.String getName()

initDebug

protected void initDebug(RuntimeParameters params)

init

private void init(RuntimeParameters params)
Initialise caching based on the handler object of the query planner result that this planner has received


plan

private QueryPlannerResult plan(ow.id.ID key,
                                RuntimeParameters params)
                         throws QProcException
invoked by methods that are involved in processing the current query of this object

Parameters:
key -
params -
Returns:
Throws:
QProcException

plan

public QueryPlannerResult plan(ow.id.ID key,
                               Graph query,
                               RuntimeParameters params)
                        throws QProcException
The main method to execute the matchgraphtopkp2p() algorithm.

Specified by:
plan in interface QPlannerAlgorithmRecursive
Parameters:
key -
graph -
config -
Returns:
Throws:
QProcException

executeInit

private void executeInit(RuntimeParameters params)
Invoked by the query peer to plan the processing of the query

Parameters:
initPeer - the query peer
params - query message parameters
graph - query graph
qpresult - result object to store answers or answer statistics (depending on the algorithm)

execute

private void execute(QueryPlannerResult qpresult)
              throws QProcException
Execution performed by each internal peer or root peer.
It is possible that the same peer is mapped to more than one k-nodes of the query. To support this, we have to
keep a different timer for each keyword.

Parameters:
graph -
Throws:
QProcException

updateResult

private void updateResult(QueryPlannerResult source,
                          QueryPlannerResult target,
                          int topK,
                          boolean memOnly)
Update the query planner result with information from the query planner result of this object

Parameters:
qpresult -

gmatch

protected void gmatch(Node n,
                      java.util.Collection kedges,
                      Graph qgraph)
               throws QProcException
perform local matching of the schema graphs matching a given k-edge

Parameters:
initPeer -
n - the k-node that is the parent of a sub-tree of the k-query
graph -
Throws:
QProcException

prematching

private void prematching()
Ensures that necessary resources are available for matching.
For example, the k-query needs to be stored to the database, etc.


match

protected boolean match(Node n,
                        java.util.Collection ngraphs,
                        Node nj,
                        java.util.Collection njgraphs,
                        RuntimeParameters params,
                        QueryPlannerResult qpresult)
                 throws AutoMedException
Match a pair of k-nodes using the corresponding HDM graphs that are mapped to them.

Parameters:
n - the first k-node
ngraphs - the set of index graphs of the first k-node
nj - the second k-node (to be matched with the first k-node)
njgraphs - the set of index graphs of the second k-node
params -
qpresult - the query planner result object in which to store answers (mappings)
Returns:
Throws:
AutoMedException

handleResult

public java.lang.Object[] handleResult(java.lang.Object result)
                                throws QProcException
Handle the search results returned by peers. This method is invoked by the query peer on receipt of the result returned by peer

Specified by:
handleResult in interface QPlannerAlgorithmRecursive
Throws:
QProcException

preExecute

protected void preExecute(Node knode)
Invoked by internal or root peer to match its k-node with the leaf child k-node (of its sub-tree), from which this call was initiated.
In other words, this method is invoked each time a leaf child k-node has completed its processing and forwarded the result to this node (its parent).

Throws:
AutoMedException

postExecute

protected void postExecute(Node knode)
                    throws QProcException
Invoked to perform post-processing.

Throws:
QProcException

handle_LUP_WFILTER

protected java.io.Serializable handle_LUP_WFILTER(ow.id.ID key,
                                                  QueryPlannerResult qpresult,
                                                  RuntimeParameters params,
                                                  boolean forward)
                                           throws AutoMedException
Throws:
AutoMedException

addEventHandler

public void addEventHandler(P2PListener listener)
Specified by:
addEventHandler in interface QPlannerAlgorithmRecursive

fireEvent

public void fireEvent(int event,
                      java.lang.Object data)
Specified by:
fireEvent in interface QPlannerAlgorithmRecursive

clear

public void clear()
Specified by:
clear in interface QPlannerAlgorithmRecursive

isIConfigBPF

public boolean isIConfigBPF(RuntimeParameters params)

isMyMessage

private boolean isMyMessage(RuntimeParameters params)
Return true if a DHT message has the same id as the message id of this object


addKQueryResultHandler

private void addKQueryResultHandler()
Add a handler to handle the event of receiving the k-query result


addLookUpWithFilterHandler

private void addLookUpWithFilterHandler()
Add a handler to handle look-up with filter function


getCoverageSetStats

public java.lang.Object getCoverageSetStats(RuntimeParameters params,
                                            java.lang.Object dhtIDAddress)
This method is used by a user-application the coverage set statistics


addGetCoverageStatsHandler

private void addGetCoverageStatsHandler()
Prepare a handler for top-k mapping request


getCoverageSetStats

private java.util.Map getCoverageSetStats(RuntimeParameters params)
Method to process get-coverageset message.
Obtain statistics about all the coverage sets of a given k-edge

Parameters:
cfg -
Returns:

fetchMappings

public java.lang.Object fetchMappings(java.lang.Object dhtIDAndAddress,
                                      RuntimeParameters params)
This method is used by a user-application wanting to request the next top-k mapppings


addFetchMappingHandler

private void addFetchMappingHandler()
Prepare a protocol handler for handling top-k mapping request


fetchMappings

private java.util.Map fetchMappings(RuntimeParameters params)
Method to process top-k mapping message

Parameters:
cfg -
Returns: