public class MongoDBVMaintenance extends java.lang.Object implements VMaintenance
Constructor and Description |
---|
MongoDBVMaintenance(MongoDBVDatabase db)
Constructs the maintenance object
|
Modifier and Type | Method and Description |
---|---|
long[] |
findDanglingCommits(long expiry,
java.util.concurrent.TimeUnit unit)
Finds commits which do not belong to a named branch.
|
long[] |
findUnreferencedDocuments(java.lang.String collection,
long expiry,
java.util.concurrent.TimeUnit unit)
Finds documents which do not belong to a commit.
|
long |
pruneDanglingCommits(long expiry,
java.util.concurrent.TimeUnit unit)
Deletes all dangling commits from the database.
|
long |
pruneUnreferencedDocuments(java.lang.String collection,
long expiry,
java.util.concurrent.TimeUnit unit)
Deletes all unreferenced documents from the database.
|
public MongoDBVMaintenance(MongoDBVDatabase db)
db
- the databasepublic long[] findDanglingCommits(long expiry, java.util.concurrent.TimeUnit unit)
VMaintenance
Finds commits which do not belong to a named branch. Only those commits are considered which are older than the given expiry time (i.e. a commit which has been added just a minute ago will not be considered if the expiry time is larger than one minute).
Attention: this method may return commits which are indeed dangling but which might still be needed by some other thread/process. Please do not delete such commits from the database if you're unsure whether they are still needed. A good strategy to avoid such situations is to use a long expiry time, so only commits which are very old will be considered.
findDanglingCommits
in interface VMaintenance
expiry
- the expiry time. Only those commits older than this
time will be considered.unit
- the time unit for the expiry argumentpublic long pruneDanglingCommits(long expiry, java.util.concurrent.TimeUnit unit)
VMaintenance
Deletes all dangling commits from the database. Only those commits are considered which are older than the given expiry time (i.e. a commit which has been added just a minute ago will not be considered if the expiry time is larger than one minute).
Attention: this is a destructive method. Commits may seem dangling but they might still be needed by some other thread/process. Please make sure you're absolutely sure what you are doing before calling this method. Accidentally deleting non-dangling commits may leave your database in a broken state! A good strategy to avoid this is to choose an expiry time that is long enough for all your transactions.
pruneDanglingCommits
in interface VMaintenance
expiry
- the expiry time. Only those commits older than this
time will be considered.unit
- the time unit for the expiry argumentpublic long[] findUnreferencedDocuments(java.lang.String collection, long expiry, java.util.concurrent.TimeUnit unit)
VMaintenance
Finds documents which do not belong to a commit. Only those documents are considered which are older than the given expiry time (i.e. a document that has been added just a minute ago will not be considered if the expiry time is larger than one minute).
Attention: this method may return documents that seem to be unreferenced but are still be needed by some other thread/process that is just about to create a new commit. Please do not delete such documents from the database if you're unsure whether they are still needed. A good strategy to avoid such situations is to use a long expiry time, so only documents which are very old will be considered.
findUnreferencedDocuments
in interface VMaintenance
collection
- the name of the collection to searchexpiry
- the expiry time. Only those documents older than this
time will be considered.unit
- the time unit for the expiry argumentpublic long pruneUnreferencedDocuments(java.lang.String collection, long expiry, java.util.concurrent.TimeUnit unit)
VMaintenance
Deletes all unreferenced documents from the database. Only those documents are considered which are older than the given expiry time (i.e. a document that has been added just a minute ago will not be considered if the expiry time is larger than one minute).
Attention: this is a destructive method. Documents may seem unreferenced but they might still be needed by some other thread/process which is just about to create a new commit. Please make sure you're absolutely sure what you are doing before calling this method. Accidentally deleting referenced documents may leave your database in a broken state! A good strategy to avoid this is to choose an expiry time that is long enough for all your transactions.
pruneUnreferencedDocuments
in interface VMaintenance
collection
- the name of the collection to searchexpiry
- the expiry time. Only those documents older than this
time will be considered.unit
- the time unit for the expiry argument