Skip to content

Commit f276570

Browse files
author
Ganeshwara Hananda
authored
Add Cluster RPC definition which supports discovery protocol (#107)
## What is the goal of this PR? We have added Cluster RPC definition which supports discovery protocol. The definition would allow implementations such as Client Java and Grakn Cluster to discover and exchange cluster information. ## What are the changes implemented in this PR? - Adds Cluster RPC which supports discovery protocol. It exposes cluster information allowing for efficient communication between client and Grakn Cluster: - allows for discovering servers which belong to the cluster - allows for discovering the replicas belonging of a database
1 parent fbebfee commit f276570

File tree

7 files changed

+173
-2
lines changed

7 files changed

+173
-2
lines changed

.grabl/automation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ build:
3636
command: |
3737
bazel build //...
3838
bazel run @graknlabs_dependencies//tool/checkstyle:test-coverage
39-
bazel test $(bazel query 'kind(checkstyle_test, //...)')
39+
bazel test $(bazel query 'kind(checkstyle_test, //...)') --test_output=errors
4040
build-dependency:
4141
image: graknlabs-ubuntu-20.04
4242
command: |

grpc/java/BUILD

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ java_grpc_compile(
3838
]
3939
)
4040

41+
java_grpc_compile(
42+
name = "protocol-grakn-cluster-src",
43+
deps = [
44+
"//protobuf/cluster:grakn-cluster-proto",
45+
"//protobuf/cluster:cluster-proto",
46+
"//protobuf/cluster:database-proto"
47+
]
48+
)
49+
4150
java_library(
4251
name = "protocol",
4352
srcs = [":protocol-src"],
@@ -53,6 +62,21 @@ java_library(
5362
tags = ["maven_coordinates=io.grakn.protocol:grakn-protocol:{pom_version}", "checkstyle_ignore"],
5463
)
5564

65+
java_library(
66+
name = "protocol-cluster",
67+
srcs = [":protocol-grakn-cluster-src"],
68+
deps = [
69+
"@maven//:com_google_guava_guava",
70+
"@maven//:com_google_protobuf_protobuf_java",
71+
"@maven//:io_grpc_grpc_core",
72+
"@maven//:io_grpc_grpc_protobuf",
73+
"@maven//:io_grpc_grpc_stub",
74+
"@maven//:io_grpc_grpc_api",
75+
"@maven//:javax_annotation_javax_annotation_api", # gRPC needs this in order to compile in Java 11 and Java 14
76+
],
77+
tags = ["maven_coordinates=io.grakn.protocol:grakn-cluster-protocol:{pom_version}", "checkstyle_ignore"],
78+
)
79+
5680
checkstyle_test(
5781
name = "checkstyle",
5882
include = glob(["*"]),

grpc/python/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@
1414
# You should have received a copy of the GNU Affero General Public License
1515
# along with this program. If not, see <https://www.gnu.org/licenses/>.
1616
#
17-

protobuf/cluster/BUILD

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#
2+
# Copyright (C) 2021 Grakn Labs
3+
#
4+
# This program is free software: you can redistribute it and/or modify
5+
# it under the terms of the GNU Affero General Public License as
6+
# published by the Free Software Foundation, either version 3 of the
7+
# License, or (at your option) any later version.
8+
#
9+
# This program is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU Affero General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU Affero General Public License
15+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
#
17+
18+
package(default_visibility = ["//visibility:public"])
19+
20+
load("@graknlabs_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test")
21+
22+
proto_library(
23+
name = "grakn-cluster-proto",
24+
srcs = ["grakn-cluster.proto"],
25+
deps = [":cluster-proto", ":database-proto"],
26+
)
27+
28+
proto_library(
29+
name = "cluster-proto",
30+
srcs = [":cluster.proto"],
31+
)
32+
33+
proto_library(
34+
name = "database-proto",
35+
srcs = [":database.proto"],
36+
)
37+
38+
checkstyle_test(
39+
name = "checkstyle",
40+
include = glob(["*"]),
41+
license_type = "agpl",
42+
size = "small",
43+
)

protobuf/cluster/cluster.proto

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// Copyright (C) 2021 Grakn Labs
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as
6+
// published by the Free Software Foundation, either version 3 of the
7+
// License, or (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
//
17+
18+
syntax = "proto3";
19+
20+
option java_package = "grakn.protocol.cluster";
21+
option java_outer_classname = "ClusterProto";
22+
23+
package grakn.protocol.cluster;
24+
25+
message Cluster {
26+
message Discover {
27+
message Req {}
28+
message Res {
29+
repeated string servers = 1;
30+
}
31+
}
32+
}

protobuf/cluster/database.proto

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//
2+
// Copyright (C) 2021 Grakn Labs
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as
6+
// published by the Free Software Foundation, either version 3 of the
7+
// License, or (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
//
17+
18+
syntax = "proto3";
19+
20+
option java_package = "grakn.protocol.cluster";
21+
option java_outer_classname = "DatabaseProto";
22+
23+
package grakn.protocol.cluster;
24+
25+
message Database {
26+
message Discover {
27+
message Req {
28+
string database = 1;
29+
}
30+
31+
message Res {
32+
repeated Replica replicas = 1;
33+
34+
message Replica {
35+
string address = 1;
36+
string database = 2;
37+
bool is_leader = 3;
38+
int64 term = 4;
39+
}
40+
}
41+
}
42+
}

protobuf/cluster/grakn-cluster.proto

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// Copyright (C) 2021 Grakn Labs
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as
6+
// published by the Free Software Foundation, either version 3 of the
7+
// License, or (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
//
17+
18+
syntax = "proto3";
19+
20+
option java_package = "grakn.protocol.cluster";
21+
option java_outer_classname = "GraknClusterProto";
22+
23+
import "protobuf/cluster/cluster.proto";
24+
import "protobuf/cluster/database.proto";
25+
26+
package grakn.protocol.cluster;
27+
28+
service GraknCluster {
29+
rpc cluster_discover (Cluster.Discover.Req) returns (Cluster.Discover.Res);
30+
rpc database_discover (Database.Discover.Req) returns (Database.Discover.Res);
31+
}

0 commit comments

Comments
 (0)