Package com.biglybt.core.content
Class RelatedContentManager
- java.lang.Object
-
- com.biglybt.core.content.RelatedContentManager
-
public class RelatedContentManager extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
RelatedContentManager.ByteArrayHashMapEx<T>
protected static class
RelatedContentManager.ContentCache
protected class
RelatedContentManager.DownloadInfo
protected static class
RelatedContentManager.RCMSearchXFer
private static class
RelatedContentManager.SecondaryLookup
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description protected
RelatedContentManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addDownloads(Download[] downloads, boolean initialising)
void
addListener(RelatedContentManagerListener listener)
protected void
addPersistentlyDeleted(RelatedContent[] content)
private void
addURLToDomainKeySet(java.util.Set<java.lang.String> set, java.net.URL u)
protected void
analyseResponse(RelatedContentManager.DownloadInfo to_info, RelatedContentManagerListener listener)
(package private) void
checkAlternativePubs(RelatedContentManager.DownloadInfo to_info, byte[] map_bytes, int f_cutoff)
(package private) void
checkI2PSearcher(boolean force)
private RelatedContentSearcher
checkMixSearcher()
protected void
contentChanged(boolean is_dirty)
protected void
contentChanged(RelatedContentManager.DownloadInfo info)
static java.lang.String[]
convertNetworks(byte net)
static byte
convertNetworks(java.lang.String[] networks)
protected RelatedContentManager.DownloadInfo
decodeInfo(java.util.Map map, byte[] from_hash, int level, boolean explicit, java.util.Set<java.lang.String> unique_keys)
protected java.lang.String[]
decodeTags(byte[] bytes)
protected void
decrementUnread()
(package private) void
delayedInit()
void
delete(RelatedContent[] content)
protected void
delete(RelatedContent[] content, RelatedContentManager.ContentCache content_cache, boolean persistent)
void
deleteAll()
(package private) void
deleteRelatedContent()
private RelatedContentManager.DownloadInfo
deserialiseDI(java.util.Map<java.lang.String,java.lang.Object> info_map, RelatedContentManager.ContentCache cc)
protected byte[]
domainsToArray(java.util.Set<java.lang.String> domains, int max)
private void
dump()
protected byte[]
encodeTags(java.lang.String[] tags)
protected void
enforceMaxResults(boolean reset_explicit)
protected void
enforceMaxResults(RelatedContentManager.ContentCache content_cache, boolean reset_explicit)
protected boolean
enoughSpaceFor(RelatedContentManager.ContentCache content_cache, RelatedContentManager.DownloadInfo fi)
protected Download
getDownload(byte[] hash)
boolean
getFilterActiveOnly()
private byte[][]
getKeys(Download download)
int
getMaxResults()
int
getMaxSearchLevel()
private byte
getNetworks(Download download)
int
getNumUnread()
protected byte[]
getPermDelKey(RelatedContent info)
protected java.lang.String
getPrivateInfoKey(RelatedContent info)
RelatedContent[]
getRelatedContent()
protected java.util.List<RelatedContentManager.DownloadInfo>
getRelatedContentAsList()
static RelatedContentManager
getSingleton()
private java.lang.String
getString(java.lang.String[] args)
private java.lang.String[]
getTags(Download download)
protected java.util.List
getURLList(TOTorrent torrent, java.lang.String key)
protected boolean
globalFilter(RelatedContent content)
protected void
incrementUnread()
boolean
isEnabled()
protected boolean
isPersistentlyDeleted(RelatedContent content)
protected java.util.List<byte[]>
loadPersistentlyDeleted()
protected RelatedContentManager.ContentCache
loadRelatedContent()
void
lookupAttributes(byte[] from_hash, RelatedAttributeLookupListener listener)
void
lookupAttributes(byte[] from_hash, java.lang.String[] networks, RelatedAttributeLookupListener listener)
(package private) void
lookupAttributesSupport(byte[] from_hash, byte networks, RelatedAttributeLookupListener listener)
void
lookupContent(byte[] hash, RelatedContentLookupListener listener)
void
lookupContent(byte[] hash, java.lang.String[] networks, RelatedContentLookupListener listener)
void
lookupContent(long file_size, RelatedContentLookupListener listener)
void
lookupContent(long file_size, java.lang.String[] networks, RelatedContentLookupListener listener)
(package private) void
lookupContentSupport(byte[] from_hash, int level, byte networks, boolean explicit, RelatedContentLookupListener listener)
(package private) void
lookupContentSupport(long file_size, byte networks, RelatedContentLookupListener listener)
private void
lookupContentSupport0(byte[] from_hash, byte[] key_bytes, java.lang.String op_str, int level, byte networks, boolean explicit, RelatedContentLookupListener listener)
protected void
popuplateSecondaryLookups(RelatedContentManager.ContentCache content_cache)
static void
preInitialise(Core _core)
(package private) void
publish()
private boolean
publish(RelatedContentManager.DownloadInfo from_info, RelatedContentManager.DownloadInfo to_info)
(package private) void
publishNext()
void
releaseTemporarySpace()
void
removeListener(RelatedContentManagerListener listener)
(package private) void
republish()
void
reserveTemporarySpace()
void
reset()
protected void
reset(boolean reset_perm_dels)
protected void
resetPersistentlyDeleted()
protected void
saveRelatedContent(int tick_count)
SearchInstance
searchRCM(java.util.Map<java.lang.String,java.lang.Object> search_parameters, SearchObserver observer)
(package private) SearchInstance
searchRCMSupport(java.util.Map<java.lang.String,java.lang.Object> search_parameters, SearchObserver observer)
protected void
secondaryLookup()
private DHTPluginInterface
selectDHT(byte networks)
private java.util.Map<java.lang.String,java.lang.Object>
serialiseDI(RelatedContentManager.DownloadInfo info, RelatedContentManager.ContentCache cc)
void
setAllRead()
protected void
setConfigDirty()
void
setFilterActiveOnly(boolean b)
void
setMaxResults(int _max)
void
setMaxSearchLevel(int _level)
protected java.lang.String
truncateTag(java.lang.String tag)
-
-
-
Field Detail
-
FILE_ASSOC_MIN_SIZE
public static final long FILE_ASSOC_MIN_SIZE
- See Also:
- Constant Field Values
-
RCM_SEARCH_PROPERTY_TRACKER_KEYS
public static final int RCM_SEARCH_PROPERTY_TRACKER_KEYS
- See Also:
- Constant Field Values
-
RCM_SEARCH_PROPERTY_WEB_SEED_KEYS
public static final int RCM_SEARCH_PROPERTY_WEB_SEED_KEYS
- See Also:
- Constant Field Values
-
RCM_SEARCH_PROPERTY_TAGS
public static final int RCM_SEARCH_PROPERTY_TAGS
- See Also:
- Constant Field Values
-
RCM_SEARCH_PROPERTY_NETWORKS
public static final int RCM_SEARCH_PROPERTY_NETWORKS
- See Also:
- Constant Field Values
-
TRACE
private static final boolean TRACE
- See Also:
- Constant Field Values
-
MAX_HISTORY
private static final int MAX_HISTORY
- See Also:
- Constant Field Values
-
MAX_TITLE_LENGTH
private static final int MAX_TITLE_LENGTH
- See Also:
- Constant Field Values
-
MAX_CONCURRENT_PUBLISH
private static final int MAX_CONCURRENT_PUBLISH
-
DISABLE_PUBLISHING
private static final boolean DISABLE_PUBLISHING
-
prefer_i2p
private static boolean prefer_i2p
-
TEMPORARY_SPACE_DELTA
private static final int TEMPORARY_SPACE_DELTA
- See Also:
- Constant Field Values
-
MAX_RANK
private static final int MAX_RANK
- See Also:
- Constant Field Values
-
CONFIG_FILE
private static final java.lang.String CONFIG_FILE
- See Also:
- Constant Field Values
-
PERSIST_DEL_FILE
private static final java.lang.String PERSIST_DEL_FILE
- See Also:
- Constant Field Values
-
CONFIG_TOTAL_UNREAD
private static final java.lang.String CONFIG_TOTAL_UNREAD
- See Also:
- Constant Field Values
-
singleton
private static RelatedContentManager singleton
-
core
private static Core core
-
TIMER_PERIOD
protected static final int TIMER_PERIOD
- See Also:
- Constant Field Values
-
CONFIG_SAVE_CHECK_PERIOD
private static final int CONFIG_SAVE_CHECK_PERIOD
- See Also:
- Constant Field Values
-
CONFIG_SAVE_PERIOD
private static final int CONFIG_SAVE_PERIOD
- See Also:
- Constant Field Values
-
CONFIG_SAVE_CHECK_TICKS
private static final int CONFIG_SAVE_CHECK_TICKS
- See Also:
- Constant Field Values
-
CONFIG_SAVE_TICKS
private static final int CONFIG_SAVE_TICKS
- See Also:
- Constant Field Values
-
PUBLISH_CHECK_PERIOD
private static final int PUBLISH_CHECK_PERIOD
- See Also:
- Constant Field Values
-
PUBLISH_CHECK_TICKS
private static final int PUBLISH_CHECK_TICKS
- See Also:
- Constant Field Values
-
PUBLISH_SLEEPING_CHECK_PERIOD
private static final int PUBLISH_SLEEPING_CHECK_PERIOD
- See Also:
- Constant Field Values
-
PUBLISH_SLEEPING_CHECK_TICKS
private static final int PUBLISH_SLEEPING_CHECK_TICKS
- See Also:
- Constant Field Values
-
SECONDARY_LOOKUP_PERIOD
private static final int SECONDARY_LOOKUP_PERIOD
- See Also:
- Constant Field Values
-
SECONDARY_LOOKUP_TICKS
private static final int SECONDARY_LOOKUP_TICKS
- See Also:
- Constant Field Values
-
REPUBLISH_PERIOD
private static final int REPUBLISH_PERIOD
- See Also:
- Constant Field Values
-
REPUBLISH_TICKS
private static final int REPUBLISH_TICKS
- See Also:
- Constant Field Values
-
I2P_SEARCHER_CHECK_PERIOD
private static final int I2P_SEARCHER_CHECK_PERIOD
- See Also:
- Constant Field Values
-
I2P_SEARCHER_CHECK_TICKS
private static final int I2P_SEARCHER_CHECK_TICKS
- See Also:
- Constant Field Values
-
INITIAL_PUBLISH_DELAY
private static final int INITIAL_PUBLISH_DELAY
- See Also:
- Constant Field Values
-
INITIAL_PUBLISH_TICKS
private static final int INITIAL_PUBLISH_TICKS
- See Also:
- Constant Field Values
-
CONFIG_DISCARD_MILLIS
private static final int CONFIG_DISCARD_MILLIS
- See Also:
- Constant Field Values
-
NET_NONE
protected static final byte NET_NONE
- See Also:
- Constant Field Values
-
NET_PUBLIC
protected static final byte NET_PUBLIC
- See Also:
- Constant Field Values
-
NET_I2P
protected static final byte NET_I2P
- See Also:
- Constant Field Values
-
NET_TOR
protected static final byte NET_TOR
- See Also:
- Constant Field Values
-
NET_PUBLIC_ARRAY
private static final java.lang.String[] NET_PUBLIC_ARRAY
-
NET_I2P_ARRAY
private static final java.lang.String[] NET_I2P_ARRAY
-
NET_TOR_ARRAY
private static final java.lang.String[] NET_TOR_ARRAY
-
NET_PUBLIC_AND_I2P_ARRAY
private static final java.lang.String[] NET_PUBLIC_AND_I2P_ARRAY
-
rcm_lock
protected final java.lang.Object rcm_lock
-
plugin_interface
private PluginInterface plugin_interface
-
ta_networks
private TorrentAttribute ta_networks
-
ta_category
private TorrentAttribute ta_category
-
public_dht_plugin
private DHTPluginInterface public_dht_plugin
-
i2p_dht_plugin_map
private volatile java.util.Map<java.lang.Byte,DHTPluginInterface> i2p_dht_plugin_map
-
tag_manager
private TagManager tag_manager
-
global_random_id
private long global_random_id
-
pub_download_infos1
private java.util.LinkedList<RelatedContentManager.DownloadInfo> pub_download_infos1
-
pub_download_infos2
private java.util.LinkedList<RelatedContentManager.DownloadInfo> pub_download_infos2
-
non_pub_download_infos1
private java.util.LinkedList<RelatedContentManager.DownloadInfo> non_pub_download_infos1
-
non_pub_download_infos2
private java.util.LinkedList<RelatedContentManager.DownloadInfo> non_pub_download_infos2
-
download_info_map
private RelatedContentManager.ByteArrayHashMapEx<RelatedContentManager.DownloadInfo> download_info_map
-
download_priv_set
private java.util.Set<java.lang.String> download_priv_set
-
enabled
private final boolean enabled
-
max_search_level
private int max_search_level
-
max_results
private int max_results
-
global_filter_active_only
private boolean global_filter_active_only
-
temporary_space
private java.util.concurrent.atomic.AtomicInteger temporary_space
-
publishing_count
private int publishing_count
-
listeners
CopyOnWriteList<RelatedContentManagerListener> listeners
-
initialisation_complete_sem
AESemaphore initialisation_complete_sem
-
content_cache_ref
private RelatedContentManager.ContentCache content_cache_ref
-
content_cache
private java.lang.ref.WeakReference<RelatedContentManager.ContentCache> content_cache
-
content_dirty
private boolean content_dirty
-
last_config_access
private long last_config_access
-
content_discard_ticks
private int content_discard_ticks
-
total_unread
private java.util.concurrent.atomic.AtomicInteger total_unread
-
content_change_dispatcher
private AsyncDispatcher content_change_dispatcher
-
SECONDARY_LOOKUP_CACHE_MAX
private static final int SECONDARY_LOOKUP_CACHE_MAX
- See Also:
- Constant Field Values
-
secondary_lookups
java.util.LinkedList<RelatedContentManager.SecondaryLookup> secondary_lookups
-
secondary_lookup_in_progress
boolean secondary_lookup_in_progress
-
secondary_lookup_complete_time
long secondary_lookup_complete_time
-
transfer_type
RelatedContentManager.RCMSearchXFer transfer_type
-
searchers
final CopyOnWriteList<RelatedContentSearcher> searchers
-
added_i2p_searcher
private boolean added_i2p_searcher
-
mix_searcher
private RelatedContentSearcher mix_searcher
-
MAX_TRANSIENT_CACHE
private static final int MAX_TRANSIENT_CACHE
- See Also:
- Constant Field Values
-
transient_info_cache
protected static java.util.Map<java.lang.String,RelatedContentManager.DownloadInfo> transient_info_cache
-
persist
boolean persist
-
last_pub_was_pub
private boolean last_pub_was_pub
-
MAX_TAG_LENGTH
private static final int MAX_TAG_LENGTH
- See Also:
- Constant Field Values
-
MAX_TAGS_TOTAL_LENGTH
private static final int MAX_TAGS_TOTAL_LENGTH
- See Also:
- Constant Field Values
-
PD_BLOOM_INITIAL_SIZE
private static final int PD_BLOOM_INITIAL_SIZE
- See Also:
- Constant Field Values
-
PD_BLOOM_INCREMENT_SIZE
private static final int PD_BLOOM_INCREMENT_SIZE
- See Also:
- Constant Field Values
-
persist_del_bloom
private BloomFilter persist_del_bloom
-
-
Constructor Detail
-
RelatedContentManager
protected RelatedContentManager() throws ContentException
- Throws:
ContentException
-
-
Method Detail
-
preInitialise
public static void preInitialise(Core _core)
-
getSingleton
public static RelatedContentManager getSingleton() throws ContentException
- Throws:
ContentException
-
delayedInit
void delayedInit()
-
checkI2PSearcher
void checkI2PSearcher(boolean force)
-
checkMixSearcher
private RelatedContentSearcher checkMixSearcher()
-
isEnabled
public boolean isEnabled()
-
getMaxSearchLevel
public int getMaxSearchLevel()
-
setMaxSearchLevel
public void setMaxSearchLevel(int _level)
-
getMaxResults
public int getMaxResults()
-
setMaxResults
public void setMaxResults(int _max)
-
getFilterActiveOnly
public boolean getFilterActiveOnly()
-
setFilterActiveOnly
public void setFilterActiveOnly(boolean b)
-
selectDHT
private DHTPluginInterface selectDHT(byte networks)
-
addDownloads
protected void addDownloads(Download[] downloads, boolean initialising)
-
republish
void republish()
-
publish
void publish()
-
publishNext
void publishNext()
-
publish
private boolean publish(RelatedContentManager.DownloadInfo from_info, RelatedContentManager.DownloadInfo to_info) throws java.lang.Exception
- Throws:
java.lang.Exception
-
checkAlternativePubs
void checkAlternativePubs(RelatedContentManager.DownloadInfo to_info, byte[] map_bytes, int f_cutoff)
-
decodeInfo
protected RelatedContentManager.DownloadInfo decodeInfo(java.util.Map map, byte[] from_hash, int level, boolean explicit, java.util.Set<java.lang.String> unique_keys)
-
lookupAttributes
public void lookupAttributes(byte[] from_hash, RelatedAttributeLookupListener listener) throws ContentException
- Throws:
ContentException
-
lookupAttributes
public void lookupAttributes(byte[] from_hash, java.lang.String[] networks, RelatedAttributeLookupListener listener) throws ContentException
- Throws:
ContentException
-
lookupAttributesSupport
void lookupAttributesSupport(byte[] from_hash, byte networks, RelatedAttributeLookupListener listener) throws ContentException
- Throws:
ContentException
-
lookupContent
public void lookupContent(byte[] hash, RelatedContentLookupListener listener) throws ContentException
- Throws:
ContentException
-
lookupContent
public void lookupContent(byte[] hash, java.lang.String[] networks, RelatedContentLookupListener listener) throws ContentException
- Throws:
ContentException
-
lookupContent
public void lookupContent(long file_size, RelatedContentLookupListener listener) throws ContentException
- Throws:
ContentException
-
lookupContent
public void lookupContent(long file_size, java.lang.String[] networks, RelatedContentLookupListener listener) throws ContentException
- Throws:
ContentException
-
lookupContentSupport
void lookupContentSupport(long file_size, byte networks, RelatedContentLookupListener listener) throws ContentException
- Throws:
ContentException
-
lookupContentSupport
void lookupContentSupport(byte[] from_hash, int level, byte networks, boolean explicit, RelatedContentLookupListener listener) throws ContentException
- Throws:
ContentException
-
getString
private java.lang.String getString(java.lang.String[] args)
-
lookupContentSupport0
private void lookupContentSupport0(byte[] from_hash, byte[] key_bytes, java.lang.String op_str, int level, byte networks, boolean explicit, RelatedContentLookupListener listener) throws ContentException
- Throws:
ContentException
-
popuplateSecondaryLookups
protected void popuplateSecondaryLookups(RelatedContentManager.ContentCache content_cache)
-
secondaryLookup
protected void secondaryLookup()
-
contentChanged
protected void contentChanged(RelatedContentManager.DownloadInfo info)
-
contentChanged
protected void contentChanged(boolean is_dirty)
-
delete
public void delete(RelatedContent[] content)
-
delete
protected void delete(RelatedContent[] content, RelatedContentManager.ContentCache content_cache, boolean persistent)
-
getPrivateInfoKey
protected java.lang.String getPrivateInfoKey(RelatedContent info)
-
analyseResponse
protected void analyseResponse(RelatedContentManager.DownloadInfo to_info, RelatedContentManagerListener listener)
-
enoughSpaceFor
protected boolean enoughSpaceFor(RelatedContentManager.ContentCache content_cache, RelatedContentManager.DownloadInfo fi)
-
getRelatedContent
public RelatedContent[] getRelatedContent()
-
getRelatedContentAsList
protected java.util.List<RelatedContentManager.DownloadInfo> getRelatedContentAsList()
-
reset
public void reset()
-
reset
protected void reset(boolean reset_perm_dels)
-
searchRCM
public SearchInstance searchRCM(java.util.Map<java.lang.String,java.lang.Object> search_parameters, SearchObserver observer) throws SearchException
- Throws:
SearchException
-
searchRCMSupport
SearchInstance searchRCMSupport(java.util.Map<java.lang.String,java.lang.Object> search_parameters, SearchObserver observer) throws SearchException
- Throws:
SearchException
-
setConfigDirty
protected void setConfigDirty()
-
loadRelatedContent
protected RelatedContentManager.ContentCache loadRelatedContent()
-
saveRelatedContent
protected void saveRelatedContent(int tick_count)
-
deleteRelatedContent
void deleteRelatedContent()
-
getNumUnread
public int getNumUnread()
-
setAllRead
public void setAllRead()
-
deleteAll
public void deleteAll()
-
incrementUnread
protected void incrementUnread()
-
decrementUnread
protected void decrementUnread()
-
getDownload
protected Download getDownload(byte[] hash)
-
getKeys
private byte[][] getKeys(Download download)
-
domainsToArray
protected byte[] domainsToArray(java.util.Set<java.lang.String> domains, int max)
-
getURLList
protected java.util.List getURLList(TOTorrent torrent, java.lang.String key)
-
addURLToDomainKeySet
private void addURLToDomainKeySet(java.util.Set<java.lang.String> set, java.net.URL u)
-
getNetworks
private byte getNetworks(Download download)
-
convertNetworks
public static java.lang.String[] convertNetworks(byte net)
-
convertNetworks
public static byte convertNetworks(java.lang.String[] networks)
-
getTags
private java.lang.String[] getTags(Download download)
-
encodeTags
protected byte[] encodeTags(java.lang.String[] tags)
-
truncateTag
protected java.lang.String truncateTag(java.lang.String tag)
-
decodeTags
protected java.lang.String[] decodeTags(byte[] bytes)
-
getPermDelKey
protected byte[] getPermDelKey(RelatedContent info)
-
loadPersistentlyDeleted
protected java.util.List<byte[]> loadPersistentlyDeleted()
-
addPersistentlyDeleted
protected void addPersistentlyDeleted(RelatedContent[] content)
-
globalFilter
protected boolean globalFilter(RelatedContent content)
-
isPersistentlyDeleted
protected boolean isPersistentlyDeleted(RelatedContent content)
-
resetPersistentlyDeleted
protected void resetPersistentlyDeleted()
-
reserveTemporarySpace
public void reserveTemporarySpace()
-
releaseTemporarySpace
public void releaseTemporarySpace()
-
enforceMaxResults
protected void enforceMaxResults(boolean reset_explicit)
-
enforceMaxResults
protected void enforceMaxResults(RelatedContentManager.ContentCache content_cache, boolean reset_explicit)
-
addListener
public void addListener(RelatedContentManagerListener listener)
-
removeListener
public void removeListener(RelatedContentManagerListener listener)
-
serialiseDI
private java.util.Map<java.lang.String,java.lang.Object> serialiseDI(RelatedContentManager.DownloadInfo info, RelatedContentManager.ContentCache cc)
-
deserialiseDI
private RelatedContentManager.DownloadInfo deserialiseDI(java.util.Map<java.lang.String,java.lang.Object> info_map, RelatedContentManager.ContentCache cc)
-
dump
private void dump()
-
-