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

/**
 * These .proto interfaces are public and stable.
 * Please see https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-common/Compatibility.html
 * for what changes are allowed for a *stable* .proto interface.
 */

syntax = "proto2";
option java_package = "org.apache.hadoop.yarn.proto";
option java_outer_classname = "YarnProtos";
option java_generic_services = true;
option java_generate_equals_and_hash = true;
package hadoop.yarn;

import "Security.proto";

message SerializedExceptionProto {
  optional string message = 1;
  optional string trace = 2;
  optional string class_name = 3;
  optional SerializedExceptionProto cause = 4;
}

message ApplicationIdProto {
  optional int32 id = 1;
  optional int64 cluster_timestamp = 2;
}

message ApplicationAttemptIdProto {
  optional ApplicationIdProto application_id = 1;
  optional int32 attemptId = 2;
}

message ContainerIdProto {
  optional ApplicationIdProto app_id = 1;
  optional ApplicationAttemptIdProto app_attempt_id = 2;
  optional int64 id = 3;
}

enum ResourceTypesProto {
  COUNTABLE = 0;
}

message ResourceInformationProto {
  required string key = 1;
  optional int64 value = 2;
  optional string units = 3;
  optional ResourceTypesProto type = 4;
  repeated string tags = 5;
  repeated StringStringMapProto attributes = 6;
}

message ResourceTypeInfoProto {
  required string name = 1;
  optional string units = 2;
  optional ResourceTypesProto type = 3;
}

message ResourceProto {
  optional int64 memory = 1;
  optional int32 virtual_cores = 2;
  repeated ResourceInformationProto resource_value_map = 3;
}

message ResourceUtilizationProto {
  optional int32 pmem = 1;
  optional int32 vmem = 2;
  optional float cpu = 3;
  repeated StringFloatMapProto customResources = 4;
}

message ResourceOptionProto {
  optional ResourceProto resource = 1;
  optional int32 over_commit_timeout = 2;
}

message ResourceProfileEntry {
  required string name = 1;
  required ResourceProto resources = 2;
}

message ResourceProfilesProto {
  repeated ResourceProfileEntry resource_profiles_map = 1;
}

message NodeResourceMapProto {
  optional NodeIdProto node_id = 1;
  optional ResourceOptionProto resource_option = 2;
}

message PriorityProto {
  optional int32 priority = 1;
}

enum ContainerStateProto {
  C_NEW = 1;
  C_RUNNING = 2;
  C_COMPLETE = 3;
}

enum ContainerSubStateProto {
 /**
  * NEW, LOCALIZING, SCHEDULED,
  * REINITIALIZING_AWAITING_KILL, RELAUNCHING,
  */
  CSS_SCHEDULED = 1;

 /**
  * RUNNING, REINITIALIZING, PAUSING, KILLING
  */
  CSS_RUNNING = 2;

 /**
  * PAUSED, RESUMING
  */
  CSS_PAUSED = 3;

 /**
  * LOCALIZATION_FAILED, EXITED_WITH_SUCCESS,
  * EXITED_WITH_FAILURE,
  * CONTAINER_CLEANEDUP_AFTER_KILL,
  * CONTAINER_RESOURCES_CLEANINGUP
  */
  CSS_COMPLETING = 4;

 /**
  * DONE
  */
  CSS_DONE = 5;
}

message ContainerProto {
  optional ContainerIdProto id = 1;
  optional NodeIdProto nodeId = 2;
  optional string node_http_address = 3;
  optional ResourceProto resource = 4;
  optional PriorityProto priority = 5;
  optional hadoop.common.TokenProto container_token = 6;
  optional ExecutionTypeProto execution_type = 7 [default = GUARANTEED];
  optional int64 allocation_request_id = 8 [default = -1];
  optional int32 version = 9 [default = 0];
  repeated string allocation_tags = 10;
  optional string exposed_ports = 11;
}

