remove from snapshot

This commit is contained in:
mpostma 2021-03-22 16:58:19 +01:00
parent 44dcfe29aa
commit d73fbdef2e
No known key found for this signature in database
GPG Key ID: CBC8A7C1D7A28C3A
4 changed files with 7 additions and 99 deletions

View File

@ -462,22 +462,6 @@ impl IndexActorHandle {
})
}
pub fn from_snapshot(
path: impl AsRef<Path>,
index_size: usize,
snapshot_path: impl AsRef<Path>,
) -> anyhow::Result<Self> {
let snapshot_path = snapshot_path.as_ref().join("indexes");
let indexes_path = path.as_ref().join("indexes");
for entry in snapshot_path.read_dir()? {
let entry = entry?;
let src = snapshot_path.join(entry.file_name());
let dest = indexes_path.join(entry.file_name());
compression::from_tar_gz(src, dest)?;
}
Self::new(path, index_size)
}
pub async fn create_index(&self, uuid: Uuid, primary_key: Option<String>) -> Result<IndexMeta> {
let (ret, receiver) = oneshot::channel();
let msg = IndexMsg::CreateIndex {

View File

@ -67,36 +67,13 @@ impl IndexController {
let index_size = options.max_mdb_size.get_bytes() as usize;
let update_store_size = options.max_udb_size.get_bytes() as usize;
let uuid_resolver;
let index_handle;
let update_handle;
match options.import_snapshot {
Some(ref snapshot_path) => {
uuid_resolver =
uuid_resolver::UuidResolverHandle::from_snapshot(&path, &snapshot_path)?;
index_handle = index_actor::IndexActorHandle::from_snapshot(
&path,
index_size,
&snapshot_path,
)?;
update_handle = update_actor::UpdateActorHandle::from_snapshot(
index_handle.clone(),
&path,
update_store_size,
&snapshot_path,
)?;
}
None => {
uuid_resolver = uuid_resolver::UuidResolverHandle::new(&path)?;
index_handle = index_actor::IndexActorHandle::new(&path, index_size)?;
update_handle = update_actor::UpdateActorHandle::new(
index_handle.clone(),
&path,
update_store_size,
)?;
}
}
let uuid_resolver = uuid_resolver::UuidResolverHandle::new(&path)?;
let index_handle = index_actor::IndexActorHandle::new(&path, index_size)?;
let update_handle = update_actor::UpdateActorHandle::new(
index_handle.clone(),
&path,
update_store_size,
)?;
if options.schedule_snapshot {
let snapshot_service = SnapshotService::new(

View File

@ -306,41 +306,6 @@ where
Ok(Self { sender })
}
pub fn from_snapshot(
index_handle: IndexActorHandle,
path: impl AsRef<Path>,
update_store_size: usize,
snapshot: impl AsRef<Path>,
) -> anyhow::Result<Self> {
let src = snapshot.as_ref().join("updates");
let dst = path.as_ref().join("updates");
fs::create_dir_all(&dst)?;
// restore the update stores
for entry in src.read_dir()? {
let entry = entry?;
// filter out the update_files directory.
if entry.file_type()?.is_file() {
let src = src.join(entry.file_name());
let dest = dst.join(entry.file_name());
compression::from_tar_gz(src, dest)?;
}
}
// restore the update files
let src = src.join("update_files");
let dst = dst.join("update_files");
fs::create_dir_all(&dst)?;
for entry in src.read_dir()? {
let entry = entry?;
let src = src.join(entry.file_name());
let dst = dst.join(entry.file_name());
fs::copy(src, dst)?;
}
Self::new(index_handle, path, update_store_size)
}
pub async fn update(
&self,
meta: UpdateMeta,

View File

@ -143,17 +143,6 @@ impl UuidResolverHandle {
Ok(Self { sender })
}
pub fn from_snapshot(
db_path: impl AsRef<Path>,
snapshot_path: impl AsRef<Path>
) -> anyhow::Result<Self> {
let (sender, reveiver) = mpsc::channel(100);
let store = HeedUuidStore::from_snapshot(snapshot_path, db_path)?;
let actor = UuidResolverActor::new(reveiver, store);
tokio::spawn(actor.run());
Ok(Self { sender })
}
pub async fn resolve(&self, name: String) -> anyhow::Result<Uuid> {
let (ret, receiver) = oneshot::channel();
let msg = UuidResolveMsg::Resolve { uid: name, ret };
@ -251,13 +240,6 @@ impl HeedUuidStore {
let db = env.create_database(None)?;
Ok(Self { env, db })
}
fn from_snapshot(snapshot: impl AsRef<Path>, path: impl AsRef<Path>) -> anyhow::Result<Self> {
let src = snapshot.as_ref().join("uuids");
let dst = path.as_ref().join("uuids");
compression::from_tar_gz(src, dst)?;
Self::new(path)
}
}
#[async_trait::async_trait]