/**
 * 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.
 */

// This file contains protocol buffers that are used for RegionServerStatusProtocol.

option java_package = "org.apache.hadoop.hbase.protobuf.generated";
option java_outer_classname = "RegionServerStatusProtos";
option java_generic_services = true;
option java_generate_equals_and_hash = true;
option optimize_for = SPEED;

import "HBase.proto";
import "ClusterStatus.proto";

message RegionServerStartupRequest {
  /** Port number this regionserver is up on */
  required uint32 port = 1;

  /** This servers' startcode */
  required uint64 server_start_code = 2;

  /** Current time of the region server in ms */
  required uint64 server_current_time = 3;
}

message RegionServerStartupResponse {
  /**
   * Configuration for the regionserver to use: e.g. filesystem,
   * hbase rootdir, the hostname to use creating the RegionServer ServerName,
   * etc
   */
  repeated NameStringPair map_entries = 1;
}

message RegionServerReportRequest {
  required ServerName server = 1;

  /** load the server is under */
  optional ServerLoad load = 2;
}

message RegionServerReportResponse {
}

message ReportRSFatalErrorRequest {
  /** name of the server experiencing the error */
  required ServerName server = 1;

  /** informative text to expose in the master logs and UI */
  required string error_message = 2;
}

message ReportRSFatalErrorResponse {
}

message GetLastFlushedSequenceIdRequest {
  /** region name */
  required bytes region_name = 1;
}

message GetLastFlushedSequenceIdResponse {
  /** the last HLog sequence id flushed from MemStore to HFile for the region */
  required uint64 last_flushed_sequence_id = 1;
}

service RegionServerStatusService {
  /** Called when a region server first starts. */
  rpc RegionServerStartup(RegionServerStartupRequest)
    returns(RegionServerStartupResponse);

  /** Called to report the load the RegionServer is under. */
  rpc RegionServerReport(RegionServerReportRequest)
    returns(RegionServerReportResponse);

  /**
   * Called by a region server to report a fatal error that is causing it to
   * abort.
   */
  rpc ReportRSFatalError(ReportRSFatalErrorRequest)
    returns(ReportRSFatalErrorResponse);

  /** Called to get the sequence id of the last MemStore entry flushed to an
   * HFile for a specified region. Used by the region server to speed up
   * log splitting. */
  rpc GetLastFlushedSequenceId(GetLastFlushedSequenceIdRequest)
    returns(GetLastFlushedSequenceIdResponse);
}
