List of usage examples for java.util.concurrent LinkedBlockingQueue LinkedBlockingQueue
public LinkedBlockingQueue(Collection<? extends E> c)
From source file:com.jivesoftware.os.upena.uba.service.Nanny.java
public Nanny(PasswordStore passwordStore, UpenaClient upenaClient, RepositoryProvider repositoryProvider, InstanceDescriptor instanceDescriptor, InstancePath instancePath, DeployableValidator deployableValidator, DeployLog deployLog, HealthLog healthLog, DeployableScriptInvoker invokeScript, UbaLog ubaLog, Cache<String, Boolean> haveRunConfigExtractionCache) { this.passwordStore = passwordStore; this.upenaClient = upenaClient; this.repositoryProvider = repositoryProvider; this.instanceDescriptor = new AtomicReference<>(instanceDescriptor); this.instancePath = instancePath; this.deployableValidator = deployableValidator; this.deployLog = deployLog; this.healthLog = healthLog; this.invokeScript = invokeScript; this.ubaLog = ubaLog; linkedBlockingQueue = new LinkedBlockingQueue<>(10); threadPoolExecutor = new ThreadPoolExecutor(1, 1, 1000, TimeUnit.MILLISECONDS, linkedBlockingQueue); boolean exists = instancePath.deployLog().exists(); LOG.info("Stats script for {} exists == {}", instanceDescriptor, exists); redeploy = new AtomicBoolean(!exists); destroyed = new AtomicBoolean(false); this.haveRunConfigExtractionCache = haveRunConfigExtractionCache; }
From source file:org.yamj.core.service.ScanningScheduler.java
@Scheduled(initialDelay = 5000, fixedDelay = 45000) public void scanMediaData() throws Exception { int maxThreads = configService.getIntProperty("yamj3.scheduler.mediadatascan.maxThreads", 1); if (maxThreads <= 0) { if (!messageDisabledMediaData) { messageDisabledMediaData = Boolean.TRUE; LOG.info("Media data scanning is disabled"); }//from w w w .ja v a 2 s . c o m return; } else { messageDisabledMediaData = Boolean.FALSE; } int maxResults = configService.getIntProperty("yamj3.scheduler.mediadatascan.maxResults", 20); List<QueueDTO> queueElements = metadataStorageService.getMediaQueueForScanning(maxResults); if (CollectionUtils.isEmpty(queueElements)) { LOG.debug("No media data found to scan"); return; } LOG.info("Found {} media data objects to process; scan with {} threads", queueElements.size(), maxThreads); BlockingQueue<QueueDTO> queue = new LinkedBlockingQueue<QueueDTO>(queueElements); ExecutorService executor = Executors.newFixedThreadPool(maxThreads); for (int i = 0; i < maxThreads; i++) { PluginMetadataRunner worker = new PluginMetadataRunner(queue, pluginMetadataService); executor.execute(worker); } executor.shutdown(); // run until all workers have finished while (!executor.isTerminated()) { try { TimeUnit.SECONDS.sleep(5); } catch (InterruptedException ignore) { } } LOG.debug("Finished media data scanning"); }
From source file:com.openteach.diamond.network.waverider.session.DefaultSession.java
@Override public boolean init() { state = SessionStateEnum.WAVERIDER_SESSION_STATE_FREE; inputBuffer = new LinkedBlockingQueue<ByteBuffer>(inBufferSize); outputBuffer = new LinkedBlockingQueue<Command>(outBufferSize); waitMoreDataLock = new byte[0]; thread = threadFactory.newThread(new SessionTask()); thread.start();//from w w w .j a va2 s . co m return true; }
From source file:org.apache.solr.client.solrj.impl.StreamingUpdateSolrServer.java
/** * Uses the supplied HttpClient to send documents to the Solr server, the HttpClient should be instantiated using a * MultiThreadedHttpConnectionManager.//from w w w . j a va 2 s.c o m */ public StreamingUpdateSolrServer(String solrServerUrl, HttpClient client, int queueSize, int threadCount) throws MalformedURLException { super(solrServerUrl, client); queue = new LinkedBlockingQueue<UpdateRequest>(queueSize); this.threadCount = threadCount; runners = new LinkedList<Runner>(); }
From source file:github.madmarty.madsonic.util.ImageLoader.java
public ImageLoader(Context context) { this.context = context; final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); final int cacheSize = maxMemory / 4; cache = new LruCache<String, Bitmap>(cacheSize) { @Override// w w w. j ava 2 s . c om protected int sizeOf(String key, Bitmap bitmap) { return bitmap.getRowBytes() * bitmap.getHeight() / 1024; } @Override protected void entryRemoved(boolean evicted, String key, Bitmap oldBitmap, Bitmap newBitmap) { if (evicted) { try { oldBitmap.recycle(); } catch (Exception e) { // Do nothing, just means that the drawable is a flat image } } } }; queue = new LinkedBlockingQueue<Task>(1000); // Determine the density-dependent image sizes. imageSizeDefault = (int) Math .round((context.getResources().getDrawable(R.drawable.unknown_album).getIntrinsicHeight())); LOG.info("imageSizeDefault: " + imageSizeDefault); imageSizeMedium = 180; // (int) Math.round((context.getResources().getDrawable(R.drawable.unknown_album_medium).getIntrinsicHeight()));; LOG.info("imageSizeMedium: " + imageSizeMedium); DisplayMetrics metrics = context.getResources().getDisplayMetrics(); imageSizeLarge = (int) Math.round(Math.min(metrics.widthPixels, metrics.heightPixels) * 0.6); LOG.info("imageSizeLarge: " + imageSizeLarge); // imageSizeDefault = Util.getCoverSize(context); for (int i = 0; i < CONCURRENCY; i++) { new Thread(this, "ImageLoader").start(); } createLargeUnknownImage(context); }
From source file:cx.fbn.nevernote.threads.IndexRunner.java
public IndexRunner(String logname, String u, String i, String r, String uid, String pswd, String cpswd) { foundWords = new TreeSet<String>(); logger = new ApplicationLogger(logname); conn = new DatabaseConnection(logger, u, i, r, uid, pswd, cpswd, 500); indexType = SCAN;/* www . j a v a 2s . c om*/ guid = null; keepRunning = true; doc = new QDomDocument(); workQueue = new LinkedBlockingQueue<String>(MAX_QUEUED_WAITING); }
From source file:org.obiba.onyx.core.domain.participant.ParticipantAttributeReader.java
private void doFlatten(ParticipantElement participantElement, Group group, List<ParticipantAttribute> attributeList) { if (participantElement instanceof ParticipantAttribute) { ParticipantAttribute attribute = (ParticipantAttribute) participantElement; attribute.setGroup(group);/*from w w w. j ava2 s .c om*/ if (group.getName().equals(Group.DEFAULT_GROUP_NAME)) { // Add attributes without a group to the default group. group.addParticipantAttribute(attribute); } attributeList.add(attribute); return; } else if (participantElement instanceof Group) { Group childGroup = (Group) participantElement; LinkedBlockingQueue<ParticipantAttribute> childElements = new LinkedBlockingQueue<ParticipantAttribute>( childGroup.getParticipantAttributes()); for (ParticipantElement childElement : childElements) { doFlatten(childElement, childGroup, attributeList); } } }
From source file:com.indeed.imhotep.builder.tsv.TsvConverter.java
public TsvConverter() { executor = new ThreadPoolExecutor(PARALLEL_BUILDS, 10, 30, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(10000), new NamedThreadFactory("Builder", true)); }
From source file:it.txt.ens.client.subscriber.printer.osgi.Activator.java
public Activator() { // filters = new LinkedBlockingQueue<Filter>(CONFIGURATION_CAPACITY); filters = new LinkedBlockingQueue<SubscriberFilter>(CONFIGURATION_CAPACITY); }
From source file:org.mzd.shap.spring.task.PooledTaskExecutor.java
/** * Initialization method. This must be called before using the instance. * // www . j a v a2s. c o m * @throws ApplicationException */ public void init() throws ApplicationException { LOGGER.info("Initializing instance"); if (getThreadPool() != null) { throw new ApplicationException("This instance has already been initialized"); } BlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(getQueueCapacity()); setThreadPool(new ThreadPoolExecutor(getCorePoolSize(), getMaximumPoolSize(), getKeepAliveTime(), TimeUnit.SECONDS, queue)); getThreadPool().allowCoreThreadTimeOut(true); }