Skip to content

Commit 6271fc3

Browse files
committed
reserve infrastructures for multiply modules
1 parent 9af6329 commit 6271fc3

File tree

3 files changed

+26
-14
lines changed

3 files changed

+26
-14
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
authors = ["Hao Shi <[email protected]>"]
55

66
[dependencies]
7-
neb = { git = "https://github.com/ShisoftResearch/Nebuchadnezzar", branch = "feature/dovahkiin" }
7+
neb = { git = "https://github.com/ShisoftResearch/Nebuchadnezzar", branch = "develop" }
88
#neb = { path = "../Nebuchadnezzar" }
99
bifrost = { git = "https://github.com/shisoft/bifrost", branch = "develop" }
1010
bifrost_plugins = { git = "https://github.com/shisoft/bifrost", branch = "develop" }

scripts/repeatdly_model_test.sh

100755100644
File mode changed.

src/server/mod.rs

+25-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
use bifrost::rpc;
12
use std::sync::Arc;
23
use bifrost::raft::state_machine::master::ExecError;
34
use neb::client::{Client as NebClient, NebClientError};
4-
use neb::server::{ServerOptions, NebServer, ServerError};
5+
use neb::server::{ServerOptions as NebServerOptions, NebServer, ServerError};
6+
use bifrost::tcp::{STANDALONE_ADDRESS_STRING};
57

68
use graph::Graph;
79

@@ -24,29 +26,39 @@ pub struct MorpheusServer {
2426
}
2527

2628
impl MorpheusServer {
27-
pub fn new(opts: &ServerOptions)
28-
-> Result<Arc<MorpheusServer>, MorpheusServerError> {
29-
let neb_server = NebServer::new(opts).map_err(MorpheusServerError::ServerError)?;
29+
pub fn new(
30+
neb_opts: &NebServerOptions
31+
) -> Result<Arc<MorpheusServer>, MorpheusServerError> {
32+
let server_addr = if neb_opts.standalone {&STANDALONE_ADDRESS_STRING} else {&neb_opts.address};
33+
let rpc_server = rpc::Server::new(server_addr);
34+
rpc::Server::listen_and_resume(&rpc_server);
35+
if !neb_opts.is_meta && neb_opts.standalone {
36+
return Err(MorpheusServerError::ServerError(ServerError::StandaloneMustAlsoBeMetaServer))
37+
}
38+
39+
let neb_server = NebServer::new(
40+
neb_opts, server_addr, &rpc_server
41+
).map_err(MorpheusServerError::ServerError)?;
3042
let neb_client = Arc::new(NebClient::new(
31-
&neb_server.rpc, &opts.meta_members,
32-
&opts.group_name).map_err(MorpheusServerError::ClientError)?);
33-
if opts.is_meta {
43+
&neb_server.rpc, &neb_opts.meta_members,
44+
&neb_opts.group_name).map_err(MorpheusServerError::ClientError)?);
45+
if neb_opts.is_meta {
3446
if let &Some(ref raft_service) = &neb_server.raft_service {
35-
schema::SchemaContainer::new_meta_service(&opts.group_name, raft_service);
47+
schema::SchemaContainer::new_meta_service(&neb_opts.group_name, raft_service);
3648
} else {
3749
panic!("raft service should be ready for meta server");
3850
}
3951
}
4052
let schema_container = schema::SchemaContainer::new_client(
41-
&opts.group_name, &neb_client.raft_client, &neb_client, &neb_server.meta
53+
&neb_opts.group_name, &neb_client.raft_client, &neb_client, &neb_server.meta
4254
).map_err(MorpheusServerError::InitSchemaError)?;
4355
let graph = Arc::new(Graph::new(&schema_container, &neb_client)
4456
.map_err(MorpheusServerError::InitSchemaError)?);
4557
Ok(Arc::new(MorpheusServer {
46-
neb_server: neb_server,
47-
neb_client: neb_client,
48-
schema_container: schema_container,
49-
graph: graph
58+
neb_server,
59+
neb_client,
60+
schema_container,
61+
graph
5062
}))
5163
}
5264
}

0 commit comments

Comments
 (0)