Add SSH command to run Git garbage collection

Add a new SSH command that allows to run the Git garbage collection
for specific or all Gerrit projects.

The default parameters for the Git garbage collection can be defined
in the user global Git configuration file of the system user that
runs the Gerrit server.

It is possible to specify repository specific parameters for the
garbage collection in the Git configuration files on repository
level.

All GC runs are logged in a newly added GC log file. This log file
also contains statistics of the repositories that were garbage
collected.

Change-Id: Ie8730e3db785d5e05d5b739cfb1ef87ba515e870
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2012-02-09 15:47:52 +01:00
committed by Shawn Pearce
parent 910e954ac8
commit 619169b4eb
20 changed files with 860 additions and 1 deletions

View File

@@ -0,0 +1,82 @@
// Copyright (C) 2012 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 com.google.gerrit.common.data;
import com.google.common.collect.Lists;
import com.google.gerrit.reviewdb.client.Project;
import java.util.List;
public class GarbageCollectionResult {
protected List<Error> errors;
public GarbageCollectionResult() {
errors = Lists.newArrayList();
}
public void addError(Error e) {
errors.add(e);
}
public List<Error> getErrors() {
return errors;
}
public boolean hasErrors() {
return !errors.isEmpty();
}
public static class Error {
public static enum Type {
/** Git garbage collection was already scheduled for this project */
GC_ALREADY_SCHEDULED,
/** The repository was not found. */
REPOSITORY_NOT_FOUND,
/** The Git garbage collection failed. */
GC_FAILED
}
protected Type type;
protected Project.NameKey projectName;
protected Error() {
}
public Error(Type type, Project.NameKey projectName) {
this.type = type;
this.projectName = projectName;
}
public Type getType() {
return type;
}
public Project.NameKey getProjectName() {
return projectName;
}
@Override
public String toString() {
StringBuilder b = new StringBuilder();
b.append(type);
if (projectName != null) {
b.append(" ").append(projectName);
}
return b.toString();
}
}
}

View File

@@ -67,6 +67,9 @@ public class GlobalCapability {
/** Maximum result limit per executed query. */
public static final String QUERY_LIMIT = "queryLimit";
/** Can run the Git garbage collection. */
public static final String RUN_GC = "runGC";
/** Forcefully restart replication to any configured destination. */
public static final String START_REPLICATION = "startReplication";
@@ -94,6 +97,7 @@ public class GlobalCapability {
NAMES_ALL.add(KILL_TASK);
NAMES_ALL.add(PRIORITY);
NAMES_ALL.add(QUERY_LIMIT);
NAMES_ALL.add(RUN_GC);
NAMES_ALL.add(START_REPLICATION);
NAMES_ALL.add(VIEW_CACHES);
NAMES_ALL.add(VIEW_CONNECTIONS);