summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2019-10-11 17:50:29 -0400
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2019-10-11 17:50:29 -0400
commit52408c6afbefbf2482b7be70ed2543ee74b041d3 (patch)
tree91ae214f2e38e53dd349628d3afa7b970fe9056a
parentdfef00a2c85b8150bc4d77e9c7dd06ba1514d2a6 (diff)
parenta307c88714f3e3da14b07743f91542fabcfd7706 (diff)
downloadjgit-52408c6afbefbf2482b7be70ed2543ee74b041d3.tar.gz
jgit-52408c6afbefbf2482b7be70ed2543ee74b041d3.zip
Merge changes from topic 'packfile-offloading-stats'
* changes: PackWriter/Statistics: Report offloaded size CachedPackUriProvider: Add size to the pack information
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/CachedPackUriProvider.java21
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackStatistics.java30
4 files changed, 51 insertions, 4 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
index 5d9f32d40b..2f370d8c52 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
@@ -2077,7 +2077,7 @@ public class UploadPackTest {
assertThat(protocolsSupported, hasItems("https"));
if (!protocolsSupported.contains("https"))
return null;
- return new PackInfo("myhash", "myuri");
+ return new PackInfo("myhash", "myuri", 100);
}
});
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/CachedPackUriProvider.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/CachedPackUriProvider.java
index 5cbc2baeb2..b50f7392dc 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/CachedPackUriProvider.java
+++ b/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 uri;
+ private final int size;
+
/**
* 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.uri = uri;
+ this.size = size;
}
/**
@@ -99,5 +107,12 @@ public interface CachedPackUriProvider {
public String getUri() {
return uri;
}
+
+ /**
+ * @return the size of the packfile in bytes (-1 if unknown)
+ */
+ public long getSize() {
+ return size;
+ }
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
index 43067d364d..2f770e96fb 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
@@ -1230,6 +1230,8 @@ public class PackWriter implements AutoCloseable {
if (packInfo != null) {
o.writeString(packInfo.getHash() + ' ' +
packInfo.getUri() + '\n');
+ stats.offloadedPackfiles += 1;
+ stats.offloadedPackfileSize += packInfo.getSize();
} else {
unwrittenCachedPacks.add(pack);
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackStatistics.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackStatistics.java
index e6e3d4fb12..645da0a068 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackStatistics.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackStatistics.java
@@ -271,6 +271,20 @@ public class PackStatistics {
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
* and blobs.)
*/
@@ -598,6 +612,22 @@ public class PackStatistics {
}
/**
+ * @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.
*
* @return total time spent processing this pack.