예제 #1
0
 static void writeDoc1(Document doc, PrintStream out) throws IOException {
   Vector<Annotation> entities = doc.annotationsOfType("entity");
   if (entities == null) {
     System.err.println("No Entity: " + doc);
     return;
   }
   Iterator<Annotation> entityIt = entities.iterator();
   int i = 0;
   while (entityIt.hasNext()) {
     Annotation entity = entityIt.next();
     Vector mentions = (Vector) entity.get("mentions");
     Iterator mentionIt = mentions.iterator();
     String nameType = (String) entity.get("nameType");
     while (mentionIt.hasNext()) {
       Annotation mention1 = (Annotation) mentionIt.next();
       Annotation mention2 = new Annotation("refobj", mention1.span(), new FeatureSet());
       mention2.put("objid", Integer.toString(i));
       if (nameType != null) {
         mention2.put("netype", nameType);
       }
       doc.addAnnotation(mention2);
     }
     i++;
   }
   // remove other annotations.
   String[] annotypes = doc.getAnnotationTypes();
   for (i = 0; i < annotypes.length; i++) {
     String t = annotypes[i];
     if (!(t.equals("tagger") || t.equals("refobj") || t.equals("ENAMEX"))) {
       doc.removeAnnotationsOfType(t);
     }
   }
   writeDocRaw(doc, out);
   return;
 }
예제 #2
0
  /**
   * Put the JAIN-SIP stack in a state where it cannot receive any data and frees the network ports
   * used. That is to say remove JAIN-SIP <tt>ListeningPoint</tt>s and <tt>SipProvider</tt>s.
   */
  @SuppressWarnings("unchecked") // jain-sip legacy code
  private void stopListening() {
    try {
      this.secureJainSipProvider.removeSipListener(this);
      this.stack.deleteSipProvider(this.secureJainSipProvider);
      this.secureJainSipProvider = null;
      this.clearJainSipProvider.removeSipListener(this);
      this.stack.deleteSipProvider(this.clearJainSipProvider);
      this.clearJainSipProvider = null;

      Iterator<ListeningPoint> it = this.stack.getListeningPoints();
      Vector<ListeningPoint> lpointsToRemove = new Vector<ListeningPoint>();
      while (it.hasNext()) {
        lpointsToRemove.add(it.next());
      }

      it = lpointsToRemove.iterator();
      while (it.hasNext()) {
        this.stack.deleteListeningPoint(it.next());
      }

      this.stack.stop();
      if (logger.isTraceEnabled()) logger.trace("stopped listening");
    } catch (ObjectInUseException ex) {
      logger.fatal("Failed to stop listening", ex);
    }
  }
예제 #3
0
  void writeFiles(Vector allConfigs) {

    Hashtable allFiles = computeAttributedFiles(allConfigs);

    Vector allConfigNames = new Vector();
    for (Iterator i = allConfigs.iterator(); i.hasNext(); ) {
      allConfigNames.add(((BuildConfig) i.next()).get("Name"));
    }

    TreeSet sortedFiles = sortFiles(allFiles);

    startTag("Files", null);

    for (Iterator i = makeFilters(sortedFiles).iterator(); i.hasNext(); ) {
      doWriteFiles(sortedFiles, allConfigNames, (NameFilter) i.next());
    }

    startTag(
        "Filter",
        new String[] {
          "Name", "Resource Files",
          "Filter", "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
        });
    endTag("Filter");

    endTag("Files");
  }
예제 #4
0
  /**
   * This method exports the single pattern decision instance to the XML. It MUST be called by an
   * XML exporter, as this will not have a complete header.
   *
   * @param ratDoc The ratDoc generated by the XML exporter
   * @return the SAX representation of the object.
   */
  public Element toXML(Document ratDoc) {
    Element decisionE;
    RationaleDB db = RationaleDB.getHandle();

    // Now, add pattern to doc
    String entryID = db.getRef(this);
    if (entryID == null) {
      entryID = db.addPatternDecisionRef(this);
    }

    decisionE = ratDoc.createElement("DR:patternDecision");
    decisionE.setAttribute("rid", entryID);
    decisionE.setAttribute("name", name);
    decisionE.setAttribute("type", type.toString());
    decisionE.setAttribute("phase", devPhase.toString());
    decisionE.setAttribute("status", status.toString());
    // decisionE.setAttribute("artifact", artifact);

    Element descE = ratDoc.createElement("description");
    Text descText = ratDoc.createTextNode(description);
    descE.appendChild(descText);
    decisionE.appendChild(descE);

    // Add child pattern references...
    Iterator<Pattern> cpi = candidatePatterns.iterator();
    while (cpi.hasNext()) {
      Pattern cur = cpi.next();
      Element curE = ratDoc.createElement("refChildPattern");
      Text curText = ratDoc.createTextNode("p" + new Integer(cur.getID()).toString());
      curE.appendChild(curText);
      decisionE.appendChild(curE);
    }

    return decisionE;
  }
