Examples of MetricsInputStream


Examples of org.sonatype.nexus.blobstore.file.internal.MetricsInputStream

  private void readContentAndValidateMetrics(final BlobId blobId,
                                             final InputStream inputStream,
                                             final BlobMetrics metadataMetrics)
      throws NoSuchAlgorithmException, IOException
  {
    final MetricsInputStream measured = new MetricsInputStream(inputStream);
    ByteStreams.copy(measured, nullOutputStream());

    checkEqual("stream length", metadataMetrics.getContentSize(), measured.getSize(), blobId);
    checkEqual("SHA1 hash", metadataMetrics.getSHA1Hash(), measured.getMessageDigest(), blobId);
  }
View Full Code Here

Examples of org.sonatype.nexus.blobstore.file.internal.MetricsInputStream

    // Ensure path exists for new blob
    Path dir = path.getParent();
    checkNotNull(dir, "Null parent for path: %s", path);
    DirSupport.mkdir(dir);

    final MetricsInputStream input = new MetricsInputStream(data);
    try {
      try (final OutputStream output = Files.newOutputStream(path, StandardOpenOption.CREATE_NEW)) {
        ByteStreams.copy(input, output);
      }
    }
    finally {
      // FIXME: Revisit closing stream which is passed in as parameter, this should be the responsibility of the caller
      data.close();
    }

    return input.getMetrics();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.