/*
  * Clean up the temporary data used to run the tests.
  * This method is not intended to be called by clients, it will be called
  * automatically when the clients use a ReconcilerTestSuite.
  */
 public void cleanup() throws Exception {
   // rm -rf eclipse sub-dir
   boolean leaveDirty =
       Boolean.parseBoolean(TestActivator.getContext().getProperty("p2.tests.doNotClean"));
   if (leaveDirty) return;
   for (Iterator iter = toRemove.iterator(); iter.hasNext(); ) {
     File next = (File) iter.next();
     delete(next);
   }
   output = null;
   toRemove.clear();
 }
Esempio n. 2
0
 /**
  * Refresh the repository from the URL.
  *
  * @throws Exception
  */
 public boolean refresh() {
   exception = null;
   try {
     resources.clear();
     parseDocument(url);
     visited = null;
     return true;
   } catch (Exception e) {
     e.printStackTrace();
     exception = e;
   }
   return false;
 }
  private void removeUser(String user) {
    int count = 0;

    if (user_vidNameMap.containsKey(user)) {
      Set<String> vids = user_vidNameMap.get(user);
      Iterator<String> it = vids.iterator();
      while (it.hasNext()) {
        removeFromvidName_UserMap(user, it.next());
      }
      vids.clear();
      user_vidNameMap.remove(user);
    }
    activeUsers.remove(user);
    int ans = masterService.psDisConnectClient(hostAdder, user);
    while (ans != ACK) {
      if (count > 10) throw new RuntimeException("Time out in removing user from MS");
      reconnectToMS();
      ans = masterService.psDisConnectClient(hostAdder, user);
      count++;
    }
    System.out.println("User " + user + " removed.");
  }
 TaskObjectsExecutionResults submitWork(Vector originating_clients, TaskObject[] tasks)
     throws IOException, ClassNotFoundException, PDBatchTaskExecutorException {
   Set workers2rm = new HashSet(); // Set<PDBTEW2Listener>
   PDBTEW2Listener t = null;
   utils.Messenger.getInstance()
       .msg(
           "PDBTExecSingleCltWrkInitSrv.submitWork(clts,tasks): "
               + "finding an available worker connection among "
               + getNumWorkers()
               + " known workers",
           1);
   // 1. find a worker (via Round-Robin)
   synchronized (this) {
     boolean cont = true;
     while (cont) {
       workers2rm.clear();
       Iterator sit = getWorkers().keySet().iterator();
       while (sit.hasNext()) {
         Socket s = (Socket) sit.next();
         t = (PDBTEW2Listener) getWorkers().get(s);
         boolean is_avail = t.getAvailability() && !getWorking().contains(t);
         // the _working set is needed so that submitWork() is guaranteed not
         // to choose twice the same worker before the worker is done with the
         // first request.
         if (is_avail) {
           cont = false; // break out of the top-level while-loop too
           getWorking().add(t);
           break;
         } else {
           if (t.isConnectionLost()) workers2rm.add(t);
           t = null; // reset to null
         }
       }
       // remove any "lost connections" worker listeners
       Iterator it = workers2rm.iterator();
       while (it.hasNext()) getWorkers().remove(it.next());
       if (t == null) {
         // before trying again to find an available worker, wait a while
         try {
           wait(_CHECK_PERIOD_MSECS); // wait out the workers for some time
         } catch (InterruptedException e) {
           // e.printStackTrace();
           Thread.currentThread().interrupt(); // recommended
         }
       }
     }
   } // synchronized (this)
   if (t == null) { // failed to find an available thread
     utils.Messenger.getInstance()
         .msg("PDBTExecSingleCltWrkInitSrv.submitWork(clt,tasks): no available threads...", 1);
     throw new PDBatchTaskExecutorException("no available worker or known srv to undertake work");
   }
   utils.Messenger.getInstance()
       .msg("PDBTExecSingleCltWrkInitSrv.submitWork(clt,tasks): found an available worker", 1);
   // 2. submit tasks and get back results
   TaskObjectsExecutionRequest req = new TaskObjectsExecutionRequest(originating_clients, tasks);
   utils.Messenger.getInstance()
       .msg(
           "PDBTExecSingleCltWrkInitSrv.submitWork(clt,tasks): created the TaskObjectsExecutionRequest to send",
           1);
   RRObject res = submitWork(req, t);
   utils.Messenger.getInstance()
       .msg(
           "PDBTExecSingleCltWrkInitSrv.submitWork(tasks): finished running submitWork(req,ois,oos)",
           1);
   synchronized (this) {
     getWorking().remove(t); // declare worker's availability again
     notifyAll(); // declare I'm done. With only a single client connected, not of much use.
   }
   if (res instanceof TaskObjectsExecutionResults) return (TaskObjectsExecutionResults) res;
   else {
     throw new PDBatchTaskExecutorException(
         "PDBTExecSingleCltWrkInitSrv.submitWork(tasks): worker failed to process tasks.");
   }
 }
Esempio n. 5
0
 /**
  * Removes all audio event listeners from being notified of future audio events, if any were
  * present. If none were present, has no effect.
  */
 public static void clearAudioEventListeners() {
   listeners.clear();
 }