Browse Source

Merge changes from topic 'packfile-offloading-stats'

* changes:
  PackWriter/Statistics: Report offloaded size
  CachedPackUriProvider: Add size to the pack information
next
Jonathan Tan 5 years ago committed by Gerrit Code Review @ Eclipse.org
parent
commit
52408c6afb
  1. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
  2. 21
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/CachedPackUriProvider.java
  3. 2
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
  4. 30
      org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackStatistics.java

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java

@ -2077,7 +2077,7 @@ public class UploadPackTest {
assertThat(protocolsSupported, hasItems("https")); assertThat(protocolsSupported, hasItems("https"));
if (!protocolsSupported.contains("https")) if (!protocolsSupported.contains("https"))
return null; return null;
return new PackInfo("myhash", "myuri"); return new PackInfo("myhash", "myuri", 100);
} }
}); });

21
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/CachedPackUriProvider.java

@ -76,14 +76,22 @@ public interface CachedPackUriProvider {
private final String hash; private final String hash;
private final String uri; private final String uri;
private final int size;
/** /**
* Constructs an object containing information about a packfile. * Constructs an object containing information about a packfile.
* @param hash the hash of the packfile as a hexadecimal string *
* @param uri the URI corresponding to the packfile * @param hash
* the hash of the packfile as a hexadecimal string
* @param uri
* the URI corresponding to the packfile
* @param size
* the size of the packfile in bytes
*/ */
public PackInfo(String hash, String uri) { public PackInfo(String hash, String uri, int size) {
this.hash = hash; this.hash = hash;
this.uri = uri; this.uri = uri;
this.size = size;
} }
/** /**
@ -99,5 +107,12 @@ public interface CachedPackUriProvider {
public String getUri() { public String getUri() {
return uri; return uri;
} }
/**
* @return the size of the packfile in bytes (-1 if unknown)
*/
public long getSize() {
return size;
}
} }
} }

2
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java

@ -1230,6 +1230,8 @@ public class PackWriter implements AutoCloseable {
if (packInfo != null) { if (packInfo != null) {
o.writeString(packInfo.getHash() + ' ' + o.writeString(packInfo.getHash() + ' ' +
packInfo.getUri() + '\n'); packInfo.getUri() + '\n');
stats.offloadedPackfiles += 1;
stats.offloadedPackfileSize += packInfo.getSize();
} else { } else {
unwrittenCachedPacks.add(pack); unwrittenCachedPacks.add(pack);
} }

30
org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackStatistics.java

@ -270,6 +270,20 @@ public class PackStatistics {
* @since 5.4*/ * @since 5.4*/
public long treesTraversed; public long treesTraversed;
/**
* Amount of packfile uris sent to the client to download via HTTP.
*
* @since 5.6
*/
public long offloadedPackfiles;
/**
* Total size (in bytes) offloaded to HTTP downloads.
*
* @since 5.6
*/
public long offloadedPackfileSize;
/** /**
* Statistics about each object type in the pack (commits, tags, trees * Statistics about each object type in the pack (commits, tags, trees
* and blobs.) * and blobs.)
@ -597,6 +611,22 @@ public class PackStatistics {
return statistics.treesTraversed; return statistics.treesTraversed;
} }
/**
* @return amount of packfiles offloaded (sent as "packfile-uri")/
* @since 5.6
*/
public long getOffloadedPackfiles() {
return statistics.offloadedPackfiles;
}
/**
* @return total size (in bytes) offloaded to HTTP downloads.
* @since 5.6
*/
public long getOffloadedPackfilesSize() {
return statistics.offloadedPackfileSize;
}
/** /**
* Get total time spent processing this pack. * Get total time spent processing this pack.
* *

Loading…
Cancel
Save