Guava ListeningExecutorService - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Guava ListeningExecutorService class.

This code example shows how to use the following methods:shutdownNow
         this.service = service;
      } 
 
      @Override 
      public void close() throws IOException {
         List<Runnable> runnables = service.shutdownNow();
         if (!runnables.isEmpty())
            logger.warn("when shutting down executor %s, runnables outstanding: %s", service, runnables);
      } 
   } 
 
   final ListeningExecutorService userExecutorFromConstructor;
 
   public ExecutorServiceModule() { 
      this.userExecutorFromConstructor = null;
   } 
 
   /** 
    * @deprecated {@code ioExecutor} is no longer used. This constructor will be removed in jclouds v2. 
    * Use {@link #ExecutorServiceModule(ExecutorService)} instead. 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:awaitTermination, shutdown
    ListeningExecutorService executorService = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
 
    // create dummy log/index files, and load the reader from them 
    final File logFile = new File("reloadabletest.spl");
    create(Sparkey.getIndexFile(logFile));
    final ReloadableSparkeyReader reader = ReloadableSparkeyReader.fromLogFile(logFile, executorService).get();
 
    // should be ignored (same file) 
    reader.load(logFile);
 
    // should load from second file now 
    final File logFile2 = new File("reloadabletest2.spl");
    create(Sparkey.getIndexFile(logFile2));
    reader.load(logFile2);
 
    reader.close();
    executorService.shutdown();
    executorService.awaitTermination(10, TimeUnit.SECONDS);
 
    Sparkey.getIndexFile(logFile).delete();

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:shutdown
   protected void tearDown() { 
      api.deleteNode(prefix); 
      api.deleteNode(prefix + 1); 
 
      this.testExecutorService.shutdown();
      this.testListeningExecutorService.shutdown();
 
      super.tearDown(); 
   } 
 
   @Test
   public void testExecute() { 
      assertTrue(size(strategy.execute()) > 0, "Expected one or more elements");
   } 
 
   public void testExecuteConcurrentlyWithExecutorService() { 
      assertTrue(size(strategy.execute(testExecutorService)) > 0, "Expected one or more elements");
   } 
 
   public void testExecuteConcurrentlyWithListeningExecutorService() { 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:shutdown
   protected void tearDown() { 
      api.deleteNode(prefix); 
      api.deleteNode(prefix + 1); 
 
      this.testExecutorService.shutdown();
      this.testListeningExecutorService.shutdown();
 
      super.tearDown(); 
   } 
 
   @Test
   public void testExecute() { 
      assertTrue(size(strategy.execute("_default")) > 0, "Expected one or more elements");
   } 
 
   @Test
   public void testExecuteConcurrentlyWithExecutorService() { 
      assertTrue(size(strategy.execute(testExecutorService, "_default")) > 0,
            "Expected one or more elements"); 
   } 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:shutdown
      api.deleteCookbook(PREFIX, "1.0.0");
      api.deleteCookbook(PREFIX + 1, "0.0.0");
      api.deleteCookbook(PREFIX + 1, "1.0.0");
 
      this.testExecutorService.shutdown();
      this.testListeningExecutorService.shutdown();
 
      super.tearDown(); 
   } 
 
   @Test
   public void testExecute() { 
      assertTrue(size(strategy.execute("_default")) > 0, "Expected one or more elements");
   } 
 
   @Test
   public void testExecuteConcurrentlyWithExecutorService() { 
      assertTrue(size(strategy.execute(testExecutorService, "_default")) > 0,
            "Expected one or more elements"); 
   } 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:submit
        futureParts.put(part, futureETag);
    } 
 
    @Override 
    public ListenableFuture<String> execute(final String container, final Blob blob, final PutOptions options, final BlobToObject blob2Object) {
        return ioExecutor.submit(new Callable<String>() {
                    @Override 
                    public String call() throws Exception {
                        String key = blob.getMetadata().getName();
                        Payload payload = blob.getPayload();
                        MultipartUploadSlicingAlgorithm algorithm = new MultipartUploadSlicingAlgorithm();
                        algorithm.calculateChunkSize(payload.getContentMetadata()
                                .getContentLength()); 
                        int parts = algorithm.getParts();
                        long chunkSize = algorithm.getChunkSize();
                        long remaining = algorithm.getRemaining();
                        if (parts > 0) {
                            CommonSwiftClient client = ablobstore.getContext().unwrap(SwiftApiMetadata.CONTEXT_TOKEN).getApi();
                            final Map<Integer, ListenableFuture<String>> futureParts =
                                    new ConcurrentHashMap<Integer, ListenableFuture<String>>();
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:submit
  public void close() { 
    underlyingExecutor.shutdown();
  } 
 
  public <T> Response<T> submit(RequestCallable<T> requestCallable) {
    return new Response<T>(callExecutor.submit(requestCallable));
  } 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:submit
			XEventPump.LOG.error(errorMsg);
			throw new Error(errorMsg);
		} 
 
		// pass x event from x-event-pump thread to x-executor thread. 
		this.xExecutor.submit(new Callable<Void>() {
			@Override 
			public Void call() {
				XEventPump.this.xEventBus.post(xcb_generic_event);
				xcb_generic_event.delete();
				return null; 
			} 
		}); 
 
		// schedule next event retrieval 
		this.xEventPumpExecutor.submit(this);
		return null; 
	} 
 
	public void start() { 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:submit
 
    Preconditions.checkNotNull(emailAddress, "'emailAddress' must be present");
 
    final String cleanEmailAddress = emailAddress.toLowerCase().trim();
 
    return gravatarExecutorService.submit(new Callable<Optional<BufferedImage>>() {
 
      @Override 
      public Optional<BufferedImage> call() throws Exception {
        return cache.get(cleanEmailAddress);
      } 
    }); 
 
  } 
 
  /** 
   * @param emailAddress The cleaned email address to use as an MD5 lookup 
   * 
   * @return The buffered image if present 
   */ 
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:shutdown
        executor = listeningDecorator(newCachedThreadPool());
    } 
 
    @After 
    public void tearDown() { 
        executor.shutdown();
    } 
 
    @Test(expected = IllegalStateException.class)
    public void notStarted() throws ExecutionException, InterruptedException {
        ManagementOperation<Integer> op = ManagementOperation.done("test", 42);
        assertTrue(op.isDone());
        assertEquals(42, (int) op.get());
        sameThreadExecutor().execute(op);
    } 
 
    @Test
    public void succeeded() throws InterruptedException, ExecutionException, TimeoutException {
        ManagementOperation<Long> op = newManagementOperation("test", new Callable<Long>() {
            @Override 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java