RetryingInputStream( T object, ObjectOpenFunction<T> objectOpenFunction, Predicate<Throwable> retryCondition, int maxRetry ) throws IOException { this.object = object; this.objectOpenFunction = objectOpenFunction; this.retryCondition = retryCondition; this.maxRetry = maxRetry; this.delegate = new CountingInputStream(objectOpenFunction.open(object)); }
@Override protected void setUp() throws Exception { super.setUp(); counter = new CountingInputStream(new ByteArrayInputStream(new byte[20])); }
public ExampleRecordCursor(List<ExampleColumnHandle> columnHandles, ByteSource byteSource) { this.columnHandles = columnHandles; fieldToColumnIndex = new int[columnHandles.size()]; for (int i = 0; i < columnHandles.size(); i++) { ExampleColumnHandle columnHandle = columnHandles.get(i); fieldToColumnIndex[i] = columnHandle.getOrdinalPosition(); } try (CountingInputStream input = new CountingInputStream(byteSource.openStream())) { lines = byteSource.asCharSource(UTF_8).readLines().iterator(); totalBytes = input.getCount(); } catch (IOException e) { throw new UncheckedIOException(e); } }
CountingInputStream countingInputStream = new CountingInputStream(in); Collection<Map<String, Object>> events; try {
public void testMarkNotSupported() { counter = new CountingInputStream(new UnmarkableInputStream()); try { counter.reset(); fail(); } catch (IOException expected) { assertThat(expected).hasMessageThat().isEqualTo("Mark not supported"); } }
delegate = new CountingInputStream(objectOpenFunction.open(object, startOffset));
@Override public void handle(HttpExchange exchange) throws IOException { CountingInputStream input = new CountingInputStream(exchange.getRequestBody()); CountingOutputStream output = new CountingOutputStream(exchange.getResponseBody()); exchange.setStreams(input, output); Stopwatch stopwatch = latency.start(); try { handleImpl(exchange); } finally { stopwatch.stop(); bytesReceived.increment(input.getCount()); bytesSent.increment(output.getCount()); } }
public NutDataInputStream(InputStream in) { checkNotNull(in); this.count = new CountingInputStream(in); this.crc = new CRC32InputStream(count); this.in = new DataInputStream(crc); }
protected final StreamMetadata storeBlocksAndGetHashlessMetadata(@Nullable Transaction tx, long id, InputStream stream) { CountingInputStream countingStream = new CountingInputStream(stream); // Try to store the bytes in the stream and get length try { storeBlocksFromStream(tx, id, countingStream); } catch (IOException e) { long length = countingStream.getCount(); StreamMetadata metadata = StreamMetadata.newBuilder() .setStatus(Status.FAILED) .setLength(length) .setHash(com.google.protobuf.ByteString.EMPTY) .build(); storeMetadataAndIndex(id, metadata); log.error("Could not store stream {}. Failed after {} bytes.", id, length, e); throw Throwables.rewrapAndThrowUncheckedException("Failed to store stream.", e); } long length = countingStream.getCount(); return StreamMetadata.newBuilder() .setStatus(Status.STORED) .setLength(length) .setHash(com.google.protobuf.ByteString.EMPTY) .build(); }
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed") public InputStreamSliceInput(InputStream inputStream) { pushbackInputStream = new PushbackInputStream(inputStream); countingInputStream = new CountingInputStream(pushbackInputStream); dataInputStream = new LittleEndianDataInputStream(countingInputStream); }
private TestingResponse(HttpStatus status, ListMultimap<String, String> headers, InputStream input) { this.status = requireNonNull(status, "status is null"); this.headers = ImmutableListMultimap.copyOf(toHeaderMap(requireNonNull(headers, "headers is null"))); this.countingInputStream = new CountingInputStream(requireNonNull(input, "input is null")); }
public TestingResponse(HttpStatus status, ListMultimap<String, String> headers, InputStream input) { this.status = requireNonNull(status, "status is null"); this.headers = ImmutableListMultimap.copyOf(toHeaderMap(requireNonNull(headers, "headers is null"))); this.countingInputStream = new CountingInputStream(requireNonNull(input, "input is null")); }
List<File> uncompressTarGzFile(File inputFile, File outputDir, Consumer<ProgressEntity> stateCallback) { try (CountingInputStream countingInputStream = new CountingInputStream(new FileInputStream(inputFile)); InputStream inputStream = new GZIPInputStream(countingInputStream)) { final long finalSize = FileUtils.sizeOf(inputFile); return uncompress(inputStream, countingInputStream, outputDir, finalSize, stateCallback); } catch (IOException e) { throw new ArchiveException(TAR_ERROR_MESSAGE, e); } }
public JettyResponse(Response response, InputStream inputStream) { this.response = response; this.inputStream = new CountingInputStream(inputStream); this.headers = toHeadersMap(response.getHeaders()); }
JettyResponse(Response response, InputStream inputStream) { this.response = response; this.inputStream = new CountingInputStream(inputStream); this.headers = toHeadersMap(response.getHeaders()); }
List<File> uncompressTarFile(File inputFile, File outputDir, Consumer<ProgressEntity> stateCallback) { try (CountingInputStream countingInputStream = new CountingInputStream(new FileInputStream(inputFile))) { final long finalSize = FileUtils.sizeOf(inputFile); return uncompress(countingInputStream, countingInputStream, outputDir, finalSize, stateCallback); } catch (IOException e) { throw new ArchiveException(TAR_ERROR_MESSAGE, e); } }
List<File> uncompressZipFile(File inputFile, File outputDir, Consumer<ProgressEntity> stateCallback) { try (CountingInputStream inputStream = new CountingInputStream(new FileInputStream(inputFile))) { final long finalSize = FileUtils.sizeOf(inputFile); List<File> files = uncompress(inputStream, inputStream, outputDir, finalSize, stateCallback); return files; } catch (IOException e) { throw new ArchiveException(ZIP_ERROR_MESSAGE, e); } }
public void sort(InputStream inputStream, OutputStream outputStream) { long begin = System.currentTimeMillis(); CountingInputStream countingInputStream = new CountingInputStream(inputStream); doSort(countingInputStream, outputStream); LogUtils.infoTimeTaken(LOG, begin, countingInputStream.getCount(), "Sorted stream of %d bytes", countingInputStream.getCount()); }
@NotNull @Override public InputStream getNewStream() { accessCount++; stream = new CountingInputStream(super.getNewStream()); return stream; }
public TestARCReader(WARCRecordInfo recinfo) throws IOException { setIn(new CountingInputStream(buildRecordContent(recinfo))); // ARCRecord tries to read off version-block if offset==0 and // alignedOnFirstRecord is true (it is by default). As we don't have // version-block at offset 0, we disable this behavior. setAlignedOnFirstRecord(false); }