예제 #5
0
 /**
  * Reads all of the files in the given directory and adds them as children of the directory tree
  * node. Requires that the passed node represents a directory.
  */
 private void readDirectory(Node parentNode, File parentDir) {
   File[] children = parentDir.listFiles();
   if (children == null) return;
   if (verbose) {
     System.out.print(".");
     System.out.flush();
   }
   for (int i = 0; i < children.length; i++) {
     File child = children[i];
     children[i] = null;
     boolean isDir = child.isDirectory();
     boolean mustSkip = false;
     if (isDir) {
       for (Iterator iter = subdirsToIgnore.iterator(); iter.hasNext(); ) {
         if (child.getName().equals((String) iter.next())) {
           mustSkip = true;
           break;
         }
       }
     }
     if (!mustSkip) {
       Node childNode = new Node(child);
       parentNode.addChild(childNode);
       if (isDir) {
         readDirectory(childNode, child);
       }
     }
   }
 }
예제 #6
0
 protected void layoutFooter(Page page) {
   ServletUtil.doLayoutFooter(
       page, (footnotes == null ? null : footnotes.iterator()), getLockssApp().getVersionInfo());
   if (footnotes != null) {
     footnotes.removeAllElements();
   }
 }
예제 #7
0
  public static String[] parseString(String text, String seperator) {
    Vector vResult = new Vector();
    if (text == null || "".equals(text)) {
      return null;
    }
    String tempStr = text.trim();
    String currentLabel = null;
    int index = tempStr.indexOf(seperator);
    while (index != -1) {
      currentLabel = tempStr.substring(0, index).trim();

      if (!"".equals(currentLabel)) {
        vResult.addElement(currentLabel);
      }
      tempStr = tempStr.substring(index + 1);
      index = tempStr.indexOf(seperator);
    } // Last label
    currentLabel = tempStr.trim();
    if (!"".equals(currentLabel)) {
      vResult.addElement(currentLabel);
    }
    String[] re = new String[vResult.size()];
    Iterator it = vResult.iterator();
    index = 0;
    while (it.hasNext()) {
      re[index] = (String) it.next();
      index++;
    }
    return re;
  }
예제 #8
0
  void writeCustomToolConfig(Vector configs, String[] customToolAttrs) {
    for (Iterator i = configs.iterator(); i.hasNext(); ) {
      startTag("FileConfiguration", new String[] {"Name", (String) i.next()});
      tag("Tool", customToolAttrs);

      endTag("FileConfiguration");
    }
  }
  /**
   * Returns true iff all the files listed in this tracker's dependency list exist and are at the
   * same version as when they were recorded.
   *
   * @return a boolean
   */
  boolean isUpToDate(Properties properties) {
    Iterator e;

    // fixes bug 962
    {
      if (mProperties.size() != properties.size()) {
        mLogger.debug(
            /* (non-Javadoc)
             * @i18n.test
             * @org-mes="my size " + p[0]
             */
            org.openlaszlo.i18n.LaszloMessages.getMessage(
                DependencyTracker.class.getName(),
                "051018-181",
                new Object[] {new Integer(mProperties.size())}));
        mLogger.debug(
            /* (non-Javadoc)
             * @i18n.test
             * @org-mes="new size " + p[0]
             */
            org.openlaszlo.i18n.LaszloMessages.getMessage(
                DependencyTracker.class.getName(),
                "051018-189",
                new Object[] {new Integer(properties.size())}));
        return false;
      }

      for (e = mProperties.keySet().iterator(); e.hasNext(); ) {
        String key = (String) e.next();
        String val0 = mProperties.getProperty(key);
        String val1 = properties.getProperty(key);

        // val0 can't be null; properties don't allow that
        if (val1 == null || !val0.equals(val1)) {
          mLogger.debug(
              /* (non-Javadoc)
               * @i18n.test
               * @org-mes="Missing or changed property: " + p[0]
               */
              org.openlaszlo.i18n.LaszloMessages.getMessage(
                  DependencyTracker.class.getName(), "051018-207", new Object[] {val0}));
          return false;
        }
      }
    }

    for (e = mDependencies.iterator(); e.hasNext(); ) {
      FileInfo saved = (FileInfo) e.next();
      FileInfo current = new FileInfo(saved.mPathname);
      if (!saved.isUpToDate(current)) {
        mLogger.debug(saved.mPathname + " has changed");
        mLogger.debug("was " + saved.mLastMod);
        mLogger.debug(" is " + current.mLastMod);
        return false;
      }
    }
    return true;
  }
