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:
committed by
Shawn Pearce
parent
910e954ac8
commit
619169b4eb
@@ -0,0 +1,42 @@
|
||||
// Copyright (C) 2013 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.server.git;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
@Singleton
|
||||
class GarbageCollectionQueue {
|
||||
private final Set<Project.NameKey> projectsScheduledForGc = Sets.newHashSet();
|
||||
|
||||
synchronized Set<Project.NameKey> addAll(Collection<Project.NameKey> projects) {
|
||||
Set<Project.NameKey> added =
|
||||
Sets.newLinkedHashSetWithExpectedSize(projects.size());
|
||||
for (Project.NameKey p : projects) {
|
||||
if (projectsScheduledForGc.add(p)) {
|
||||
added.add(p);
|
||||
}
|
||||
}
|
||||
return added;
|
||||
}
|
||||
|
||||
synchronized void gcFinished(Project.NameKey project) {
|
||||
projectsScheduledForGc.remove(project);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user