message ContainerReportProto {
  optional ContainerIdProto container_id = 1;
  optional ResourceProto resource = 2;
  optional NodeIdProto node_id = 3;
  optional PriorityProto priority = 4;
  optional int64 creation_time = 5;
  optional int64 finish_time = 6;
  optional string diagnostics_info = 7 [default = "N/A"];
  optional string log_url = 8;
  optional int32 container_exit_status = 9;
  optional ContainerStateProto container_state = 10;
  optional string node_http_address = 11;
  optional ExecutionTypeProto executionType = 12 [default = GUARANTEED];
  optional string exposed_ports = 13;
}

enum YarnApplicationStateProto {
  NEW = 1;
  NEW_SAVING = 2;
  SUBMITTED = 3;
  ACCEPTED = 4;
  RUNNING = 5;
  FINISHED = 6;
  FAILED = 7;
  KILLED = 8;
}

enum YarnApplicationAttemptStateProto {
  APP_ATTEMPT_NEW = 1;
  APP_ATTEMPT_SUBMITTED = 2;
  APP_ATTEMPT_SCHEDULED = 3;
  APP_ATTEMPT_ALLOCATED_SAVING = 4;
  APP_ATTEMPT_ALLOCATED = 5;
  APP_ATTEMPT_LAUNCHED = 6;
  APP_ATTEMPT_FAILED = 7;
  APP_ATTEMPT_RUNNING = 8;
  APP_ATTEMPT_FINISHING = 9;
  APP_ATTEMPT_FINISHED = 10;
  APP_ATTEMPT_KILLED = 11;
}

enum FinalApplicationStatusProto {
  APP_UNDEFINED = 0;
  APP_SUCCEEDED = 1;
  APP_FAILED = 2;
  APP_KILLED = 3;
  APP_ENDED = 4;
}

message URLProto {
  optional string scheme = 1;
  optional string host = 2;
  optional int32 port = 3;
  optional string file = 4;
  optional string userInfo = 5;
}

enum LocalResourceVisibilityProto {
  PUBLIC = 1;
  PRIVATE = 2;
  APPLICATION = 3;
}

enum LocalResourceTypeProto {
  ARCHIVE = 1;
  FILE = 2;
  PATTERN = 3;
}

message LocalResourceProto {
  optional URLProto resource = 1;
  optional int64 size = 2;
  optional int64 timestamp = 3;
  optional LocalResourceTypeProto type = 4;
  optional LocalResourceVisibilityProto visibility = 5;
  optional string pattern = 6;
  optional bool should_be_uploaded_to_shared_cache = 7;
}

message StringLongMapProto {
  required string key  = 1;
  required int64 value = 2;
}

message StringFloatMapProto {
  required string key  = 1;
  required float value = 2;
}

message ApplicationResourceUsageReportProto {
  optional int32 num_used_containers = 1;
  optional int32 num_reserved_containers = 2;
  optional ResourceProto used_resources = 3;
  optional ResourceProto reserved_resources = 4;
  optional ResourceProto needed_resources = 5;
  optional int64 memory_seconds = 6;
  optional int64 vcore_seconds = 7;
  optional float queue_usage_percentage = 8;
  optional float cluster_usage_percentage = 9;
  optional int64 preempted_memory_seconds = 10;
  optional int64 preempted_vcore_seconds = 11;
  repeated StringLongMapProto application_resource_usage_map = 12;
  repeated StringLongMapProto application_preempted_resource_usage_map = 13;
}