예제 #10
0
 public synchronized TaskReport[] getReduceTaskReports(String jobid) {
   JobInProgress job = (JobInProgress) jobs.get(jobid);
   if (job == null) {
     return new TaskReport[0];
   } else {
     Vector reports = new Vector();
     Vector completeReduceTasks = job.reportTasksInProgress(false, true);
     for (Iterator it = completeReduceTasks.iterator(); it.hasNext(); ) {
       TaskInProgress tip = (TaskInProgress) it.next();
       reports.add(tip.generateSingleReport());
     }
     Vector incompleteReduceTasks = job.reportTasksInProgress(false, false);
     for (Iterator it = incompleteReduceTasks.iterator(); it.hasNext(); ) {
       TaskInProgress tip = (TaskInProgress) it.next();
       reports.add(tip.generateSingleReport());
     }
     return (TaskReport[]) reports.toArray(new TaskReport[reports.size()]);
   }
 }
예제 #11
0
  public void writeProjectFile(String projectFileName, String projectName, Vector allConfigs)
      throws IOException {
    System.out.println();
    System.out.println("    Writing .vcproj file...");
    // If we got this far without an error, we're safe to actually
    // write the .vcproj file
    printWriter = new PrintWriter(new FileWriter(projectFileName));

    printWriter.println("<?xml version=\"1.0\" encoding=\"windows-1251\"?>");
    startTag(
        "VisualStudioProject",
        new String[] {
          "ProjectType", "Visual C++",
          "Version", projectVersion(),
          "Name", projectName,
          "ProjectGUID", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}",
          "SccProjectName", "",
          "SccLocalPath", ""
        });

    startTag("Platforms", null);
    tag("Platform", new String[] {"Name", Util.os});
    endTag("Platforms");

    startTag("Configurations", null);

    for (Iterator i = allConfigs.iterator(); i.hasNext(); ) {
      writeConfiguration((BuildConfig) i.next());
    }

    endTag("Configurations");

    tag("References", null);

    writeFiles(allConfigs);

    tag("Globals", null);

    endTag("VisualStudioProject");
    printWriter.close();

    System.out.println("    Done.");
  }
예제 #12
0
  /**
   * Get a listing of files given path 'src'
   *
   * <p>This function is admittedly very inefficient right now. We'll make it better later.
   */
  public DFSFileInfo[] getListing(UTF8 src) {
    String srcs = normalizePath(src);

    synchronized (rootDir) {
      INode targetNode = rootDir.getNode(srcs);
      if (targetNode == null) {
        return null;
      } else {
        Vector contents = new Vector();
        targetNode.listContents(contents);

        DFSFileInfo listing[] = new DFSFileInfo[contents.size()];
        int i = 0;
        for (Iterator it = contents.iterator(); it.hasNext(); i++) {
          listing[i] = new DFSFileInfo((INode) it.next());
        }
        return listing;
      }
    }
  }
