当前位置: 首页>>代码示例>>Java>>正文


Java ListeningScheduledExecutorService类代码示例

本文整理汇总了Java中com.google.common.util.concurrent.ListeningScheduledExecutorService的典型用法代码示例。如果您正苦于以下问题:Java ListeningScheduledExecutorService类的具体用法?Java ListeningScheduledExecutorService怎么用?Java ListeningScheduledExecutorService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ListeningScheduledExecutorService类属于com.google.common.util.concurrent包,在下文中一共展示了ListeningScheduledExecutorService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ApacheThriftMethodInvoker

import com.google.common.util.concurrent.ListeningScheduledExecutorService; //导入依赖的package包/类
public ApacheThriftMethodInvoker(
        ListeningExecutorService executorService,
        ListeningScheduledExecutorService delayService,
        TTransportFactory transportFactory,
        TProtocolFactory protocolFactory,
        Duration connectTimeout,
        Duration requestTimeout,
        Optional<HostAndPort> socksProxy,
        Optional<SSLContext> sslContext)
{
    this.executorService = requireNonNull(executorService, "executorService is null");
    this.delayService = requireNonNull(delayService, "delayService is null");
    this.transportFactory = requireNonNull(transportFactory, "transportFactory is null");
    this.protocolFactory = requireNonNull(protocolFactory, "protocolFactory is null");
    this.connectTimeoutMillis = Ints.saturatedCast(requireNonNull(connectTimeout, "connectTimeout is null").toMillis());
    this.requestTimeoutMillis = Ints.saturatedCast(requireNonNull(requestTimeout, "requestTimeout is null").toMillis());
    this.socksProxy = requireNonNull(socksProxy, "socksProxy is null");
    this.sslContext = requireNonNull(sslContext, "sslContext is null");
}
 
开发者ID:airlift,项目名称:drift,代码行数:20,代码来源:ApacheThriftMethodInvoker.java

示例2: testNoOpScheduledExecutorInvokeAll

