Gnutella::PacketProcessing::DynamicSearching::DynamicSearch Class Reference

#include <DynamicSearch.h> [code]

Inherits QObject.

Inheritance diagram for Gnutella::PacketProcessing::DynamicSearching::DynamicSearch:

Inheritance graph
[legend]
Collaboration diagram for Gnutella::PacketProcessing::DynamicSearching::DynamicSearch:

Collaboration graph
[legend]
List of all members.

Detailed Description

Todo:
What about dynamic quering with leaf guidance? What about apllication filters? We should search until the searcher says they got enough results.

Definition at line 38 of file DynamicSearch.h.

Public Types

typedef QList< PacketSession * > Sessions

Signals

void searchStopped (const Query &)
void statusRequest (const QueryStatusRequest &)

Public Member Functions

 DynamicSearch (const Query &, Sessions)
 ~DynamicSearch ()
void startSearch ()
void stopSearch ()
void countHits (const QueryHits &)
 Counts the hits in the QueryHits packet.
void countHits (const QueryStatusResponse &)
 Reads the hits count from the QueryStatusResponse packet.
void addSession (PacketSession *session)
 Adds a new session to the list of sessions which can be queried.
void removeSession (PacketSession *session)
 Removes a session that is no longer available from the internal list.

Private Slots

void timeout ()
 The slot which processes timer events.

Private Member Functions

 DynamicSearch (const DynamicSearch &)
DynamicSearchoperator= (const DynamicSearch &)
bool hasEnoughHits ()
void doProbeQuery ()
 Sends a probe query over one or more connections.
void doQuery ()
 Sends a query to one or more connections.
void sendPacket (quint16 sessionsCount, bool dropSessions=true)
 Sends the query packet over sessionsCount sessions.
void sendStatusRequest ()
 Send a QueryStatusRequest packet.
quint32 hostsPerConnection (quint16 ttl)
 Calculates the number of host that are reachable within the given ttl.
qint16 computeTtl (quint32 hostToQuery, quint16 numConnections)
 Returns the ttl required to reach hostsToQuery over numSessions.

Private Attributes

DynamicSearchPrivatep


Member Typedef Documentation

typedef QList<PacketSession *> Gnutella::PacketProcessing::DynamicSearching::DynamicSearch::Sessions
 

Definition at line 44 of file DynamicSearch.h.


Constructor & Destructor Documentation

Gnutella::PacketProcessing::DynamicSearching::DynamicSearch::DynamicSearch const DynamicSearch  )  [private]
 

DynamicSearch::DynamicSearch const Query ,
Sessions 
 

Definition at line 78 of file DynamicSearch.cpp.

DynamicSearch::~DynamicSearch  ) 
 

Definition at line 88 of file DynamicSearch.cpp.


Member Function Documentation

void DynamicSearch::addSession PacketSession session  ) 
 

Adds a new session to the list of sessions which can be queried.

Definition at line 242 of file DynamicSearch.cpp.

qint16 DynamicSearch::computeTtl quint32  hostToQuery,
quint16  numConnections
[private]
 

Returns the ttl required to reach hostsToQuery over numSessions.

Definition at line 269 of file DynamicSearch.cpp.

void DynamicSearch::countHits const QueryStatusResponse response  ) 
 

Reads the hits count from the QueryStatusResponse packet.

The QueryStatusResponse packet contains the number of hits that passed all client-side filters. This number should be used when calculating parameters for the next round of the dynamic search.

Definition at line 223 of file DynamicSearch.cpp.

void DynamicSearch::countHits const QueryHits  ) 
 

Counts the hits in the QueryHits packet.

Definition at line 210 of file DynamicSearch.cpp.

void DynamicSearch::doProbeQuery  )  [private]
 

Sends a probe query over one or more connections.

A probe query (over one or more connections) is sent in the beginning of each new search in order to gain some initial knowledge about the popularity of the given query.

The dynamic search is further performed in sendQuery().

Definition at line 120 of file DynamicSearch.cpp.

void DynamicSearch::doQuery  )  [private]
 

Sends a query to one or more connections.

Called for each query step (normally after a timeout elapses). Calculates the TTL of the query, and the number of connections to send it over.

An initial query whose aim is to "probe" the popularity of the search is sent by sendProbeQuery().

Definition at line 142 of file DynamicSearch.cpp.

bool DynamicSearch::hasEnoughHits  )  [private]
 

Definition at line 105 of file DynamicSearch.cpp.

quint32 DynamicSearch::hostsPerConnection quint16  ttl  )  [private]
 

Calculates the number of host that are reachable within the given ttl.

Definition at line 255 of file DynamicSearch.cpp.

DynamicSearch& Gnutella::PacketProcessing::DynamicSearching::DynamicSearch::operator= const DynamicSearch  )  [private]
 

void DynamicSearch::removeSession PacketSession session  ) 
 

Removes a session that is no longer available from the internal list.

Definition at line 249 of file DynamicSearch.cpp.

void Gnutella::PacketProcessing::DynamicSearching::DynamicSearch::searchStopped const Query  )  [signal]
 

void DynamicSearch::sendPacket quint16  sessionsCount,
bool  dropSessions = true
[private]
 

Sends the query packet over sessionsCount sessions.

The function sends the query over sessionsCount sessions. If dropSessions is true, then the sessions will be removed from the list and not query will be send again over any of them. If dropSessions is false, then the sessions will be moved to the back of the sessions list and could be queried again later. The latter is useful for the session over which we send the probe queries (see doProbeQuery())

Definition at line 293 of file DynamicSearch.cpp.

void DynamicSearch::sendStatusRequest  )  [private]
 

Send a QueryStatusRequest packet.

Sends a QueryStatusRequest packet to request the client to report the number hits that have passed the client's filters. After sending the request the DynamicSearch will wait for the QueryStatusResponse packet before performing the next round of the dynamic search algorithm.

Definition at line 173 of file DynamicSearch.cpp.

void DynamicSearch::startSearch  ) 
 

Definition at line 93 of file DynamicSearch.cpp.

void Gnutella::PacketProcessing::DynamicSearching::DynamicSearch::statusRequest const QueryStatusRequest  )  [signal]
 

void DynamicSearch::stopSearch  ) 
 

Definition at line 99 of file DynamicSearch.cpp.

void DynamicSearch::timeout  )  [private, slot]
 

The slot which processes timer events.

Definition at line 184 of file DynamicSearch.cpp.


Member Data Documentation

DynamicSearchPrivate* Gnutella::PacketProcessing::DynamicSearching::DynamicSearch::p [private]
 

Definition at line 75 of file DynamicSearch.h.


The documentation for this class was generated from the following files: