From 30fd2864abd8ed5b0944c9eaf0d1dc76d9136119 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Sun, 11 Mar 2018 19:11:35 +0900 Subject: [PATCH] Use WindowCacheStats from JGit Since [1] JGit exposes a public class WindowCacheStats, allowing to access the statistics from WindowCache which is not a public API. Remove the WindowCacheStatAccessor and use the new API instead. [1] https://git.eclipse.org/r/#/c/116501/ Change-Id: I73dff00c309efd37030c02af91e7e7643b9b3751 --- .../gerrit/metrics/proc/JGitMetricModule.java | 6 ++-- .../server/restapi/config/GetSummary.java | 6 ++-- java/org/eclipse/jgit/BUILD | 1 - .../storage/file/WindowCacheStatAccessor.java | 30 ------------------- 4 files changed, 6 insertions(+), 37 deletions(-) delete mode 100644 java/org/eclipse/jgit/internal/storage/file/WindowCacheStatAccessor.java diff --git a/java/com/google/gerrit/metrics/proc/JGitMetricModule.java b/java/com/google/gerrit/metrics/proc/JGitMetricModule.java index c3eb39f2f2..4487ae5882 100644 --- a/java/com/google/gerrit/metrics/proc/JGitMetricModule.java +++ b/java/com/google/gerrit/metrics/proc/JGitMetricModule.java @@ -18,7 +18,7 @@ import com.google.common.base.Supplier; import com.google.gerrit.metrics.Description; import com.google.gerrit.metrics.Description.Units; import com.google.gerrit.metrics.MetricMaker; -import org.eclipse.jgit.internal.storage.file.WindowCacheStatAccessor; +import org.eclipse.jgit.storage.file.WindowCacheStats; public class JGitMetricModule extends MetricModule { @Override @@ -32,7 +32,7 @@ public class JGitMetricModule extends MetricModule { new Supplier() { @Override public Long get() { - return WindowCacheStatAccessor.getOpenBytes(); + return WindowCacheStats.getOpenBytes(); } }); @@ -43,7 +43,7 @@ public class JGitMetricModule extends MetricModule { new Supplier() { @Override public Integer get() { - return WindowCacheStatAccessor.getOpenFiles(); + return WindowCacheStats.getOpenFiles(); } }); } diff --git a/java/com/google/gerrit/server/restapi/config/GetSummary.java b/java/com/google/gerrit/server/restapi/config/GetSummary.java index 26f069c7dc..a3824360a3 100644 --- a/java/com/google/gerrit/server/restapi/config/GetSummary.java +++ b/java/com/google/gerrit/server/restapi/config/GetSummary.java @@ -37,7 +37,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.eclipse.jgit.internal.storage.file.WindowCacheStatAccessor; +import org.eclipse.jgit.storage.file.WindowCacheStats; import org.kohsuke.args4j.Option; @RequiresCapability(GlobalCapability.MAINTAIN_SERVER) @@ -125,8 +125,8 @@ public class GetSummary implements RestReadView { long mTotal = r.totalMemory(); long mInuse = mTotal - mFree; - int jgitOpen = WindowCacheStatAccessor.getOpenFiles(); - long jgitBytes = WindowCacheStatAccessor.getOpenBytes(); + int jgitOpen = WindowCacheStats.getOpenFiles(); + long jgitBytes = WindowCacheStats.getOpenBytes(); MemSummaryInfo memSummaryInfo = new MemSummaryInfo(); memSummaryInfo.total = bytes(mTotal); diff --git a/java/org/eclipse/jgit/BUILD b/java/org/eclipse/jgit/BUILD index 65bc1185b7..b9b807a94a 100644 --- a/java/org/eclipse/jgit/BUILD +++ b/java/org/eclipse/jgit/BUILD @@ -39,7 +39,6 @@ java_library( srcs = [ "diff/EditDeserializer.java", "diff/ReplaceEdit.java", - "internal/storage/file/WindowCacheStatAccessor.java", "lib/ObjectIdSerialization.java", ], visibility = ["//visibility:public"], diff --git a/java/org/eclipse/jgit/internal/storage/file/WindowCacheStatAccessor.java b/java/org/eclipse/jgit/internal/storage/file/WindowCacheStatAccessor.java deleted file mode 100644 index f8c434063a..0000000000 --- a/java/org/eclipse/jgit/internal/storage/file/WindowCacheStatAccessor.java +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2009 The Android Open Source Project -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.eclipse.jgit.internal.storage.file; - -// Hack to obtain visibility to package level methods only. -// These aren't yet part of the public JGit API. - -public class WindowCacheStatAccessor { - public static int getOpenFiles() { - return WindowCache.getInstance().getOpenFiles(); - } - - public static long getOpenBytes() { - return WindowCache.getInstance().getOpenBytes(); - } - - private WindowCacheStatAccessor() {} -}