Examples of ExecutorService


Examples of java.util.concurrent.ExecutorService

      ModuleMetaData conflict = new ModuleMetaData();
      conflict.setName("conflict.war");
      conflict.setUniqueName(SIMPLE_TRIMMED_PATH);
      modsmd.add(conflict);
     
      ExecutorService executor = Executors.newFixedThreadPool(3);
     
      CountDownLatch startLatch = new CountDownLatch(4);
      CountDownLatch finishLatch = new CountDownLatch(3);
     
      DeploymentTask warTask = new DeploymentTask(startLatch, finishLatch, war);
      executor.execute(warTask);
     
      DeploymentTask jarTask = new DeploymentTask(startLatch, finishLatch, jar);
      executor.execute(jarTask);
     
      DeploymentTask appclientTask = new DeploymentTask(startLatch, finishLatch, appClient);
      executor.execute(appclientTask);
     
      startLatch.countDown();
     
      assertTrue(finishLatch.await(5, TimeUnit.SECONDS));
     
View Full Code Here

Examples of java.util.concurrent.ExecutorService

          callables.add(downloadThread);
        }
        // Loop until all images are downloaded or timeout is reached
        long totalTimeout = DOWNLOAD_TIMEOUT + DOWNLOAD_TIMEOUT_ONE_TILE * tiles.size();
        log.debug("=== total timeout (millis): {}", totalTimeout);
        ExecutorService service = Executors.newFixedThreadPool(DOWNLOAD_MAX_THREADS);
        List<Future<ImageResult>> futures = service.invokeAll(callables, totalTimeout, TimeUnit.MILLISECONDS);
        // determine the pixel bounds of the mosaic
        Bbox pixelBounds = getPixelBounds(tiles);
        // create the images for the mosaic
        List<RenderedImage> images = new ArrayList<RenderedImage>();
        for (Future<ImageResult> future : futures) {
View Full Code Here

Examples of java.util.concurrent.ExecutorService

        compare(t);
    }

    private void compare(Thread[] t) throws InterruptedException {
    ExecutorService pool =
      Executors.newFixedThreadPool(t.length);
   
        for (Thread ti : t)
            pool.execute(ti);
   
    pool.shutdown();
    pool.awaitTermination(20, TimeUnit.SECONDS);

        for (int i = 0; i < x.size(); ++i)
            assertEquals(x.get(i), output[i], 1e-10);
    }
View Full Code Here

Examples of java.util.concurrent.ExecutorService

            callables.add(downloadThread);
          }
          // Loop until all images are downloaded or timeout is reached
          long totalTimeout = DOWNLOAD_TIMEOUT + DOWNLOAD_TIMEOUT_ONE_TILE * tiles.size();
          log.debug("=== total timeout (millis): {}", totalTimeout);
          ExecutorService service = Executors.newFixedThreadPool(DOWNLOAD_MAX_THREADS);
          List<Future<ImageResult>> futures = service.invokeAll(callables, totalTimeout,
              TimeUnit.MILLISECONDS);
          // determine the pixel bounds of the mosaic
          Bbox pixelBounds = getPixelBounds(tiles);
          int imageWidth = configurationService.getRasterLayerInfo(getLayerId()).getTileWidth();
          int imageHeight = configurationService.getRasterLayerInfo(getLayerId()).getTileHeight();
View Full Code Here

Examples of java.util.concurrent.ExecutorService

    executor.setThreadFactory(new ThreadFactoryBuilder()
        .setDaemon(true)
        .setThreadFactory(executor.getThreadFactory())
        .build());

    ExecutorService service = Executors.unconfigurableExecutorService(executor);

    addDelayedShutdownHook(service, terminationTimeout, timeUnit);

    return service;
  }
View Full Code Here

Examples of java.util.concurrent.ExecutorService

        final IRepositoryReader repo = pPathElement.getReader();

        if (!executors.containsKey(repo))
            executors.put(repo, Executors.newSingleThreadExecutor());

        final ExecutorService service = executors.get(repo);
        LOG.trace("Submitting fetch task for repo executor " + repo.getRootURI());
        return service.submit(new ChildFetcher(pPathElement));
    }
View Full Code Here

Examples of java.util.concurrent.ExecutorService

            String title = null;
            wikiparserrecord poison = newRecord();
            int threads = Math.max(2, Runtime.getRuntime().availableProcessors() - 1);
            BlockingQueue<wikiparserrecord> in = new ArrayBlockingQueue<wikiparserrecord>(threads * 10);
            BlockingQueue<wikiparserrecord> out = new ArrayBlockingQueue<wikiparserrecord>(threads * 10);
            ExecutorService service = Executors.newFixedThreadPool(threads + 1);
            convertConsumer[] consumers = new convertConsumer[threads];
            Future<?>[] consumerResults = new Future[threads];
            for (int i = 0; i < threads; i++) {
                consumers[i] = new convertConsumer(in, out, poison);
                consumerResults[i] = service.submit(consumers[i]);
            }
            convertWriter   writer = new convertWriter(out, poison, targetdir, targetstub);
            Future<Integer> writerResult = service.submit(writer);
           
            wikiparserrecord record;
            int q;
            while ((t = r.readLine()) != null) {
                if ((p = t.indexOf("<base>")) >= 0 && (q = t.indexOf("</base>", p)) > 0) {
View Full Code Here

Examples of java.util.concurrent.ExecutorService

       
        // init reader, producer and consumer
        PositionAwareReader in = new PositionAwareReader(dumpFile);
        indexProducer producer = new indexProducer(100, idxFromWikimediaXML(dumpFile));
        wikiConsumer consumer = new wikiConsumer(100, producer);
        ExecutorService service = Executors.newFixedThreadPool(2);
        Future<Integer> producerResult = service.submit(consumer);
        Future<Integer> consumerResult = service.submit(producer);
        service.shutdown();
       
        // read the wiki dump
        long start, stop;
        while (in.seek(pagestartb)) {
            start = in.pos() - 6;
View Full Code Here

Examples of java.util.concurrent.ExecutorService

     * @param bufferSize
     * @return
     */
    public final static initDataConsumer asynchronusInitializer(final String name, final int keylength, final ByteOrder objectOrder, final int idxbytes, final int expectedspace) {
        final initDataConsumer initializer = new initDataConsumer(new HandleMap(keylength, objectOrder, idxbytes, expectedspace, name));
        final ExecutorService service = Executors.newSingleThreadExecutor();
        initializer.setResult(service.submit(initializer));
        service.shutdown();
        return initializer;
    }
View Full Code Here

Examples of java.util.concurrent.ExecutorService

        }

        // create a concurrent thread that consumes data as it is read
        // and computes the md5 while doing IO
        final md5FilechunkConsumer md5consumer = new md5FilechunkConsumer(1024 * 64, 8);
        final ExecutorService service = Executors.newSingleThreadExecutor();
        final Future<MessageDigest> md5result = service.submit(md5consumer);
        service.shutdown();

        filechunk c;
        try {
            while (true) {
                c = md5consumer.nextFree();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.