diff options
| author | Stefan Boberg <[email protected]> | 2021-08-11 12:09:34 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-08-11 12:09:52 +0200 |
| commit | f84f5d9c1ca60c39cb27c806900d6a99727650d3 (patch) | |
| tree | ac7b7b8337456a57175b5750c13424464bfd5fbd | |
| parent | trivial: Updated comment (diff) | |
| download | zen-f84f5d9c1ca60c39cb27c806900d6a99727650d3.tar.xz zen-f84f5d9c1ca60c39cb27c806900d6a99727650d3.zip | |
Implemented Flush() operation for CID/CAS store interfaces
| -rw-r--r-- | zenserver/zenserver.cpp | 6 | ||||
| -rw-r--r-- | zenstore/CAS.cpp | 10 | ||||
| -rw-r--r-- | zenstore/cidstore.cpp | 7 | ||||
| -rw-r--r-- | zenstore/compactcas.cpp | 8 | ||||
| -rw-r--r-- | zenstore/compactcas.h | 1 | ||||
| -rw-r--r-- | zenstore/filecas.cpp | 11 | ||||
| -rw-r--r-- | zenstore/filecas.h | 1 | ||||
| -rw-r--r-- | zenstore/include/zenstore/CAS.h | 1 | ||||
| -rw-r--r-- | zenstore/include/zenstore/cidstore.h | 7 |
9 files changed, 49 insertions, 3 deletions
diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp index eb8df2b23..d2a15ae76 100644 --- a/zenserver/zenserver.cpp +++ b/zenserver/zenserver.cpp @@ -235,6 +235,12 @@ public: } } + void Flush() + { + m_CasStore->Flush(); + m_CidStore->Flush(); + } + private: bool m_TestMode = false; std::filesystem::path m_DataRoot; diff --git a/zenstore/CAS.cpp b/zenstore/CAS.cpp index 1f477cb17..36cf85549 100644 --- a/zenstore/CAS.cpp +++ b/zenstore/CAS.cpp @@ -40,6 +40,7 @@ public: virtual void Initialize(const CasStoreConfiguration& InConfig) override; virtual CasStore::InsertResult InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash) override; virtual IoBuffer FindChunk(const IoHash& ChunkHash) override; + virtual void Flush() override; private: void PickDefaultDirectory(); @@ -143,13 +144,20 @@ CasImpl::FindChunk(const IoHash& ChunkHash) return IoBuffer{}; } +void +CasImpl::Flush() +{ + m_SmallStrategy.Flush(); + m_TinyStrategy.Flush(); + m_LargeStrategy.Flush(); +} + ////////////////////////////////////////////////////////////////////////// CasStore* CreateCasStore() { return new CasImpl(); - // return new FileCasImpl(); } ////////////////////////////////////////////////////////////////////////// diff --git a/zenstore/cidstore.cpp b/zenstore/cidstore.cpp index e041574a4..a89a8ac22 100644 --- a/zenstore/cidstore.cpp +++ b/zenstore/cidstore.cpp @@ -57,6 +57,8 @@ struct CidStore::CidState spdlog::debug("CID index initialized: {} entries found", m_CidMap.size()); } + + void Flush() { m_LogFile.Flush(); } }; ////////////////////////////////////////////////////////////////////////// @@ -82,4 +84,9 @@ CidStore::FindChunkByCid(const IoHash& DecompressedId) return m_Impl->FindChunkByCid(DecompressedId); } +void CidStore::Flush() +{ + m_Impl->Flush(); +} + } // namespace zen diff --git a/zenstore/compactcas.cpp b/zenstore/compactcas.cpp index 416943b77..b658425e7 100644 --- a/zenstore/compactcas.cpp +++ b/zenstore/compactcas.cpp @@ -116,4 +116,12 @@ CasContainerStrategy::FindChunk(const IoHash& ChunkHash) return IoBuffer(); } +void +CasContainerStrategy::Flush() +{ + m_CasLog.Flush(); + m_SmallObjectIndex.Flush(); + m_SmallObjectFile.Flush(); +} + } // namespace zen diff --git a/zenstore/compactcas.h b/zenstore/compactcas.h index db115c85d..c65af0435 100644 --- a/zenstore/compactcas.h +++ b/zenstore/compactcas.h @@ -47,6 +47,7 @@ struct CasContainerStrategy CasStore::InsertResult InsertChunk(IoBuffer Chunk, const IoHash& chunkHash); IoBuffer FindChunk(const IoHash& chunkHash); void Initialize(const std::string_view ContainerBaseName, uint64_t Alignment, bool IsNewStore); + void Flush(); private: const CasStoreConfiguration& m_Config; diff --git a/zenstore/filecas.cpp b/zenstore/filecas.cpp index 2972fbca6..737d3e517 100644 --- a/zenstore/filecas.cpp +++ b/zenstore/filecas.cpp @@ -279,6 +279,17 @@ FileCasStrategy::FindChunk(const IoHash& ChunkHash) return Chunk; } +void +FileCasStrategy::Flush() +{ + // Since we don't keep files open after writing there's nothing specific + // to flush here. + // + // Depending on what semantics we want Flush() to provide, it could be + // argued that this should just flush the volume which we are using to + // store the CAS files on here? +} + /** * Straightforward file-per-chunk CAS store implementation */ diff --git a/zenstore/filecas.h b/zenstore/filecas.h index 21ad8ba7c..da89b927c 100644 --- a/zenstore/filecas.h +++ b/zenstore/filecas.h @@ -18,6 +18,7 @@ struct FileCasStrategy CasStore::InsertResult InsertChunk(const void* chunkData, size_t chunkSize, const IoHash& chunkHash); CasStore::InsertResult InsertChunk(IoBuffer Chunk, const IoHash& chunkHash); IoBuffer FindChunk(const IoHash& chunkHash); + void Flush(); private: const CasStoreConfiguration& m_Config; diff --git a/zenstore/include/zenstore/CAS.h b/zenstore/include/zenstore/CAS.h index b4c97a6fd..f01b562cb 100644 --- a/zenstore/include/zenstore/CAS.h +++ b/zenstore/include/zenstore/CAS.h @@ -52,6 +52,7 @@ public: virtual void Initialize(const CasStoreConfiguration& Config) = 0; virtual InsertResult InsertChunk(IoBuffer Data, const IoHash& ChunkHash) = 0; virtual IoBuffer FindChunk(const IoHash& ChunkHash) = 0; + virtual void Flush() = 0; protected: CasStoreConfiguration m_Config; diff --git a/zenstore/include/zenstore/cidstore.h b/zenstore/include/zenstore/cidstore.h index e365b198e..edc3f5582 100644 --- a/zenstore/include/zenstore/cidstore.h +++ b/zenstore/include/zenstore/cidstore.h @@ -17,8 +17,10 @@ class IoBuffer; /** Content Store * * Data in the content store is referenced by content identifiers (CIDs), rather than their - * literal hash. This is required to map uncompressed hashes to compressed hashes and may - * be used to deal with other indirections in the future. + * literal hash. This class maps uncompressed hashes to compressed hashes and may + * be used to deal with other kinds of indirections in the future. For example, if we want + * to support chunking then a CID may represent a list of chunks which could be concatenated + * to form the referenced chunk. * */ class CidStore @@ -29,6 +31,7 @@ public: void AddCompressedCid(const IoHash& DecompressedId, const IoHash& Compressed); IoBuffer FindChunkByCid(const IoHash& DecompressedId); + void Flush(); private: struct CidState; |