message ApplicationReportProto {
  optional ApplicationIdProto applicationId = 1;
  optional string user = 2;
  optional string queue = 3;
  optional string name = 4;
  optional string host = 5;
  optional int32 rpc_port = 6;
  optional hadoop.common.TokenProto client_to_am_token = 7;
  optional YarnApplicationStateProto yarn_application_state = 8;
  optional string trackingUrl = 9;
  optional string diagnostics = 10 [default = "N/A"];
  optional int64 startTime = 11;
  optional int64 finishTime = 12;
  optional FinalApplicationStatusProto final_application_status = 13;
  optional ApplicationResourceUsageReportProto app_resource_Usage = 14;
  optional string originalTrackingUrl = 15;
  optional ApplicationAttemptIdProto currentApplicationAttemptId = 16;
  optional float progress = 17;
  optional string applicationType = 18;
  optional hadoop.common.TokenProto am_rm_token = 19;
  repeated string applicationTags = 20;
  optional LogAggregationStatusProto log_aggregation_status = 21;
  optional bool unmanaged_application = 22 [default = false];
  optional PriorityProto priority = 23;
  optional string appNodeLabelExpression = 24;
  optional string amNodeLabelExpression = 25;
  repeated AppTimeoutsMapProto appTimeouts = 26;
  optional int64 launchTime = 27;
  optional int64 submitTime = 28;
  optional string rmClusterId = 29;
}

message AppTimeoutsMapProto {
  optional ApplicationTimeoutTypeProto application_timeout_type = 1;
  optional ApplicationTimeoutProto application_timeout = 2;
}

message ApplicationTimeoutProto {
  required ApplicationTimeoutTypeProto application_timeout_type = 1;
  optional string expire_time = 2;
  optional int64 remaining_time = 3;
}

enum LogAggregationStatusProto {
  LOG_DISABLED = 1;
  LOG_NOT_START = 2;
  LOG_RUNNING = 3;
  LOG_SUCCEEDED = 4;
  LOG_FAILED = 5;
  LOG_TIME_OUT = 6;
  LOG_RUNNING_WITH_FAILURE = 7;
}

message ApplicationAttemptReportProto {
  optional ApplicationAttemptIdProto application_attempt_id = 1;
  optional string host = 2;
  optional int32 rpc_port = 3;
  optional string tracking_url = 4;
  optional string diagnostics = 5 [default = "N/A"];
  optional YarnApplicationAttemptStateProto yarn_application_attempt_state = 6;
  optional ContainerIdProto am_container_id = 7;
  optional string original_tracking_url = 8;
  optional int64 startTime = 9;
  optional int64 finishTime = 10;
}

enum NodeStateProto {
  NS_NEW = 1; 
  NS_RUNNING = 2; 
  NS_UNHEALTHY = 3;
  NS_DECOMMISSIONED = 4; 
  NS_LOST = 5;
  NS_REBOOTED = 6;
  NS_DECOMMISSIONING = 7;
  NS_SHUTDOWN = 8;
}

message NodeIdProto {
  optional string host = 1;
  optional int32 port = 2;
}

enum NodeUpdateTypeProto {
  NODE_USABLE = 0;
  NODE_UNUSABLE = 1;
  NODE_DECOMMISSIONING = 2;
}

message NodeReportProto {
  optional NodeIdProto nodeId = 1;
  optional string httpAddress = 2;
  optional string rackName = 3;
  optional ResourceProto used = 4;
  optional ResourceProto capability = 5;
  optional int32 numContainers = 6;
  optional NodeStateProto node_state = 7;
  optional string health_report = 8;
  optional int64 last_health_report_time = 9;
  repeated string node_labels = 10;
  optional ResourceUtilizationProto containers_utilization = 11;
  optional ResourceUtilizationProto node_utilization = 12;
  optional uint32 decommissioning_timeout = 13;
  optional NodeUpdateTypeProto node_update_type = 14;
  repeated NodeAttributeProto node_attributes = 15;
}

message NodeIdToLabelsProto {
  optional NodeIdProto nodeId = 1;
  repeated string nodeLabels = 2;
}

message LabelsToNodeIdsProto {
  optional string nodeLabels = 1;
  repeated NodeIdProto nodeId = 2;
}

message NodeLabelProto {
  optional string name = 1;
  optional bool isExclusive = 2 [default = true]; 
}

enum NodeAttributeTypeProto {
  STRING = 1;
}

message NodeAttributeKeyProto {
  optional string attributePrefix = 1 [default="rm.yarn.io"];
  required string attributeName = 2;
}

message NodeAttributeProto {
  required NodeAttributeKeyProto attributeKey = 1;
  optional NodeAttributeTypeProto attributeType = 2 [default = STRING];
  optional string attributeValue = 3 [default=""];
}


