Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YARN-5025. Container move (relocation) between nodes #134

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import java.util.concurrent.atomic.AtomicInteger;

import org.apache.hadoop.yarn.api.protocolrecords.CommitResponse;
import org.apache.hadoop.yarn.api.protocolrecords.GetContainerLaunchContextRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetContainerLaunchContextResponse;
import org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceRequest;
import org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceResponse;
import org.apache.hadoop.yarn.api.protocolrecords.ReInitializeContainerRequest;
Expand Down Expand Up @@ -481,6 +483,13 @@ public ResourceLocalizationResponse localize(
ResourceLocalizationRequest request) throws YarnException, IOException {
return null;
}

@Override
public GetContainerLaunchContextResponse getContainerLaunchContext(
GetContainerLaunchContextRequest request) throws YarnException, IOException {
throw new UnsupportedOperationException("getting the container launch context is not " +
"supported for this implementation of ContainerManagementProtocol");
}

@Override
public ReInitializeContainerResponse reInitializeContainer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@
import org.apache.hadoop.mapreduce.v2.util.MRBuilderUtils;
import org.apache.hadoop.yarn.api.ContainerManagementProtocol;
import org.apache.hadoop.yarn.api.protocolrecords.CommitResponse;
import org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceRequest;
import org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceResponse;
import org.apache.hadoop.yarn.api.protocolrecords.GetContainerLaunchContextRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetContainerLaunchContextResponse;
import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesResponse;
import org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceRequest;
import org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceResponse;
import org.apache.hadoop.yarn.api.protocolrecords.ReInitializeContainerRequest;
import org.apache.hadoop.yarn.api.protocolrecords.ReInitializeContainerResponse;
import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationRequest;
Expand All @@ -70,7 +72,8 @@
import org.apache.hadoop.yarn.api.records.Priority;
import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.api.records.Token;
import org.apache.hadoop.yarn.client.api.impl.ContainerManagementProtocolProxy.ContainerManagementProtocolProxyData;
import org.apache.hadoop.yarn.client.api.impl.ContainerManagementProtocolProxy
.ContainerManagementProtocolProxyData;
import org.apache.hadoop.yarn.event.Event;
import org.apache.hadoop.yarn.event.EventHandler;
import org.apache.hadoop.yarn.exceptions.YarnException;
Expand Down Expand Up @@ -486,6 +489,13 @@ public ResourceLocalizationResponse localize(
ResourceLocalizationRequest request) throws YarnException, IOException {
return null;
}

@Override
public GetContainerLaunchContextResponse getContainerLaunchContext(
GetContainerLaunchContextRequest request) throws YarnException, IOException {
throw new UnsupportedOperationException("getting the container launch context is not " +
"supported for this implementation of ContainerManagementProtocol");
}

@Override
public ReInitializeContainerResponse reInitializeContainer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import org.apache.hadoop.classification.InterfaceStability.Stable;
import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.yarn.api.protocolrecords.CommitResponse;
import org.apache.hadoop.yarn.api.protocolrecords.GetContainerLaunchContextRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetContainerLaunchContextResponse;
import org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceRequest;
import org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceResponse;
import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesRequest;
Expand Down Expand Up @@ -51,7 +53,7 @@
/**
* <p>The protocol between an <code>ApplicationMaster</code> and a
* <code>NodeManager</code> to start/stop and increase resource of containers
* and to get status of running containers.</p>
* and to get status and launch context of running containers.</p>
*
* <p>If security is enabled the <code>NodeManager</code> verifies that the
* <code>ApplicationMaster</code> has truly been allocated the container
Expand Down Expand Up @@ -220,6 +222,22 @@ SignalContainerResponse signalToContainer(SignalContainerRequest request)
@Unstable
ResourceLocalizationResponse localize(ResourceLocalizationRequest request)
throws YarnException, IOException;

/**
* Gets container launch context for a container specified in
* {@link GetContainerLaunchContextRequest}.
* This protocol is only used by the container relocation logic, between node managers, to
* transfer the launch context of the container to be relocated to the target node.
*
* @param request specifies the id of the container for which the launch context is requested
* @return Response that contains the requested container launch context
* @throws YarnException
* @throws IOException
*/
@Public
@Stable
GetContainerLaunchContextResponse getContainerLaunchContext(
GetContainerLaunchContextRequest request) throws YarnException, IOException;

