Java 类org.apache.commons.collections.buffer.CircularFifoBuffer 实例源码

项目:gocd    文件:GoArtifactsManipulatorTest.java   
@Test
public void shouldBombWithErrorWhenStatusCodeReturnedIsRequestEntityTooLarge() throws IOException, InterruptedException {
    long size = anyLong();
    when(httpService.upload(any(String.class), size, any(File.class), any(Properties.class))).thenReturn(HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE);

    CircularFifoBuffer buffer = (CircularFifoBuffer) ReflectionUtil.getField(ReflectionUtil.getField(goPublisher, "consoleOutputTransmitter"), "buffer");
    synchronized (buffer) {
        try {
            goArtifactsManipulatorStub.publish(goPublisher, "some_dest", tempFile, jobIdentifier);
            fail("should have thrown request entity too large error");
        } catch (RuntimeException e) {
            String expectedMessage = "Artifact upload for file " + tempFile.getAbsolutePath() + " (Size: "+size+") was denied by the server. This usually happens when server runs out of disk space.";
            assertThat(e.getMessage(), is("java.lang.RuntimeException: " + expectedMessage + ".  HTTP return code is 413"));
            assertThat(buffer.toString().contains(expectedMessage), is(true));
        }
    }
}
项目:neoscada    文件:AbstractRequestBlock.java   
public Statistics ( final DataItemFactory itemFactory, final int size )
{
    this.stateItem = itemFactory.createInput ( "state", null );
    this.timeoutStateItem = itemFactory.createInput ( "timeout", null );
    this.lastUpdateItem = itemFactory.createInput ( "lastUpdate", null );
    this.lastTimeDiffItem = itemFactory.createInput ( "lastDiff", null );
    this.avgDiffItem = itemFactory.createInput ( "avgDiff", null );
    this.checksumErrorsItem = itemFactory.createInput ( "checksumErrors", null );

    this.sizeItem = itemFactory.createInput ( "size", null );
    this.sizeItem.updateData ( Variant.valueOf ( size ), null, null );

    this.lastUpdate = System.currentTimeMillis ();
    this.diffBuffer = new CircularFifoBuffer ( 20 );
}
项目:LSM9DS1-Pi4j-Driver    文件:AsyncPollingHelper.java   
/***********************************************************************************************
 * @param driver Handle to the driver class that will do the polling
 ***********************************************************************************************/
public AsyncPollingHelper(Driver driver) {
    this.driver = driver;

    //Default the max buffer size to 10 seconds worth of imu data
    int maxSize = Math.round(driver.getDatarate().getHz() * 10);
    fifo = BufferUtils.synchronizedBuffer(new CircularFifoBuffer(maxSize));
}
项目:storm_spring_boot_demo    文件:NthLastModifiedTimeTracker.java   
public NthLastModifiedTimeTracker(int numTimesToTrack) {
  if (numTimesToTrack < 1) {
    throw new IllegalArgumentException(
        "numTimesToTrack must be greater than zero (you requested " + numTimesToTrack + ")");
  }
  lastModifiedTimesMillis = new CircularFifoBuffer(numTimesToTrack);
  initLastModifiedTimesMillis();
}
项目:Android_RuuvitagScannner    文件:PlotSource.java   
public static PlotSource getInstance()
{
    if(instance == null)
    {
        instance = new PlotSource();
        buffer = new CircularFifoBuffer(BUFFER_SIZE);
    }

    return instance;
}
项目:jmzml    文件:MzMLUnmarshaller.java   
/**
 * TODO: Javadoc missing
 *
 * @param bBuf
 * @return
 */
