@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)); } } }
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 ); }
/*********************************************************************************************** * @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)); }
public NthLastModifiedTimeTracker(int numTimesToTrack) { if (numTimesToTrack < 1) { throw new IllegalArgumentException( "numTimesToTrack must be greater than zero (you requested " + numTimesToTrack + ")"); } lastModifiedTimesMillis = new CircularFifoBuffer(numTimesToTrack); initLastModifiedTimesMillis(); }
public static PlotSource getInstance() { if(instance == null) { instance = new PlotSource(); buffer = new CircularFifoBuffer(BUFFER_SIZE); } return instance; }
/** * 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); }
@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(); } } }
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); }
/** * 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); }
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); }
public NthLastModifiedTimeTracker(int numTimesToTrack) { if (numTimesToTrack < 1) { throw new IllegalArgumentException("numTimesToTrack must be greater than zero (you requested " + numTimesToTrack + ")"); } lastModifiedTimesMillis = new CircularFifoBuffer(numTimesToTrack); initLastModifiedTimesMillis(); }
/************************************************************************************************ * @param size sets the maximum size of the circular fifo buffer ************************************************************************************************/ public void setBufferSize(int size){ fifo = (CircularFifoBuffer) BufferUtils.synchronizedBuffer(new CircularFifoBuffer(size)); }
@SuppressWarnings("unchecked") RollingLogOutputStream(int maxLines) { ringBuffer = new CircularFifoBuffer(maxLines); }
public DefaultBlockReleaseStrategy(int period) { freeBlockNumQueue = new CircularFifoBuffer(period); }
public PerSecAnalyzer(Queue<JSONObject> in) { super(in); this.timings = new CircularFifoBuffer(capacity); }
public TweetOutputAnalyzer(Queue<JSONObject> in) { super(in); this.buffer = new CircularFifoBuffer(32); }
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); }
/** * @return the expiredUsersLog */ public CircularFifoBuffer getExpiredUsersLog() { return expiredUsersLog; }
private NotificationList() { list = BufferUtils.synchronizedBuffer(new CircularFifoBuffer(10)); }
public LogHandler() { super(); logBuffer = new CircularFifoBuffer(DEFAULT_BUFFER_SIZE); instanceRef.set(this); }
public CircularFifoBuffer getLogBuffer() { return this.logBuffer; }
/** * 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); }
public GapSmoothing(int gapWidthInFrames) { this.gapWidthInFrames = gapWidthInFrames; frameBuffer = new CircularFifoBuffer(gapWidthInFrames+1); }
public SlidingWindowStateIterator(CircularFifoBuffer buffer) { this.buffer = buffer; this.streamRecordIterator = new StreamRecordIterator(); }
public ChannelBuffer(final String name, final int bufferSize) { this.channelName = name; this.messageBuffer = BufferUtils.synchronizedBuffer(new CircularFifoBuffer(bufferSize)); this.size = bufferSize; }
public void createChannelBuffer() { this.messageBuffer = BufferUtils.synchronizedBuffer(new CircularFifoBuffer(MAX_BUFFER_SIZE)); this.size = MAX_BUFFER_SIZE; }
public void createChannelBuffer(final int bufferSize) { this.messageBuffer = BufferUtils.synchronizedBuffer(new CircularFifoBuffer(bufferSize)); this.size = bufferSize; }
@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); }
/** * @param expiredUsersLog * the expiredUsersLog to set */ public void setExpiredUsersLog(CircularFifoBuffer expiredUsersLog) { this.expiredUsersLog = expiredUsersLog; }
/** * 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); }