@Override public int getNumThreads() { return this.server.getThreadPool().getThreads(); }
@Override public int getNumIdleThreads() { return this.server.getThreadPool().getIdleThreads(); }
private void createThreadPool() { final int maxThreads = this.props .getInt("jetty.maxThreads", Constants.DEFAULT_JETTY_MAX_THREAD_COUNT); final QueuedThreadPool httpThreadPool = new QueuedThreadPool(maxThreads); this.server.setThreadPool(httpThreadPool); addThreadPoolGauges(httpThreadPool); }
connector.setPort(this.port); connector.setReuseAddress(true); QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setName("VoldemortHttp"); threadPool.setMaxThreads(this.numberOfThreads); Server httpServer = new Server(); httpServer.setConnectors(new Connector[] { connector });
public QueuedThreadPool(int maxThreads) { this(); setMaxThreads(maxThreads); }
/** Schedule the task on the given timeout. * The task exiry will be called after the timeout duration. * @param timer */ public void schedule(Timeout timer, long delay) { timer.schedule(this,delay); }
public void tick() { tick(-1); }
protected PoolThread newThread(Runnable job) { synchronized(_lock) { PoolThread thread =new PoolThread(job); _threads.add(thread); thread.setName(_name+"-"+_id++); thread.start(); return thread; } }
PoolThread() { setDaemon(_daemon); setPriority(_priority); }
PoolThread() { setDaemon(_daemon); setPriority(_priority); }
public void join() throws InterruptedException { synchronized (_joinLock) { while (isRunning()) _joinLock.wait(); } // TODO remove this semi busy loop! while (isStopping()) Thread.sleep(10); }
public void join() throws InterruptedException { synchronized (_joinLock) { while (isRunning()) _joinLock.wait(); } // TODO remove this semi busy loop! while (isStopping()) Thread.sleep(100); }
/** Cancel the task. * Remove the task from the timeout. */ public void cancel() { Timeout timeout = _timeout; if (timeout!=null) { synchronized (timeout._lock) { unlink(); _timestamp=0; } } }
/** Set the maximum number of threads. * Delegated to the named or anonymous Pool. * @see #getMaxThreads * @param maxThreads maximum number of threads. */ public void setMaxThreads(int maxThreads) { if (isStarted() && maxThreads<_minThreads) throw new IllegalArgumentException("!minThreads<maxThreads"); _maxThreads=maxThreads; }
/** Set the maximum number of threads. * Delegated to the named or anonymous Pool. * @see #getMaxThreads * @param maxThreads maximum number of threads. */ public void setMaxThreads(int maxThreads) { if (isStarted() && maxThreads<_minThreads) throw new IllegalArgumentException("!minThreads<maxThreads"); _maxThreads=maxThreads; }
/** Copy Stream in to Stream out until EOF or exception. * in own thread */ public static void copyThread(InputStream in, OutputStream out) { try{ Job job=new Job(in,out); if (!Singleton.__pool.dispatch(job)) job.run(); } catch(Exception e) { Log.warn(e); } }
/** Reschedule the task on the current timeout. * The task timeout is rescheduled as if it had been cancelled and * scheduled on the current timeout. */ public void reschedule() { Timeout timeout = _timeout; if (timeout!=null) timeout.schedule(this,_delay); }
PoolThread(Runnable job) { setDaemon(_daemon); setPriority(_priority); _job=job; }
/** Schedule the task on the given timeout. * The task exiry will be called after the timeout duration. * @param timer */ public void schedule(Timeout timer) { timer.schedule(this); }
public void schedule(Task task) { schedule(task,0L); }