message NodeAttributeInfoProto {
  required NodeAttributeKeyProto attributeKey = 1;
  required NodeAttributeTypeProto attributeType = 2;
}

message NodeToAttributeValueProto {
  required string hostname = 1;
  required string attributeValue = 2;
}

message AttributeToNodesProto {
  required NodeAttributeKeyProto nodeAttribute = 1;
  repeated NodeToAttributeValueProto nodeValueMap = 2;
}

message NodeToAttributesProto {
  optional string node = 1;
  repeated NodeAttributeProto nodeAttributes = 2;
}

enum ContainerTypeProto {
  APPLICATION_MASTER = 1;
  TASK = 2;
}

enum ExecutionTypeProto {
  GUARANTEED = 1;
  OPPORTUNISTIC = 2;
}

message DeregisterSubClustersProto {
  optional string subClusterId = 1;
  optional string deregisterState = 2;
  optional string lastHeartBeatTime = 3;
  optional string information = 4;
  optional string subClusterState = 5;
}

message FederationQueueWeightProto {
  optional string routerWeight = 1;
  optional string amrmWeight = 2;
  optional string headRoomAlpha = 3;
  optional string queue = 4;
  optional string policyManagerClassName = 5;
}

message FederationSubClusterProto {
  optional string subClusterId = 1;
  optional string lastHeartBeatTime = 2;
  optional string subClusterState = 3;
}

////////////////////////////////////////////////////////////////////////
////// From AM_RM_Protocol /////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
message ResourceRequestProto {
  optional PriorityProto priority = 1;
  optional string resource_name = 2;
  optional ResourceProto capability = 3;
  optional int32 num_containers = 4;
  optional bool relax_locality = 5 [default = true];
  optional string node_label_expression = 6;
  optional ExecutionTypeRequestProto execution_type_request = 7;
  optional int64 allocation_request_id = 8 [default = -1];
}

message ExecutionTypeRequestProto {
  optional ExecutionTypeProto execution_type = 1 [default = GUARANTEED];
  optional bool enforce_execution_type = 2 [default = false];
}

message SchedulingRequestProto {
  optional int64 allocationRequestId = 1 [default = 0];
  optional PriorityProto priority = 2;
  optional ExecutionTypeRequestProto executionType = 3;
  repeated string allocationTags = 4;
  optional ResourceSizingProto resourceSizing = 5;
  optional PlacementConstraintProto placementConstraint = 6;
}

message ResourceSizingProto {
  optional int32 numAllocations = 1;
  optional ResourceProto resources = 2;
}

enum AMCommandProto {
  AM_RESYNC = 1;
  AM_SHUTDOWN = 2;
}

enum RejectionReasonProto {
  RRP_COULD_NOT_PLACE_ON_NODE = 1;
  RRP_COULD_NOT_SCHEDULE_ON_NODE = 2;
}

message RejectedSchedulingRequestProto {
  required RejectionReasonProto reason = 1;
  required SchedulingRequestProto request = 2;
}

message PreemptionMessageProto {
  optional StrictPreemptionContractProto strictContract = 1;
  optional PreemptionContractProto contract = 2;
}

message StrictPreemptionContractProto {
  repeated PreemptionContainerProto container = 1;
}

message PreemptionContractProto {
  repeated PreemptionResourceRequestProto resource = 1;
  repeated PreemptionContainerProto container = 2;
}

message PreemptionContainerProto {
  optional ContainerIdProto id = 1;
}

message PreemptionResourceRequestProto {
  optional ResourceRequestProto resource = 1;
}

message ResourceBlacklistRequestProto {
  repeated string blacklist_additions = 1; 
  repeated string blacklist_removals = 2; 
}

