syntax = "proto2";

option java_multiple_files = true;
option java_package = "alluxio.grpc";
option java_outer_classname = "RaftJournalProto";

package alluxio.grpc.meta;

import "grpc/common.proto";

message JournalQueryRequest {
  optional GetSnapshotInfoRequest snapshotInfoRequest = 1 [deprecated = true];
  optional GetSnapshotRequest snapshotRequest = 2 [deprecated = true];
  optional AddQuorumServerRequest addQuorumServerRequest = 3;
}

message JournalQueryResponse {
  option deprecated = true;
  optional GetSnapshotInfoResponse snapshotInfoResponse = 1 [deprecated = true];
}

message AddQuorumServerRequest {
  optional NetAddress serverAddress = 1;
}

message GetSnapshotInfoRequest {
  option deprecated = true;
  optional SnapshotMetadata snapshotInfo = 1 [deprecated = true];
}

message GetSnapshotInfoResponse {
  option deprecated = true;
  optional SnapshotMetadata latest = 1 [deprecated = true];
}

message GetSnapshotRequest {
  option deprecated = true;
}

message SnapshotMetadata {
  optional int64 snapshotTerm = 1;
  optional int64 snapshotIndex = 2;
  optional bool exists = 3;
}

message SnapshotData {
  optional int64 snapshotTerm = 1;
  optional int64 snapshotIndex = 2;
  optional bytes chunk = 3;
  optional int64 offset = 4 [deprecated = true];
  optional bool eof = 5 [deprecated = true];
}

message UploadSnapshotPRequest {
  option deprecated = true;
  optional SnapshotData data = 1 [deprecated = true];
}

message UploadSnapshotPResponse {
  option deprecated = true;
  optional int64 offsetReceived = 1 [deprecated = true];
}

message DownloadSnapshotPRequest {
  option deprecated = true;
  optional int64 offsetReceived = 1 [deprecated = true];
}

message DownloadSnapshotPResponse {
  option deprecated = true;
  optional SnapshotData data = 1 [deprecated = true];
}

message LatestSnapshotInfoPRequest {}

/**
  * This interface contains raft service endpoints for Alluxio masters.
  */
service RaftJournalService {

  /**
   * Uploads a snapshot to primary master.
   */
  rpc UploadSnapshot (stream UploadSnapshotPRequest) returns (stream UploadSnapshotPResponse) {
    option deprecated = true;
  };

  /**
   * Downloads a snapshot from primary master.
   */
  rpc DownloadSnapshot (stream DownloadSnapshotPRequest) returns (stream DownloadSnapshotPResponse) {
    option deprecated = true;
  };

  /**
   * Requests information about snapshots on a particular machine.
   */
  rpc RequestLatestSnapshotInfo(LatestSnapshotInfoPRequest) returns (SnapshotMetadata) {}

  /**
   * Request to download the snapshot information from a particular machine.
   */
  rpc RequestLatestSnapshotData(SnapshotMetadata) returns (stream SnapshotData) {}
}