/**
* ReInitialize the Container with a new Launch Context.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.hadoop.yarn.api.ApplicationMasterProtocol;
import org.apache.hadoop.yarn.api.records.Container;
import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.ContainerMoveRequest;
import org.apache.hadoop.yarn.api.records.ResourceBlacklistRequest;
import org.apache.hadoop.yarn.api.records.ResourceRequest;
import org.apache.hadoop.yarn.api.records.UpdateContainerRequest;
Expand All @@ -52,6 +53,11 @@
* the <code>ResourceManager</code> about the change in
* requirements of running containers.
* </li>
* <li>
* A list of {@link ContainerMoveRequest} to inform
* the <code>ResourceManager</code> about the application's
* container relocation needs.
* </li>
* </ul>
*
* @see ApplicationMasterProtocol#allocate(AllocateRequest)
Expand All @@ -77,13 +83,27 @@ public static AllocateRequest newInstance(int responseID, float appProgress,
List<ContainerId> containersToBeReleased,
ResourceBlacklistRequest resourceBlacklistRequest,
List<UpdateContainerRequest> updateRequests) {
return newInstance(responseID, appProgress, resourceAsk,
containersToBeReleased, resourceBlacklistRequest, updateRequests,
null);
}

@Public
@Stable
public static AllocateRequest newInstance(int responseID, float appProgress,
List<ResourceRequest> resourceAsk,
List<ContainerId> containersToBeReleased,
ResourceBlacklistRequest resourceBlacklistRequest,
List<UpdateContainerRequest> updateRequests,
List<ContainerMoveRequest> moveAsk) {
AllocateRequest allocateRequest = Records.newRecord(AllocateRequest.class);
allocateRequest.setResponseId(responseID);
allocateRequest.setProgress(appProgress);
allocateRequest.setAskList(resourceAsk);
allocateRequest.setReleaseList(containersToBeReleased);
allocateRequest.setResourceBlacklistRequest(resourceBlacklistRequest);
allocateRequest.setUpdateRequests(updateRequests);
allocateRequest.setMoveAskList(moveAsk);
return allocateRequest;
}

Expand Down Expand Up @@ -211,4 +231,27 @@ public abstract void setResourceBlacklistRequest(
@Unstable
public abstract void setUpdateRequests(
List<UpdateContainerRequest> updateRequests);

/**
* Get the list of container move requests being sent by the
* <code>ApplicationMaster</code>.
*
* @return list of <code>ContainerMoveRequest</code>
* being sent by the <code>ApplicationMaster</code>.
*/
@Public
@Unstable
public abstract List<ContainerMoveRequest> getMoveAskList();

/**
* Set the list of container move requests to inform the
* <code>ResourceManager</code> about the containers that need to be
* relocated.
*
* @param containerMoveRequests list of <code>ContainerMoveRequest</code>
* for containers that need to be relocated.
*/
@Public
@Unstable
public abstract void setMoveAskList(List<ContainerMoveRequest> containerMoveRequests);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* 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.Stable;
import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.ContainerManagementProtocol;
import org.apache.hadoop.yarn.util.Records;

/**
* <p>The request sent by one <code>NodeManager</code> to another
* <code>NodeManager</code> in order to get the launch context of the container with id
* <em>containerId</em>.</p>
*
* <p>This request is used only for container relocation, where the launch context of
* the origin container is necessary for launching the relocated container on the target node.</p>
*
* @see ContainerManagementProtocol#getContainerLaunchContext(GetContainerLaunchContextRequest)
*/
public abstract class GetContainerLaunchContextRequest {

@Public
@Stable
public static GetContainerLaunchContextRequest newInstance(ContainerId containerId) {
GetContainerLaunchContextRequest request =
Records.newRecord(GetContainerLaunchContextRequest.class);
request.setContainerId(containerId);
return request;
}

/**
* Gets the container id for which the launch context is requested.
* @return the container id for which the launch context is requested
*/
@Public
@Stable
public abstract ContainerId getContainerId();

/**
* Sets the container id for which the launch context is requested.
* @param containerId the container id for which the launch context is requested
*/
@Public
@Stable
public abstract void setContainerId(ContainerId containerId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* 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.Stable;
import org.apache.hadoop.yarn.api.records.ContainerLaunchContext;
import org.apache.hadoop.yarn.util.Records;

/**
* <p>The response for a container launch context request sent between
* <code>NodeManager</code>s. It contains the requested container launch context.</p>
*
* <p>This request is used only for container relocation, where a launch context
* of the origin container is necessary for launching the relocated container on
* the target node.</p>
*/
public abstract class GetContainerLaunchContextResponse {

@Public
@Stable
public static GetContainerLaunchContextResponse newInstance(ContainerLaunchContext
containerLaunchContext) {
GetContainerLaunchContextResponse request =
Records.newRecord(GetContainerLaunchContextResponse.class);
request.setContainerLaunchContext(containerLaunchContext);
return request;
}

/**
* Gets the launch context of the requested container.
* @return the launch context of the requested container
*/
@Public
@Stable
public abstract ContainerLaunchContext getContainerLaunchContext();

/**
* Sets the launch context of the requested container.
* @param containerLaunchContext the launch context of the requested container
*/
@Public
@Stable
public abstract void setContainerLaunchContext(ContainerLaunchContext containerLaunchContext);
}
Loading