Package com.biglybt.core.content
Class RelatedContentSearcher
- java.lang.Object
-
- com.biglybt.core.content.RelatedContentSearcher
-
- All Implemented Interfaces:
DistributedDatabaseTransferHandler
public class RelatedContentSearcher extends java.lang.Object implements DistributedDatabaseTransferHandler
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
RelatedContentSearcher.ForeignBloom
private static class
RelatedContentSearcher.MySearchObserver
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description protected
RelatedContentSearcher(RelatedContentManager _manager, DistributedDatabaseTransferType _transfer_type, DHTPluginInterface _dht_plugin, boolean _defer_ddb_check)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
checkDDB()
private void
checkKeyBloom()
private java.lang.String
escapeTag(java.lang.String tag)
private java.lang.String
fixupTerm(java.lang.String term)
(package private) void
foreignBloomFailed(DistributedDatabaseContact contact)
private java.util.List<RelatedContentManager.DownloadInfo>
getDHTInfos(boolean search_cvs_only)
protected DHTPluginInterface
getDHTPlugin()
private java.util.List<java.lang.String>
getDHTWords(RelatedContentManager.DownloadInfo info)
private BloomFilter
getKeyBloom(boolean include_dht_local)
private void
harvestBlooms()
(package private) DistributedDatabaseContact
importContact(DHTPluginContact contact, int network)
private boolean
isPopularity(java.lang.String term)
(package private) static void
logSearch(java.lang.String str)
(package private) java.util.List<RelatedContent>
matchContent(java.lang.String term, int min_seeds, int min_leechers, int max_age_secs, boolean is_local, boolean search_cvs_only)
DistributedDatabaseValue
read(DistributedDatabaseContact contact, DistributedDatabaseTransferType type, DistributedDatabaseKey ddb_key)
protected java.util.Map<java.lang.String,java.lang.Object>
receiveRemoteRequest(DistributedDatabaseContact originator, java.util.Map<java.lang.String,java.lang.Object> request)
(package private) java.util.List<DistributedDatabaseContact>
searchForeignBlooms(java.lang.String term)
protected SearchInstance
searchRCM(java.util.Map<java.lang.String,java.lang.Object> search_parameters, SearchObserver _observer)
protected BloomFilter
sendRemoteFetch(DistributedDatabaseContact contact)
protected java.util.List<DistributedDatabaseContact>
sendRemoteSearch(SearchInstance si, java.util.Set<java.lang.String> hashes_sync_me, DistributedDatabaseContact contact, java.lang.String term, int min_seeds, int min_leechers, int max_age_secs, SearchObserver _observer)
protected BloomFilter
sendRemoteUpdate(RelatedContentSearcher.ForeignBloom f_bloom)
private void
testKeyBloom()
protected void
timerTick(boolean enabled, int tick_count)
private java.lang.String
transformTerm(java.lang.String term)
private java.lang.String
unescapeTag(java.lang.String tag)
protected void
updateKeyBloom(RelatedContentManager.ContentCache cc)
DistributedDatabaseValue
write(DistributedDatabaseContact contact, DistributedDatabaseTransferType type, DistributedDatabaseKey key, DistributedDatabaseValue value)
-
-
-
Field Detail
-
SEARCH_CVS_ONLY_DEFAULT
static final boolean SEARCH_CVS_ONLY_DEFAULT
-
TRACE_SEARCH
private static final boolean TRACE_SEARCH
- See Also:
- Constant Field Values
-
SEARCH_MIN_SEEDS_DEFAULT
private static final int SEARCH_MIN_SEEDS_DEFAULT
- See Also:
- Constant Field Values
-
SEARCH_MIN_LEECHERS_DEFAULT
private static final int SEARCH_MIN_LEECHERS_DEFAULT
- See Also:
- Constant Field Values
-
SEARCH_MAX_AGE_SECS_DEFAULT
private static final int SEARCH_MAX_AGE_SECS_DEFAULT
- See Also:
- Constant Field Values
-
SEARCH_POP_MIN_SEEDS_DEFAULT
private static final int SEARCH_POP_MIN_SEEDS_DEFAULT
- See Also:
- Constant Field Values
-
SEARCH_POP_MIN_LEECHERS_DEFAULT
private static final int SEARCH_POP_MIN_LEECHERS_DEFAULT
- See Also:
- Constant Field Values
-
SEARCH_POP_MAX_AGE_SECS_DEFAULT
private static final int SEARCH_POP_MAX_AGE_SECS_DEFAULT
- See Also:
- Constant Field Values
-
MAX_REMOTE_SEARCH_RESULTS
private static final int MAX_REMOTE_SEARCH_RESULTS
- See Also:
- Constant Field Values
-
MAX_REMOTE_SEARCH_CONTACTS
private static final int MAX_REMOTE_SEARCH_CONTACTS
- See Also:
- Constant Field Values
-
MAX_REMOTE_SEARCH_MILLIS
private static final int MAX_REMOTE_SEARCH_MILLIS
- See Also:
- Constant Field Values
-
REDUCED_REMOTE_SEARCH_MILLIS
private static final int REDUCED_REMOTE_SEARCH_MILLIS
- See Also:
- Constant Field Values
-
MAX_LOCAL_POPULAR_RESULTS
private static final int MAX_LOCAL_POPULAR_RESULTS
- See Also:
- Constant Field Values
-
HARVEST_MAX_BLOOMS
private static final int HARVEST_MAX_BLOOMS
- See Also:
- Constant Field Values
-
HARVEST_MAX_FAILS_HISTORY
private static final int HARVEST_MAX_FAILS_HISTORY
- See Also:
- Constant Field Values
-
HARVEST_BLOOM_UPDATE_MILLIS
private static final int HARVEST_BLOOM_UPDATE_MILLIS
- See Also:
- Constant Field Values
-
HARVEST_BLOOM_DISCARD_MILLIS
private static final int HARVEST_BLOOM_DISCARD_MILLIS
- See Also:
- Constant Field Values
-
HARVEST_BLOOM_OP_RESET_MILLIS
private static final int HARVEST_BLOOM_OP_RESET_MILLIS
- See Also:
- Constant Field Values
-
HARVEST_BLOOM_OP_RESET_TICKS
private static final int HARVEST_BLOOM_OP_RESET_TICKS
- See Also:
- Constant Field Values
-
HARVEST_BLOOM_SE_RESET_MILLIS
private static final int HARVEST_BLOOM_SE_RESET_MILLIS
- See Also:
- Constant Field Values
-
HARVEST_BLOOM_SE_RESET_TICKS
private static final int HARVEST_BLOOM_SE_RESET_TICKS
- See Also:
- Constant Field Values
-
KEY_BLOOM_LOAD_FACTOR
private static final int KEY_BLOOM_LOAD_FACTOR
- See Also:
- Constant Field Values
-
KEY_BLOOM_MIN_BITS
private static final int KEY_BLOOM_MIN_BITS
- See Also:
- Constant Field Values
-
KEY_BLOOM_MAX_BITS
private static final int KEY_BLOOM_MAX_BITS
- See Also:
- Constant Field Values
-
KEY_BLOOM_MAX_ENTRIES
private static final int KEY_BLOOM_MAX_ENTRIES
- See Also:
- Constant Field Values
-
key_bloom_with_local
private volatile BloomFilter key_bloom_with_local
-
key_bloom_without_local
private volatile BloomFilter key_bloom_without_local
-
last_key_bloom_update
private volatile long last_key_bloom_update
-
ignore_words
private java.util.Set<java.lang.String> ignore_words
-
harvested_blooms
ByteArrayHashMap<RelatedContentSearcher.ForeignBloom> harvested_blooms
-
harvested_fails
ByteArrayHashMap<java.lang.String> harvested_fails
-
harvest_op_requester_bloom
private volatile BloomFilter harvest_op_requester_bloom
-
harvest_se_requester_bloom
private volatile BloomFilter harvest_se_requester_bloom
-
harvest_dispatcher
final AsyncDispatcher harvest_dispatcher
-
manager
final RelatedContentManager manager
-
transfer_type
private final DistributedDatabaseTransferType transfer_type
-
dht_plugin
final DHTPluginInterface dht_plugin
-
ddb
DistributedDatabase ddb
-
-
Constructor Detail
-
RelatedContentSearcher
protected RelatedContentSearcher(RelatedContentManager _manager, DistributedDatabaseTransferType _transfer_type, DHTPluginInterface _dht_plugin, boolean _defer_ddb_check)
-
-
Method Detail
-
getDHTPlugin
protected DHTPluginInterface getDHTPlugin()
-
timerTick
protected void timerTick(boolean enabled, int tick_count)
-
checkDDB
private void checkDDB()
-
searchRCM
protected SearchInstance searchRCM(java.util.Map<java.lang.String,java.lang.Object> search_parameters, SearchObserver _observer) throws SearchException
- Throws:
SearchException
-
fixupTerm
private java.lang.String fixupTerm(java.lang.String term)
-
escapeTag
private java.lang.String escapeTag(java.lang.String tag)
-
unescapeTag
private java.lang.String unescapeTag(java.lang.String tag)
-
transformTerm
private java.lang.String transformTerm(java.lang.String term)
-
matchContent
java.util.List<RelatedContent> matchContent(java.lang.String term, int min_seeds, int min_leechers, int max_age_secs, boolean is_local, boolean search_cvs_only)
-
sendRemoteSearch
protected java.util.List<DistributedDatabaseContact> sendRemoteSearch(SearchInstance si, java.util.Set<java.lang.String> hashes_sync_me, DistributedDatabaseContact contact, java.lang.String term, int min_seeds, int min_leechers, int max_age_secs, SearchObserver _observer)
-
sendRemoteFetch
protected BloomFilter sendRemoteFetch(DistributedDatabaseContact contact)
-
sendRemoteUpdate
protected BloomFilter sendRemoteUpdate(RelatedContentSearcher.ForeignBloom f_bloom)
-
receiveRemoteRequest
protected java.util.Map<java.lang.String,java.lang.Object> receiveRemoteRequest(DistributedDatabaseContact originator, java.util.Map<java.lang.String,java.lang.Object> request)
-
read
public DistributedDatabaseValue read(DistributedDatabaseContact contact, DistributedDatabaseTransferType type, DistributedDatabaseKey ddb_key) throws DistributedDatabaseException
- Specified by:
read
in interfaceDistributedDatabaseTransferHandler
- Throws:
DistributedDatabaseException
-
write
public DistributedDatabaseValue write(DistributedDatabaseContact contact, DistributedDatabaseTransferType type, DistributedDatabaseKey key, DistributedDatabaseValue value) throws DistributedDatabaseException
- Specified by:
write
in interfaceDistributedDatabaseTransferHandler
- Throws:
DistributedDatabaseException
-
checkKeyBloom
private void checkKeyBloom()
-
getKeyBloom
private BloomFilter getKeyBloom(boolean include_dht_local)
-
getDHTWords
private java.util.List<java.lang.String> getDHTWords(RelatedContentManager.DownloadInfo info)
-
updateKeyBloom
protected void updateKeyBloom(RelatedContentManager.ContentCache cc)
-
getDHTInfos
private java.util.List<RelatedContentManager.DownloadInfo> getDHTInfos(boolean search_cvs_only)
-
testKeyBloom
private void testKeyBloom()
-
harvestBlooms
private void harvestBlooms()
-
importContact
DistributedDatabaseContact importContact(DHTPluginContact contact, int network) throws DistributedDatabaseException
- Throws:
DistributedDatabaseException
-
foreignBloomFailed
void foreignBloomFailed(DistributedDatabaseContact contact)
-
isPopularity
private boolean isPopularity(java.lang.String term)
-
searchForeignBlooms
java.util.List<DistributedDatabaseContact> searchForeignBlooms(java.lang.String term)
-
logSearch
static void logSearch(java.lang.String str)
-
-