List of usage examples for com.google.common.collect Queues newConcurrentLinkedQueue
public static <E> ConcurrentLinkedQueue<E> newConcurrentLinkedQueue(Iterable<? extends E> elements)
From source file:com.ormanli.duplicatefinder.util.FileUtil.java
public FileUtil(String path) { List<File> fileList = getFileList(path); queue = Queues.newConcurrentLinkedQueue(Lists.partition(fileList, (int) Math.ceil(fileList.size() / (double) Runtime.getRuntime().availableProcessors()))); }
From source file:com.google.gmail.provider.GMailProvider.java
@Override public StreamsResultSet readCurrent() { StreamsResultSet current;/*from w w w .j av a2s . c o m*/ synchronized (GMailProvider.class) { current = new StreamsResultSet(Queues.newConcurrentLinkedQueue(providerQueue)); current.setCounter(new DatumStatusCounter()); current.getCounter().add(countersCurrent); countersTotal.add(countersCurrent); countersCurrent = new DatumStatusCounter(); providerQueue.clear(); } return current; }
From source file:org.apache.streams.amazon.kinesis.KinesisPersistReader.java
public StreamsResultSet readCurrent() { StreamsResultSet current;/*from ww w . j a va2 s. co m*/ synchronized (KinesisPersistReader.class) { current = new StreamsResultSet(Queues.newConcurrentLinkedQueue(persistQueue)); persistQueue.clear(); } return current; }
From source file:com.facebook.hiveio.tailer.TailerCmd.java
@Override public void execute() throws Exception { HadoopNative.requireHadoopNative();//from ww w.j a v a 2s.c o m args.process(); chooseRecordPrinter(); HostPort metastoreHostPort = getMetastoreHostPort(); if (metastoreHostPort == null) { return; } LOG.info("Creating Hive client for Metastore at {}", metastoreHostPort); ThriftHiveMetastore.Iface client = HiveMetastores.create(metastoreHostPort.host, metastoreHostPort.port); HiveInputDescription inputDesc = initInput(metastoreHostPort); HiveStats hiveStats = HiveUtils.statsOf(client, inputDesc); LOG.info("{}", hiveStats); HiveConf hiveConf = HiveUtils.newHiveConf(TailerCmd.class); args.inputTable.process(hiveConf); LOG.info("Setting up input using {}", inputDesc); HiveApiInputFormat.setProfileInputDesc(hiveConf, inputDesc, DEFAULT_PROFILE_ID); HiveApiInputFormat hapi = new HiveApiInputFormat(); hapi.setMyProfileId(DEFAULT_PROFILE_ID); List<InputSplit> splits = hapi.getSplits(new JobContext(hiveConf, new JobID())); LOG.info("Have {} splits to read", splits.size()); HiveTableDesc hiveTableDesc = new HiveTableDesc(args.inputTable.database, args.inputTable.table); HiveTableSchema schema = HiveTableSchemas.lookup(client, hiveConf, hiveTableDesc); chooseRowParser(schema); Stats stats = Stats.create(hiveStats); Context context = new Context(hapi, hiveConf, schema, hiveStats, stats); long startNanos = System.nanoTime(); if (args.multiThread.isSingleThreaded()) { context.splitsQueue = Queues.newArrayDeque(splits); readSplits(context); } else { context.splitsQueue = Queues.newConcurrentLinkedQueue(splits); multiThreaded(context, args.multiThread.threads); } long timeNanos = System.nanoTime() - startNanos; if (args.appendStatsTo != null) { OutputStream out = new FileOutputStream(args.appendStatsTo, true); try { stats.printEndBenchmark(context, args, timeNanos, out); } finally { out.close(); } } System.err.println("Finished."); if (args.metricsOpts.stderrEnabled()) { args.metricsOpts.dumpMetricsToStderr(); } }
From source file:org.apache.streams.facebook.provider.FacebookUserstreamProvider.java
public StreamsResultSet readCurrent() { StreamsResultSet current;//w w w . j a v a 2s . c o m synchronized (FacebookUserstreamProvider.class) { current = new StreamsResultSet(Queues.newConcurrentLinkedQueue(providerQueue)); current.setCounter(new DatumStatusCounter()); current.getCounter().add(countersCurrent); countersTotal.add(countersCurrent); countersCurrent = new DatumStatusCounter(); providerQueue.clear(); } return current; }
From source file:org.apache.streams.datasift.provider.DatasiftPushProvider.java
@Override public StreamsResultSet readCurrent() { StreamsResultSet current;//from w ww . j av a 2 s .c o m lock.writeLock().lock(); current = new StreamsResultSet(Queues.newConcurrentLinkedQueue(providerQueue)); providerQueue.clear(); lock.writeLock().unlock(); return current; }