Skip to content

Commit

Permalink
integrate HeadBagRestorer, updated HeadBagCacheManager into HybridPDR…
Browse files Browse the repository at this point in the history
…DatasetRestorer
  • Loading branch information
RayPlante committed Jan 8, 2024
1 parent bad0e22 commit d7ec362
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@ public void restoreObject(String id, Reservation resv, String name, JSONObject m
}
}

@Override
protected InputStream openBag(String bagfilename) throws FileNotFoundException, StorageVolumeException {
try {
return ltstore.openFile(bagfilename);
} catch (FileNotFoundException ex) {
return restrictedLtstore.openFile(bagfilename);
}
}

/**
* consult the given head bag and return the name of the bag that contains the file indicated by
* the given filepath.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ public class HybridPDRDatasetRestorerTest {
ConfigurableCache cache = null;

// Helper method to create HeadBagCacheManager. Adjust based on your actual implementation.
HeadBagCacheManager createHBCache(BagStorage ltstore) throws IOException, CacheManagementException {
HeadBagCacheManager createHBCache(BagStorage reststore, BagStorage pubstore)
throws IOException, CacheManagementException
{
File tf = tempf.newFolder("headbags");
File dbf = new File(tf, "inventory.sqlite");
HeadBagDB.initializeSQLiteDB(dbf.getAbsolutePath());
Expand All @@ -66,7 +68,7 @@ HeadBagCacheManager createHBCache(BagStorage ltstore) throws IOException, CacheM
cvd = new File(tf, "cv1"); cvd.mkdir();
cache.addCacheVolume(new FilesystemCacheVolume(cvd, "cv1"), 2000000, null, true);

return new HeadBagCacheManager(cache, sidb, ltstore, new FileCopyRestorer(ltstore), "88434");
return new HeadBagCacheManager(cache, sidb, new HeadBagRestorer(reststore, pubstore), "88434");
}

ConfigurableCache createDataCache() throws CacheManagementException, IOException {
Expand Down Expand Up @@ -102,7 +104,7 @@ public void setUp() throws IOException, CacheManagementException {
publicLtstore = new FilesystemLongTermStorage(ltsdir);
restrictedLtstore = new FilesystemLongTermStorage(ltsdir + "/restricted");

hbcm = createHBCache(restrictedLtstore);
hbcm = createHBCache(restrictedLtstore, publicLtstore);
cache = createDataCache();
rstr = new HybridPDRDatasetRestorer(publicLtstore, restrictedLtstore, hbcm, 500);

Expand Down

0 comments on commit d7ec362

Please sign in to comment.