fiftyone.device.example.batch
Class FutureUaProcessor

java.lang.Object
  extended by fiftyone.device.example.batch.UaProcessor.Base
      extended by fiftyone.device.example.batch.FutureUaProcessor
All Implemented Interfaces:
UaProcessor

public class FutureUaProcessor
extends UaProcessor.Base

Implementation of UaProcessor that uses ExecutorCompletionService to do detections.

All results are stored in memory, so while this class is fast to execute it cannot carry out large numbers of detections. It's fine for the 20k HTTP User-Agents distributed as a sample.


Nested Class Summary
 
Nested classes/interfaces inherited from interface fiftyone.device.example.batch.UaProcessor
UaProcessor.Base
 
Field Summary
 
Fields inherited from class fiftyone.device.example.batch.UaProcessor.Base
count, limit, numberOfThreads, provider, start, stop, useragents
 
Constructor Summary
FutureUaProcessor(BufferedReader useragents, Provider provider, int numberOfThreads, int limit)
           
 
Method Summary
static long getCpuTime()
          Get CPU time in nanoseconds.
 void printStats(PrintWriter output)
          Writes timings (overall) of of a detection test
 void process()
          Process the set of UA Headers
 void writeResults(BufferedWriter writer)
          Writes results (for each UA string) of detection test
 
Methods inherited from class fiftyone.device.example.batch.UaProcessor.Base
writeHeaders, writeMatch
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FutureUaProcessor

public FutureUaProcessor(BufferedReader useragents,
                         Provider provider,
                         int numberOfThreads,
                         int limit)
                  throws IOException
Throws:
IOException
Method Detail

getCpuTime

public static long getCpuTime()
Get CPU time in nanoseconds. The run time may not support resolutions finer than microsecond

Returns:
CPU time as long.

process

public void process()
             throws Exception
Description copied from interface: UaProcessor
Process the set of UA Headers

Throws:
Exception - if there was a problem accessing data file.

printStats

public void printStats(PrintWriter output)
Description copied from interface: UaProcessor
Writes timings (overall) of of a detection test

Specified by:
printStats in interface UaProcessor
Overrides:
printStats in class UaProcessor.Base
Parameters:
output - a PrintWriter to report the timings on

writeResults

public void writeResults(BufferedWriter writer)
                  throws IOException
Description copied from interface: UaProcessor
Writes results (for each UA string) of detection test

Parameters:
writer - a BufferedWriter to write the results to
Throws:
IOException - if there was a problem accessing data file.


Copyright © 2017 51Degrees. All rights reserved.