private String convert2String(CircularFifoBuffer bBuf) {
    byte[] tmp = new byte[bBuf.size()];
    int tmpCnt = 0;
    for (Object aBBuf : bBuf) {
        tmp[tmpCnt++] = (Byte) aBBuf;
    }
    return new String(tmp);
}
项目:big-data-system    文件:NthLastModifiedTimeTracker.java   
public NthLastModifiedTimeTracker(int numTimesToTrack) {
  if (numTimesToTrack < 1) {
    throw new IllegalArgumentException(
        "numTimesToTrack must be greater than zero (you requested " + numTimesToTrack + ")");
  }
  lastModifiedTimesMillis = new CircularFifoBuffer(numTimesToTrack);
  initLastModifiedTimesMillis();
}
项目:cdh-storm    文件:NthLastModifiedTimeTracker.java   
public NthLastModifiedTimeTracker(int numTimesToTrack) {
  if (numTimesToTrack < 1) {
    throw new IllegalArgumentException(
        "numTimesToTrack must be greater than zero (you requested " + numTimesToTrack + ")");
  }
  lastModifiedTimesMillis = new CircularFifoBuffer(numTimesToTrack);
  initLastModifiedTimesMillis();
}
项目:storm-net-adapter    文件:NthLastModifiedTimeTracker.java   
public NthLastModifiedTimeTracker(int numTimesToTrack) {
  if (numTimesToTrack < 1) {
    throw new IllegalArgumentException(
        "numTimesToTrack must be greater than zero (you requested " + numTimesToTrack + ")");
  }
  lastModifiedTimesMillis = new CircularFifoBuffer(numTimesToTrack);
  initLastModifiedTimesMillis();
}
项目:tajo    文件:Lag.java   
@Override
public void eval(FunctionContext ctx, Tuple params) {
  LagContext lagCtx = (LagContext)ctx;
  if(lagCtx.lagBuffer == null) {
    int lagNum = 0;
    if (params.size() == 1) {
      lagNum = 1;
    } else {
      lagNum = params.getInt4(1);
    }
    lagCtx.lagBuffer = new CircularFifoBuffer(lagNum+1);
  }

  if (!params.isBlankOrNull(0)) {
    lagCtx.lagBuffer.add(params.asDatum(0));
  } else {
    lagCtx.lagBuffer.add(NullDatum.get());
  }

  if (lagCtx.defaultDatum == null) {
   if (params.size() == 3) {
     lagCtx.defaultDatum = params.asDatum(2);
   } else {
     lagCtx.defaultDatum = NullDatum.get();
   }
  }
}
项目:incubator-storm    文件:NthLastModifiedTimeTracker.java   
public NthLastModifiedTimeTracker(int numTimesToTrack) {
  if (numTimesToTrack < 1) {
    throw new IllegalArgumentException(
        "numTimesToTrack must be greater than zero (you requested " + numTimesToTrack + ")");
  }
  lastModifiedTimesMillis = new CircularFifoBuffer(numTimesToTrack);
  initLastModifiedTimesMillis();
}
项目:NeuroWaveWar    文件:eegPort.java   
public eegPort(PApplet applet, Serial serial) {
  app = applet;
  serialPort = serial;

  rawDataBuffer = new CircularFifoBuffer(4096);
  vectorBuffer = new CircularFifoBuffer(4096);
  attentionBuffer = new CircularFifoBuffer(3600);
  meditationBuffer = new CircularFifoBuffer(3600);
}
项目:NeuroWaveWar    文件:eegPort.java   
public eegPort(PApplet applet, Serial serial) {
  app = applet;
  serialPort = serial;

  rawDataBuffer = new CircularFifoBuffer(4096);
  vectorBuffer = new CircularFifoBuffer(4096);
  attentionBuffer = new CircularFifoBuffer(3600);
  meditationBuffer = new CircularFifoBuffer(3600);
}
项目:NeuroWaveWar    文件:eegPort.java   
public eegPort(PApplet applet, Serial serial) {
  app = applet;
  serialPort = serial;

  rawDataBuffer = new CircularFifoBuffer(4096);
  vectorBuffer = new CircularFifoBuffer(4096);
  attentionBuffer = new CircularFifoBuffer(3600);
  meditationBuffer = new CircularFifoBuffer(3600);
}
项目:NeuroWaveWar    文件:eegPort.java   
public eegPort(PApplet applet, Serial serial) {
  app = applet;
  serialPort = serial;

  rawDataBuffer = new CircularFifoBuffer(4096);
  vectorBuffer = new CircularFifoBuffer(4096);
  attentionBuffer = new CircularFifoBuffer(3600);
  meditationBuffer = new CircularFifoBuffer(3600);
}
项目:flink-perf    文件:NthLastModifiedTimeTracker.java   
public NthLastModifiedTimeTracker(int numTimesToTrack) {
  if (numTimesToTrack < 1) {
    throw new IllegalArgumentException(
        "numTimesToTrack must be greater than zero (you requested " + numTimesToTrack + ")");
  }
  lastModifiedTimesMillis = new CircularFifoBuffer(numTimesToTrack);
  initLastModifiedTimesMillis();
}
项目:docks    文件:VQVADTrainer.java   
/**
 * See the class documentation for a full explanation of the parameters.
 *
 * @param trainingBufferSize
 * @param energyMinLevel
 * @param energyFraction
 * @param vqSize
 * @param maxKMeansIter
 */
