Package nux.xom.pool

Examples of nux.xom.pool.DocumentMap


        }
      }
    };
   
    return new DocumentPool(
      new DocumentMap(
        new PoolConfig().
          setCompressionLevel(docPoolCompression).
          setCapacity(docPoolCapacity)),
        docFactory);
  }
View Full Code Here


   
    if (args.length > ++k) config.setMaxIdleTime(Long.parseLong(args[k]));
   
    if (args.length > ++k) config.setMaxLifeTime(Long.parseLong(args[k]));
   
    final DocumentMap pool = new DocumentMap(config);
   
    final File[] files = new File[numFiles];
    new File("tmp").mkdir();
    for (int j=0; j < numFiles; j++) {
      files[j] = new File("tmp/file" + j + ".xml");
      System.out.println("writing " + files[j]);
      FileWriter out = new FileWriter(files[j]);
      out.write("<hello/>");
      out.flush();
      out.close();
    }
   
    for (int j=0; j < threads; j++) {
      final int t = j;
      Runnable runner = new Runnable() {
        public void run() {
          try {
            Builder builder = new Builder();
            int i = 0;
            while (i < files.length) {
              System.out.println("t="+ t + ", index="+i);
              Document doc = builder.build(files[i]);
              Object key = files[i];
              pool.putDocument(key, doc);
              i++;
            }
            System.out.println("done");
          }
          catch (Throwable t) {
View Full Code Here

    if (args.length > ++k) config.setMaxLifeTime(Long.parseLong(args[k]));
   
    int printStep = 10;
    if (args.length > ++k) printStep = Math.max(1, Integer.parseInt(args[k]));
   
    final DocumentMap pool = new DocumentMap(config);
   
    for (int j=0; j < threads; j++) {
      final int t = j;
      final Document xmlDoc = doc;
      final int step = printStep;
      Runnable runner = new Runnable() {
        public void run() {
          try {
            int i = 0;
            while (true) {
              if (i % step == 0) System.out.println("t="+ t + ", index=" + i);
              Document doc;
              if (xmlDoc == null) {
                Element root = new Element("root");
                Element child = new Element("child");
                root.appendChild(child);
                for (int j=0; j < 10000; j++) child.appendChild("xxxxxxxxxxxxxxxxxx" + j);
                doc = new Document(root);
              }
              else {
                doc = xmlDoc;
                if (config.getCompressionLevel() == -1) doc = new Document(doc);
              }
             
              Object key = new Integer(i + t*100);
//              Object key = new Integer(-1);
              pool.putDocument(key, doc);
             
//              // simulate hot cache items (gc should bias against collecting these)
              pool.getDocument(new Integer(8));
             
//              pool.getDocument(key);
              i++;
            }
          }
View Full Code Here

TOP

Related Classes of nux.xom.pool.DocumentMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.