diff --git a/scripts/install/install_python_and_ansible.sh b/scripts/install/install_python_and_ansible.sh index cdad7c5..757c842 100644 --- a/scripts/install/install_python_and_ansible.sh +++ b/scripts/install/install_python_and_ansible.sh @@ -54,9 +54,11 @@ fi # 调用函数,将要检查的命令和对应的包名称传递给函数 install_command "python3" "python3" install_command "pip3" "python3-pip" +install_command "unrar" "unrar" # 示例:调用函数检查并安装 'requests' 包 check_and_install_python_package "requests" check_and_install_python_package "ansible" #==4.9.0 check_and_install_python_package "wordlist" check_and_install_python_package "jsondiff" +check_and_install_python_package "numpy" diff --git a/src/general/m_fs/mod.rs b/src/general/m_fs/mod.rs index 93893c8..47c277f 100644 --- a/src/general/m_fs/mod.rs +++ b/src/general/m_fs/mod.rs @@ -11,14 +11,11 @@ use std::{ use ws_derive::LogicalModule; use crate::{ - logical_module_view_impl, result::{ErrCvt, WSResult}, - sys::{LogicalModule, LogicalModuleNewArgs, LogicalModulesRef}, + sys::{LogicalModule, LogicalModuleNewArgs}, util::JoinHandleWrapper, }; -logical_module_view_impl!(FsView); -logical_module_view_impl!(FsView, fs, Fs); #[derive(LogicalModule)] pub struct Fs { fd_files: SkipMap>>, diff --git a/src/general/network/m_p2p.rs b/src/general/network/m_p2p.rs index a06893d..312d1e9 100644 --- a/src/general/network/m_p2p.rs +++ b/src/general/network/m_p2p.rs @@ -2,10 +2,7 @@ use std::{ collections::HashMap, marker::PhantomData, net::SocketAddr, - sync::{ - atomic::{AtomicU32, Ordering}, - Arc, - }, + sync::atomic::{AtomicU32, Ordering}, time::Duration, }; @@ -152,7 +149,6 @@ pub struct P2PModule { (TaskId, NodeID), Mutex>>>, >, - rpc_holder: RwLock>>>, pub p2p_kernel: P2PQuicNode, // pub state_trans_tx: tokio::sync::broadcast::Sender, pub nodes_config: NodesConfig, @@ -180,7 +176,6 @@ impl LogicalModule for P2PModule { p2p_kernel: P2PQuicNode::new(args.clone()), dispatch_map: HashMap::new().into(), waiting_tasks: Default::default(), - rpc_holder: HashMap::new().into(), nodes_config, next_task_id: AtomicU32::new(0), view: P2PView::new(args.logical_modules_ref.clone()), @@ -499,19 +494,3 @@ impl P2PModule { ) } } - -// #[async_trait] -// impl P2P for P2PModule { -// async fn send_for_response(&self, nodeid: NodeID, req_data: Vec) -> WSResult> { -// // let (tx, rx) = tokio::sync::oneshot::channel(); -// // self.p2p_kernel.send(nodeid, req_data, tx).await?; -// // let res = rx.await?; - -// Ok(vec![]) -// } - -// async fn send(&self, nodeid: NodeID, msg_id:u64,req_data: Vec) -> WSResult<()> { -// self.p2p_kernel.send(nodeid, req_data).await?; -// Ok(()) -// } -// } diff --git a/src/main.rs b/src/main.rs index 161796b..a8d683d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,8 +4,10 @@ unused_imports, unused_variables, unused_mut, + unused_attributes, + dead_code, clippy::unnecessary_mut_passed, - unused_results + unused_results, )] use clap::Parser; diff --git a/src/master/m_http_handler.rs b/src/master/m_http_handler.rs index 4dff46d..ea7aad4 100644 --- a/src/master/m_http_handler.rs +++ b/src/master/m_http_handler.rs @@ -23,7 +23,6 @@ use super::{m_master::Master, m_metric_observor::MetricObservor}; logical_module_view_impl!(MasterHttpHandlerView); logical_module_view_impl!(MasterHttpHandlerView, p2p, P2PModule); -logical_module_view_impl!(MasterHttpHandlerView, http_handler, Box); logical_module_view_impl!(MasterHttpHandlerView, master, Option); logical_module_view_impl!( MasterHttpHandlerView, diff --git a/src/master/m_master.rs b/src/master/m_master.rs index 7cc0bd1..90e3ed7 100644 --- a/src/master/m_master.rs +++ b/src/master/m_master.rs @@ -17,8 +17,6 @@ use crate::{ util::JoinHandleWrapper, }; -use super::m_master_kv::MasterKv; - trait NodeWeighteFetcher: Send + Sync + 'static { // NOTE: get weight return node weight // larger is better @@ -29,12 +27,6 @@ struct StrawNodeSelector { weight_fetcher: Box, } -impl StrawNodeSelector { - fn new(weight_fetcher: Box) -> Self { - Self { weight_fetcher } - } -} - // NOTE: Straw2 algorithm impl NodeSelector for StrawNodeSelector { fn select_node(&self, all_node_cnt: usize, fn_name: &str) -> NodeID { @@ -78,12 +70,9 @@ impl NodeSelector for HashNodeSelector { logical_module_view_impl!(MasterView); logical_module_view_impl!(MasterView, p2p, P2PModule); logical_module_view_impl!(MasterView, master, Option); -logical_module_view_impl!(MasterView, master_kv, Option); #[derive(LogicalModule)] pub struct Master { - // each_fn_caching: HashMap>, - node_selector: Box, pub rpc_caller_distribute_task: RPCCaller, view: MasterView, } @@ -96,7 +85,6 @@ impl LogicalModule for Master { { Self { view: MasterView::new(args.logical_modules_ref.clone()), - node_selector: Box::new(HashNodeSelector), rpc_caller_distribute_task: RPCCaller::default(), } } diff --git a/src/master/m_master_kv.rs b/src/master/m_master_kv.rs index 913c7d9..d95eec3 100644 --- a/src/master/m_master_kv.rs +++ b/src/master/m_master_kv.rs @@ -41,7 +41,6 @@ logical_module_view_impl!(MasterKvView, kv_store_engine, KvStoreEngine); #[derive(LogicalModule)] pub struct MasterKv { - kv_map: RwLock, Vec>>, lock_notifiers: RwLock, (NodeID, u32, Arc)>>, rpc_handler: RPCHandler, view: MasterKvView, @@ -57,7 +56,6 @@ impl LogicalModule for MasterKv { Self: Sized, { Self { - kv_map: RwLock::new(HashMap::new()), lock_notifiers: RwLock::new(HashMap::new()), rpc_handler: RPCHandler::default(), view: MasterKvView::new(args.logical_modules_ref.clone()), diff --git a/src/sys.rs b/src/sys.rs index b357dd1..3a62d9b 100644 --- a/src/sys.rs +++ b/src/sys.rs @@ -132,7 +132,6 @@ macro_rules! logical_modules { ($($modules:ident,$ts:ty),+)=>{ pub struct LogicalModules { - new_cnt:usize, start_cnt:usize, $(pub $modules: $ts),+ } @@ -381,7 +380,6 @@ impl LogicalModules { kv_user_client: None, instance_manager: None, executor: None, - new_cnt: 0, start_cnt: 0, }; diff --git a/src/worker/m_executor.rs b/src/worker/m_executor.rs index 01c8564..6d4f289 100644 --- a/src/worker/m_executor.rs +++ b/src/worker/m_executor.rs @@ -1,7 +1,7 @@ use core::panic; use std::{mem::ManuallyDrop, sync::atomic::AtomicU32}; -use super::{m_instance_manager::InstanceManager, m_kv_user_client::KvUserClient}; +use super::m_instance_manager::InstanceManager; use crate::{ general::{ m_appmeta_manager::{AppMetaManager, FnArg}, @@ -38,7 +38,6 @@ logical_module_view_impl!(ExecutorView, p2p, P2PModule); logical_module_view_impl!(ExecutorView, appmeta_manager, AppMetaManager); logical_module_view_impl!(ExecutorView, instance_manager, Option); logical_module_view_impl!(ExecutorView, executor, Option); -logical_module_view_impl!(ExecutorView, kv_user_client, Option); #[derive(LogicalModule)] pub struct Executor { diff --git a/src/worker/m_http_handler.rs b/src/worker/m_http_handler.rs index 134657f..3d4e053 100644 --- a/src/worker/m_http_handler.rs +++ b/src/worker/m_http_handler.rs @@ -1,8 +1,5 @@ use crate::{ - general::network::{ - http_handler::{start_http_handler, HttpHandler, LocalReqIdAllocator}, - m_p2p::P2PModule, - }, + general::network::http_handler::{start_http_handler, HttpHandler, LocalReqIdAllocator}, logical_module_view_impl, result::WSResult, sys::{LogicalModule, LogicalModuleNewArgs, LogicalModulesRef}, @@ -45,8 +42,6 @@ impl LogicalModule for WorkerHttpHandler { } logical_module_view_impl!(WorkerHttpHandlerView); -logical_module_view_impl!(WorkerHttpHandlerView, p2p, P2PModule); -logical_module_view_impl!(WorkerHttpHandlerView, http_handler, Box); logical_module_view_impl!(WorkerHttpHandlerView, executor, Option); #[async_trait] diff --git a/src/worker/m_instance_manager.rs b/src/worker/m_instance_manager.rs index e42a729..f6e8622 100644 --- a/src/worker/m_instance_manager.rs +++ b/src/worker/m_instance_manager.rs @@ -1,9 +1,7 @@ use super::{m_executor::FunctionCtx, wasm::WasmInstance}; use crate::{ - general::network::m_p2p::P2PModule, - logical_module_view_impl, result::WSResult, - sys::{LogicalModule, LogicalModuleNewArgs, LogicalModulesRef}, + sys::{LogicalModule, LogicalModuleNewArgs}, util::JoinHandleWrapper, worker::wasm_host_funcs, // worker::host_funcs, }; @@ -175,14 +173,6 @@ impl EachAppCache { } } -logical_module_view_impl!(InstanceManagerView); -logical_module_view_impl!(InstanceManagerView, p2p, P2PModule); -logical_module_view_impl!( - InstanceManagerView, - instance_manager, - Option -); - #[derive(LogicalModule)] pub struct InstanceManager { // cache: Mutex>, @@ -191,8 +181,6 @@ pub struct InstanceManager { /// instance addr 2 running function pub instance_running_function: parking_lot::RwLock>, pub next_instance_id: AtomicU64, - pub view: InstanceManagerView, - // exe_view: ExecutorView, } #[async_trait] @@ -202,13 +190,10 @@ impl LogicalModule for InstanceManager { Self: Sized, { Self { - // cache: Mutex::new(LRUCache::new(10)), using_map: SkipMap::new(), file_dir: args.nodes_config.file_dir.clone(), instance_running_function: parking_lot::RwLock::new(HashMap::new()), next_instance_id: AtomicU64::new(0), - view: InstanceManagerView::new(args.logical_modules_ref.clone()), - // exe_view: ExecutorView::new(args.logical_modules_ref.clone()), } } async fn start(&self) -> WSResult> { diff --git a/src/worker/m_kv_user_client.rs b/src/worker/m_kv_user_client.rs index d9e59bb..ee3c3ad 100644 --- a/src/worker/m_kv_user_client.rs +++ b/src/worker/m_kv_user_client.rs @@ -14,25 +14,15 @@ use crate::{ util::JoinHandleWrapper, }; use async_trait::async_trait; -// use crossbeam_skiplist::SkipMap; - use ws_derive::LogicalModule; -use super::{m_executor::Executor, m_instance_manager::InstanceManager, m_worker::WorkerCore}; - -// use super::super::kv_interface::KvInterface; - logical_module_view_impl!(KvUserClientView); logical_module_view_impl!(KvUserClientView, p2p, P2PModule); -logical_module_view_impl!(KvUserClientView, kv_user_client, Option); -logical_module_view_impl!(KvUserClientView, instance_manager, Option); -logical_module_view_impl!(KvUserClientView, worker, Option); -logical_module_view_impl!(KvUserClientView, executor, Option); #[derive(LogicalModule)] pub struct KvUserClient { // testmap: SkipMap, Vec>, - pub view: KvUserClientView, + view: KvUserClientView, rpc_caller_kv: RPCCaller, } @@ -89,7 +79,6 @@ lazy_static::lazy_static! { // unsafe { (*res).as_ref().unwrap().kv_user_client() } // } - #[async_trait] impl KvInterface for KvUserClient { async fn call(&self, req: KvRequests, opt: KvOptions) -> WSResult { diff --git a/src/worker/m_worker.rs b/src/worker/m_worker.rs index fcb57da..82a2e5c 100644 --- a/src/worker/m_worker.rs +++ b/src/worker/m_worker.rs @@ -1,7 +1,4 @@ -use crate::{ - general::network::m_p2p::P2PModule, logical_module_view_impl, sys::LogicalModulesRef, - util::JoinHandleWrapper, -}; +use crate::util::JoinHandleWrapper; use async_trait::async_trait; use ws_derive::LogicalModule; @@ -10,23 +7,16 @@ use crate::{ sys::{LogicalModule, LogicalModuleNewArgs}, }; -logical_module_view_impl!(WorkerView); -logical_module_view_impl!(WorkerView, p2p, P2PModule); - #[derive(LogicalModule)] -pub struct WorkerCore { - pub view: WorkerView, -} +pub struct WorkerCore {} #[async_trait] impl LogicalModule for WorkerCore { - fn inner_new(args: LogicalModuleNewArgs) -> Self + fn inner_new(_args: LogicalModuleNewArgs) -> Self where Self: Sized, { - Self { - view: WorkerView::new(args.logical_modules_ref.clone()), - } + Self {} } async fn start(&self) -> WSResult> { let all = vec![]; diff --git a/src/worker/wasm_host_funcs/fs.rs b/src/worker/wasm_host_funcs/fs.rs index a3b0c2a..2e37fee 100644 --- a/src/worker/wasm_host_funcs/fs.rs +++ b/src/worker/wasm_host_funcs/fs.rs @@ -28,19 +28,6 @@ fn open_file(caller: Caller, args: Vec) -> Result, Hos Ok(vec![]) } -fn read_file_at(caller: Caller, args: Vec) -> Result, HostFuncError> { - let fd = args[0].to_i32(); - if fd < 0 { - tracing::error!("function read_file_at: invalid fd"); - return Ok(vec![]); - } - let data = utils::mutu8sclice(&caller, args[1].to_i32(), args[2].to_i32()).unwrap(); - let offset = args[3].to_i32(); - let retlen = utils::mutref::(&caller, args[4].to_i32()); - *retlen = m_fs().read_file_at(fd, offset, data).unwrap() as i32; - - Ok(vec![]) -} // fd, data, len, offset, retlen_ptr type ReadFileArgs = (i32, i32, i32, i32, i32); #[cfg_attr(target_os = "linux", async_host_function)]