public class GC
extends java.lang.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 |
---|---|
java.util.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(java.util.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.
|
java.util.Collection<PackFile> |
repack()
Packs all objects which reachable from any of the heads into one pack
file.
|
void |
setExpire(java.util.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. |
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 java.util.Collection<PackFile> gc() throws java.io.IOException, java.text.ParseException
FileRepository
. It will
PackFile
's which are newly createdjava.io.IOException
java.text.ParseException
- If the configuration parameter "gc.pruneexpire" couldn't be
parsedpublic void prunePacked() throws java.io.IOException
java.io.IOException
public void prune(java.util.Set<ObjectId> objectsToKeep) throws java.io.IOException, java.text.ParseException
objectsToKeep
- a set of objects which should explicitly not be prunedjava.io.IOException
java.text.ParseException
- If the configuration parameter "gc.pruneexpire" couldn't be
parsedpublic void packRefs() throws java.io.IOException
java.io.IOException
public java.util.Collection<PackFile> repack() throws java.io.IOException
java.io.IOException
- when during reading of refs, index, packfiles, objects,
reflog-entries or during writing to the packfiles
IOException
occurspublic GC.RepoStatistics getStatistics() throws java.io.IOException
java.io.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 setExpire(java.util.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 © 2013. All Rights Reserved.