public VQVADTrainer(int trainingBufferSize, int minFrameCount, double energyMinLevel, double energyFraction, int vqSize, int maxKMeansIter) {
    this.minFrameCount = minFrameCount;
    this.energyMinLevel = energyMinLevel;
    this.energyFraction = energyFraction;
    this.vqSize = vqSize;

    trainingFrameBuffer = new CircularFifoBuffer(trainingBufferSize);
    clusterer = new KMeansPlusPlusClusterer<DoublePoint>(vqSize, maxKMeansIter);
}
项目:vs.msc.ws14    文件:SlidingWindowState.java   
public SlidingWindowState(long windowSize, long slideInterval, long timeUnitInMillis) {
    this.currentRecordCount = 0;
    // here we assume that windowSize and slidingStep is divisible by
    // computationGranularity.
    this.fullRecordCount = (int) (windowSize / timeUnitInMillis);
    this.slideRecordCount = (int) (slideInterval / timeUnitInMillis);
    this.buffer = new CircularFifoBuffer(fullRecordCount);
    this.iterator = new SlidingWindowStateIterator<T>(buffer);
}
项目:sentweet    文件:NthLastModifiedTimeTracker.java   
public NthLastModifiedTimeTracker(int numTimesToTrack) {
    if (numTimesToTrack < 1) {
        throw new IllegalArgumentException("numTimesToTrack must be greater than zero (you requested "
            + numTimesToTrack + ")");
    }
    lastModifiedTimesMillis = new CircularFifoBuffer(numTimesToTrack);
    initLastModifiedTimesMillis();
}
项目:ajira    文件:NthLastModifiedTimeTracker.java   
public NthLastModifiedTimeTracker(int numTimesToTrack) {
    if (numTimesToTrack < 1) {
        throw new IllegalArgumentException(
                "numTimesToTrack must be greater than zero (you requested "
                        + numTimesToTrack + ")");
    }
    lastModifiedTimesMillis = new CircularFifoBuffer(numTimesToTrack);
    initLastModifiedTimesMillis();
}
项目:jstorm    文件:NthLastModifiedTimeTracker.java   
public NthLastModifiedTimeTracker(int numTimesToTrack) {
    if (numTimesToTrack < 1) {
        throw new IllegalArgumentException(
                "numTimesToTrack must be greater than zero (you requested " + numTimesToTrack + ")");
    }
    lastModifiedTimesMillis = new CircularFifoBuffer(numTimesToTrack);
    initLastModifiedTimesMillis();
}
项目:LSM9DS1-Pi4j-Driver    文件:AsyncPollingHelper.java   
/************************************************************************************************
 * @param size sets the maximum size of the circular fifo buffer
 ************************************************************************************************/
