/** * Tests the given scenario for uploading a file while flushing * periodically and making sure the data is always consistent * with what I'd expect. * @param variation The variation/scenario to test. */ private void testConsistencyAfterManyFlushes(FlushFrequencyVariation variation) throws Exception { Path uploadedFile = new Path("/uploadedFile"); OutputStream outStream = testAccount.getFileSystem().create(uploadedFile); final int totalSize = 9123; int flushPeriod; switch (variation) { case BeforeSingleBufferFull: flushPeriod = 300; break; case AfterSingleBufferFull: flushPeriod = 600; break; case AfterAllRingBufferFull: flushPeriod = 1600; break; default: throw new IllegalArgumentException("Unknown variation: " + variation); } for (int i = 0; i < totalSize; i++) { outStream.write(i % byteValuePeriod); if ((i + 1) % flushPeriod == 0) { outStream.flush(); assertDataInTempBlob(i + 1); } } outStream.close(); assertDataInFile(uploadedFile, totalSize); } }
if ((i + 1) % flushPeriod == 0) { outStream.flush(); assertDataInTempBlob(i + 1);