Skip to content

Commit

Permalink
RATIS-58 Add rmap.proto
Browse files Browse the repository at this point in the history
  • Loading branch information
enis committed Apr 10, 2017
1 parent ac55b5f commit 0af9735
Showing 1 changed file with 189 additions and 0 deletions.
189 changes: 189 additions & 0 deletions ratis-proto-shaded/src/main/proto/RMap.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
syntax = "proto3";
option java_package = "org.apache.ratis.shaded.proto.rmap";
option java_outer_classname = "RMapProtos";
option java_generate_equals_and_hash = true;
package ratis.rmap;

// TODO: This .proto file should go to the ratis-replicated-map module, but we need it here
// due to shading.

// Metadata about a replicated map
message RMapInfo {
int64 rmap_id = 1;
string name = 2;
string key_class = 3;
string value_class = 4;
string key_serde_class = 5;
string value_serde_class = 6;
string key_comparator_class = 7;
}

// An entry in a replicated map.`
message Entry {
bytes key = 1;
bytes value = 2;
}

// TODO: raft client should allow a Service decleration, and calling a method from the service
// similar to how coprocessor calls work in HBase.
message Request {
oneof RequestType {
MultiActionRequest multi_action_request = 1;
ScanRequest scan_request = 2;
CreateRMapRequest create_rmap_request = 3;
DeleteRMapRequest delete_rmap_request = 4;
ListRMapInfosRequest list_rmap_infos_request = 5;
}
}

message Response {
ExceptionResponse exception = 1;
oneof ResponseType {
MultiActionResponse multi_action_response = 2;
ScanResponse scan_response = 3;
CreateRMapResponse create_rmap_response = 4;
DeleteRMapResponse delete_rmap_response = 5;
ListRMapInfosResponse list_rmap_infos_response = 6;
}
}

message MultiActionRequest {
int64 rmap_id = 1;
repeated Action action = 2;
}

message Action {
oneof ActionType {
GetRequest get_request = 1;
PutRequest put_request = 2;
}
}

message ActionResponse {
oneof ActionType {
GetResponse get_response = 1;
PutResponse put_response = 2;
}
}

message MultiActionResponse {
repeated ActionResponse action_response = 1;
}

message CreateRMapRequest {
RMapInfo rmap_info = 1;
}

message CreateRMapResponse {
RMapInfo rmap_info = 1;
}

message DeleteRMapRequest {
int64 rmap_id = 1;
}

message DeleteRMapResponse {
}

message ListRMapInfosRequest {
oneof ListRMapInfosType {
// if set, we only care about a particular RMapInfo
int64 rmap_id = 1;

// only return infos whose names match this pattern
string name_pattern = 2;
}
}

message ListRMapInfosResponse {
repeated RMapInfo rmap_info = 1;
}

message GetRequest {
bytes key = 1;
}

message GetResponse {
bool found = 1;
bytes key = 2;
bytes value = 3;
}

message PutRequest {
bytes key = 1;
bytes value = 2;
}

message PutResponse {
}

message Scan {
bytes start_Key = 1;
bytes end_key = 2;
bool start_key_inclusive = 3;
bool end_key_inclusive = 4;
bool keys_only = 5;
int32 limit = 6;
}

message ScanRequest {
int64 rmap_id = 1;
Scan scan = 2;
}

message ScanResponse {
repeated Entry entry = 1;
}

message ExceptionResponse {
// Class name of the exception thrown from the server
string exception_class_name = 1;
// Exception stack trace from the server side
string stack_trace = 2;
// Optional hostname. Filled in for some exceptions such as region moved
// where exception gives clue on where the region may have moved.
string hostname = 3;
int32 port = 4;
// Set if we are NOT to retry on receipt of this exception
bool do_not_retry = 5;
}

message Id {
int64 id = 1;
}

message WALEntry {
int64 rmap_id = 1; // these are shared by all WALEntry types
repeated Entry entry = 2;
oneof WALEntryType {
// Multi is not here, because we do not want to create one more object unnecessarily
CreateRMapWALEntry create_rmap_entry = 3;
DeleteRMapWALEntry delete_rmap_entry = 4;
}
}

message CreateRMapWALEntry {
RMapInfo rmap_info = 1;
Id id = 2;
}

message DeleteRMapWALEntry {
int64 id = 1;
}

0 comments on commit 0af9735

Please sign in to comment.