List of usage examples for com.google.common.util.concurrent MoreExecutors listeningDecorator
@GwtIncompatible("TODO") public static ListeningScheduledExecutorService listeningDecorator(ScheduledExecutorService delegate)
From source file:org.sonar.server.computation.taskprocessor.CeProcessingSchedulerExecutorServiceImpl.java
public CeProcessingSchedulerExecutorServiceImpl(CeConfiguration ceConfiguration) { super(MoreExecutors.listeningDecorator( Executors.newScheduledThreadPool(ceConfiguration.getWorkerCount(), new ThreadFactoryBuilder() .setNameFormat(THREAD_NAME_PREFIX + "%d").setPriority(Thread.MIN_PRIORITY).build()))); }
From source file:com.dangdang.ddframe.job.util.concurrent.ExecutorServiceObject.java
/** * ?.// w w w .j a v a2 s. co m * * @return ? */ public ExecutorService createExecutorService() { return MoreExecutors.listeningDecorator(MoreExecutors.getExitingExecutorService(threadPoolExecutor)); }
From source file:com.google.pubsub.clients.common.LoadTestRunner.java
private static void runTest(StartRequest request) { log.info("Request received, starting up server."); ListeningExecutorService executor = MoreExecutors .listeningDecorator(Executors.newFixedThreadPool(request.getMaxOutstandingRequests() + 10)); final RateLimiter rateLimiter = RateLimiter.create(request.getRequestRate()); final Semaphore outstandingTestLimiter = new Semaphore(request.getMaxOutstandingRequests(), false); final long toSleep = request.getStartTime().getSeconds() * 1000 - System.currentTimeMillis(); if (toSleep > 0) { try {//w ww. j a v a 2 s.c o m Thread.sleep(toSleep); } catch (InterruptedException e) { log.error("Interrupted sleeping, starting test now."); } } stopwatch.start(); while (shouldContinue(request)) { outstandingTestLimiter.acquireUninterruptibly(); rateLimiter.acquire(); executor.submit(task).addListener(outstandingTestLimiter::release, executor); } stopwatch.stop(); executor.shutdownNow(); finished.set(true); log.info("Load test complete."); }
From source file:com.fullcontact.sstable.index.SSTableIndexIndexer.java
public SSTableIndexIndexer(final Configuration configuration) { this.configuration = configuration; this.decimalFormat = new DecimalFormat("#0.00"); this.service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10)); }
From source file:com.tangrainc.inappbilling.InAppBillingHelper.java
public InAppBillingHelper(Context context, String[] productIdentifiers) { _executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()); _productIdentifiers = productIdentifiers; _context = context;//from ww w . j a va2 s.c o m ServiceConnection _serviceConn = new ServiceConnection() { @Override public void onServiceDisconnected(ComponentName name) { Log.d(TAG, "Billing Service disconnected."); _service = null; } @Override public void onServiceConnected(ComponentName name, IBinder service) { Log.d(TAG, "Billing Service connected."); _service = IInAppBillingService.Stub.asInterface(service); } }; Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); serviceIntent.setPackage("com.android.vending"); _context.bindService(serviceIntent, _serviceConn, Context.BIND_AUTO_CREATE); }
From source file:brooklyn.entity.rebind.persister.PersistenceStoreObjectAccessorWriterTestFixture.java
@BeforeMethod(alwaysRun = true) public void setUp() throws Exception { executor = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool()); accessor = newPersistenceStoreObjectAccessor(); }
From source file:ratpack.exec.internal.DefaultExecController.java
public DefaultExecController(int numThreads) { this.numThreads = numThreads; this.eventLoopGroup = new NioEventLoopGroup(numThreads, new ExecControllerBindingThreadFactory("ratpack-compute", Thread.MAX_PRIORITY)); this.computeExecutor = MoreExecutors.listeningDecorator(eventLoopGroup); this.blockingExecutor = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool( new ExecControllerBindingThreadFactory("ratpack-blocking", Thread.NORM_PRIORITY))); this.control = new DefaultExecControl(this); }
From source file:org.jclouds.chef.strategy.internal.ListCookbookVersionsImpl.java
@Override public Iterable<? extends CookbookVersion> execute(ExecutorService executor) { return this.executeConcurrently(MoreExecutors.listeningDecorator(executor)); }
From source file:co.paralleluniverse.fibers.jdbc.FiberDriver.java
@Suspendable @Override//from w ww.ja v a 2 s .c o m public FiberConnection connect(final String url, final Properties info) throws SQLException { final String dbURL = url.replaceFirst("fiber:", ""); final int threadCount = Integer.parseInt(info.getProperty(THREADS_COUNT, "10")); info.remove(THREADS_COUNT); final ExecutorService es = Executors.newFixedThreadPool(threadCount, new ThreadFactoryBuilder().setNameFormat("jdbc-worker-%d").setDaemon(true).build()); final Connection con = JDBCFiberAsync.exec(es, new CheckedCallable<Connection, SQLException>() { @Override public Connection call() throws SQLException { return DriverManager.getConnection(dbURL, info); } }); return new FiberConnection(con, MoreExecutors.listeningDecorator(es)); }
From source file:com.zaradai.bloodstone.execution.job.LocalServer.java
@Inject LocalServer(ExecutorService executorService, GraphExecutorFactory graphExecutorFactory, FlowBuilder flowBuilder) {/*from ww w .j av a2 s .c o m*/ this.graphExecutorFactory = graphExecutorFactory; this.flowBuilder = flowBuilder; this.executorService = MoreExecutors.listeningDecorator(executorService); }