Class DfsGarbageCollector
- java.lang.Object
-
- org.eclipse.jgit.internal.storage.dfs.DfsGarbageCollector
-
public class DfsGarbageCollector extends java.lang.Object
Repack and garbage collect a repository.
-
-
Constructor Summary
Constructors Constructor Description DfsGarbageCollector(DfsRepository repository)
Initialize a garbage collector.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getCoalesceGarbageLimit()
java.util.List<DfsPackDescription>
getNewPacks()
java.util.List<PackWriter.Statistics>
getNewPackStatistics()
PackConfig
getPackConfig()
java.util.List<DfsPackDescription>
getSourcePacks()
boolean
pack(ProgressMonitor pm)
Create a single new pack file containing all of the live objects.DfsGarbageCollector
setCoalesceGarbageLimit(long limit)
Set the byte size limit for garbage packs to be repacked.DfsGarbageCollector
setPackConfig(PackConfig newConfig)
-
-
-
Constructor Detail
-
DfsGarbageCollector
public DfsGarbageCollector(DfsRepository repository)
Initialize a garbage collector.- Parameters:
repository
- repository objects to be packed will be read from.
-
-
Method Detail
-
getPackConfig
public PackConfig getPackConfig()
- Returns:
- configuration used to generate the new pack file.
-
setPackConfig
public DfsGarbageCollector setPackConfig(PackConfig newConfig)
- Parameters:
newConfig
- the new configuration to use when creating the pack file.- Returns:
this
-
getCoalesceGarbageLimit
public long getCoalesceGarbageLimit()
- Returns:
- garbage packs smaller than this size will be repacked.
-
setCoalesceGarbageLimit
public DfsGarbageCollector setCoalesceGarbageLimit(long limit)
Set the byte size limit for garbage packs to be repacked.Any UNREACHABLE_GARBAGE pack smaller than this limit will be repacked at the end of the run. This allows the garbage collector to coalesce unreachable objects into a single file.
If an UNREACHABLE_GARBAGE pack is already larger than this limit it will be left alone by the garbage collector. This avoids unnecessary disk IO reading and copying the objects.
If limit is set to 0 the UNREACHABLE_GARBAGE coalesce is disabled.
If limit is set toLong.MAX_VALUE
, everything is coalesced.Keeping unreachable garbage prevents race conditions with repository changes that may suddenly need an object whose only copy was stored in the UNREACHABLE_GARBAGE pack.
- Parameters:
limit
- size in bytes.- Returns:
this
-
pack
public boolean pack(ProgressMonitor pm) throws java.io.IOException
Create a single new pack file containing all of the live objects.This method safely decides which packs can be expired after the new pack is created by validating the references have not been modified in an incompatible way.
- Parameters:
pm
- progress monitor to receive updates on as packing may take a while, depending on the size of the repository.- Returns:
- true if the repack was successful without race conditions. False if a race condition was detected and the repack should be run again later.
- Throws:
java.io.IOException
- a new pack cannot be created.
-
getSourcePacks
public java.util.List<DfsPackDescription> getSourcePacks()
- Returns:
- all of the source packs that fed into this compaction.
-
getNewPacks
public java.util.List<DfsPackDescription> getNewPacks()
- Returns:
- new packs created by this compaction.
-
getNewPackStatistics
public java.util.List<PackWriter.Statistics> getNewPackStatistics()
- Returns:
- statistics corresponding to the
getNewPacks()
.
-
-