////////////////////////////////////////////////////////////////////////
////// From client_RM_Protocol /////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
message ApplicationSubmissionContextProto {
  optional ApplicationIdProto application_id = 1;
  optional string application_name = 2 [default = "N/A"];
  optional string queue = 3 [default = "default"];
  optional PriorityProto priority = 4;
  optional ContainerLaunchContextProto am_container_spec = 5;
  optional bool cancel_tokens_when_complete = 6 [default = true];
  optional bool unmanaged_am = 7 [default = false];
  optional int32 maxAppAttempts = 8 [default = 0];
  optional ResourceProto resource = 9;
  optional string applicationType = 10 [default = "YARN"];
  optional bool keep_containers_across_application_attempts = 11 [default = false];
  repeated string applicationTags = 12;
  optional int64 attempt_failures_validity_interval = 13 [default = -1];
  optional LogAggregationContextProto log_aggregation_context = 14;
  optional ReservationIdProto reservation_id = 15;
  optional string node_label_expression = 16;
  repeated ResourceRequestProto am_container_resource_request = 17;
  repeated ApplicationTimeoutMapProto application_timeouts = 18;
  repeated StringStringMapProto application_scheduling_properties = 19;
}

enum ApplicationTimeoutTypeProto {
  APP_TIMEOUT_LIFETIME = 1;
}

message ApplicationTimeoutMapProto {
  optional ApplicationTimeoutTypeProto application_timeout_type = 1;
  optional int64 timeout = 2;
}

message ApplicationUpdateTimeoutMapProto {
  optional ApplicationTimeoutTypeProto application_timeout_type = 1;
  optional string expire_time = 2;
}

message LogAggregationContextProto {
 optional string include_pattern = 1 [default = ".*"];
 optional string exclude_pattern = 2 [default = ""];
 optional string rolled_logs_include_pattern = 3 [default = ""];
 optional string rolled_logs_exclude_pattern = 4 [default = ".*"];
 optional string log_aggregation_policy_class_name = 5;
 optional string log_aggregation_policy_parameters = 6;
}

enum ApplicationAccessTypeProto {
  APPACCESS_VIEW_APP = 1;
  APPACCESS_MODIFY_APP = 2;
}

message ApplicationACLMapProto {
  optional ApplicationAccessTypeProto accessType = 1;
  optional string acl = 2 [default = " "];
}

message YarnClusterMetricsProto {
  optional int32 num_node_managers = 1;
  optional int32 num_decommissioned_nms = 2;
  optional int32 num_active_nms = 3;
  optional int32 num_lost_nms = 4;
  optional int32 num_unhealthy_nms = 5;
  optional int32 num_rebooted_nms = 6;
  optional int32 num_decommissioning_nms = 7;
  optional int32 num_shutdown_nms = 8;
}

enum QueueStateProto {
  Q_STOPPED = 1;
  Q_RUNNING = 2;
  Q_DRAINING = 3;
}

message QueueStatisticsProto {
  optional int64 numAppsSubmitted = 1;
  optional int64 numAppsRunning = 2;
  optional int64 numAppsPending = 3;
  optional int64 numAppsCompleted = 4;
  optional int64 numAppsKilled = 5;
  optional int64 numAppsFailed = 6;
  optional int64 numActiveUsers = 7;
  optional int64 availableMemoryMB = 8;
  optional int64 allocatedMemoryMB = 9;
  optional int64 pendingMemoryMB = 10;
  optional int64 reservedMemoryMB = 11;
  optional int64 availableVCores = 12;
  optional int64 allocatedVCores = 13;
  optional int64 pendingVCores = 14;
  optional int64 reservedVCores = 15;
  optional int64 allocatedContainers = 16;
  optional int64 pendingContainers = 17;
  optional int64 reservedContainers = 18;
}