import com.google.common.util.concurrent.ListeningScheduledExecutorService; //导入依赖的package包/类
public void testNoOpScheduledExecutorInvokeAll() throws ExecutionException, InterruptedException {
  ListeningScheduledExecutorService executor = TestingExecutors.noOpScheduledExecutor();
  taskDone = false;
  Callable<Boolean> task = new Callable<Boolean>() {
    @Override public Boolean call() {
      taskDone = true;
      return taskDone;
    }
  };
  List<Future<Boolean>> futureList = executor.invokeAll(
      ImmutableList.of(task), 10, TimeUnit.MILLISECONDS);
  Future<Boolean> future = futureList.get(0);
  assertFalse(taskDone);
  assertTrue(future.isDone());
  try {
    future.get();
    fail();
  } catch (CancellationException e) {
    // pass
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:22,代码来源:TestingExecutorsTest.java

示例3: getExecutor

import com.google.common.util.concurrent.ListeningScheduledExecutorService; //导入依赖的package包/类
/**
 * Returns the executor shared by KnowledgeStore components. If no executor is setup using
 * {@link #setExecutor(ScheduledExecutorService)}, an executor is automatically created using
 * the thread number and naming given by system properties
 * {@code eu.fbk.knowledgestore.threadCount} and {@code eu.fbk.knowledgestore.threadNumber}.
 *
 * @return the shared executor
 */
public static ListeningScheduledExecutorService getExecutor() {
    synchronized (executorPrivate) {
        if (executor == null) {
            final String threadName = MoreObjects.firstNonNull(
                    System.getProperty("eu.fbk.knowledgestore.threadName"), "worker-%02d");
            int threadCount = 32;
            try {
                threadCount = Integer.parseInt(System
                        .getProperty("eu.fbk.knowledgestore.threadCount"));
            } catch (final Throwable ex) {
                // ignore
            }
            executor = Util.newScheduler(threadCount, threadName, true);
            executorPrivate.set(true);
        }
        return executor;
    }
}
 
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:27,代码来源:Data.java

示例4: testNoOpScheduledExecutorInvokeAll

import com.google.common.util.concurrent.ListeningScheduledExecutorService; //导入依赖的package包/类
public void testNoOpScheduledExecutorInvokeAll() throws ExecutionException, InterruptedException {
  ListeningScheduledExecutorService executor = TestingExecutors.noOpScheduledExecutor();
  taskDone = false;
  Callable<Boolean> task =
      new Callable<Boolean>() {
        @Override
        public Boolean call() {
          taskDone = true;
          return taskDone;
        }
      };
  List<Future<Boolean>> futureList =
      executor.invokeAll(ImmutableList.of(task), 10, TimeUnit.MILLISECONDS);
  Future<Boolean> future = futureList.get(0);
  assertFalse(taskDone);
  assertTrue(future.isDone());
  try {
    future.get();
    fail();
  } catch (CancellationException e) {
    // pass
  }
}
 
开发者ID:google,项目名称:guava,代码行数:24,代码来源:TestingExecutorsTest.java

示例5: get

import com.google.common.util.concurrent.ListeningScheduledExecutorService; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public synchronized <T extends ExecutorService> T get(Class<T> type) {
    if (instances.containsKey(checkNotNull(type))) {
        return (T) instances.get(type).get();
    }
    Factory<? extends ExecutorService> factory = factories.get(type);
    checkArgument(factory != null, type);
    ListeningExecutorService instance = MoreExecutors.listeningDecorator(factory.get());
    ImmutableList<Class<? extends ExecutorService>> types;
    if (instance instanceof ScheduledExecutorService) {
        types = ImmutableList.<Class<? extends ExecutorService>>of(
                ScheduledExecutorService.class,
                ListeningScheduledExecutorService.class);
    } else {
        types = ImmutableList.<Class<? extends ExecutorService>>of(
                ExecutorService.class,
                ListeningExecutorService.class);
    }
    ExecutorServiceService<ListeningExecutorService> service = ExecutorServiceService.newInstance(instance);
    service.startAsync().awaitRunning();
    for (Class<? extends ExecutorService> t: types) {
        instances.put(t, service);
    }
    return (T) service.get();
}
 
开发者ID:lisaglendenning,项目名称:zookeeper-lite,代码行数:26,代码来源:ListeningExecutorServiceFactory.java

示例6: configure

import com.google.common.util.concurrent.ListeningScheduledExecutorService; //导入依赖的package包/类
@Override
protected void configure() {
    int threads = 16; // TODO: Link to number of cores
    ListeningScheduledExecutorService scheduledExecutor = MoreExecutors.listeningDecorator(Executors
            .newScheduledThreadPool(threads));
    ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool());

    ThreadPools executors = new ThreadPools(scheduledExecutor, executor);
    bind(ThreadPools.class).toInstance(executors);

    RedisKeyValueStore redis = new RedisKeyValueStore(redisAddress, executor);
    KeyValueService keyValueService = new RedisKeyValueService(redis);
    bind(KeyValueService.class).toInstance(keyValueService);

    BlobService blobService = new LocalBlobService(executor, basePath);
    bind(BlobService.class).toInstance(blobService);

    bind(VolumeProvider.class).to(CloudVolumeProvider.class).asEagerSingleton();
}
 
开发者ID:justinsb,项目名称:cloudata,代码行数:20,代码来源:BlockStoreModule.java

示例7: testNoOpScheduledExecutorShutdown

import com.google.common.util.concurrent.ListeningScheduledExecutorService; //导入依赖的package包/类
public void testNoOpScheduledExecutorShutdown() {
  ListeningScheduledExecutorService executor = TestingExecutors.noOpScheduledExecutor();
  assertFalse(executor.isShutdown());
  assertFalse(executor.isTerminated());
  executor.shutdown();
  assertTrue(executor.isShutdown());
  assertTrue(executor.isTerminated());
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:9,代码来源:TestingExecutorsTest.java

示例8: newScheduler

import com.google.common.util.concurrent.ListeningScheduledExecutorService; //导入依赖的package包/类
private static ListeningScheduledExecutorService newScheduler() {
    final ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(1);
    scheduler.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
    scheduler.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
    scheduler.setRemoveOnCancelPolicy(true);
    return MoreExecutors.listeningDecorator(scheduler);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:8,代码来源:MatchRealtimeScheduler.java

示例9: ByteStreamUploader

import com.google.common.util.concurrent.ListeningScheduledExecutorService; //导入依赖的package包/类
/**
 * Creates a new instance.
 *
 * @param instanceName the instance name to be prepended to resource name of the {@code Write}
 *     call. See the {@code ByteStream} service definition for details
 * @param channel the {@link io.grpc.Channel} to use for calls
 * @param callCredentials the credentials to use for authentication. May be {@code null}, in which
 *     case no authentication is performed
 * @param callTimeoutSecs the timeout in seconds after which a {@code Write} gRPC call must be
 *     complete. The timeout resets between retries
 * @param retrier the {@link Retrier} whose backoff strategy to use for retry timings.
 * @param retryService the executor service to schedule retries on. It's the responsibility of the
 *     caller to properly shutdown the service after use. Users should avoid shutting down the
 *     service before {@link #shutdown()} has been called
 */
public ByteStreamUploader(
    @Nullable String instanceName,
    Channel channel,
    @Nullable CallCredentials callCredentials,
    long callTimeoutSecs,
    Retrier retrier,
    ListeningScheduledExecutorService retryService) {
  checkArgument(callTimeoutSecs > 0, "callTimeoutSecs must be gt 0.");

  this.instanceName = instanceName;
  this.channel = channel;
  this.callCredentials = callCredentials;
  this.callTimeoutSecs = callTimeoutSecs;
  this.retrier = retrier;
  this.retryService = retryService;
}
 
开发者ID:bazelbuild,项目名称:bazel-buildfarm,代码行数:32,代码来源:ByteStreamUploader.java

示例10: newScheduler

import com.google.common.util.concurrent.ListeningScheduledExecutorService; //导入依赖的package包/类
public static ListeningScheduledExecutorService newScheduler(final int numThreads,
        final String nameFormat, final boolean daemon) {
    final ThreadFactory factory = new ThreadFactoryBuilder().setDaemon(daemon)
            .setNameFormat(nameFormat)
            .setUncaughtExceptionHandler(new UncaughtExceptionHandler() {

                @Override
                public void uncaughtException(final Thread thread, final Throwable ex) {
                    LOGGER.error("Uncaught exception in thread " + thread.getName(), ex);
                }

            }).build();
    return decorate(Executors.newScheduledThreadPool(numThreads, factory));
}
 
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:15,代码来源:Util.java

示例11: decorate

import com.google.common.util.concurrent.ListeningScheduledExecutorService; //导入依赖的package包/类
public static ListeningScheduledExecutorService decorate(
        final ScheduledExecutorService executor) {
    if (executor instanceof MDCScheduledExecutorService) {
        return (MDCScheduledExecutorService) executor;
    } else if (executor instanceof ListeningScheduledExecutorService) {
        return new MDCScheduledExecutorService((ListeningScheduledExecutorService) executor);
    } else {
        // return MoreExecutors.listeningDecorator(executor);
        return new MDCScheduledExecutorService(MoreExecutors.listeningDecorator(executor));
    }
}
 
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:12,代码来源:Util.java

示例12: valueChanged

import com.google.common.util.concurrent.ListeningScheduledExecutorService; //导入依赖的package包/类
@Override
public void valueChanged(ListSelectionEvent e) {
  boolean hasFocus = otrosApplication.getApplicationJFrame().isFocused();
  final boolean enabled = otrosApplication.getConfiguration().getBoolean(ConfKeys.JUMP_TO_CODE_AUTO_JUMP_ENABLED, false);
  if (hasFocus && enabled && !e.getValueIsAdjusting()) {
    try {
      final LogData logData = dataTableModel.getLogData(table.convertRowIndexToModel(e.getFirstIndex()));
      Optional<Integer> line = Optional.empty();
      if (StringUtils.isNotBlank(logData.getLine()) && StringUtils.isAlphanumeric(logData.getLine())) {
        line = Optional.of(Integer.valueOf(logData.getLine()));
      }
      final LocationInfo li = new LocationInfo(
        Optional.ofNullable(logData.getClazz()).orElseGet(logData::getLoggerName),
        logData.getMethod(), logData.getFile(),
        line,
        Optional.ofNullable(logData.getMessage()));
      final JumpToCodeService jumpToCodeService = otrosApplication.getServices().getJumpToCodeService();
      final boolean ideAvailable = jumpToCodeService.isIdeAvailable();
      if (ideAvailable) {
        scheduledJump.map(input -> {
          input.cancel(false);
          return Boolean.TRUE;
        });
        ListeningScheduledExecutorService scheduledExecutorService = otrosApplication.getServices().getTaskSchedulerService().getListeningScheduledExecutorService();
        delayMs = 300;
        ListenableScheduledFuture<?> jump = scheduledExecutorService.schedule(
          new JumpRunnable(li, jumpToCodeService), delayMs, TimeUnit.MILLISECONDS
        );

        scheduledJump = Optional.of(jump);
      }
    } catch (Exception e1) {
      LOGGER.warn("Can't perform jump to code: " + e1.getMessage(), e1);
      e1.printStackTrace();
    }

  }
}
 
开发者ID:otros-systems,项目名称:otroslogviewer,代码行数:39,代码来源:JumpToCodeSelectionListener.java

示例13: executor_Valid_SetsService

import com.google.common.util.concurrent.ListeningScheduledExecutorService; //导入依赖的package包/类
@Test
public void executor_Valid_SetsService() {
    Key<ListeningScheduledExecutorService> executorServiceKey = Key.get(ListeningScheduledExecutorService.class);
    builder.exectuor(executorServiceKey);

    assertEquals(executorServiceKey, builder.getService());
}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:8,代码来源:AbstractReaperModuleBuilderTest.java

示例14: MDCPropagatingScheduledExecutorService

import com.google.common.util.concurrent.ListeningScheduledExecutorService; //导入依赖的package包/类
public MDCPropagatingScheduledExecutorService(ScheduledExecutorService executorService) {
  if (executorService instanceof ListeningScheduledExecutorService) {
    this.executorService = (ListeningScheduledExecutorService)executorService;
  } else {
    this.executorService = MoreExecutors.listeningDecorator(executorService);
  }
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:8,代码来源:MDCPropagatingScheduledExecutorService.java

示例15: ByteStreamUploader

import com.google.common.util.concurrent.ListeningScheduledExecutorService; //导入依赖的package包/类
/**
 * Creates a new instance.
 *
 * @param instanceName the instance name to be prepended to resource name of the {@code Write}
 *     call. See the {@code ByteStream} service definition for details
 * @param channel the {@link io.grpc.Channel} to use for calls
 * @param callCredentials the credentials to use for authentication. May be {@code null}, in which
 *     case no authentication is performed
 * @param callTimeoutSecs the timeout in seconds after which a {@code Write} gRPC call must be
 *     complete. The timeout resets between retries
 * @param retrier the {@link RemoteRetrier} whose backoff strategy to use for retry timings.
 * @param retryService the executor service to schedule retries on. It's the responsibility of the
 *     caller to properly shutdown the service after use. Users should avoid shutting down the
 *     service before {@link #shutdown()} has been called
 */
public ByteStreamUploader(
    @Nullable String instanceName,
    Channel channel,
    @Nullable CallCredentials callCredentials,
    long callTimeoutSecs,
    RemoteRetrier retrier,
    ListeningScheduledExecutorService retryService) {
  checkArgument(callTimeoutSecs > 0, "callTimeoutSecs must be gt 0.");

  this.instanceName = instanceName;
  this.channel = channel;
  this.callCredentials = callCredentials;
  this.callTimeoutSecs = callTimeoutSecs;
  this.retrier = retrier;
  this.retryService = retryService;
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:32,代码来源:ByteStreamUploader.java


注:本文中的com.google.common.util.concurrent.ListeningScheduledExecutorService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。