Skip to content

Commit

Permalink
YARN-4957. Add getNewReservation in ApplicationClientProtocol (Sean P…
Browse files Browse the repository at this point in the history
…o via curino)
  • Loading branch information
Carlo Curino committed May 25, 2016
1 parent 3c83cee commit 013532a
Show file tree
Hide file tree
Showing 34 changed files with 1,634 additions and 517 deletions.
Expand Up @@ -44,6 +44,7 @@
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.yarn.api.ApplicationClientProtocol;
import org.apache.hadoop.yarn.api.protocolrecords.GetNewReservationResponse;
import org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteRequest;
import org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteResponse;
import org.apache.hadoop.yarn.api.protocolrecords.ReservationListRequest;
Expand Down Expand Up @@ -435,6 +436,12 @@ public void moveApplicationAcrossQueues(ApplicationId appId, String queue)
client.moveApplicationAcrossQueues(appId, queue);
}

@Override
public GetNewReservationResponse createReservation() throws YarnException,
IOException {
return client.createReservation();
}

@Override
public ReservationSubmissionResponse submitReservation(
ReservationSubmissionRequest request) throws YarnException, IOException {
Expand Down
Expand Up @@ -96,6 +96,8 @@
import org.apache.hadoop.yarn.api.protocolrecords.GetLabelsToNodesResponse;
import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationResponse;
import org.apache.hadoop.yarn.api.protocolrecords.GetNewReservationRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetNewReservationResponse;
import org.apache.hadoop.yarn.api.protocolrecords.GetNodesToLabelsRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetNodesToLabelsResponse;
import org.apache.hadoop.yarn.api.protocolrecords.GetQueueInfoRequest;
Expand Down Expand Up @@ -423,6 +425,12 @@ public GetContainersResponse getContainers(GetContainersRequest request)
return null;
}

@Override
public GetNewReservationResponse getNewReservation(
GetNewReservationRequest request) throws YarnException, IOException {
return null;
}

