public class GC extends Object
FileRepository
. Instances of this class
are not thread-safe. Don't use the same instance from multiple threads.
This class started as a copy of DfsGarbageCollector from Shawn O. Pearce
adapted to FileRepositories.Modifier and Type | Class and Description |
---|---|
class |
GC.RepoStatistics
A class holding statistical data for a FileRepository regarding how many
objects are stored as loose or packed objects
|
Constructor and Description |
---|
GC(FileRepository repo)
Creates a new garbage collector with default values.
|
Modifier and Type | Method and Description |
---|---|
Collection<PackFile> |
gc()
Runs a garbage collector on a
FileRepository . |
GC.RepoStatistics |
getStatistics()
Returns the number of objects stored in pack files.
|
void |
packRefs()
Packs all non-symbolic, loose refs into packed-refs.
|
void |
prune(Set<ObjectId> objectsToKeep)
Like "git prune" this method tries to prune all loose objects which are
unreferenced.
|
void |
prunePacked()
Like "git prune-packed" this method tries to prune all loose objects
which can be found in packs.
|
Collection<PackFile> |
repack()
Packs all objects which reachable from any of the heads into one pack
file.
|
void |
setExpire(Date expire)
During gc() or prune() each unreferenced, loose object which has been
created or modified after or at
expire will not be pruned. |
void |
setExpireAgeMillis(long expireAgeMillis)
During gc() or prune() each unreferenced, loose object which has been
created or modified in the last
expireAgeMillis milliseconds
will not be pruned. |
void |
setPackConfig(PackConfig pconfig)
Set the PackConfig used when (re-)writing packfiles.
|
GC |
setProgressMonitor(ProgressMonitor pm)
Set the progress monitor used for garbage collection methods.
|
public GC(FileRepository repo)
null
as progress monitor will be used.repo
- the repo to work onpublic Collection<PackFile> gc() throws IOException, ParseException
FileRepository
. It will
PackFile
's which are newly createdIOException
ParseException
- If the configuration parameter "gc.pruneexpire" couldn't be
parsedpublic void prunePacked() throws IOException
IOException
public void prune(Set<ObjectId> objectsToKeep) throws IOException, ParseException
objectsToKeep
- a set of objects which should explicitly not be prunedIOException
ParseException
- If the configuration parameter "gc.pruneexpire" couldn't be
parsedpublic void packRefs() throws IOException
IOException
public Collection<PackFile> repack() throws IOException
IOException
- when during reading of refs, index, packfiles, objects,
reflog-entries or during writing to the packfiles
IOException
occurspublic GC.RepoStatistics getStatistics() throws IOException
IOException
public GC setProgressMonitor(ProgressMonitor pm)
pm
- public void setExpireAgeMillis(long expireAgeMillis)
expireAgeMillis
milliseconds
will not be pruned. Only older objects may be pruned. If set to 0 then
every object is a candidate for pruning.expireAgeMillis
- minimal age of objects to be pruned in milliseconds.public void setPackConfig(PackConfig pconfig)
pconfig
- the PackConfig
used when writing packspublic void setExpire(Date expire)
expire
will not be pruned.
Only older objects may be pruned. If set to null then every object is a
candidate for pruning.expire
- instant in time which defines object expiration
objects with modification time before this instant are expired
objects with modification time newer or equal to this instant
are not expiredCopyright © 2015. All rights reserved.