Search in sources :

Example 1 with DHTTrackerPlugin

use of com.biglybt.plugin.tracker.dht.DHTTrackerPlugin in project BiglyBT by BiglySoftware.

the class CoreImpl method announceAll.

protected void announceAll(boolean force) {
    Logger.log(new LogEvent(LOGID, "Updating trackers"));
    GlobalManager gm = getGlobalManager();
    if (gm != null) {
        List downloads = gm.getDownloadManagers();
        long now = SystemTime.getCurrentTime();
        for (int i = 0; i < downloads.size(); i++) {
            DownloadManager dm = (DownloadManager) downloads.get(i);
            Long last_announce_l = (Long) dm.getUserData(DM_ANNOUNCE_KEY);
            long last_announce = last_announce_l == null ? create_time : last_announce_l.longValue();
            TRTrackerAnnouncer an = dm.getTrackerClient();
            if (an != null) {
                TRTrackerAnnouncerResponse last_announce_response = an.getLastResponse();
                if (now - last_announce > 15 * 60 * 1000 || last_announce_response == null || last_announce_response.getStatus() == TRTrackerAnnouncerResponse.ST_OFFLINE || force) {
                    dm.setUserData(DM_ANNOUNCE_KEY, new Long(now));
                    Logger.log(new LogEvent(LOGID, "    updating tracker for " + dm.getDisplayName()));
                    dm.requestTrackerAnnounce(true);
                }
            }
        }
    }
    PluginInterface dht_tracker_pi = getPluginManager().getPluginInterfaceByClass(DHTTrackerPlugin.class);
    if (dht_tracker_pi != null) {
        ((DHTTrackerPlugin) dht_tracker_pi.getPlugin()).announceAll();
    }
}
Also used : GlobalManager(com.biglybt.core.global.GlobalManager) LogEvent(com.biglybt.core.logging.LogEvent) TRTrackerAnnouncer(com.biglybt.core.tracker.client.TRTrackerAnnouncer) TRTrackerAnnouncerResponse(com.biglybt.core.tracker.client.TRTrackerAnnouncerResponse) AtomicLong(java.util.concurrent.atomic.AtomicLong) DHTTrackerPlugin(com.biglybt.plugin.tracker.dht.DHTTrackerPlugin) DownloadManager(com.biglybt.core.download.DownloadManager)

Example 2 with DHTTrackerPlugin

use of com.biglybt.plugin.tracker.dht.DHTTrackerPlugin in project BiglyBT by BiglySoftware.

the class LightWeightSeedManager method startUp.

protected void startUp() {
    synchronized (this) {
        if (started) {
            return;
        }
        started = true;
    }
    boolean release_now = true;
    try {
        final PluginManager plugin_manager = CoreFactory.getSingleton().getPluginManager();
        PluginInterface pi = plugin_manager.getPluginInterfaceByClass(DHTTrackerPlugin.class);
        if (pi != null) {
            final DHTTrackerPlugin plugin = (DHTTrackerPlugin) pi.getPlugin();
            new AEThread2("LWS:waitForPlug", true) {

                @Override
                public void run() {
                    try {
                        plugin.waitUntilInitialised();
                        if (plugin.isRunning()) {
                            tttorrent = DDBaseImpl.getSingleton(CoreFactory.getSingleton()).getTTTorrent();
                        }
                        Set<LWSDownload> to_add;
                        try {
                            PluginInterface anon_pi = plugin_manager.getPluginInterfaceByID("azneti2phelper");
                            if (anon_pi != null) {
                                anon_dht_tracker_plugin = anon_pi.getIPC();
                            }
                        } catch (Throwable e) {
                            Debug.out(e);
                        }
                        synchronized (this) {
                            public_dht_tracker_plugin = plugin;
                            to_add = new HashSet<>(dht_add_queue);
                            dht_add_queue.clear();
                        }
                        Iterator<LWSDownload> it = to_add.iterator();
                        while (it.hasNext()) {
                            addDownload(it.next());
                        }
                    } finally {
                        init_sem.releaseForever();
                    }
                }
            }.start();
            release_now = false;
        } else {
            synchronized (dht_add_queue) {
                borked = true;
                dht_add_queue.clear();
            }
        }
    } finally {
        if (release_now) {
            init_sem.releaseForever();
        }
    }
}
Also used : PluginManager(com.biglybt.pif.PluginManager) PluginInterface(com.biglybt.pif.PluginInterface) DHTTrackerPlugin(com.biglybt.plugin.tracker.dht.DHTTrackerPlugin)

Aggregations

DHTTrackerPlugin (com.biglybt.plugin.tracker.dht.DHTTrackerPlugin)2 DownloadManager (com.biglybt.core.download.DownloadManager)1 GlobalManager (com.biglybt.core.global.GlobalManager)1 LogEvent (com.biglybt.core.logging.LogEvent)1 TRTrackerAnnouncer (com.biglybt.core.tracker.client.TRTrackerAnnouncer)1 TRTrackerAnnouncerResponse (com.biglybt.core.tracker.client.TRTrackerAnnouncerResponse)1 PluginInterface (com.biglybt.pif.PluginInterface)1 PluginManager (com.biglybt.pif.PluginManager)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1