@Override
public ReservationSubmissionResponse submitReservation(
ReservationSubmissionRequest request) throws YarnException, IOException {
Expand Down
Expand Up @@ -37,6 +37,8 @@
import org.apache.hadoop.yarn.api.protocolrecords.GetLabelsToNodesResponse;
import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationResponse;
import org.apache.hadoop.yarn.api.protocolrecords.GetNewReservationRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetNewReservationResponse;
import org.apache.hadoop.yarn.api.protocolrecords.GetNodesToLabelsRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetNodesToLabelsResponse;
import org.apache.hadoop.yarn.api.protocolrecords.GetQueueInfoRequest;
Expand Down Expand Up @@ -301,6 +303,28 @@ public GetQueueUserAclsInfoResponse getQueueUserAcls(
public MoveApplicationAcrossQueuesResponse moveApplicationAcrossQueues(
MoveApplicationAcrossQueuesRequest request) throws YarnException, IOException;

/**
* <p>The interface used by clients to obtain a new {@link ReservationId} for
* submitting new reservations.</p>
*
* <p>The <code>ResourceManager</code> responds with a new, unique,
* {@link ReservationId} which is used by the client to submit
* a new reservation.</p>
*
* @param request to get a new <code>ReservationId</code>
* @return response containing the new <code>ReservationId</code> to be used
* to submit a new reservation
* @throws YarnException if the reservation system is not enabled.
* @throws IOException on IO failures.
* @see #submitReservation(ReservationSubmissionRequest)
*/
@Public
@Unstable
@Idempotent
GetNewReservationResponse getNewReservation(
GetNewReservationRequest request)
throws YarnException, IOException;

/**
* <p>
* The interface used by clients to submit a new reservation to the
Expand Down Expand Up @@ -349,6 +373,7 @@ public MoveApplicationAcrossQueuesResponse moveApplicationAcrossQueues(
*/
@Public
@Unstable
@Idempotent
public ReservationSubmissionResponse submitReservation(
ReservationSubmissionRequest request) throws YarnException, IOException;

Expand Down
@@ -0,0 +1,41 @@
/**
* 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.
*/

package org.apache.hadoop.yarn.api.protocolrecords;

import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.yarn.util.Records;

/**
* <p>The request sent by clients to get a new {@code ReservationId} for
* submitting an reservation.</p>
*
* {@code ApplicationClientProtocol#getNewReservation(GetNewReservationRequest)}
*/
@Public
@Unstable
public abstract class GetNewReservationRequest {
@Public
@Unstable
public static GetNewReservationRequest newInstance() {
GetNewReservationRequest request =
Records.newRecord(GetNewReservationRequest.class);
return request;
}
}
@@ -0,0 +1,71 @@
/**
* 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.
*/

package org.apache.hadoop.yarn.api.protocolrecords;

import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Stable;
import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.yarn.api.records.ReservationId;
import org.apache.hadoop.yarn.util.Records;

/**
* <p>The response sent by the <code>ResourceManager</code> to the client for
* a request to get a new {@link ReservationId} for submitting reservations.</p>
*
* <p>Clients can submit an reservation with the returned
* {@link ReservationId}.</p>
*
* {@code ApplicationClientProtocol#getNewReservation(GetNewReservationRequest)}
*/
@Public
@Unstable
public abstract class GetNewReservationResponse {

@Private
@Unstable
public static GetNewReservationResponse newInstance(
ReservationId reservationId) {
GetNewReservationResponse response =
Records.newRecord(GetNewReservationResponse.class);
response.setReservationId(reservationId);
return response;
}

/**
* Get a new {@link ReservationId} to be used to submit a reservation.
*
* @return a {@link ReservationId} representing the unique id to identify
* a reservation with which it was submitted.
*/
@Public
@Unstable
public abstract ReservationId getReservationId();

/**
* Set a new {@link ReservationId} to be used to submit a reservation.
*
* @param reservationId a {@link ReservationId} representing the unique id to
* identify a reservation with which it was submitted.
*/
@Private
@Unstable
public abstract void setReservationId(ReservationId reservationId);

}
Expand Up @@ -22,6 +22,7 @@
import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.yarn.api.records.QueueInfo;
import org.apache.hadoop.yarn.api.records.ReservationDefinition;
import org.apache.hadoop.yarn.api.records.ReservationId;
import org.apache.hadoop.yarn.util.Records;

/**
Expand All @@ -38,11 +39,13 @@ public abstract class ReservationSubmissionRequest {
@Public
@Unstable
public static ReservationSubmissionRequest newInstance(
ReservationDefinition reservationDefinition, String queueName) {
ReservationDefinition reservationDefinition, String queueName,
ReservationId reservationId) {
ReservationSubmissionRequest request =
Records.newRecord(ReservationSubmissionRequest.class);
request.setReservationDefinition(reservationDefinition);
request.setQueue(queueName);
request.setReservationId(reservationId);
return request;
}

Expand Down Expand Up @@ -94,4 +97,24 @@ public abstract void setReservationDefinition(
@Unstable
public abstract void setQueue(String queueName);

/**
* Get the reservation id that corresponds to the reservation submission.
*
* @return reservation id that will be used to identify the reservation
* submission.
*/
@Public
@Unstable
public abstract ReservationId getReservationId();

/**
* Set the reservation id that corresponds to the reservation submission.
*
* @param reservationId reservation id that will be used to identify the
* reservation submission.
*/
@Public
@Unstable
public abstract void setReservationId(ReservationId reservationId);

}
Expand Up @@ -21,56 +21,28 @@
import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.yarn.api.records.ReservationDefinition;
import org.apache.hadoop.yarn.api.records.ReservationId;
import org.apache.hadoop.yarn.util.Records;

/**
* {@link ReservationSubmissionResponse} contains the answer of the admission
* control system in the {@code ResourceManager} to a reservation create
* operation. Response contains a {@link ReservationId} if the operation was
* successful, if not an exception reporting reason for a failure.
*
* @see ReservationDefinition
*
* <p>The response sent by the <code>ResourceManager</code> to a client on
* reservation submission.</p>
*
* <p>Currently, this is empty.</p>
*
* {@code ApplicationClientProtocol#submitReservation(
* ReservationSubmissionRequest)}
*
*/
@Public
@Unstable
public abstract class ReservationSubmissionResponse {

@Private
@Unstable
public static ReservationSubmissionResponse newInstance(
ReservationId reservationId) {
public static ReservationSubmissionResponse newInstance() {
ReservationSubmissionResponse response =
Records.newRecord(ReservationSubmissionResponse.class);
response.setReservationId(reservationId);
return response;
}

/**
* Get the {@link ReservationId}, that corresponds to a valid resource
* allocation in the scheduler (between start and end time of this
* reservation)
*
* @return the {@link ReservationId} representing the unique id of the
* corresponding reserved resource allocation in the scheduler
*/
@Public
@Unstable
public abstract ReservationId getReservationId();

/**
* Set the {@link ReservationId}, that correspond to a valid resource
* allocation in the scheduler (between start and end time of this
* reservation)
*
* @param reservationId the {@link ReservationId} representing the the unique
* id of the corresponding reserved resource allocation in the
* scheduler
*/
@Private
@Unstable
public abstract void setReservationId(ReservationId reservationId);

}
Expand Up @@ -50,6 +50,7 @@ service ApplicationClientProtocolService {
rpc getApplicationAttempts (GetApplicationAttemptsRequestProto) returns (GetApplicationAttemptsResponseProto);
rpc getContainerReport (GetContainerReportRequestProto) returns (GetContainerReportResponseProto);
rpc getContainers (GetContainersRequestProto) returns (GetContainersResponseProto);
rpc getNewReservation (GetNewReservationRequestProto) returns (GetNewReservationResponseProto);
rpc submitReservation (ReservationSubmissionRequestProto) returns (ReservationSubmissionResponseProto);
rpc updateReservation (ReservationUpdateRequestProto) returns (ReservationUpdateResponseProto);
rpc deleteReservation (ReservationDeleteRequestProto) returns (ReservationDeleteResponseProto);
Expand Down
Expand Up @@ -367,13 +367,20 @@ message ReleaseSharedCacheResourceResponseProto {
// reservation_protocol
//////////////////////////////////////////////////////

message GetNewReservationRequestProto {
}

message GetNewReservationResponseProto {
optional ReservationIdProto reservation_id = 1;
}

message ReservationSubmissionRequestProto {
optional string queue = 1;
optional ReservationDefinitionProto reservation_definition = 2;
optional ReservationIdProto reservation_id = 3;
}

message ReservationSubmissionResponseProto {
optional ReservationIdProto reservation_id = 1;
}

message ReservationUpdateRequestProto {
Expand Down
Expand Up @@ -32,6 +32,7 @@
import org.apache.hadoop.io.Text;
import org.apache.hadoop.service.AbstractService;
import org.apache.hadoop.yarn.api.ApplicationClientProtocol;
import org.apache.hadoop.yarn.api.protocolrecords.GetNewReservationResponse;
import org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteRequest;
import org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteResponse;
import org.apache.hadoop.yarn.api.protocolrecords.ReservationListRequest;
Expand Down Expand Up @@ -533,6 +534,20 @@ public abstract List<ContainerReport> getContainers(
public abstract void moveApplicationAcrossQueues(ApplicationId appId,
String queue) throws YarnException, IOException;

/**
* <p>
* Obtain a {@link GetNewReservationResponse} for a new reservation,
* which contains the {@link ReservationId} object.
* </p>
*
* @return The {@link GetNewReservationResponse} containing a new
* {@link ReservationId} object.
* @throws YarnException if reservation cannot be created.
* @throws IOException if reservation cannot be created.
*/
public abstract GetNewReservationResponse createReservation()
throws YarnException, IOException;

/**
* <p>
* The interface used by clients to submit a new reservation to the
Expand Down Expand Up @@ -666,7 +681,7 @@ public abstract ReservationDeleteResponse deleteReservation(
* @return response that contains information about reservations that are
* being searched for.
* @throws YarnException if the request is invalid
* @throws IOException
* @throws IOException if the request failed otherwise
*
*/
@Public
Expand Down Expand Up @@ -725,8 +740,10 @@ public abstract Map<NodeLabel, Set<NodeId>> getLabelsToNodes(
* </p>
*
* @return cluster node labels collection
* @throws YarnException
* @throws IOException
* @throws YarnException when there is a failure in
* {@see ApplicationClientProtocol}
* @throws IOException when there is a failure in
* {@see ApplicationClientProtocol}
*/
@Public
@Unstable
Expand Down

0 comments on commit 013532a

Please sign in to comment.