NS: add interface to remove an entry by file id from a filesystem view

parent 8203f7cc
......@@ -122,6 +122,16 @@ public:
virtual std::shared_ptr<ICollectionIterator<IFileMD::id_t>>
getFileList(IFileMD::location_t location) = 0;
//----------------------------------------------------------------------------
//! Erase an entry from all filesystem view collections
//!
//! @param location where to remove
//! @param file id to remove
//!
//! @return
//----------------------------------------------------------------------------
virtual void eraseEntry(IFileMD::location_t location, IFileMD::id_t) = 0;
//----------------------------------------------------------------------------
//! Get an approximately random file residing within the given filesystem.
//!
......@@ -131,7 +141,7 @@ public:
//! @return bool indicating whether the operation was successful
//----------------------------------------------------------------------------
virtual bool getApproximatelyRandomFileInFs(IFileMD::location_t location,
IFileMD::id_t &retval) = 0;
IFileMD::id_t& retval) = 0;
//----------------------------------------------------------------------------
//! Get number of files on the given file system
......
......@@ -149,6 +149,25 @@ void FileSystemView::fileMDRead(IFileMD* obj)
}
}
//------------------------------------------------------------------------------
// Erase an entry from all filesystem view collections
//------------------------------------------------------------------------------
void
FileSystemView::eraseEntry(IFileMD::location_t location, IFileMD::id_t id)
{
if (location < pFiles.size()) {
pFiles[location].erase(id);
}
if (location < pUnlinkedFiles.size()) {
pUnlinkedFiles[location].erase(id);
}
pNoReplicas.erase(id);
return ;
}
//------------------------------------------------------------------------------
// Get iterator to list of files on a particular file system
//------------------------------------------------------------------------------
......@@ -166,9 +185,10 @@ std::shared_ptr<ICollectionIterator<IFileMD::id_t>>
//------------------------------------------------------------------------------
// Get an approximately random file residing within the given filesystem.
//------------------------------------------------------------------------------
bool FileSystemView::getApproximatelyRandomFileInFs(IFileMD::location_t location,
IFileMD::id_t &retval) {
bool FileSystemView::getApproximatelyRandomFileInFs(IFileMD::location_t
location,
IFileMD::id_t& retval)
{
if (pFiles.size() <= location) {
return false;
}
......
......@@ -71,6 +71,16 @@ public:
return true;
}
//----------------------------------------------------------------------------
//! Erase an entry from all filesystem view collections
//!
//! @param file id
//!
//! @return
//----------------------------------------------------------------------------
virtual void eraseEntry(IFileMD::location_t location, IFileMD::id_t);
//----------------------------------------------------------------------------
//! Get iterator to list of files on a particular file system
//!
......@@ -90,7 +100,7 @@ public:
//! @return bool indicating whether the operation was successful
//----------------------------------------------------------------------------
bool getApproximatelyRandomFileInFs(IFileMD::location_t location,
IFileMD::id_t &retval) override;
IFileMD::id_t& retval) override;
//----------------------------------------------------------------------------
//! Get number of files on the given file system
......@@ -154,7 +164,8 @@ public:
//! @return shard ptr to collection iterator
//----------------------------------------------------------------------------
std::shared_ptr<ICollectionIterator<IFileMD::id_t>>
getStreamingNoReplicasFileList() override {
getStreamingNoReplicasFileList() override
{
return getNoReplicasFileList();
}
......
......@@ -202,6 +202,15 @@ public:
//----------------------------------------------------------------------------
virtual bool fileMDCheck(IFileMD* file) override;
//----------------------------------------------------------------------------
//! Erase an entry from all filesystem view collections
//!
//! @param file id
//!
//! @return
//----------------------------------------------------------------------------
virtual void eraseEntry(IFileMD::location_t location, IFileMD::id_t);
//----------------------------------------------------------------------------
//! Get iterator to list of files on a particular file system
//!
......@@ -221,7 +230,7 @@ public:
//! @return bool indicating whether the operation was successful
//----------------------------------------------------------------------------
bool getApproximatelyRandomFileInFs(IFileMD::location_t location,
IFileMD::id_t &retval) override;
IFileMD::id_t& retval) override;
//----------------------------------------------------------------------------
//! Get number of files on the given file system
......@@ -386,7 +395,8 @@ private:
///! Regular filelists
std::map<IFileMD::location_t, std::unique_ptr<FileSystemHandler>> mFiles;
///! Unlinked filelists
std::map<IFileMD::location_t, std::unique_ptr<FileSystemHandler>> mUnlinkedFiles;
std::map<IFileMD::location_t, std::unique_ptr<FileSystemHandler>>
mUnlinkedFiles;
///! Mutex protecting access to the maps. Not the contents of the maps,
///! though.
std::mutex mMutex;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment