package jetbrains.buildServer.buildTriggers.vcs.git;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.util.Map;
* @return parent dir of local repositories
*/
@NotNull
- public File getBaseMirrorsDir();
+ File getBaseMirrorsDir();
/**
* Get default directory for remote repository with specified url
* @return see above
*/
@NotNull
- public File getMirrorDir(@NotNull String repositoryUrl);
+ File getMirrorDir(@NotNull String repositoryUrl);
/**
* Mark dir as invalid, urls mapped to this dir will get another mapping
* on subsequent call to getMirrorDir()
* @param dir dir of interest
*/
- public void invalidate(@NotNull File dir);
+ void invalidate(@NotNull File dir);
- public Map<String, File> getMappings();
+ @NotNull
+ Map<String, File> getMappings();
+
+ long getLastUsedTime(@NotNull final File dir);
- public long getLastUsedTime(@NotNull final File dir);
+ /**
+ * Returns url for the given clone directory name inside the baseMirrorsDir
+ * or null if mapping from the url is not found
+ * @param cloneDirName clone directory name of interest
+ * @return see above
+ */
+ @Nullable
+ String getUrl(@NotNull String cloneDirName);
}
}
+ @NotNull
public Map<String, File> getMappings() {
Map<String, String> mirrorMapSnapshot;
synchronized (myLock) {
return result;
}
+ @Nullable
+ @Override
+ public String getUrl(@NotNull String cloneDirName) {
+ Map<String, String> mirrorMapSnapshot;
+ synchronized (myLock) {
+ mirrorMapSnapshot = new HashMap<String, String>(myMirrorMap);
+ }
+ for (Map.Entry<String, String> e : mirrorMapSnapshot.entrySet()) {
+ if (cloneDirName.equals(e.getValue()))
+ return e.getKey();
+ }
+ return null;
+ }
public long getLastUsedTime(@NotNull final File dir) {
File timestamp = new File(dir, "timestamp");
package jetbrains.buildServer.buildTriggers.vcs.git.health;
import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.util.Pair;
+import jetbrains.buildServer.buildTriggers.vcs.git.MirrorManager;
import jetbrains.buildServer.serverSide.ServerPaths;
import jetbrains.buildServer.serverSide.auth.Permission;
import jetbrains.buildServer.serverSide.healthStatus.HealthStatusItem;
private static final Logger LOG = Logger.getInstance(GitGcErrorsHealthPage.class.getName());
private final ServerPaths myServerPaths;
+ private final MirrorManager myMirrorManager;
public GitGcErrorsHealthPage(@NotNull PluginDescriptor pluginDescriptor,
@NotNull PagePlaces pagePlaces,
- @NotNull ServerPaths serverPaths) {
+ @NotNull ServerPaths serverPaths,
+ @NotNull MirrorManager mirrorManager) {
super(GitGcErrorsHealthReport.REPORT_TYPE, pagePlaces);
myServerPaths = serverPaths;
+ myMirrorManager = mirrorManager;
setIncludeUrl(pluginDescriptor.getPluginResourcesPath("health/gitGcErrorsReport.jsp"));
setVisibleOutsideAdminArea(false);
register();
public void fillModel(@NotNull final Map<String, Object> model, @NotNull final HttpServletRequest request) {
HealthStatusItem item = getStatusItem(request);
Object errors = item.getAdditionalData().get(GitGcErrorsHealthReport.ERRORS_KEY);
- Map<String, String> sortedErrors = new TreeMap<>();
+ Map<String, Pair<String, String>> sortedErrors = new TreeMap<>();
if (errors instanceof Map) {
String baseDir;
try {
if (key instanceof File && value instanceof String) {
try {
String relativePath = FileUtil.getRelativePath(baseDir, ((File)key).getCanonicalPath(), File.separatorChar);
- sortedErrors.put(relativePath, (String) value);
+ String url = myMirrorManager.getUrl(relativePath);
+ if (url != null) {
+ sortedErrors.put(url, Pair.create(relativePath, (String) value));
+ }
} catch (IOException e) {
LOG.warnAndDebugDetails("Error while preparing health report data", e);
}
<div id="${errorsBlockId}" style="margin-left: 1em; display: ${showMode == inplaceMode ? 'none' : ''}">
<c:forEach var="error" items="${errors}">
<div>
- <b><c:out value="${error.key}"/></b>: <c:out value="${error.value}"/>
+ <b><c:out value="${error.key}"/></b> (clone dir <c:out value="${error.value.first}"/>): <c:out value="${error.value.second}"/>
</div>
</c:forEach>
</div>
import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.util.FS;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.io.IOException;
}
+ @NotNull
public Map<String, File> getMappings() {
return myMirrorManager.getMappings();
}
+ @Nullable
+ @Override
+ public String getUrl(@NotNull String cloneDirName) {
+ return myMirrorManager.getUrl(cloneDirName);
+ }
+
@NotNull
public List<File> getExpiredDirs() {
long now = System.currentTimeMillis();