message QueueInfoProto {
  optional string queueName = 1;
  optional float capacity = 2;
  optional float maximumCapacity = 3;
  optional float currentCapacity = 4;
  optional QueueStateProto state = 5;
  repeated QueueInfoProto childQueues = 6;
  repeated ApplicationReportProto applications = 7;
  repeated string accessibleNodeLabels = 8;
  optional string defaultNodeLabelExpression = 9;
  optional QueueStatisticsProto queueStatistics = 10;
  optional bool preemptionDisabled = 11;
  repeated QueueConfigurationsMapProto queueConfigurationsMap = 12;
  optional bool intraQueuePreemptionDisabled = 13;
  optional float weight = 14;
  optional string queuePath = 15;
  optional int32 maxParallelApps = 16;
  optional string schedulerType = 17;
  optional int32 minResourceVCore = 18;
  optional int64 minResourceMemory = 19;
  optional int32 maxResourceVCore = 20;
  optional int64 maxResourceMemory = 21;
  optional int32 reservedResourceVCore = 22;
  optional int64 reservedResourceMemory = 23;
  optional int32 steadyFairShareVCore = 24;
  optional int64 steadyFairShareMemory = 25;
  optional string subClusterId = 26;
  optional int32 maxRunningApp = 27;
}

message QueueConfigurationsProto {
    optional float capacity = 1;
    optional float absoluteCapacity = 2;
    optional float maxCapacity = 3;
    optional float absoluteMaxCapacity = 4;
    optional float maxAMPercentage = 5;
    optional ResourceProto effectiveMinCapacity = 6;
    optional ResourceProto effectiveMaxCapacity = 7;
    optional ResourceProto configuredMinCapacity = 8;
    optional ResourceProto configuredMaxCapacity = 9;
}

message QueueConfigurationsMapProto {
    required string partitionName = 1;
    optional QueueConfigurationsProto queueConfigurations = 2;
}

enum QueueACLProto {
  QACL_SUBMIT_APPLICATIONS = 1;
  QACL_ADMINISTER_QUEUE = 2;
}

message QueueUserACLInfoProto {
  optional string queueName = 1;
  repeated QueueACLProto userAcls = 2;
}

enum SignalContainerCommandProto {
  OUTPUT_THREAD_DUMP = 1;
  GRACEFUL_SHUTDOWN = 2;
  FORCEFUL_SHUTDOWN = 3;
}

////////////////////////////////////////////////////////////////////////
////// Placement constraints ///////////////////////////////////////////
////////////////////////////////////////////////////////////////////////

message PlacementConstraintProto {
  optional SimplePlacementConstraintProto simpleConstraint = 1;
  optional CompositePlacementConstraintProto compositeConstraint = 2;
}

enum NodeAttributeOpCodeProto {
  NO_OP = 1;
  EQ = 2;
  NE = 3;
}

message SimplePlacementConstraintProto {
  required string scope = 1;
  repeated PlacementConstraintTargetProto targetExpressions = 2;
  optional int32 minCardinality = 3;
  optional int32 maxCardinality = 4;
  optional NodeAttributeOpCodeProto attributeOpCode = 5;
}

message PlacementConstraintTargetProto {
  enum TargetType {
    NODE_ATTRIBUTE = 1;
    ALLOCATION_TAG = 2;
    SELF = 3;
  }

  required TargetType targetType = 1;
  optional string targetKey = 2;
  repeated string targetValues = 3;
}

message TimedPlacementConstraintProto {
  enum DelayUnit {
    MILLISECONDS = 1;
    OPPORTUNITIES = 2;
  }

  required PlacementConstraintProto placementConstraint = 1;
  required int64 schedulingDelay = 2;
  optional DelayUnit delayUnit = 3 [ default = MILLISECONDS ];
}

message CompositePlacementConstraintProto {
  enum CompositeType {
    // All children constraints have to be satisfied.
    AND = 1;
    // One of the children constraints has to be satisfied.
    OR = 2;
    // Attempt to satisfy the first child constraint for delays[0] units (e.g.,
    // millisec or heartbeats). If this fails, try to satisfy the second child
    // constraint for delays[1] units and so on.
    DELAYED_OR = 3;
  }

  required CompositeType compositeType = 1;
  repeated PlacementConstraintProto childConstraints = 2;
  repeated TimedPlacementConstraintProto timedChildConstraints = 3;
}

// This associates a set of allocation tags to a Placement Constraint.
message PlacementConstraintMapEntryProto {
  repeated string allocation_tags = 1;
  optional PlacementConstraintProto placement_constraint = 2;
}

