Skip to content

Commit

Permalink
fix: add some warn to deny
Browse files Browse the repository at this point in the history
  • Loading branch information
ActivePeter committed Mar 20, 2024
1 parent 3e7ac61 commit a2a5277
Show file tree
Hide file tree
Showing 14 changed files with 15 additions and 107 deletions.
2 changes: 2 additions & 0 deletions scripts/install/install_python_and_ansible.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 1 addition & 4 deletions src/general/m_fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<i32, Arc<Mutex<File>>>,
Expand Down
23 changes: 1 addition & 22 deletions src/general/network/m_p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ use std::{
collections::HashMap,
marker::PhantomData,
net::SocketAddr,
sync::{
atomic::{AtomicU32, Ordering},
Arc,
},
sync::atomic::{AtomicU32, Ordering},
time::Duration,
};

Expand Down Expand Up @@ -152,7 +149,6 @@ pub struct P2PModule {
(TaskId, NodeID),
Mutex<Option<tokio::sync::oneshot::Sender<Box<dyn MsgPack>>>>,
>,
rpc_holder: RwLock<HashMap<(MsgId, NodeID), Arc<tokio::sync::Mutex<()>>>>,
pub p2p_kernel: P2PQuicNode,
// pub state_trans_tx: tokio::sync::broadcast::Sender<ModuleSignal>,
pub nodes_config: NodesConfig,
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -499,19 +494,3 @@ impl P2PModule {
)
}
}

// #[async_trait]
// impl P2P for P2PModule {
// async fn send_for_response(&self, nodeid: NodeID, req_data: Vec<u8>) -> WSResult<Vec<u8>> {
// // 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<u8>) -> WSResult<()> {
// self.p2p_kernel.send(nodeid, req_data).await?;
// Ok(())
// }
// }
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/master/m_http_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn HttpHandler>);
logical_module_view_impl!(MasterHttpHandlerView, master, Option<Master>);
logical_module_view_impl!(
MasterHttpHandlerView,
Expand Down
12 changes: 0 additions & 12 deletions src/master/m_master.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,12 +27,6 @@ struct StrawNodeSelector {
weight_fetcher: Box<dyn NodeWeighteFetcher>,
}

impl StrawNodeSelector {
fn new(weight_fetcher: Box<dyn NodeWeighteFetcher>) -> Self {
Self { weight_fetcher }
}
}

// NOTE: Straw2 algorithm
impl NodeSelector for StrawNodeSelector {
fn select_node(&self, all_node_cnt: usize, fn_name: &str) -> NodeID {
Expand Down Expand Up @@ -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<Master>);
logical_module_view_impl!(MasterView, master_kv, Option<MasterKv>);

#[derive(LogicalModule)]
pub struct Master {
// each_fn_caching: HashMap<String, HashSet<NodeId>>,
node_selector: Box<dyn NodeSelector>,
pub rpc_caller_distribute_task: RPCCaller<proto::sche::DistributeTaskReq>,
view: MasterView,
}
Expand All @@ -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(),
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/master/m_master_kv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ logical_module_view_impl!(MasterKvView, kv_store_engine, KvStoreEngine);

#[derive(LogicalModule)]
pub struct MasterKv {
kv_map: RwLock<HashMap<Vec<u8>, Vec<u8>>>,
lock_notifiers: RwLock<HashMap<Vec<u8>, (NodeID, u32, Arc<Notify>)>>,
rpc_handler: RPCHandler<proto::kv::KvRequests>,
view: MasterKvView,
Expand All @@ -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()),
Expand Down
2 changes: 0 additions & 2 deletions src/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ macro_rules! logical_modules {
($($modules:ident,$ts:ty),+)=>{

pub struct LogicalModules {
new_cnt:usize,
start_cnt:usize,
$(pub $modules: $ts),+
}
Expand Down Expand Up @@ -381,7 +380,6 @@ impl LogicalModules {
kv_user_client: None,
instance_manager: None,
executor: None,
new_cnt: 0,
start_cnt: 0,
};

Expand Down
3 changes: 1 addition & 2 deletions src/worker/m_executor.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand Down Expand Up @@ -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<InstanceManager>);
logical_module_view_impl!(ExecutorView, executor, Option<Executor>);
logical_module_view_impl!(ExecutorView, kv_user_client, Option<KvUserClient>);

#[derive(LogicalModule)]
pub struct Executor {
Expand Down
7 changes: 1 addition & 6 deletions src/worker/m_http_handler.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand Down Expand Up @@ -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<dyn HttpHandler>);
logical_module_view_impl!(WorkerHttpHandlerView, executor, Option<Executor>);

#[async_trait]
Expand Down
17 changes: 1 addition & 16 deletions src/worker/m_instance_manager.rs
Original file line number Diff line number Diff line change
@@ -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,
};
Expand Down Expand Up @@ -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<InstanceManager>
);

#[derive(LogicalModule)]
pub struct InstanceManager {
// cache: Mutex<LRUCache<Vm>>,
Expand All @@ -191,8 +181,6 @@ pub struct InstanceManager {
/// instance addr 2 running function
pub instance_running_function: parking_lot::RwLock<HashMap<String, FunctionCtx>>,
pub next_instance_id: AtomicU64,
pub view: InstanceManagerView,
// exe_view: ExecutorView,
}

#[async_trait]
Expand All @@ -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<Vec<JoinHandleWrapper>> {
Expand Down
13 changes: 1 addition & 12 deletions src/worker/m_kv_user_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<KvUserClient>);
logical_module_view_impl!(KvUserClientView, instance_manager, Option<InstanceManager>);
logical_module_view_impl!(KvUserClientView, worker, Option<WorkerCore>);
logical_module_view_impl!(KvUserClientView, executor, Option<Executor>);

#[derive(LogicalModule)]
pub struct KvUserClient {
// testmap: SkipMap<Vec<u8>, Vec<u8>>,
pub view: KvUserClientView,
view: KvUserClientView,
rpc_caller_kv: RPCCaller<KvRequests>,
}

Expand Down Expand Up @@ -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<KvResponses> {
Expand Down
18 changes: 4 additions & 14 deletions src/worker/m_worker.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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<Vec<JoinHandleWrapper>> {
let all = vec![];
Expand Down
13 changes: 0 additions & 13 deletions src/worker/wasm_host_funcs/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,6 @@ fn open_file(caller: Caller, args: Vec<WasmValue>) -> Result<Vec<WasmValue>, Hos
Ok(vec![])
}

fn read_file_at(caller: Caller, args: Vec<WasmValue>) -> Result<Vec<WasmValue>, 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::<i32>(&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)]
Expand Down

0 comments on commit a2a5277

Please sign in to comment.