Package com.google.common.util.concurrent

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


      }

      @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

            String command) {
        log.info("=== about to call ===\n{}", command);
        final List<String> commands =
                Lists.newArrayList(Splitter.on(" ").split(command));

        SimpleTimeLimiter timeLimiter = new SimpleTimeLimiter();
        Callable<List<String>> work = new Callable<List<String>>() {
            @Override
            public List<String> call() throws Exception {
                Process process =
                        ClientWorkFlow.invokeClient(workingDirectory,
                                commands);
                process.waitFor();
                List<String> output = ClientWorkFlow.getOutput(process);
                logOutputLines(output);
                return output;
            }
        };
        try {
            return timeLimiter
                    .callWithTimeout(work, timeoutDuration, TimeUnit.SECONDS, true);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
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

            final ThreadFactory factory = new ThreadFactoryBuilder()
                    .setDaemon(true)
                    .setNameFormat("ServoMonitorGetValueLimiter-%d")
                    .build();
            service = Executors.newSingleThreadExecutor(factory);
            limiter = new SimpleTimeLimiter(service);
        } else {
            service = null;
            limiter = null;
        }
    }
View Full Code Here

        private final TimeLimiter timeLimiter;
        private final long duration;
        private final TimeUnit timeUnit;

        public FixedAttemptTimeLimit(long duration, @Nonnull TimeUnit timeUnit) {
            this(new SimpleTimeLimiter(), duration, timeUnit);
        }
View Full Code Here

        public FixedAttemptTimeLimit(long duration, @Nonnull TimeUnit timeUnit) {
            this(new SimpleTimeLimiter(), duration, timeUnit);
        }

        public FixedAttemptTimeLimit(long duration, @Nonnull TimeUnit timeUnit, @Nonnull ExecutorService executorService) {
            this(new SimpleTimeLimiter(executorService), duration, timeUnit);
        }
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.