Package com.google.common.util.concurrent

Examples of com.google.common.util.concurrent.ListeningExecutorService


        this.clientProvider = checkNotNull(hiveCluster, "hiveCluster is null");

        long expiresAfterWriteMillis = checkNotNull(cacheTtl, "cacheTtl is null").toMillis();
        long refreshMills = checkNotNull(refreshInterval, "refreshInterval is null").toMillis();

        ListeningExecutorService listeningExecutor = MoreExecutors.listeningDecorator(executor);

        databaseNamesCache = CacheBuilder.newBuilder()
                .expireAfterWrite(expiresAfterWriteMillis, MILLISECONDS)
                .refreshAfterWrite(refreshMills, MILLISECONDS)
                .build(new BackgroundCacheLoader<String, List<String>>(listeningExecutor)
View Full Code Here


        this.clientProvider = checkNotNull(hiveCluster, "hiveCluster is null");

        long expiresAfterWriteMillis = checkNotNull(cacheTtl, "cacheTtl is null").toMillis();
        long refreshMills = checkNotNull(refreshInterval, "refreshInterval is null").toMillis();

        ListeningExecutorService listeningExecutor = MoreExecutors.listeningDecorator(executor);

        databaseNamesCache = CacheBuilder.newBuilder()
                .expireAfterWrite(expiresAfterWriteMillis, MILLISECONDS)
                .refreshAfterWrite(refreshMills, MILLISECONDS)
                .build(new BackgroundCacheLoader<String, List<String>>(listeningExecutor)
View Full Code Here

    @BeforeMethod
    public void setUp()
            throws Exception
    {
        mockSession = new MockCassandraSession(CONNECTOR_ID, new CassandraClientConfig());
        ListeningExecutorService executor = listeningDecorator(newCachedThreadPool(new ThreadFactoryBuilder().setDaemon(true).build()));
        schemaProvider = new CachingCassandraSchemaProvider(
                CONNECTOR_ID,
                mockSession,
                executor,
                new Duration(5, TimeUnit.MINUTES),
View Full Code Here

    public void setUp()
            throws Exception
    {
        mockClient = new MockHiveMetastoreClient();
        MockHiveCluster mockHiveCluster = new MockHiveCluster(mockClient);
        ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool(new ThreadFactoryBuilder().setDaemon(true).build()));
        metastore = new CachingHiveMetastore(mockHiveCluster, executor, new Duration(5, TimeUnit.MINUTES), new Duration(1, TimeUnit.MINUTES));
    }
View Full Code Here

        checkNotNull(executor, "executor is null");

        long expiresAfterWriteMillis = checkNotNull(cacheTtl, "cacheTtl is null").toMillis();
        long refreshMills = checkNotNull(refreshInterval, "refreshInterval is null").toMillis();

        ListeningExecutorService listeningExecutor = MoreExecutors.listeningDecorator(executor);

        schemaNamesCache = CacheBuilder.newBuilder()
                .expireAfterWrite(expiresAfterWriteMillis, MILLISECONDS)
                .refreshAfterWrite(refreshMills, MILLISECONDS)
                .build(new BackgroundCacheLoader<String, Map<String, String>>(listeningExecutor)
View Full Code Here

    }

    private ExperimentResults runAllRunners(
        ImmutableList<ExperimentRunner> runners) {
      final int threads = Math.min(numThreads, runners.size());
      final ListeningExecutorService executor;
      if (threads > 1) {
        executor = MoreExecutors
            .listeningDecorator(Executors.newFixedThreadPool(threads));
      } else {
        executor = MoreExecutors.sameThreadExecutor();
      }
      final List<SimulationResult> results;
      try {
        // safe cast according to javadoc
        @SuppressWarnings({ "unchecked", "rawtypes" })
        final List<ListenableFuture<SimulationResult>> futures = (List) executor
            .invokeAll(runners);
        results = Futures.allAsList(futures).get();
      } catch (final InterruptedException e) {
        throw new IllegalStateException(e);
      } catch (final ExecutionException e) {
        // FIXME need some way to gracefully handle this error. All data
        // should be saved to reproduce this simulation.
        throw new IllegalStateException(e);
      }
      executor.shutdown();

      return new ExperimentResults(this, ImmutableList.copyOf(results));
    }
View Full Code Here

   @Test(enabled = true, dependsOnMethods = "testCompareSizes")
   public void testConcurrentUseOfComputeServiceToCreateNodes() throws Exception {
      final long timeoutMs = 20 * 60 * 1000;
      List<String> groups = Lists.newArrayList();
      List<ListenableFuture<NodeMetadata>> futures = Lists.newArrayList();
      ListeningExecutorService userExecutor = MoreExecutors.listeningDecorator(context.utils().userExecutor());

      try {
         for (int i = 0; i < 2; i++) {
            final int groupNum = i;
            final String group = "twin" + groupNum;
            groups.add(group);

            ListenableFuture<NodeMetadata> future = userExecutor.submit(new Callable<NodeMetadata>() {
               public NodeMetadata call() throws Exception {
                  NodeMetadata node = getOnlyElement(client.createNodesInGroup(group, 1, inboundPorts(22, 8080)
                           .blockOnPort(22, 300 + groupNum)));
                  getAnonymousLogger().info("Started node " + node.getId());
                  return node;
View Full Code Here

   }

   EventBus eventBus = new EventBus();

   public void testExitStatusZeroReturnsExecResponse() throws InterruptedException, ExecutionException {
      ListeningExecutorService userExecutor = MoreExecutors.sameThreadExecutor();
      Predicate<String> notRunningAnymore = Predicates.alwaysTrue();
      SudoAwareInitManager commandRunner = createMockBuilder(SudoAwareInitManager.class).addMockedMethod("runAction")
               .addMockedMethod("getStatement").addMockedMethod("getNode").addMockedMethod("toString")
               .createStrictMock();
      InitScript initScript = createMockBuilder(InitScript.class).addMockedMethod("getInstanceName").createStrictMock();
View Full Code Here

   }

   public void testFirstExitStatusOneButSecondExitStatusZeroReturnsExecResponse() throws InterruptedException,
            ExecutionException {
      ListeningExecutorService userExecutor = MoreExecutors.sameThreadExecutor();
      Predicate<String> notRunningAnymore = Predicates.alwaysTrue();

      SudoAwareInitManager commandRunner = createMockBuilder(SudoAwareInitManager.class).addMockedMethod("runAction")
               .addMockedMethod("getStatement").addMockedMethod("getNode").addMockedMethod("toString")
               .createStrictMock();
View Full Code Here

      verify(commandRunner, initScript);

   }

   public void testCancelInterruptStopsCommand() throws InterruptedException, ExecutionException {
      ListeningExecutorService userExecutor = MoreExecutors.sameThreadExecutor();
      Predicate<String> notRunningAnymore = Predicates.alwaysTrue();
      SudoAwareInitManager commandRunner = createMockBuilder(SudoAwareInitManager.class).addMockedMethod(
               "refreshAndRunAction").addMockedMethod("runAction").addMockedMethod("getStatement").addMockedMethod(
               "getNode").addMockedMethod("toString").createStrictMock();
      InitScript initScript = createMockBuilder(InitScript.class).addMockedMethod("getInstanceName").createStrictMock();
View Full Code Here

TOP

Related Classes of com.google.common.util.concurrent.ListeningExecutorService

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.