public void setBufferSize(int size){
    fifo = (CircularFifoBuffer) BufferUtils.synchronizedBuffer(new CircularFifoBuffer(size));
}
项目:beyondj    文件:RollingLogOutputStream.java   
@SuppressWarnings("unchecked")
RollingLogOutputStream(int maxLines) {
    ringBuffer = new CircularFifoBuffer(maxLines);
}
项目:apex-malhar    文件:DefaultBlockReleaseStrategy.java   
public DefaultBlockReleaseStrategy(int period)
{
  freeBlockNumQueue = new CircularFifoBuffer(period);
}
项目:TweetRetriever    文件:PerSecAnalyzer.java   
public PerSecAnalyzer(Queue<JSONObject> in) {
    super(in);
    this.timings = new CircularFifoBuffer(capacity);
}
项目:TweetRetriever    文件:TweetOutputAnalyzer.java   
public TweetOutputAnalyzer(Queue<JSONObject> in) {
    super(in);
    this.buffer = new CircularFifoBuffer(32);
}
项目:kafka-examples    文件:SimpleMovingAvgZkConsumer.java   
public static void main(String[] args) {
    if (args.length == 0) {
        System.out.println("SimpleMovingAvgZkConsumer {zookeeper} {group.id} {topic} {window-size} {wait-time}");
        return;
    }

    String next;
    int num;
    SimpleMovingAvgZkConsumer movingAvg = new SimpleMovingAvgZkConsumer();
    String zkUrl = args[0];
    String groupId = args[1];
    String topic = args[2];
    int window = Integer.parseInt(args[3]);
    movingAvg.waitTime = args[4];




    CircularFifoBuffer buffer = new CircularFifoBuffer(window);

    movingAvg.configure(zkUrl,groupId);

    movingAvg.start(topic);

    while ((next = movingAvg.getNextMessage()) != null) {
        int sum = 0;

        try {
            num = Integer.parseInt(next);
            buffer.add(num);
        } catch (NumberFormatException e) {
            // just ignore strings
        }

        for (Object o: buffer) {
            sum += (Integer) o;
        }

        if (buffer.size() > 0) {
            System.out.println("Moving avg is: " + (sum / buffer.size()));
        }

        // uncomment if you wish to commit offsets on every message
        // movingAvg.consumer.commitOffsets();


    }

    movingAvg.consumer.shutdown();
    System.exit(0);

}
项目:OpenSDI-Manager2    文件:UserExpiringStatus.java   
/**
 * @return the expiredUsersLog
 */
public CircularFifoBuffer getExpiredUsersLog() {
    return expiredUsersLog;
}
项目:juddi    文件:NotificationList.java   
private NotificationList() {    
    list = BufferUtils.synchronizedBuffer(new CircularFifoBuffer(10));
}
项目:phon    文件:LogHandler.java   
public LogHandler() {
    super();
    logBuffer = new CircularFifoBuffer(DEFAULT_BUFFER_SIZE);
    instanceRef.set(this);
}
项目:phon    文件:LogHandler.java   
public CircularFifoBuffer getLogBuffer() {
    return this.logBuffer;
}
项目:docks    文件:VQVADTrainer.java   
/**
 * Create a trainer with default values. Should work fine for most cases.
 */
