Package com.google.common.util.concurrent

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


        this.metricRegistry = metricRegistry;
        this.configuration = configuration;
        this.notificationService = notificationService;
        this.faultCounter = Maps.newConcurrentMap();
        this.executor = executorService();
        this.timeLimiter = new SimpleTimeLimiter(executor);
    }
View Full Code Here


            LOG.trace("Connecting to LDAP server {}:{}, binding with user {}",
                      config.getLdapHost(), config.getLdapPort(), config.getName());
        }

        // this will perform an anonymous bind if there were no system credentials
        final SimpleTimeLimiter timeLimiter = new SimpleTimeLimiter(Executors.newSingleThreadExecutor());
        @SuppressWarnings("unchecked")
        final Callable<Boolean> timeLimitedConnection = timeLimiter.newProxy(
                new Callable<Boolean>() {
                    @Override
                    public Boolean call() throws Exception {
                        return connection.connect();
                    }
View Full Code Here

      }

      @Provides
      @Singleton
      TimeLimiter timeLimiter(@Named(PROPERTY_USER_THREADS) ListeningExecutorService userExecutor){
         return new SimpleTimeLimiter(userExecutor);
      }
View Full Code Here

      }

      @Provides
      @Singleton
      TimeLimiter timeLimiter(@Named(PROPERTY_USER_THREADS) ListeningExecutorService userExecutor){
         return new SimpleTimeLimiter(userExecutor);
      }
View Full Code Here

            connection.setCatalog(query.getCatalog());
            connection.setSchema(query.getSchema());
            long start = System.nanoTime();

            try (Statement statement = connection.createStatement()) {
                TimeLimiter limiter = new SimpleTimeLimiter();
                Stopwatch stopwatch = Stopwatch.createStarted();
                Statement limitedStatement = limiter.newProxy(statement, Statement.class, timeout.toMillis(), TimeUnit.MILLISECONDS);
                try (final ResultSet resultSet = limitedStatement.executeQuery(query.getQuery())) {
                    List<List<Object>> results = limiter.callWithTimeout(getResultSetConverter(resultSet), timeout.toMillis() - stopwatch.elapsed(TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS, true);
                    return new QueryResult(State.SUCCESS, null, nanosSince(start), results);
                }
                catch (AssertionError e) {
                    if (e.getMessage().startsWith("unimplemented type:")) {
                        return new QueryResult(State.INVALID, null, null, ImmutableList.<List<Object>>of());
View Full Code Here

   }

   @Provides
   @Singleton
   TimeLimiter timeLimiter(@Named(PROPERTY_USER_THREADS) ListeningExecutorService userExecutor){
      return new SimpleTimeLimiter(userExecutor);
   }
View Full Code Here

        try (Connection connection = DriverManager.getConnection(url, username, password)) {
            trySetConnectionProperties(query, connection);
            long start = System.nanoTime();

            try (Statement statement = connection.createStatement()) {
                TimeLimiter limiter = new SimpleTimeLimiter();
                Stopwatch stopwatch = Stopwatch.createStarted();
                Statement limitedStatement = limiter.newProxy(statement, Statement.class, timeout.toMillis(), TimeUnit.MILLISECONDS);
                try (final ResultSet resultSet = limitedStatement.executeQuery(query.getQuery())) {
                    List<List<Object>> results = limiter.callWithTimeout(getResultSetConverter(resultSet), timeout.toMillis() - stopwatch.elapsed(TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS, true);
                    return new QueryResult(State.SUCCESS, null, nanosSince(start), results);
                }
                catch (AssertionError e) {
                    if (e.getMessage().startsWith("unimplemented type:")) {
                        return new QueryResult(State.INVALID, null, null, ImmutableList.<List<Object>>of());
View Full Code Here

   }

   @Provides
   @Singleton
   TimeLimiter timeLimiter(@Named(PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) {
      return new SimpleTimeLimiter(userExecutor);
   }
View Full Code Here

      }

      @Provides
      @Singleton
      TimeLimiter timeLimiter(@Named(PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) {
         return new SimpleTimeLimiter(userExecutor);
      }
View Full Code Here

      }

      @Provides
      @Singleton
      TimeLimiter timeLimiter(@Named(PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) {
         return new SimpleTimeLimiter(userExecutor);
      }
View Full Code Here

TOP

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

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.