From d73fbdef2e2de107169978a5d15235a210d6ed12 Mon Sep 17 00:00:00 2001 From: mpostma Date: Mon, 22 Mar 2021 16:58:19 +0100 Subject: [PATCH] remove from snapshot --- .../src/index_controller/index_actor.rs | 16 -------- meilisearch-http/src/index_controller/mod.rs | 37 ++++--------------- .../src/index_controller/update_actor.rs | 35 ------------------ .../src/index_controller/uuid_resolver.rs | 18 --------- 4 files changed, 7 insertions(+), 99 deletions(-) diff --git a/meilisearch-http/src/index_controller/index_actor.rs b/meilisearch-http/src/index_controller/index_actor.rs index bfa3097a7..6474bdde4 100644 --- a/meilisearch-http/src/index_controller/index_actor.rs +++ b/meilisearch-http/src/index_controller/index_actor.rs @@ -462,22 +462,6 @@ impl IndexActorHandle { }) } - pub fn from_snapshot( - path: impl AsRef, - index_size: usize, - snapshot_path: impl AsRef, - ) -> anyhow::Result { - 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) -> Result { let (ret, receiver) = oneshot::channel(); let msg = IndexMsg::CreateIndex { diff --git a/meilisearch-http/src/index_controller/mod.rs b/meilisearch-http/src/index_controller/mod.rs index d2d11d44b..1f4e857d6 100644 --- a/meilisearch-http/src/index_controller/mod.rs +++ b/meilisearch-http/src/index_controller/mod.rs @@ -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( diff --git a/meilisearch-http/src/index_controller/update_actor.rs b/meilisearch-http/src/index_controller/update_actor.rs index 9b2a90370..5cea8e64d 100644 --- a/meilisearch-http/src/index_controller/update_actor.rs +++ b/meilisearch-http/src/index_controller/update_actor.rs @@ -306,41 +306,6 @@ where Ok(Self { sender }) } - pub fn from_snapshot( - index_handle: IndexActorHandle, - path: impl AsRef, - update_store_size: usize, - snapshot: impl AsRef, - ) -> anyhow::Result { - 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, diff --git a/meilisearch-http/src/index_controller/uuid_resolver.rs b/meilisearch-http/src/index_controller/uuid_resolver.rs index 5bdbe667f..7cd41833c 100644 --- a/meilisearch-http/src/index_controller/uuid_resolver.rs +++ b/meilisearch-http/src/index_controller/uuid_resolver.rs @@ -143,17 +143,6 @@ impl UuidResolverHandle { Ok(Self { sender }) } - pub fn from_snapshot( - db_path: impl AsRef, - snapshot_path: impl AsRef - ) -> anyhow::Result { - 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 { 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: impl AsRef) -> anyhow::Result { - 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]