Skip to content

Commit

Permalink
integrate gaia to persistent store (#440)
Browse files Browse the repository at this point in the history
* add gaia port and configurations to graphscope-store charts

* Add extra configs by set key-value pairs

* add interface (#448)

* add interface

* [graphscope] add mapping of partition id to server id in GraphPartitionManager (#431)

* [graphscope] add function of mapping partition id to server id in GraphPartitionManager

Co-authored-by: siyuan0322 <siyuan0322@gmail.com>
Co-authored-by: BingqingLyu <lv_bingqing@163.com>
  • Loading branch information
3 people committed Jul 1, 2021
1 parent 6eecccd commit 809842a
Show file tree
Hide file tree
Showing 42 changed files with 741 additions and 210 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ jobs:
source ~/.bashrc
cd interactive_engine
mvn clean package -Pv2 -Drust.compile.mode=debug -DskipTests --quiet
mvn clean package -Pv2 -Drust.compile.mode=release -DskipTests --quiet
cd ${GITHUB_WORKSPACE}
mv interactive_engine/distribution/target/maxgraph.tar.gz ./
tar -zcf lib.tar.gz /opt/graphscope
Expand Down
8 changes: 8 additions & 0 deletions charts/graphscope-store/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ $ helm install my-release \
--set image.tag=latest graphscope/graphscope-store
```

Add multiple extra config to the component which is defined in the configmap by
`--set extraConfig=k1=v1:k2=v2`. Note we use `:` to seperate config items. For example,

```bash
$ helm install my-release \
--set extraConfig=k1=v1:k2=v2 graphscope/graphscope-store
```


Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,

Expand Down
12 changes: 12 additions & 0 deletions charts/graphscope-store/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,16 @@ data:
executor.graph.port=55556
executor.query.port=55557
executor.engine.port=55558
## GAIA Config
gaia.rpc.port=60000
gaia.engine.port=60001
## Extra Config
{{- if .Values.extraConfig }}
{{- $config_list := regexSplit ":" .Values.extraConfig -1 }}
{{- range $config_list }}
{{ . }}
{{- end }}
{{- end }}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ spec:
ports:
- name: port
containerPort: 55555
- name: gaia-rpc
containerPort: 60000
- name: gaia-engine
containerPort: 60001
{{- if .Values.coordinator.resources }}
resources: {{- toYaml .Values.coordinator.resources | nindent 12 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ spec:
- name: port
port: {{ .Values.coordinator.service.port }}
targetPort: port

- name: gaia-rpc
port: {{ .Values.coordinator.service.gaiaRpc }}
targetPort: gaia-rpc
- name: gaia-engine
port: {{ .Values.coordinator.service.gaiaEngine }}
targetPort: gaia-engine
selector: {{- include "graphscope-store.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: coordinator
4 changes: 4 additions & 0 deletions charts/graphscope-store/templates/frontend/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ spec:
containerPort: 55555
- name: gremlin
containerPort: 12312
- name: gaia-rpc
containerPort: 60000
- name: gaia-engine
containerPort: 60001
{{- if .Values.frontend.resources }}
resources: {{- toYaml .Values.frontend.resources | nindent 12 }}
{{- end }}
Expand Down
7 changes: 6 additions & 1 deletion charts/graphscope-store/templates/frontend/svc-headless.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ spec:
- name: port
port: {{ .Values.frontend.service.port }}
targetPort: port

- name: gaia-rpc
port: {{ .Values.frontend.service.gaiaRpc }}
targetPort: gaia-rpc
- name: gaia-engine
port: {{ .Values.frontend.service.gaiaEngine }}
targetPort: gaia-engine
selector: {{- include "graphscope-store.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: frontend
4 changes: 4 additions & 0 deletions charts/graphscope-store/templates/ingestor/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ spec:
ports:
- name: port
containerPort: 55555
- name: gaia-rpc
containerPort: 60000
- name: gaia-engine
containerPort: 60001
{{- if .Values.ingestor.resources }}
resources: {{- toYaml .Values.ingestor.resources | nindent 12 }}
{{- end }}
Expand Down
7 changes: 6 additions & 1 deletion charts/graphscope-store/templates/ingestor/svc-headless.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ spec:
- name: port
port: {{ .Values.ingestor.service.port }}
targetPort: port

- name: gaia-rpc
port: {{ .Values.ingestor.service.gaiaRpc }}
targetPort: gaia-rpc
- name: gaia-engine
port: {{ .Values.ingestor.service.gaiaEngine }}
targetPort: gaia-engine
selector: {{- include "graphscope-store.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: ingestor
4 changes: 4 additions & 0 deletions charts/graphscope-store/templates/store/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ spec:
containerPort: 55557
- name: engine
containerPort: 55558
- name: gaia-rpc
containerPort: 60000
- name: gaia-engine
containerPort: 60001
{{- if .Values.store.resources }}
resources: {{- toYaml .Values.store.resources | nindent 12 }}
{{- end }}
Expand Down
7 changes: 6 additions & 1 deletion charts/graphscope-store/templates/store/svc-headless.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ spec:
- name: engine
port: {{ .Values.store.service.engine }}
targetPort: engine

- name: gaia-rpc
port: {{ .Values.store.service.gaiaRpc }}
targetPort: gaia-rpc
- name: gaia-engine
port: {{ .Values.store.service.gaiaEngine }}
targetPort: gaia-engine
selector: {{- include "graphscope-store.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: store
26 changes: 24 additions & 2 deletions charts/graphscope-store/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ executorQueryStoreThreadCount: 2
log4rsConfig: "./conf/log4rs.yml"



extraConfig: ""

## Role Based Access
## ref: https://kubernetes.io/docs/admin/authorization/rbac/
##
Expand Down Expand Up @@ -240,6 +243,8 @@ store:
graph: 55556
query: 55557
engine: 55558
gaiaRpc: 60000
gaiaEngine: 60001

annotations: {}

Expand Down Expand Up @@ -350,6 +355,13 @@ frontend:
##
gremlinPort: 12312

## Gaia rpc port
##
gaiaRpc: 60000
## Gaia engine port
##
gaiaEngine: 60001

## Specify the nodePort value for the LoadBalancer and NodePort service types.
## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport
##
Expand Down Expand Up @@ -483,7 +495,12 @@ ingestor:
## Service port
##
port: 55555

## Gaia rpc port
##
gaiaRpc: 60000
## Gaia engine port
##
gaiaEngine: 60001
annotations: {}

## GraphScope store Pod Disruption Budget configuration
Expand Down Expand Up @@ -626,7 +643,12 @@ coordinator:
## Service port
##
port: 55555

## Gaia rpc port
##
gaiaRpc: 60000
## Gaia engine port
##
gaiaEngine: 60001
annotations: {}

## GraphScope store Pod Disruption Budget configuration
Expand Down
4 changes: 2 additions & 2 deletions interactive_engine/src/executor/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ if [ "$SKIP" = "true" ]; then
fi

if [ "$MODE" = "debug" ]; then
cargo build --all
./exec.sh cargo build --all
elif [ "$MODE" = "release" ]; then
cargo build --all --release
./exec.sh cargo build --all --release
else
exit 1
fi
Expand Down
8 changes: 7 additions & 1 deletion interactive_engine/src/executor/jna/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "maxgraph-jna"
version = "0.1.0"
authors = ["maxgraph@alibaba-inc.com"]
edition = "2018"

[lib]
crate-type = ["rlib", "cdylib"]
Expand All @@ -11,10 +12,15 @@ maxgraph-runtime = { path = "../runtime" }
maxgraph-store = { path = "../store" }
maxgraph-common = { path = "../../common/rust/common" }
maxgraph-server = { path = "../server" }
pegasus = { path = "../Pegasus" }
pegasus = { path = "../Pegasus", package = "pegasus" }
gaia_pegasus = { path = "../../../../research/gaia/pegasus/pegasus", package = "pegasus" }
pegasus_network = { path = "../../../../research/gaia/pegasus/network" }
pegasus_server = { path = "../../../../research/gaia/pegasus/server" }
gremlin_core = { path = "../../../../research/gaia/gremlin/gremlin_core" }
itertools = "0.7.8"
log = "0.3"
log4rs = "0.8.0"
lazy_static = "1.2.0"
grpcio = "=0.4.1"
tokio = { version = "1.0", features = ["macros", "sync"] }
futures = { version = "0.3.0", features = ["thread-pool"]}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
use std::os::raw::c_char;
use std::ffi::CString;

#[repr(C)]
#[allow(non_snake_case)]
pub struct EnginePortsResponse {
success: bool,
errMsg: *const c_char,
enginePort: i32,
rpcPort: i32,
}

impl EnginePortsResponse {
pub fn new(engine_port: i32, rpc_port: i32) -> Box<EnginePortsResponse> {
Box::new(EnginePortsResponse {
success: true,
errMsg: std::ptr::null(),
enginePort: engine_port,
rpcPort: rpc_port,
})
}

pub fn new_with_error(err_msg: &str) -> Box<EnginePortsResponse> {
let msg = CString::new(err_msg).unwrap();
let response = EnginePortsResponse {
success: false,
errMsg: msg.as_ptr(),
enginePort: 0,
rpcPort: 0,
};
::std::mem::forget(msg);
Box::new(response)
}
}

impl Drop for EnginePortsResponse {
fn drop(&mut self) {
unsafe {
if !self.errMsg.is_null() {
CString::from_raw(self.errMsg as *mut c_char);
}
}
}
}

#[no_mangle]
#[allow(non_snake_case)]
pub extern fn dropEnginePortsResponse(_: Box<EnginePortsResponse>) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
use std::os::raw::{c_void, c_char};
use maxgraph_store::db::proto::common::ConfigPb;
use maxgraph_store::db::common::bytes::util::parse_pb;
use maxgraph_store::db::api::GraphConfigBuilder;
use std::sync::Arc;
use maxgraph_store::db::common::unsafe_util::to_mut;
use maxgraph_store::db::graph::store::GraphStore;
use std::ffi::CStr;
use std::net::SocketAddr;
use crate::executor::gaia::gaia_server::GaiaServer;
use crate::executor::gaia::engine_ports_response::EnginePortsResponse;

pub type EngineHandle = *const c_void;
pub type GraphHandle = *const c_void;

#[no_mangle]
pub extern fn initialize(config_bytes: *const u8, len: usize) -> EngineHandle {
let config_buf = unsafe { ::std::slice::from_raw_parts(config_bytes, len) };
let config_pb = parse_pb::<ConfigPb>(config_buf).expect("parse config pb failed");
let mut config_builder = GraphConfigBuilder::new();
config_builder.set_storage_options(config_pb.get_configs().clone());
let config = Arc::new(config_builder.build());
let handle = Box::new(GaiaServer::new(config));
Box::into_raw(handle) as EngineHandle
}

#[no_mangle]
pub extern fn addPartition(engine_handle: EngineHandle, partition_id: i32, graph_handle: GraphHandle) {
let engine_ptr = unsafe {
to_mut(&*(engine_handle as *const GaiaServer))
};
let graph_ptr = unsafe {
Arc::from_raw(&*(graph_handle as *const GraphStore))
};
engine_ptr.add_partition(partition_id as u32, graph_ptr);
}

#[no_mangle]
pub extern fn updatePartitionRouting(engine_handle: EngineHandle, partition_id: i32, server_id: i32) {
let engine_ptr = unsafe {
to_mut(&*(engine_handle as *const GaiaServer))
};
engine_ptr.update_partition_routing(partition_id as u32, server_id as u32);
}

#[no_mangle]
pub extern fn startEngine(engine_handle: EngineHandle) -> Box<EnginePortsResponse> {
let engine_ptr = unsafe {
to_mut(&*(engine_handle as *const GaiaServer))
};
match engine_ptr.start() {
Ok((engine_port, server_port)) => {
EnginePortsResponse::new(engine_port as i32, server_port as i32)
},
Err(e) => {
let msg = format!("{:?}", e);
EnginePortsResponse::new_with_error(&msg)
},
}
}

#[no_mangle]
pub extern fn stopEngine(engine_handle: EngineHandle) {
let engine_ptr = unsafe {
to_mut(&*(engine_handle as *const GaiaServer))
};
engine_ptr.stop();
}

#[no_mangle]
pub extern fn updatePeerView(engine_handle: EngineHandle, peer_view_string_raw: *const c_char) {
let slice = unsafe { CStr::from_ptr(peer_view_string_raw) }.to_bytes();
let peer_view_string = std::str::from_utf8(slice).unwrap();
let peer_view = peer_view_string.split(",").map(|item| {
let mut fields = item.split("#");
let id = fields.next().unwrap().parse::<u64>().unwrap();
let host = fields.next().unwrap().parse().unwrap();
let port = fields.next().unwrap().parse().unwrap();
(id, SocketAddr::new(host, port))
}).collect::<Vec<(u64, SocketAddr)>>();
let engine_ptr = unsafe {
to_mut(&*(engine_handle as *const GaiaServer))
};
engine_ptr.update_peer_view(peer_view);
}
Loading

0 comments on commit 809842a

Please sign in to comment.