Пример #1
2
  void removeTaskEntry(String taskid) {
    // taskid --> tracker
    String tracker = (String) taskidToTrackerMap.remove(taskid);

    // tracker --> taskid
    TreeSet trackerSet = (TreeSet) trackerToTaskMap.get(tracker);
    if (trackerSet != null) {
      trackerSet.remove(taskid);
    }

    // taskid --> TIP
    taskidToTIPMap.remove(taskid);
  }
Пример #2
1
  /**
   * We lost the task tracker! All task-tracker structures have already been updated. Just process
   * the contained tasks and any jobs that might be affected.
   */
  void lostTaskTracker(String trackerName) {
    LOG.info("Lost tracker '" + trackerName + "'");
    TreeSet lostTasks = (TreeSet) trackerToTaskMap.get(trackerName);
    trackerToTaskMap.remove(trackerName);

    if (lostTasks != null) {
      for (Iterator it = lostTasks.iterator(); it.hasNext(); ) {
        String taskId = (String) it.next();
        TaskInProgress tip = (TaskInProgress) taskidToTIPMap.get(taskId);

        // Tell the job to fail the relevant task
        JobInProgress job = tip.getJob();
        job.failedTask(tip, taskId, trackerName);
      }
    }
  }
Пример #3
0
 public static void eraseIndex(User user, String indexName)
     throws SearchLibException, NamingException, IOException {
   if (user != null && !user.isAdmin()) throw new SearchLibException("Operation not permitted");
   File indexDir = getIndexDirectory(indexName);
   Client client = null;
   synchronized (ClientCatalog.class) {
     clientsLock.r.lock();
     try {
       client = CLIENTS.get(indexDir);
     } finally {
       clientsLock.r.unlock();
     }
     if (client != null) {
       client.close();
       client.delete();
     } else FileUtils.deleteDirectory(indexDir);
     if (client != null) {
       clientsLock.w.lock();
       try {
         CLIENTS.remove(client.getDirectory());
       } finally {
         clientsLock.w.unlock();
       }
       PushEvent.eventClientSwitch.publish(client);
     }
   }
 }
 public synchronized void disconnect(Peer p) {
   DownloadTask dt = task.remove(p.toString());
   if (dt != null) {
     dt.end();
     dt = null;
   }
 }
Пример #5
0
 private static void lockClientDir(File clientDir) {
   clientsLock.w.lock();
   try {
     CLIENTS.remove(clientDir);
     OLD_CLIENTS.add(clientDir);
   } finally {
     clientsLock.w.unlock();
   }
 }
Пример #6
0
 public int releaseLock(UTF8 src, UTF8 holder) {
   TreeSet holders = (TreeSet) activeLocks.get(src);
   if (holders != null && holders.contains(holder)) {
     holders.remove(holder);
     if (holders.size() == 0) {
       activeLocks.remove(src);
     }
     return COMPLETE_SUCCESS;
   } else {
     return OPERATION_FAILED;
   }
 }
Пример #7
0
 public static final void closeIndex(String indexName) throws SearchLibException {
   Client client = null;
   clientsLock.w.lock();
   try {
     File indexDirectory = getIndexDirectory(indexName);
     client = CLIENTS.get(indexDirectory);
     if (client == null) return;
     Logging.info("Closing client " + indexName);
     client.close();
     CLIENTS.remove(indexDirectory);
   } finally {
     clientsLock.w.unlock();
   }
   if (client != null) PushEvent.eventClientSwitch.publish(client);
 }
Пример #8
0
 /**
  * Update the last recorded status for the given task tracker. It assumes that the taskTrackers
  * are locked on entry.
  *
  * @author Owen O'Malley
  * @param trackerName The name of the tracker
  * @param status The new status for the task tracker
  * @return Was an old status found?
  */
 private boolean updateTaskTrackerStatus(String trackerName, TaskTrackerStatus status) {
   TaskTrackerStatus oldStatus = (TaskTrackerStatus) taskTrackers.get(trackerName);
   if (oldStatus != null) {
     totalMaps -= oldStatus.countMapTasks();
     totalReduces -= oldStatus.countReduceTasks();
     if (status == null) {
       taskTrackers.remove(trackerName);
     }
   }
   if (status != null) {
     totalMaps += status.countMapTasks();
     totalReduces += status.countReduceTasks();
     taskTrackers.put(trackerName, status);
   }
   return oldStatus != null;
 }