////////////////////////////////////////////////////////////////////////
////// From reservation_protocol /////////////////////////////////////
////////////////////////////////////////////////////////////////////////

message ReservationIdProto {
  optional int64 id = 1;
  optional int64 cluster_timestamp = 2;
}

message ReservationRequestProto {
  optional ResourceProto capability = 1;
  optional int32 num_containers = 2 [default = 1];
  optional int32 concurrency = 3 [default = 1];
  optional int64 duration = 4 [default = -1];
}

message ReservationRequestsProto {
  repeated ReservationRequestProto reservation_resources = 1;
  optional ReservationRequestInterpreterProto interpreter = 2 [default = R_ALL];
}

message ReservationDefinitionProto {
  optional ReservationRequestsProto reservation_requests = 1;
  optional int64 arrival = 2;
  optional int64 deadline = 3;
  optional string reservation_name = 4;
  optional string recurrence_expression = 5 [default = "0"];
  optional PriorityProto priority = 6;
}

message ResourceAllocationRequestProto {
  optional int64 start_time = 1;
  optional int64 end_time = 2;
  optional ResourceProto resource = 3;
}

message ReservationAllocationStateProto {
  optional ReservationDefinitionProto reservation_definition = 1;
  repeated ResourceAllocationRequestProto allocation_requests = 2;
  optional int64 start_time = 3;
  optional int64 end_time = 4;
  optional string user = 5;
  optional bool contains_gangs = 6;
  optional int64 acceptance_time = 7;
  optional ReservationIdProto reservation_id = 8;
}

enum ReservationRequestInterpreterProto {
  R_ANY = 0;
  R_ALL = 1;
  R_ORDER = 2;
  R_ORDER_NO_GAP = 3;
 }

////////////////////////////////////////////////////////////////////////
////// From container_manager //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////

message ContainerLaunchContextProto {
  repeated StringLocalResourceMapProto localResources = 1;
  optional bytes tokens = 2;
  repeated StringBytesMapProto service_data = 3;
  repeated StringStringMapProto environment = 4;
  repeated string command = 5;
  repeated ApplicationACLMapProto application_ACLs = 6;
  optional ContainerRetryContextProto container_retry_context = 7;
  optional bytes tokens_conf = 8;

}

message ContainerStatusProto {
  optional ContainerIdProto container_id = 1;
  optional ContainerStateProto state = 2;
  optional string diagnostics = 3 [default = "N/A"];
  optional int32 exit_status = 4 [default = -1000];
  optional ResourceProto capability = 5;
  optional ExecutionTypeProto executionType = 6 [default = GUARANTEED];
  repeated StringStringMapProto container_attributes = 7;
  optional ContainerSubStateProto container_sub_state = 8;
}

enum ContainerExitStatusProto {
  SUCCESS = 0;
  INVALID = -1000;
  ABORTED = -100;
  DISKS_FAILED = -101;
}

message ContainerRetryContextProto {
  optional ContainerRetryPolicyProto retry_policy = 1 [default = NEVER_RETRY];
  repeated int32 error_codes = 2;
  optional int32 max_retries = 3 [default = 0];
  optional int32 retry_interval = 4 [default = 0];
  optional int64 failures_validity_interval = 5 [default = -1];
}

enum ContainerRetryPolicyProto {
  NEVER_RETRY = 0;
  RETRY_ON_ALL_ERRORS = 1;
  RETRY_ON_SPECIFIC_ERROR_CODES = 2;
}

////////////////////////////////////////////////////////////////////////
////// From common//////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
message StringLocalResourceMapProto {
  optional string key = 1;
  optional LocalResourceProto value = 2;
}

message StringStringMapProto {
  optional string key = 1;
  optional string value = 2;
}

message StringBytesMapProto {
  optional string key = 1;
  optional bytes value = 2;
}

message CollectorInfoProto {
  optional string collector_addr = 1;
  optional hadoop.common.TokenProto collector_token = 2;
}
