public synchronized void start()

in common/src/main/java/jetbrains/buildServer/torrent/seeder/TorrentsSeeder.java [111:175]


  public synchronized void start(@NotNull InetAddress[] address,
                                 @Nullable final URI defaultTrackerURI,
                                 final int announceInterval,
                                 @NotNull final SelectorFactory selectorFactory) throws IOException {
    if (myWorking) return; // already started

    myWorking = true;

    try {
      myClient.start(address, defaultTrackerURI, announceInterval, selectorFactory);
    } catch (RejectedExecutionException e) {
      LOG.warnAndDebugDetails("Failed to start bittorrent client", e);
    }
    try {
      myExecutor.submit(new Runnable() {
        public void run() {
          checkForBrokenFiles();
          for (Map.Entry<File, File> entry : myTorrentFilesDB.getFileAndTorrentMap().entrySet()) {
            seedTorrent(entry.getKey(), entry.getValue());
          }
        }
      });
    } catch (RejectedExecutionException e) {
      LOG.warnAndDebugDetails("Failed to execute seed stored torrents task", e);
    }
    try {
      myBrokenFilesCheckerFuture = myExecutor.scheduleWithFixedDelay(new Runnable() {
        public void run() {
          try {
            checkForBrokenFiles();
          } catch (Throwable e) {
            LOG.warnAndDebugDetails("Unhandled exception in check brokenf files task", e);
          }
        }
      }, CHECK_TORRENTS_INTERVAL, CHECK_TORRENTS_INTERVAL, TimeUnit.SECONDS);
    } catch (RejectedExecutionException e) {
      LOG.warnAndDebugDetails("Failed to schedule broken files check task", e);
    }
    try {
      myClosingStorageFuture = myExecutor.scheduleWithFixedDelay(new Runnable() {
        public void run() {
          try {
            closePiecesStorage();
          } catch (Throwable e) {
            LOG.warnAndDebugDetails("Unhandled exception in closing storage task", e);
          }
        }
      }, CLOSING_STORAGE_INTERVAL, CLOSING_STORAGE_INTERVAL, TimeUnit.SECONDS);
    } catch (RejectedExecutionException e) {
      LOG.warnAndDebugDetails("Failed to schedule closing storage task", e);
    }
    try {
      myDBFlushFuture = myExecutor.scheduleWithFixedDelay(new Runnable() {
        public void run() {
          try {
            flushTorrentsDB();
          } catch (Throwable e) {
            LOG.warnAndDebugDetails("Unhandled exception in flush torrents db task", e);
          }
        }
      }, FLUSH_DB_INTERVAL, FLUSH_DB_INTERVAL, TimeUnit.SECONDS);
    } catch (RejectedExecutionException e) {
      LOG.warnAndDebugDetails("Failed to schedule db flush task", e);
    }
  }