예제 #13
0
 /**
  * This will update the FileInfo object chain to use the (possibly new) webappPath once the
  * DependencyTracker object has been reconstitutded from ondisk cache.
  */
 void updateWebappPath() {
   String webappPath = LPS.HOME(); // get it from global
   if (webappPath.equals(mWebappPath)) return;
   mLogger.debug(
       /* (non-Javadoc)
        * @i18n.test
        * @org-mes="updating webappPath from: " + p[0]
        */
       org.openlaszlo.i18n.LaszloMessages.getMessage(
           DependencyTracker.class.getName(), "051018-128", new Object[] {mWebappPath}));
   mLogger.debug(
       /* (non-Javadoc)
        * @i18n.test
        * @org-mes="updating webappPath to:   " + p[0]
        */
       org.openlaszlo.i18n.LaszloMessages.getMessage(
           DependencyTracker.class.getName(), "051018-136", new Object[] {webappPath}));
   for (Iterator e = mDependencies.iterator(); e.hasNext(); ) {
     FileInfo saved = (FileInfo) e.next();
     if (saved.mPathname.startsWith(mWebappPath)) {
       mLogger.debug(
           /* (non-Javadoc)
            * @i18n.test
            * @org-mes="updating dependencies from: " + p[0]
            */
           org.openlaszlo.i18n.LaszloMessages.getMessage(
               DependencyTracker.class.getName(), "051018-147", new Object[] {saved.mPathname}));
       saved.mPathname = webappPath + saved.mPathname.substring(mWebappPath.length());
       mLogger.debug(
           /* (non-Javadoc)
            * @i18n.test
            * @org-mes="updating dependencies to  : " + p[0]
            */
           org.openlaszlo.i18n.LaszloMessages.getMessage(
               DependencyTracker.class.getName(), "051018-157", new Object[] {saved.mPathname}));
     }
   }
   mWebappPath = webappPath;
 }
예제 #14
0
 Block[] unprotectedDelete(UTF8 src) {
   synchronized (rootDir) {
     INode targetNode = rootDir.getNode(src.toString());
     if (targetNode == null) {
       return null;
     } else {
       //
       // Remove the node from the namespace and GC all
       // the blocks underneath the node.
       //
       if (!targetNode.removeNode()) {
         return null;
       } else {
         Vector v = new Vector();
         targetNode.collectSubtreeBlocks(v);
         for (Iterator it = v.iterator(); it.hasNext(); ) {
           Block b = (Block) it.next();
           activeBlocks.remove(b);
         }
         return (Block[]) v.toArray(new Block[v.size()]);
       }
     }
   }
 }
