mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 10:37:41 +08:00
WIT: it compiles but the processing of tasks and loading of snapshots is still not implemented
This commit is contained in:
parent
03b510945b
commit
366144146b
@ -370,7 +370,7 @@ impl IndexScheduler {
|
|||||||
// The lowest in the list is the leader. And if we're not the leader
|
// The lowest in the list is the leader. And if we're not the leader
|
||||||
// we watch the node right before us to be notified if he dies.
|
// we watch the node right before us to be notified if he dies.
|
||||||
// See https://zookeeper.apache.org/doc/current/recipes.html#sc_leaderElection
|
// See https://zookeeper.apache.org/doc/current/recipes.html#sc_leaderElection
|
||||||
let clusterized = match self.zookeeper {
|
let clusterized = match self.zookeeper.clone() {
|
||||||
Some(zk) => {
|
Some(zk) => {
|
||||||
// First, load the already existing tasks in the cluster, or, if we're the first one to join the cluster, create the task directory.
|
// First, load the already existing tasks in the cluster, or, if we're the first one to join the cluster, create the task directory.
|
||||||
let tasks_watcher = match zk.create(
|
let tasks_watcher = match zk.create(
|
||||||
@ -459,7 +459,7 @@ impl IndexScheduler {
|
|||||||
) {
|
) {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(ZkError::NodeExists) => (),
|
Err(ZkError::NodeExists) => (),
|
||||||
Err(e) => return Err(e.into()),
|
Err(e) => panic!("{e}"),
|
||||||
};
|
};
|
||||||
|
|
||||||
let (_, id) = zk
|
let (_, id) = zk
|
||||||
@ -475,13 +475,13 @@ impl IndexScheduler {
|
|||||||
let string_id = id.to_string();
|
let string_id = id.to_string();
|
||||||
|
|
||||||
// there is at least us in the childrens of election
|
// there is at least us in the childrens of election
|
||||||
if childrens[0].ends_with(id.to_string()) {
|
if childrens[0].ends_with(&string_id) {
|
||||||
log::warn!("I'm the leader");
|
log::warn!("I'm the leader");
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
let should_watch = childrens
|
let should_watch = childrens
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.rfind(|path| path[path.len() - id.len()..] < id)
|
.rfind(|path| &path[path.len() - string_id.len()..] < string_id.as_str())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
log::warn!("I'm a follower When `{should_watch}` die I should check if I'm the new leader");
|
log::warn!("I'm a follower When `{should_watch}` die I should check if I'm the new leader");
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ use meilisearch_types::{compression, milli, VERSION_FILE_NAME};
|
|||||||
pub use option::Opt;
|
pub use option::Opt;
|
||||||
use option::ScheduleSnapshot;
|
use option::ScheduleSnapshot;
|
||||||
use strois::Bucket;
|
use strois::Bucket;
|
||||||
use zookeeper::ZooKeeper;
|
use zookeeper_client_sync::Zookeeper;
|
||||||
|
|
||||||
use crate::error::MeilisearchHttpError;
|
use crate::error::MeilisearchHttpError;
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ enum OnFailure {
|
|||||||
|
|
||||||
pub async fn setup_meilisearch(
|
pub async fn setup_meilisearch(
|
||||||
opt: &Opt,
|
opt: &Opt,
|
||||||
zookeeper: Option<Arc<ZooKeeper>>,
|
zookeeper: Option<Arc<Zookeeper>>,
|
||||||
) -> anyhow::Result<(Arc<IndexScheduler>, Arc<AuthController>)> {
|
) -> anyhow::Result<(Arc<IndexScheduler>, Arc<AuthController>)> {
|
||||||
let empty_db = is_empty_db(&opt.db_path);
|
let empty_db = is_empty_db(&opt.db_path);
|
||||||
let (index_scheduler, auth_controller) = if let Some(ref snapshot_path) = opt.import_snapshot {
|
let (index_scheduler, auth_controller) = if let Some(ref snapshot_path) = opt.import_snapshot {
|
||||||
@ -219,7 +219,7 @@ pub async fn setup_meilisearch(
|
|||||||
fn open_or_create_database_unchecked(
|
fn open_or_create_database_unchecked(
|
||||||
opt: &Opt,
|
opt: &Opt,
|
||||||
on_failure: OnFailure,
|
on_failure: OnFailure,
|
||||||
zookeeper: Option<Arc<ZooKeeper>>,
|
zookeeper: Option<Arc<Zookeeper>>,
|
||||||
) -> anyhow::Result<(IndexScheduler, AuthController)> {
|
) -> anyhow::Result<(IndexScheduler, AuthController)> {
|
||||||
// we don't want to create anything in the data.ms yet, thus we
|
// we don't want to create anything in the data.ms yet, thus we
|
||||||
// wrap our two builders in a closure that'll be executed later.
|
// wrap our two builders in a closure that'll be executed later.
|
||||||
@ -278,7 +278,7 @@ fn open_or_create_database_unchecked(
|
|||||||
fn open_or_create_database(
|
fn open_or_create_database(
|
||||||
opt: &Opt,
|
opt: &Opt,
|
||||||
empty_db: bool,
|
empty_db: bool,
|
||||||
zookeeper: Option<Arc<ZooKeeper>>,
|
zookeeper: Option<Arc<Zookeeper>>,
|
||||||
) -> anyhow::Result<(IndexScheduler, AuthController)> {
|
) -> anyhow::Result<(IndexScheduler, AuthController)> {
|
||||||
if !empty_db {
|
if !empty_db {
|
||||||
check_version_file(&opt.db_path)?;
|
check_version_file(&opt.db_path)?;
|
||||||
|
@ -2,7 +2,6 @@ use std::env;
|
|||||||
use std::io::{stderr, Write};
|
use std::io::{stderr, Write};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
use actix_web::http::KeepAlive;
|
use actix_web::http::KeepAlive;
|
||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
@ -13,7 +12,7 @@ use meilisearch::analytics::Analytics;
|
|||||||
use meilisearch::{analytics, create_app, prototype_name, setup_meilisearch, Opt};
|
use meilisearch::{analytics, create_app, prototype_name, setup_meilisearch, Opt};
|
||||||
use meilisearch_auth::{generate_master_key, AuthController, MASTER_KEY_MIN_SIZE};
|
use meilisearch_auth::{generate_master_key, AuthController, MASTER_KEY_MIN_SIZE};
|
||||||
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
|
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
|
||||||
use zookeeper::ZooKeeper;
|
use zookeeper_client_sync::Zookeeper;
|
||||||
|
|
||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
|
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
|
||||||
@ -65,9 +64,10 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
let timeout = Duration::from_millis(2500);
|
let zookeeper = match opt.zk_url {
|
||||||
let zookeeper =
|
Some(ref url) => Some(Arc::new(Zookeeper::connect(url).await.unwrap())),
|
||||||
opt.zk_url.as_ref().map(|url| Arc::new(ZooKeeper::connect(url, timeout, drop).unwrap()));
|
None => None,
|
||||||
|
};
|
||||||
let (index_scheduler, auth_controller) = setup_meilisearch(&opt, zookeeper).await?;
|
let (index_scheduler, auth_controller) = setup_meilisearch(&opt, zookeeper).await?;
|
||||||
|
|
||||||
#[cfg(all(not(debug_assertions), feature = "analytics"))]
|
#[cfg(all(not(debug_assertions), feature = "analytics"))]
|
||||||
|
Loading…
Reference in New Issue
Block a user