public VQVADTrainer() {
    trainingFrameBuffer = new CircularFifoBuffer(DEFAULT_FRAME_BUFFER_SIZE);
    clusterer = new KMeansPlusPlusClusterer<DoublePoint>(vqSize, DEFAULT_KMEANS_MAX_ITER);
}
项目:docks    文件:GapSmoothing.java   
public GapSmoothing(int gapWidthInFrames) {
    this.gapWidthInFrames = gapWidthInFrames;
    frameBuffer = new CircularFifoBuffer(gapWidthInFrames+1);
}
项目:vs.msc.ws14    文件:SlidingWindowStateIterator.java   
public SlidingWindowStateIterator(CircularFifoBuffer buffer) {
    this.buffer = buffer;
    this.streamRecordIterator = new StreamRecordIterator();
}
项目:AIDR    文件:ChannelBuffer.java   
public ChannelBuffer(final String name, final int bufferSize) {
    this.channelName = name;
    this.messageBuffer = BufferUtils.synchronizedBuffer(new CircularFifoBuffer(bufferSize));
    this.size = bufferSize;
}
项目:AIDR    文件:ChannelBuffer.java   
public void createChannelBuffer() {
    this.messageBuffer = BufferUtils.synchronizedBuffer(new CircularFifoBuffer(MAX_BUFFER_SIZE));
    this.size = MAX_BUFFER_SIZE;
}
项目:AIDR    文件:ChannelBuffer.java   
public void createChannelBuffer(final int bufferSize) {
    this.messageBuffer = BufferUtils.synchronizedBuffer(new CircularFifoBuffer(bufferSize));
    this.size = bufferSize;
}
项目:solr2activemq    文件:SolrToActiveMQComponent.java   
@Override
public void init( NamedList args )
{
  this.initArgs = SolrParams.toSolrParams(args);
  // Retrieve configuration

  // ActiveMQ configuration
  ACTIVEMQ_BROKER_URI = initArgs.get("activemq-broker-uri", "localhost");
  ACTIVEMQ_BROKER_PORT = initArgs.getInt("activemq-broker-port", 61616);
  ACTIVEMQ_DESTINATION_TYPE = initArgs.get("activemq-broker-destination-type", "queue");
  ACTIVEMQ_DESTINATION_NAME = initArgs.get("activemq-broker-destination-name", "solr_to_activemq_queue");

  // Solr configuration
  SOLR_HOSTNAME = initArgs.get("solr-hostname", "localhost");
  SOLR_PORT = initArgs.getInt("solr-port", 8983);
  SOLR_POOLNAME = initArgs.get("solr-poolname", "default");
  SOLR_CORENAME = initArgs.get("solr-corename", "collection");

  // Solr2ActiveMQ configuration
  BUFFER_SIZE = initArgs.getInt("solr2activemq-buffer-size", 10000);
  DEQUEUING_FROM_BUFFER_THREAD_POOL_SIZE = initArgs.getInt("solr2activemq-dequeuing-from-buffer-pool-size", 4);
  CHECK_ACTIVEMQ__POLLING = initArgs.getInt("solr2activemq-check-activemq-polling", 5000);

  System.out.println("SolrToActiveMQComponent: loaded configuration:" +
          "\n\tACTIVEMQ_BROKER_URI: " + ACTIVEMQ_BROKER_URI +
          "\n\tACTIVEMQ_BROKER_PORT: " + ACTIVEMQ_BROKER_PORT +
          "\n\tACTIVEMQ_DESTINATION_TYPE: " + ACTIVEMQ_DESTINATION_TYPE +
          "\n\tACTIVEMQ_DESTINATION_NAME: " + ACTIVEMQ_DESTINATION_NAME +
          "\n\tSOLR_HOSTNAME: " + SOLR_HOSTNAME +
          "\n\tSOLR_PORT: " + SOLR_PORT +
          "\n\tSOLR_POOLNAME: " + SOLR_POOLNAME +
          "\n\tSOLR_CORENAME: " + SOLR_CORENAME +
          "\n\tBUFFER_SIZE: " + BUFFER_SIZE +
          "\n\tDEQUEUING_FROM_BUFFER_THREAD_POOL_SIZE: " + DEQUEUING_FROM_BUFFER_THREAD_POOL_SIZE +
          "\n\tCHECK_ACTIVEMQ__POLLING: " + CHECK_ACTIVEMQ__POLLING
  );

  circularFifoBuffer = new CircularFifoBuffer(BUFFER_SIZE);
  bootstrapMessagingSystem();
  ExecutorService pool = Executors.newFixedThreadPool(4);
  for (int i=0;i< DEQUEUING_FROM_BUFFER_THREAD_POOL_SIZE;i++){
    pool.submit(new DequeueFromBuffer(),false);
  }
  pool.shutdown();
  checkActiveMQTimer.schedule(new CheckIfActiveMQNeedsBootstrap(), 0, CHECK_ACTIVEMQ__POLLING);
}
项目:OpenSDI-Manager2    文件:UserExpiringStatus.java   
/**
 * @param expiredUsersLog
 *            the expiredUsersLog to set
 */
public void setExpiredUsersLog(CircularFifoBuffer expiredUsersLog) {
    this.expiredUsersLog = expiredUsersLog;
}
项目:thoth-ml    文件:MergeUtils.java   
/**
 * Helper to merge multiple files to single file that works as a FIFO buffer
 * @param mergeFile merge output file
 * @param dirToMerge directory that contains the files to merge
 * @param lineCountLimit max number of lines allowed in the mergeFile. Older lines gets pushed out when limits is reached
 * @throws UnsupportedEncodingException
 */
public MergeUtils(String mergeFile, String dirToMerge, int lineCountLimit) throws UnsupportedEncodingException {
  this.mergeFile = mergeFile;
  this.dirToMerge = dirToMerge;
  this.fifo = new CircularFifoBuffer(lineCountLimit);
}