예제 #15
0
  /**
   * A tracker wants to know if there's a Task to run. Returns a task we'd like the TaskTracker to
   * execute right now.
   *
   * <p>Eventually this function should compute load on the various TaskTrackers, and incorporate
   * knowledge of DFS file placement. But for right now, it just grabs a single item out of the
   * pending task list and hands it back.
   */
  public synchronized Task pollForNewTask(String taskTracker) {
    //
    // Compute average map and reduce task numbers across pool
    //
    int avgMaps = 0;
    int avgReduces = 0;
    int numTaskTrackers;
    TaskTrackerStatus tts;
    synchronized (taskTrackers) {
      numTaskTrackers = taskTrackers.size();
      tts = (TaskTrackerStatus) taskTrackers.get(taskTracker);
    }
    if (numTaskTrackers > 0) {
      avgMaps = totalMaps / numTaskTrackers;
      avgReduces = totalReduces / numTaskTrackers;
    }
    int totalCapacity = numTaskTrackers * maxCurrentTasks;
    //
    // Get map + reduce counts for the current tracker.
    //
    if (tts == null) {
      LOG.warning("Unknown task tracker polling; ignoring: " + taskTracker);
      return null;
    }

    int numMaps = tts.countMapTasks();
    int numReduces = tts.countReduceTasks();

    //
    // In the below steps, we allocate first a map task (if appropriate),
    // and then a reduce task if appropriate.  We go through all jobs
    // in order of job arrival; jobs only get serviced if their
    // predecessors are serviced, too.
    //

    //
    // We hand a task to the current taskTracker if the given machine
    // has a workload that's equal to or less than the averageMaps
    // +/- TASK_ALLOC_EPSILON.  (That epsilon is in place in case
    // there is an odd machine that is failing for some reason but
    // has not yet been removed from the pool, making capacity seem
    // larger than it really is.)
    //
    synchronized (jobsByArrival) {
      if ((numMaps < maxCurrentTasks) && (numMaps <= (avgMaps + TASK_ALLOC_EPSILON))) {

        int totalNeededMaps = 0;
        for (Iterator it = jobsByArrival.iterator(); it.hasNext(); ) {
          JobInProgress job = (JobInProgress) it.next();
          if (job.getStatus().getRunState() != JobStatus.RUNNING) {
            continue;
          }

          Task t = job.obtainNewMapTask(taskTracker, tts);
          if (t != null) {
            return t;
          }

          //
          // Beyond the highest-priority task, reserve a little
          // room for failures and speculative executions; don't
          // schedule tasks to the hilt.
          //
          totalNeededMaps += job.desiredMaps();
          double padding = 0;
          if (totalCapacity > MIN_SLOTS_FOR_PADDING) {
            padding = Math.min(maxCurrentTasks, totalNeededMaps * PAD_FRACTION);
          }
          if (totalNeededMaps + padding >= totalCapacity) {
            break;
          }
        }
      }

      //
      // Same thing, but for reduce tasks
      //
      if ((numReduces < maxCurrentTasks) && (numReduces <= (avgReduces + TASK_ALLOC_EPSILON))) {

        int totalNeededReduces = 0;
        for (Iterator it = jobsByArrival.iterator(); it.hasNext(); ) {
          JobInProgress job = (JobInProgress) it.next();
          if (job.getStatus().getRunState() != JobStatus.RUNNING) {
            continue;
          }

          Task t = job.obtainNewReduceTask(taskTracker, tts);
          if (t != null) {
            return t;
          }

          //
          // Beyond the highest-priority task, reserve a little
          // room for failures and speculative executions; don't
          // schedule tasks to the hilt.
          //
          totalNeededReduces += job.desiredReduces();
          double padding = 0;
          if (totalCapacity > MIN_SLOTS_FOR_PADDING) {
            padding = Math.min(maxCurrentTasks, totalNeededReduces * PAD_FRACTION);
          }
          if (totalNeededReduces + padding >= totalCapacity) {
            break;
          }
        }
      }
    }
    return null;
  }
예제 #16
0
 public Iterator<Integer> iteratorSubPatterns() {
   return subPatternsID.iterator();
 }
예제 #17
0
 public Iterator getChildren() throws IllegalArgumentException {
   return children.iterator();
 }
예제 #18
0
  void doWriteFiles(TreeSet allFiles, Vector allConfigNames, NameFilter filter) {
    startTag(
        "Filter",
        new String[] {
          "Name", filter.name(),
          "Filter", filter.filterString()
        });

    if (filter instanceof ContainerFilter) {

      Iterator i = ((ContainerFilter) filter).babies();
      while (i.hasNext()) {
        doWriteFiles(allFiles, allConfigNames, (NameFilter) i.next());
      }

    } else {

      Iterator i = allFiles.iterator();
      while (i.hasNext()) {
        FileInfo fi = (FileInfo) i.next();

        if (!filter.match(fi)) {
          continue;
        }

        startTag("File", new String[] {"RelativePath", fi.full.replace('/', '\\')});

        FileAttribute a = fi.attr;
        if (a.pchRoot) {
          writeCustomToolConfig(
              allConfigNames,
              new String[] {
                "Name", "VCCLCompilerTool",
                "UsePrecompiledHeader", "1"
              });
        }

        if (a.noPch) {
          writeCustomToolConfig(
              allConfigNames,
              new String[] {
                "Name", "VCCLCompilerTool",
                "UsePrecompiledHeader", "0"
              });
        }

        if (a.configs != null) {
          for (Iterator j = allConfigNames.iterator(); j.hasNext(); ) {
            String cfg = (String) j.next();
            if (!a.configs.contains(cfg)) {
              startTag(
                  "FileConfiguration", new String[] {"Name", cfg, "ExcludedFromBuild", "TRUE"});
              tag("Tool", new String[] {"Name", "VCCLCompilerTool"});
              endTag("FileConfiguration");
            }
          }
        }

        endTag("File");

        // we not gonna look at this file anymore
        i.remove();
      }
    }

    endTag("Filter");
  }
예제 #19
0
 Iterator babies() {
   return children.iterator();
 }