/**
 * 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 = "proto2";
option java_package = "org.apache.hadoop.yarn.proto";
option java_outer_classname = "YarnServerResourceManagerRecoveryProtos";
option java_generic_services = true;
option java_generate_equals_and_hash = true;
package hadoop.yarn;

import "yarn_server_common_protos.proto";
import "yarn_protos.proto";
import "yarn_security_token.proto";
import "RpcHeader.proto";

////////////////////////////////////////////////////////////////////////
////// RM recovery related records /////////////////////////////////////
////////////////////////////////////////////////////////////////////////
enum RMAppAttemptStateProto {
    RMATTEMPT_NEW = 1;
    RMATTEMPT_SUBMITTED = 2;
    RMATTEMPT_SCHEDULED = 3;
    RMATTEMPT_ALLOCATED = 4;
    RMATTEMPT_LAUNCHED = 5;
    RMATTEMPT_FAILED = 6;
    RMATTEMPT_RUNNING = 7;
    RMATTEMPT_FINISHING = 8;
    RMATTEMPT_FINISHED = 9;
    RMATTEMPT_KILLED = 10;
    RMATTEMPT_ALLOCATED_SAVING = 11;
    RMATTEMPT_LAUNCHED_UNMANAGED_SAVING = 12;
    RMATTEMPT_RECOVERED = 13;
    RMATTEMPT_FINAL_SAVING = 14;
}

enum RMAppStateProto {
    RMAPP_NEW = 1;
    RMAPP_NEW_SAVING = 2;
    RMAPP_SUBMITTED = 3;
    RMAPP_ACCEPTED = 4;
    RMAPP_RUNNING = 5;
    RMAPP_FINAL_SAVING = 6;
    RMAPP_FINISHING = 7;
    RMAPP_FINISHED = 8;
    RMAPP_FAILED = 9;
    RMAPP_KILLED = 10;
}

message ApplicationStateDataProto {
    optional int64 submit_time = 1;
    optional ApplicationSubmissionContextProto application_submission_context = 2;
    optional string user = 3;
    optional int64 start_time = 4;
    optional RMAppStateProto application_state = 5;
    optional string diagnostics = 6 [default = "N/A"];
    optional int64 finish_time = 7;
    optional hadoop.common.RPCCallerContextProto caller_context = 8;
    repeated ApplicationTimeoutMapProto application_timeouts = 9;
    optional int64 launch_time = 10;
    optional string real_user = 11;
}

message ApplicationAttemptStateDataProto {
    optional ApplicationAttemptIdProto attemptId = 1;
    optional ContainerProto master_container = 2;
    optional bytes app_attempt_tokens = 3;
    optional RMAppAttemptStateProto app_attempt_state = 4;
    optional string final_tracking_url = 5;
    optional string diagnostics = 6 [default = "N/A"];
    optional int64 start_time = 7;
    optional FinalApplicationStatusProto final_application_status = 8;
    optional int32 am_container_exit_status = 9 [default = -1000];
    optional int64 memory_seconds = 10;
    optional int64 vcore_seconds = 11;
    optional int64 finish_time = 12;
    optional int64 preempted_memory_seconds = 13;
    optional int64 preempted_vcore_seconds = 14;
    repeated StringLongMapProto application_resource_usage_map = 15;
    repeated StringLongMapProto preempted_resource_usage_map = 16;
    optional int32 total_allocated_containers = 17;
}

message EpochProto {
    optional int64 epoch = 1;
}

message AMRMTokenSecretManagerStateProto {
  optional MasterKeyProto current_master_key = 1;
  optional MasterKeyProto next_master_key = 2;
}

message RMDelegationTokenIdentifierDataProto {
  optional YARNDelegationTokenIdentifierProto token_identifier = 1;
  optional int64 renewDate = 2;
}