Пример #9
0
  /**
   * Get list of each asset to be replaced, and the shots it's in.
   *
   * @return
   * @throws PipelineException
   */
  private boolean getShotsUsingAssets() throws PipelineException {
    ArrayList<ArchiveInfo> archive = mclient.archiveQuery(shotPattern, null);

    logLine("Looking for shots using lo-res assets.");
    for (ArchiveInfo curArc : archive) {
      String name = curArc.getName();
      VersionID vid = curArc.getVersionID();
      TreeSet<VersionID> allVers = mclient.getCheckedInVersionIDs(name);
      if (!vid.equals(allVers.last())) continue;

      NodeVersion ver = mclient.getCheckedInVersion(name, vid);
      Set<String> srcs = ver.getSourceNames();

      for (String loResAsset : pAssetManager.keySet()) {
        if (srcs.contains(loResAsset)) {
          // TODO chec if latest.

          logLine("\t" + getShortName(loResAsset) + ": " + getShortName(name));

          AssetInfo tempInfo = pAssetManager.get(loResAsset);

          if (!tempInfo.getLoHiResShots().containsKey(name))
            tempInfo.getLoHiResShots().put(name, null);
        } // end if
      } // end for
    } // end for

    logLine("Looking for shots using hi-res assets");
    /* - Populate lo-res */
    for (ArchiveInfo curArc : archive) {
      String name = curArc.getName();
      VersionID vid = curArc.getVersionID();
      TreeSet<VersionID> allVers = mclient.getCheckedInVersionIDs(name);
      if (!vid.equals(allVers.last())) continue;

      NodeVersion ver = mclient.getCheckedInVersion(name, vid);
      Set<String> srcs = ver.getSourceNames();

      for (String updateAsset : pAssetManager.keySet()) {
        String hiResAsset = updateAsset.replace(lr, "");
        if (srcs.contains(hiResAsset)) {
          logLine("\t" + getShortName(hiResAsset) + ": " + getShortName(name));
          AssetInfo tempInfo = pAssetManager.get(updateAsset);

          String loRes = tempInfo.getMatchingLoResShot(name);
          if (loRes == null) {
            logLine(
                "!!!\nWARNING:"
                    + getShortName(hiResAsset)
                    + " is used in the "
                    + getShortName(name)
                    + " node which has no matching lo-res model in an anim node."
                    + " So it will not be changed\n!!!");
            continue;
          }

          tempInfo.getLoHiResShots().put(loRes, name);
        } // end if
      } // end for
    } // end for(ArchiveInfo)

    logLine("");

    for (String updateAsset : potentialUpdates) {
      TreeMap<String, String> shots = pAssetManager.get(updateAsset).getLoHiResShots();
      if (shots.isEmpty()) {
        logLine(getShortName(updateAsset) + " is not used in any shots");
        pAssetManager.remove(updateAsset);
      }
      for (String loRes : shots.keySet()) {
        if (shots.get(loRes) == null)
          logLine(
              getShortName(updateAsset)
                  + " is in a hi-res shot, "
                  + getShortName(loRes)
                  + ", but doesn't have a matching hi-res"
                  + "model in the lgt node.");
      }
    }

    if (pAssetManager.isEmpty()) return false;

    return true;
  } // end getShotsUsingAssets
Пример #10
0
 /** Metodo responsavel por apagar um seguro a um cliente */
 public void removeSeguro(String cod) {
   seguros.remove(cod);
 }
Пример #11
0
  public String decisionRuleReport(double thresh, String target) {
    /*format of output:
     winning-item, thresh, rt, peak, peak-cycle, (#target-item, thresh, rt, peak, peak-cycle)
       # first-item-to-thresh,second-item-to-thresh,...tenth-item-to-thresh BASTA
     three possible outcomes:
       1. target is recognized first: report its stats only. # #
       2. another item is recognized first: report the winner, # then target stats. #
       3. no item is recognized: # report the target's stats. #
     TODO: right now, the silence segment is always the winner: this could be prevented if we wanted
     TODO: instead of top-ten to thresh, top-ten peaks might be more useful
    */

    if (target.startsWith("-") && target.length() > 1) {
      String[] split = target.split("-");
      if (split == null || split.length == 0 || (split.length == 1 && split[0].equals("")))
        target = "-";
      else {
        target = split[1];
      }
    }
    String result = "target=\t" + target + "\t";
    TreeMap decisions = decisionResults(thresh);
    decisResult next;
    // record winning-item stats
    if (decisions.size() > 0) {
      next = (decisResult) (decisions.remove(decisions.firstKey()));
      result += next.name + "\t" + next.thresh + "\t";
      if (next.recogRt == 12345) result += "\\N\t";
      else result += next.recogRt + "\t";
      result += next.peak + "\t" + next.peakRt + "\t";
    }
    // no decision results!
    else {
      result += "(null)";
      // System.out.println(result);
      return result;
    }
    result += "#\t";
    // is the winning item the target?
    if (next.name.equals(target)) {
      // yes : great! don't report anything else
    } else {
      // if not, find the target and report its stats.
      while (decisions.size() > 0) {
        next = (decisResult) (decisions.remove(decisions.firstKey()));
        if (next.name.equals(target)) {
          result += next.name + "\t" + next.thresh + "\t";
          if (next.recogRt == 12345) result += "-1\t";
          else result += next.recogRt + "\t";
          result += next.peak + "\t" + next.peakRt;
          break;
        }
      }
    }
    decisions = decisionResults(thresh);
    result += "#\t";
    for (int i = 0; decisions.size() > 0 && i < 10; i++) {
      next = (decisResult) (decisions.remove(decisions.firstKey()));
      result += next.name + "\t";
    }
    // System.out.println(result);
    return result;
  }