Package io.bdeploy.bhive.objects
Class ObjectManager
java.lang.Object
io.bdeploy.bhive.objects.ObjectManager
Provides higher level operations on the
ObjectDatabase.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceUsed for modifying operations on the DB. -
Constructor Summary
ConstructorsConstructorDescriptionObjectManager(ObjectDatabase db, ManifestDatabase mdb, ActivityReporter reporter, ExecutorService fileOps) Creates a newObjectManager. -
Method Summary
Modifier and TypeMethodDescriptionbooleancheckObject(ObjectId id, boolean remove) Checks whether a givenObjectIds backing file store is OK.<T> Tdb(ObjectManager.DbCallable<T> c) Perform an operation on the actual underlying object database.voidexportTree(ObjectId tree, Path location, ReferenceHandler handler) Exports a given tree (byObjectId) to the given location, which must not exist yet.getStreamForRelativePath(ObjectId tree, String... path) importTree(Path location, boolean skipEmpty) Import aPathrecursively into the underlyingObjectDatabase.Inserts an object into the database which can be used to reference aManifestin aTreeusingTree.EntryType.MANIFEST.insertTree(Tree tree) voidInvalidates all cached data.Create a traversable snapshot of the givenTreestate up to a given maximum depth.
-
Constructor Details
-
ObjectManager
public ObjectManager(ObjectDatabase db, ManifestDatabase mdb, ActivityReporter reporter, ExecutorService fileOps) Creates a newObjectManager. The manager itself has no state. It only provides operations on the underlyingObjectDatabase- Parameters:
db- the underlyingObjectDatabase.mdb- the underlyingManifestDatabase, only used for manifest reference lookup.reporter- used to report long running operationsfileOps- used to parallelize file operations.
-
-
Method Details
-
importTree
Import aPathrecursively into the underlyingObjectDatabase. -
exportTree
Exports a given tree (byObjectId) to the given location, which must not exist yet. -
scan
Create a traversable snapshot of the givenTreestate up to a given maximum depth.In case the root tree is damaged, it is wrapped in a dummy
TreeViewwith anullObjectId.- Parameters:
tree- the root tree to scanmaxDepth- maximum scan depth. A depth of 1 will include only direct children at the root level, and so on.
-
getStreamForRelativePath
- Parameters:
tree- the root tree to resolve frompath- the path in the tree to resolve- Returns:
- an
InputStreamto the file denoted by the path. - Throws:
IOException
-
insertManifestReference
Inserts an object into the database which can be used to reference aManifestin aTreeusingTree.EntryType.MANIFEST. -
insertTree
-
checkObject
Checks whether a givenObjectIds backing file store is OK. In case it is not, the broken file is removed from the store!- Parameters:
id- theObjectIdto checkremove- whether to remove broken objects- Returns:
- whether the stored object in the database is OK.
-
db
Perform an operation on the actual underlying object database. -
invalidateCaches
public void invalidateCaches()Invalidates all cached data.
-