private static final Client getClient(File indexDirectory) throws SearchLibException {
   clientsLock.r.lock();
   try {
     Client client = CLIENTS.get(indexDirectory);
     if (client != null) return client;
   } finally {
     clientsLock.r.unlock();
   }
   int i = 60;
   while (isOldClient(indexDirectory) && i > 0) {
     ThreadUtils.sleepMs(500);
     i--;
   }
   if (i == 0) throw new SearchLibException("Time out while getting " + indexDirectory);
   clientsLock.w.lock();
   try {
     Client client = CLIENTS.get(indexDirectory);
     if (client != null) return client;
     client =
         ClientFactory.INSTANCE.newClient(
             indexDirectory, true, false, ClientFactory.INSTANCE.properties.getSilentBackupUrl());
     CLIENTS.put(indexDirectory, client);
     return client;
   } finally {
     clientsLock.w.unlock();
   }
 }
Exemple #2
0
  /** simply dump status info to the textarea */
  private void sout(final String s) {
    Runnable soutRunner =
        new Runnable() {
          public void run() {
            if (ttaStatus.getText().equals("")) {
              ttaStatus.setText(s);
            } else {
              ttaStatus.setText(ttaStatus.getText() + "\n" + s);
            }
          }
        };

    if (ThreadUtils.isInEDT()) {
      soutRunner.run();
    } else {
      SwingUtilities.invokeLater(soutRunner);
    }
  }