mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-01-30 23:13:09 +08:00
remove from snapshot
This commit is contained in:
parent
44dcfe29aa
commit
d73fbdef2e
@ -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> {
|
pub async fn create_index(&self, uuid: Uuid, primary_key: Option<String>) -> Result<IndexMeta> {
|
||||||
let (ret, receiver) = oneshot::channel();
|
let (ret, receiver) = oneshot::channel();
|
||||||
let msg = IndexMsg::CreateIndex {
|
let msg = IndexMsg::CreateIndex {
|
||||||
|
@ -67,36 +67,13 @@ impl IndexController {
|
|||||||
let index_size = options.max_mdb_size.get_bytes() as usize;
|
let index_size = options.max_mdb_size.get_bytes() as usize;
|
||||||
let update_store_size = options.max_udb_size.get_bytes() as usize;
|
let update_store_size = options.max_udb_size.get_bytes() as usize;
|
||||||
|
|
||||||
let uuid_resolver;
|
let uuid_resolver = uuid_resolver::UuidResolverHandle::new(&path)?;
|
||||||
let index_handle;
|
let index_handle = index_actor::IndexActorHandle::new(&path, index_size)?;
|
||||||
let update_handle;
|
let update_handle = update_actor::UpdateActorHandle::new(
|
||||||
|
index_handle.clone(),
|
||||||
match options.import_snapshot {
|
&path,
|
||||||
Some(ref snapshot_path) => {
|
update_store_size,
|
||||||
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,
|
|
||||||
)?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if options.schedule_snapshot {
|
if options.schedule_snapshot {
|
||||||
let snapshot_service = SnapshotService::new(
|
let snapshot_service = SnapshotService::new(
|
||||||
|
@ -306,41 +306,6 @@ where
|
|||||||
Ok(Self { sender })
|
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(
|
pub async fn update(
|
||||||
&self,
|
&self,
|
||||||
meta: UpdateMeta,
|
meta: UpdateMeta,
|
||||||
|
@ -143,17 +143,6 @@ impl UuidResolverHandle {
|
|||||||
Ok(Self { sender })
|
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> {
|
pub async fn resolve(&self, name: String) -> anyhow::Result<Uuid> {
|
||||||
let (ret, receiver) = oneshot::channel();
|
let (ret, receiver) = oneshot::channel();
|
||||||
let msg = UuidResolveMsg::Resolve { uid: name, ret };
|
let msg = UuidResolveMsg::Resolve { uid: name, ret };
|
||||||
@ -251,13 +240,6 @@ impl HeedUuidStore {
|
|||||||
let db = env.create_database(None)?;
|
let db = env.create_database(None)?;
|
||||||
Ok(Self { env, db })
|
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]
|
#[async_trait::async_trait]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user