diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/launcher/TestContainerLauncher.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/launcher/TestContainerLauncher.java index ba404a5..1d1904e 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/launcher/TestContainerLauncher.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/launcher/TestContainerLauncher.java @@ -30,10 +30,15 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.atomic.AtomicInteger; +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.ReInitializationRequest; +import org.apache.hadoop.yarn.api.protocolrecords.ReInitializationResponse; import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationRequest; import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RestartResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RollbackResponse; import org.junit.Assert; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -476,5 +481,29 @@ public ResourceLocalizationResponse localize( ResourceLocalizationRequest request) throws YarnException, IOException { return null; } + + @Override + public ReInitializationResponse reInitializeContainer( + ReInitializationRequest request) throws YarnException, IOException { + return null; + } + + @Override + public RestartResponse restartContainer(ContainerId containerId) + throws YarnException, IOException { + return null; + } + + @Override + public RollbackResponse rollbackLastReInitialization( + ContainerId containerId) throws YarnException, IOException { + return null; + } + + @Override + public CommitResponse commitLastReInitialization(ContainerId containerId) + throws YarnException, IOException { + return null; + } } } diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/launcher/TestContainerLauncherImpl.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/launcher/TestContainerLauncherImpl.java index be1cad9..686e279 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/launcher/TestContainerLauncherImpl.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/launcher/TestContainerLauncherImpl.java @@ -46,12 +46,17 @@ import org.apache.hadoop.mapreduce.v2.app.launcher.ContainerLauncher.EventType; 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.GetContainerStatusesRequest; import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesResponse; +import org.apache.hadoop.yarn.api.protocolrecords.ReInitializationRequest; +import org.apache.hadoop.yarn.api.protocolrecords.ReInitializationResponse; import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationRequest; import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RestartResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RollbackResponse; import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerRequest; import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerResponse; import org.apache.hadoop.yarn.api.protocolrecords.StartContainersRequest; @@ -481,6 +486,30 @@ public ResourceLocalizationResponse localize( ResourceLocalizationRequest request) throws YarnException, IOException { return null; } + + @Override + public ReInitializationResponse reInitializeContainer( + ReInitializationRequest request) throws YarnException, IOException { + return null; + } + + @Override + public RestartResponse restartContainer(ContainerId containerId) + throws YarnException, IOException { + return null; + } + + @Override + public RollbackResponse rollbackLastReInitialization( + ContainerId containerId) throws YarnException, IOException { + return null; + } + + @Override + public CommitResponse commitLastReInitialization(ContainerId containerId) + throws YarnException, IOException { + return null; + } } @SuppressWarnings("serial") diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ContainerManagementProtocol.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ContainerManagementProtocol.java index f8f03b4..a8b35ea 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ContainerManagementProtocol.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ContainerManagementProtocol.java @@ -23,12 +23,17 @@ 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.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.GetContainerStatusesRequest; import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesResponse; +import org.apache.hadoop.yarn.api.protocolrecords.ReInitializationRequest; +import org.apache.hadoop.yarn.api.protocolrecords.ReInitializationResponse; import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationRequest; import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RestartResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RollbackResponse; import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerRequest; import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerResponse; import org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest; @@ -215,4 +220,52 @@ SignalContainerResponse signalToContainer(SignalContainerRequest request) @Unstable ResourceLocalizationResponse localize(ResourceLocalizationRequest request) throws YarnException, IOException; + + /** + * ReInitialize the Container with a new Launch Context. + * @param request Specify the new ContainerLaunchContext. + * @return Response that the ReInitialize request is accepted. + * @throws YarnException Exception specific to YARN. + * @throws IOException IOException thrown from the RPC layer. + */ + @Public + @Unstable + ReInitializationResponse reInitializeContainer( + ReInitializationRequest request) throws YarnException, IOException; + + /** + * Restart the container. + * @param containerId + * @return Response that the restart request is accepted. + * @throws YarnException Exception specific to YARN. + * @throws IOException IOException thrown from the RPC layer. + */ + @Public + @Unstable + RestartResponse restartContainer(ContainerId containerId) + throws YarnException, IOException; + + /** + * Rollback the Last ReInitialization if possible. + * @param containerId + * @return Response that the rollback request is accepted. + * @throws YarnException Exception specific to YARN. + * @throws IOException IOException thrown from the RPC layer. + */ + @Public + @Unstable + RollbackResponse rollbackLastReInitialization(ContainerId containerId) + throws YarnException, IOException; + + /** + * Commit the Last ReInitialization if possible. + * @param containerId + * @return Response that the commit request is accepted. + * @throws YarnException Exception specific to YARN. + * @throws IOException IOException thrown from the RPC layer. + */ + @Public + @Unstable + CommitResponse commitLastReInitialization(ContainerId containerId) + throws YarnException, IOException; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/CommitResponse.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/CommitResponse.java new file mode 100644 index 0000000..172ecbc --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/CommitResponse.java @@ -0,0 +1,35 @@ +/** + * 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.Unstable; +import org.apache.hadoop.yarn.util.Records; + +@Public +@Unstable +public abstract class CommitResponse { + + @Private + @Unstable + public static CommitResponse newInstance() { + return Records.newRecord(CommitResponse.class); + } +} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/ReInitializationRequest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/ReInitializationRequest.java new file mode 100644 index 0000000..2627ae4 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/ReInitializationRequest.java @@ -0,0 +1,96 @@ +/** + * 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.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.ContainerId; +import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; +import org.apache.hadoop.yarn.util.Records; + +@Public +@Unstable +public abstract class ReInitializationRequest { + + public static ReInitializationRequest newInstance(ContainerId containerId, + ContainerLaunchContext containerLaunchContext, boolean autoCommit) { + ReInitializationRequest record = + Records.newRecord(ReInitializationRequest.class); + record.setContainerId(containerId); + record.setContainerLaunchContext(containerLaunchContext); + record.setAutoCommit(autoCommit); + return record; + } + + /** + * Get the ContainerId of the container to re-initialize. + * + * @return ContainerId of the container to re-initialize. + */ + @Public + @Unstable + public abstract ContainerId getContainerId(); + + /** + * Set the ContainerId of the container to re-initialize. + * @param containerId the containerId of the container. + */ + @Private + @Unstable + public abstract void setContainerId(ContainerId containerId); + + /** + * Get the ContainerLaunchContext to re-initialize the container + * with. + * + * @return ContainerLaunchContext of to re-initialize the + * container with. + */ + @Public + @Unstable + public abstract ContainerLaunchContext getContainerLaunchContext(); + + /** + * Set the ContainerLaunchContext to re-initialize the container + * with. + * @param containerLaunchContext the Launch Context. + */ + @Private + @Unstable + public abstract void setContainerLaunchContext( + ContainerLaunchContext containerLaunchContext); + + + /** + * Check if AutoCommit is set for this ReInitialization. + * @return If AutoCommit is set for this ReInitialization. + */ + @Public + @Unstable + public abstract boolean getAutoCommit(); + + /** + * Set AutoCommit flag for this ReInitialization. + * @param autoCommit Auto Commit. + */ + @Private + @Unstable + public abstract void setAutoCommit(boolean autoCommit); +} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/ReInitializationResponse.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/ReInitializationResponse.java new file mode 100644 index 0000000..715929d --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/ReInitializationResponse.java @@ -0,0 +1,38 @@ +/** + * 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.Unstable; +import org.apache.hadoop.yarn.util.Records; + +/** + * The response to the {@link ReInitializationRequest}. + */ +@Public +@Unstable +public abstract class ReInitializationResponse { + + @Private + @Unstable + public static ReInitializationResponse newInstance() { + return Records.newRecord(ReInitializationResponse.class); + } +} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/RestartResponse.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/RestartResponse.java new file mode 100644 index 0000000..22f51c4 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/RestartResponse.java @@ -0,0 +1,38 @@ +/** + * 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.Unstable; +import org.apache.hadoop.yarn.util.Records; + +/** + * The response to a restart Container request. + */ +@Public +@Unstable +public abstract class RestartResponse { + + @Private + @Unstable + public static RestartResponse newInstance() { + return Records.newRecord(RestartResponse.class); + } +} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/RollbackResponse.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/RollbackResponse.java new file mode 100644 index 0000000..4bb6305 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/RollbackResponse.java @@ -0,0 +1,35 @@ +/** + * 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.Unstable; +import org.apache.hadoop.yarn.util.Records; + +@Public +@Unstable +public abstract class RollbackResponse { + + @Private + @Unstable + public static RollbackResponse newInstance() { + return Records.newRecord(RollbackResponse.class); + } +} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/containermanagement_protocol.proto b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/containermanagement_protocol.proto index a28fa27..9a95ca8 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/containermanagement_protocol.proto +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/containermanagement_protocol.proto @@ -28,6 +28,7 @@ option java_generic_services = true; option java_generate_equals_and_hash = true; package hadoop.yarn; +import "yarn_protos.proto"; import "yarn_service_protos.proto"; service ContainerManagementProtocolService { @@ -37,4 +38,9 @@ service ContainerManagementProtocolService { rpc increaseContainersResource(IncreaseContainersResourceRequestProto) returns (IncreaseContainersResourceResponseProto); rpc signalToContainer(SignalContainerRequestProto) returns (SignalContainerResponseProto); rpc localize(ResourceLocalizationRequestProto) returns (ResourceLocalizationResponseProto); + + rpc reInitializeContainer(ReInitializationRequestProto) returns (ReInitializationResponseProto); + rpc restartContainer(ContainerIdProto) returns (RestartResponseProto); + rpc rollbackLastReInitialization(ContainerIdProto) returns (RollbackResponseProto); + rpc commitLastReInitialization(ContainerIdProto) returns (CommitResponseProto); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_service_protos.proto b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_service_protos.proto index 97eaa5c..ddb7b5b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_service_protos.proto +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_service_protos.proto @@ -294,6 +294,24 @@ message ResourceLocalizationRequestProto { message ResourceLocalizationResponseProto { } +message ReInitializationRequestProto { + optional ContainerIdProto container_id = 1; + optional ContainerLaunchContextProto container_launch_context = 2; + optional bool auto_commit = 3 [default = true]; +} + +message ReInitializationResponseProto { +} + +message RestartResponseProto { +} + +message RollbackResponseProto { +} + +message CommitResponseProto { +} + //// bulk API records message StartContainersRequestProto { repeated StartContainerRequestProto start_container_request = 1; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/client/ContainerManagementProtocolPBClientImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/client/ContainerManagementProtocolPBClientImpl.java index 2c4fade..e4afa0e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/client/ContainerManagementProtocolPBClientImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/client/ContainerManagementProtocolPBClientImpl.java @@ -27,33 +27,52 @@ import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.yarn.api.ContainerManagementProtocol; import org.apache.hadoop.yarn.api.ContainerManagementProtocolPB; +import org.apache.hadoop.yarn.api.protocolrecords.CommitResponse; 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.ReInitializationRequest; +import org.apache.hadoop.yarn.api.protocolrecords.ReInitializationResponse; import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationRequest; import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RestartResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RollbackResponse; import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerRequest; import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerResponse; import org.apache.hadoop.yarn.api.protocolrecords.StartContainersRequest; import org.apache.hadoop.yarn.api.protocolrecords.StartContainersResponse; import org.apache.hadoop.yarn.api.protocolrecords.StopContainersRequest; import org.apache.hadoop.yarn.api.protocolrecords.StopContainersResponse; +import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.CommitResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetContainerStatusesRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetContainerStatusesResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.IncreaseContainersResourceRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.IncreaseContainersResourceResponsePBImpl; + +import org.apache.hadoop.yarn.api.protocolrecords.impl.pb + .ReInitializationRequestPBImpl; +import org.apache.hadoop.yarn.api.protocolrecords.impl.pb + .ReInitializationResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ResourceLocalizationRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ResourceLocalizationResponsePBImpl; + +import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.RestartResponsePBImpl; +import org.apache.hadoop.yarn.api.protocolrecords.impl.pb + .RollbackResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.SignalContainerRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.SignalContainerResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.StartContainersRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.StartContainersResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.StopContainersRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.StopContainersResponsePBImpl; +import org.apache.hadoop.yarn.api.records.ContainerId; +import org.apache.hadoop.yarn.api.records.impl.pb.ProtoUtils; import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.ipc.RPCUtil; +import org.apache.hadoop.yarn.proto.YarnProtos; +import org.apache.hadoop.yarn.proto.YarnServiceProtos; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusesRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.IncreaseContainersResourceRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.ResourceLocalizationRequestProto; @@ -185,4 +204,60 @@ public ResourceLocalizationResponse localize( return null; } } + + @Override + public ReInitializationResponse reInitializeContainer( + ReInitializationRequest request) throws YarnException, IOException { + YarnServiceProtos.ReInitializationRequestProto requestProto = + ((ReInitializationRequestPBImpl) request).getProto(); + try { + return new ReInitializationResponsePBImpl( + proxy.reInitializeContainer(null, requestProto)); + } catch (ServiceException e) { + RPCUtil.unwrapAndThrowException(e); + return null; + } + } + + @Override + public RestartResponse restartContainer(ContainerId containerId) + throws YarnException, IOException { + YarnProtos.ContainerIdProto containerIdProto = ProtoUtils + .convertToProtoFormat(containerId); + try { + return new RestartResponsePBImpl( + proxy.restartContainer(null, containerIdProto)); + } catch (ServiceException e) { + RPCUtil.unwrapAndThrowException(e); + return null; + } + } + + @Override + public RollbackResponse rollbackLastReInitialization(ContainerId containerId) + throws YarnException, IOException { + YarnProtos.ContainerIdProto containerIdProto = ProtoUtils + .convertToProtoFormat(containerId); + try { + return new RollbackResponsePBImpl( + proxy.rollbackLastReInitialization(null, containerIdProto)); + } catch (ServiceException e) { + RPCUtil.unwrapAndThrowException(e); + return null; + } + } + + @Override + public CommitResponse commitLastReInitialization(ContainerId containerId) + throws YarnException, IOException { + YarnProtos.ContainerIdProto containerIdProto = ProtoUtils + .convertToProtoFormat(containerId); + try { + return new CommitResponsePBImpl( + proxy.commitLastReInitialization(null, containerIdProto)); + } catch (ServiceException e) { + RPCUtil.unwrapAndThrowException(e); + return null; + } + } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ContainerManagementProtocolPBServiceImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ContainerManagementProtocolPBServiceImpl.java index 9e34d66..5eec300 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ContainerManagementProtocolPBServiceImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ContainerManagementProtocolPBServiceImpl.java @@ -23,37 +23,57 @@ import org.apache.hadoop.classification.InterfaceAudience.Private; import org.apache.hadoop.yarn.api.ContainerManagementProtocol; import org.apache.hadoop.yarn.api.ContainerManagementProtocolPB; +import org.apache.hadoop.yarn.api.protocolrecords.CommitResponse; import org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesResponse; +import org.apache.hadoop.yarn.api.protocolrecords.ReInitializationResponse; import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RestartResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RollbackResponse; import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerResponse; import org.apache.hadoop.yarn.api.protocolrecords.StartContainersResponse; import org.apache.hadoop.yarn.api.protocolrecords.StopContainersResponse; +import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.CommitResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.IncreaseContainersResourceRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.IncreaseContainersResourceResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetContainerStatusesRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetContainerStatusesResponsePBImpl; + +import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ReInitializationRequestPBImpl; +import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ReInitializationResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ResourceLocalizationRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.ResourceLocalizationResponsePBImpl; + +import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.RestartResponsePBImpl; +import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.RollbackResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.SignalContainerRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.SignalContainerResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.StartContainersRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.StartContainersResponsePBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.StopContainersRequestPBImpl; import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.StopContainersResponsePBImpl; + +import org.apache.hadoop.yarn.api.records.ContainerId; +import org.apache.hadoop.yarn.api.records.impl.pb.ProtoUtils; import org.apache.hadoop.yarn.exceptions.YarnException; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.IncreaseContainersResourceRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.IncreaseContainersResourceResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusesRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusesResponseProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReInitializationRequestProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReInitializationResponseProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.ResourceLocalizationRequestProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.ResourceLocalizationResponseProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.RestartResponseProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.RollbackResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.SignalContainerRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.SignalContainerResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainersRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainersResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.StopContainersRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.StopContainersResponseProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.ResourceLocalizationRequestProto; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.ResourceLocalizationResponseProto; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.CommitResponseProto; import com.google.protobuf.RpcController; import com.google.protobuf.ServiceException; @@ -156,4 +176,64 @@ public ResourceLocalizationResponseProto localize(RpcController controller, throw new ServiceException(e); } } + + @Override + public ReInitializationResponseProto reInitializeContainer( + RpcController controller, ReInitializationRequestProto proto) + throws ServiceException { + ReInitializationRequestPBImpl request = + new ReInitializationRequestPBImpl(proto); + try { + ReInitializationResponse response = real.reInitializeContainer(request); + return ((ReInitializationResponsePBImpl) response).getProto(); + } catch (YarnException e) { + throw new ServiceException(e); + } catch (IOException e) { + throw new ServiceException(e); + } + } + + @Override + public RestartResponseProto restartContainer(RpcController controller, + ContainerIdProto containerId) throws ServiceException { + ContainerId request = ProtoUtils.convertFromProtoFormat(containerId); + try { + RestartResponse response = real.restartContainer(request); + return ((RestartResponsePBImpl) response).getProto(); + } catch (YarnException e) { + throw new ServiceException(e); + } catch (IOException e) { + throw new ServiceException(e); + } + } + + @Override + public RollbackResponseProto rollbackLastReInitialization( + RpcController controller, ContainerIdProto containerId) throws + ServiceException { + ContainerId request = ProtoUtils.convertFromProtoFormat(containerId); + try { + RollbackResponse response = real.rollbackLastReInitialization(request); + return ((RollbackResponsePBImpl) response).getProto(); + } catch (YarnException e) { + throw new ServiceException(e); + } catch (IOException e) { + throw new ServiceException(e); + } + } + + @Override + public CommitResponseProto commitLastReInitialization( + RpcController controller, ContainerIdProto containerId) throws + ServiceException { + ContainerId request = ProtoUtils.convertFromProtoFormat(containerId); + try { + CommitResponse response = real.commitLastReInitialization(request); + return ((CommitResponsePBImpl) response).getProto(); + } catch (YarnException e) { + throw new ServiceException(e); + } catch (IOException e) { + throw new ServiceException(e); + } + } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/CommitResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/CommitResponsePBImpl.java new file mode 100644 index 0000000..fc6409b --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/CommitResponsePBImpl.java @@ -0,0 +1,66 @@ +/** + * 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.impl.pb; + +import com.google.protobuf.TextFormat; +import org.apache.hadoop.yarn.api.protocolrecords.CommitResponse; +import org.apache.hadoop.yarn.proto.YarnServiceProtos; + +public class CommitResponsePBImpl extends CommitResponse { + YarnServiceProtos.CommitResponseProto proto = + YarnServiceProtos.CommitResponseProto.getDefaultInstance(); + YarnServiceProtos.CommitResponseProto.Builder builder = null; + boolean viaProto = false; + + public CommitResponsePBImpl() { + builder = YarnServiceProtos.CommitResponseProto.newBuilder(); + } + + public CommitResponsePBImpl(YarnServiceProtos.CommitResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public YarnServiceProtos.CommitResponseProto getProto() { + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + @Override + public int hashCode() { + return getProto().hashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other.getClass().isAssignableFrom(this.getClass())) { + return this.getProto().equals(this.getClass().cast(other).getProto()); + } + return false; + } + + @Override + public String toString() { + return TextFormat.shortDebugString(getProto()); + } +} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/ReInitializationRequestPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/ReInitializationRequestPBImpl.java new file mode 100644 index 0000000..cd68e4b --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/ReInitializationRequestPBImpl.java @@ -0,0 +1,172 @@ +/** + * 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.impl.pb; + +import com.google.protobuf.TextFormat; +import org.apache.hadoop.yarn.api.protocolrecords.ReInitializationRequest; +import org.apache.hadoop.yarn.api.records.ContainerId; +import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; +import org.apache.hadoop.yarn.api.records.impl.pb.ContainerLaunchContextPBImpl; +import org.apache.hadoop.yarn.api.records.impl.pb.ProtoUtils; +import org.apache.hadoop.yarn.proto.YarnProtos; +import org.apache.hadoop.yarn.proto.YarnServiceProtos; +import org.apache.hadoop.yarn.proto.YarnServiceProtos.ReInitializationRequestProto; + +public class ReInitializationRequestPBImpl extends ReInitializationRequest { + private ReInitializationRequestProto proto = + ReInitializationRequestProto.getDefaultInstance(); + private ReInitializationRequestProto.Builder builder = null; + private boolean viaProto = false; + + private ContainerId containerId; + private ContainerLaunchContext containerLaunchContext; + + public ReInitializationRequestPBImpl() { + builder = ReInitializationRequestProto.newBuilder(); + } + + public ReInitializationRequestPBImpl(ReInitializationRequestProto proto) { + this.proto = proto; + viaProto = true; + } + + public ReInitializationRequestProto getProto() { + mergeLocalToProto(); + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + private void mergeLocalToProto() { + if (viaProto) { + maybeInitBuilder(); + } + mergeLocalToBuilder(); + proto = builder.build(); + viaProto = true; + } + + private void mergeLocalToBuilder() { + if (this.containerId != null) { + builder.setContainerId(ProtoUtils.convertToProtoFormat(this.containerId)); + } + if (this.containerLaunchContext != null) { + builder.setContainerLaunchContext(convertToProtoFormat(this.containerLaunchContext)); + } + } + + private void maybeInitBuilder() { + if (viaProto || builder == null) { + builder = ReInitializationRequestProto.newBuilder(proto); + } + viaProto = false; + } + + @Override + public ContainerId getContainerId() { + YarnServiceProtos.ReInitializationRequestProtoOrBuilder p = + viaProto ? proto : builder; + if (this.containerId != null) { + return this.containerId; + } + if (!p.hasContainerId()) { + return null; + } + this.containerId = ProtoUtils.convertFromProtoFormat(p.getContainerId()); + return this.containerId; + } + + @Override + public void setContainerId(ContainerId containerId) { + maybeInitBuilder(); + if (containerId == null) { + builder.clearContainerId(); + } + this.containerId = containerId; + } + + @Override + public ContainerLaunchContext getContainerLaunchContext() { + YarnServiceProtos.ReInitializationRequestProtoOrBuilder p = + viaProto ? proto : builder; + if (this.containerLaunchContext != null) { + return this.containerLaunchContext; + } + if (!p.hasContainerLaunchContext()) { + return null; + } + this.containerLaunchContext = + convertFromProtoFormat(p.getContainerLaunchContext()); + return this.containerLaunchContext; + } + + @Override + public void setContainerLaunchContext( + ContainerLaunchContext containerLaunchContext) { + maybeInitBuilder(); + if (containerLaunchContext == null) + builder.clearContainerLaunchContext(); + this.containerLaunchContext = containerLaunchContext; + } + + @Override + public boolean getAutoCommit() { + YarnServiceProtos.ReInitializationRequestProtoOrBuilder p = + viaProto ? proto : builder; + if (!p.hasAutoCommit()) { + return false; + } + return (p.getAutoCommit()); + } + + @Override + public void setAutoCommit(boolean autoCommit) { + maybeInitBuilder(); + builder.setAutoCommit(autoCommit); + } + + private ContainerLaunchContextPBImpl convertFromProtoFormat(YarnProtos.ContainerLaunchContextProto p) { + return new ContainerLaunchContextPBImpl(p); + } + + private YarnProtos.ContainerLaunchContextProto convertToProtoFormat(ContainerLaunchContext t) { + return ((ContainerLaunchContextPBImpl)t).getProto(); + } + + @Override + public int hashCode() { + return getProto().hashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other.getClass().isAssignableFrom(this.getClass())) { + return this.getProto().equals(this.getClass().cast(other).getProto()); + } + return false; + } + + @Override + public String toString() { + return TextFormat.shortDebugString(getProto()); + } + +} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/ReInitializationResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/ReInitializationResponsePBImpl.java new file mode 100644 index 0000000..a795ce9 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/ReInitializationResponsePBImpl.java @@ -0,0 +1,67 @@ +/** + * 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.impl.pb; + +import com.google.protobuf.TextFormat; +import org.apache.hadoop.yarn.api.protocolrecords.ReInitializationResponse; +import org.apache.hadoop.yarn.proto.YarnServiceProtos; + +public class ReInitializationResponsePBImpl extends ReInitializationResponse { + YarnServiceProtos.ReInitializationResponseProto proto = + YarnServiceProtos.ReInitializationResponseProto.getDefaultInstance(); + YarnServiceProtos.ReInitializationResponseProto.Builder builder = null; + boolean viaProto = false; + + public ReInitializationResponsePBImpl() { + builder = YarnServiceProtos.ReInitializationResponseProto.newBuilder(); + } + + public ReInitializationResponsePBImpl(YarnServiceProtos + .ReInitializationResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public YarnServiceProtos.ReInitializationResponseProto getProto() { + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + @Override + public int hashCode() { + return getProto().hashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other.getClass().isAssignableFrom(this.getClass())) { + return this.getProto().equals(this.getClass().cast(other).getProto()); + } + return false; + } + + @Override + public String toString() { + return TextFormat.shortDebugString(getProto()); + } +} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RestartResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RestartResponsePBImpl.java new file mode 100644 index 0000000..9c42b5d --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RestartResponsePBImpl.java @@ -0,0 +1,66 @@ +/** + * 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.impl.pb; + +import com.google.protobuf.TextFormat; +import org.apache.hadoop.yarn.api.protocolrecords.RestartResponse; +import org.apache.hadoop.yarn.proto.YarnServiceProtos; + +public class RestartResponsePBImpl extends RestartResponse { + YarnServiceProtos.RestartResponseProto proto = + YarnServiceProtos.RestartResponseProto.getDefaultInstance(); + YarnServiceProtos.RestartResponseProto.Builder builder = null; + boolean viaProto = false; + + public RestartResponsePBImpl() { + builder = YarnServiceProtos.RestartResponseProto.newBuilder(); + } + + public RestartResponsePBImpl(YarnServiceProtos.RestartResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public YarnServiceProtos.RestartResponseProto getProto() { + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + @Override + public int hashCode() { + return getProto().hashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other.getClass().isAssignableFrom(this.getClass())) { + return this.getProto().equals(this.getClass().cast(other).getProto()); + } + return false; + } + + @Override + public String toString() { + return TextFormat.shortDebugString(getProto()); + } +} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RollbackResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RollbackResponsePBImpl.java new file mode 100644 index 0000000..e26fe2d --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/RollbackResponsePBImpl.java @@ -0,0 +1,66 @@ +/** + * 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.impl.pb; + +import com.google.protobuf.TextFormat; +import org.apache.hadoop.yarn.api.protocolrecords.RollbackResponse; +import org.apache.hadoop.yarn.proto.YarnServiceProtos; + +public class RollbackResponsePBImpl extends RollbackResponse { + YarnServiceProtos.RollbackResponseProto proto = + YarnServiceProtos.RollbackResponseProto.getDefaultInstance(); + YarnServiceProtos.RollbackResponseProto.Builder builder = null; + boolean viaProto = false; + + public RollbackResponsePBImpl() { + builder = YarnServiceProtos.RollbackResponseProto.newBuilder(); + } + + public RollbackResponsePBImpl(YarnServiceProtos.RollbackResponseProto proto) { + this.proto = proto; + viaProto = true; + } + + public YarnServiceProtos.RollbackResponseProto getProto() { + proto = viaProto ? proto : builder.build(); + viaProto = true; + return proto; + } + + @Override + public int hashCode() { + return getProto().hashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other.getClass().isAssignableFrom(this.getClass())) { + return this.getProto().equals(this.getClass().cast(other).getProto()); + } + return false; + } + + @Override + public String toString() { + return TextFormat.shortDebugString(getProto()); + } +} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestContainerLaunchRPC.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestContainerLaunchRPC.java index 8dcf029..03d9090 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestContainerLaunchRPC.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestContainerLaunchRPC.java @@ -32,12 +32,17 @@ import org.apache.hadoop.security.SecurityUtil; import org.apache.hadoop.util.StringUtils; 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.GetContainerStatusesRequest; import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesResponse; +import org.apache.hadoop.yarn.api.protocolrecords.ReInitializationRequest; +import org.apache.hadoop.yarn.api.protocolrecords.ReInitializationResponse; import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationRequest; import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RestartResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RollbackResponse; import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerRequest; import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerResponse; import org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest; @@ -206,5 +211,29 @@ public ResourceLocalizationResponse localize( ResourceLocalizationRequest request) throws YarnException, IOException { return null; } + + @Override + public ReInitializationResponse reInitializeContainer( + ReInitializationRequest request) throws YarnException, IOException { + return null; + } + + @Override + public RestartResponse restartContainer(ContainerId containerId) + throws YarnException, IOException { + return null; + } + + @Override + public RollbackResponse rollbackLastReInitialization( + ContainerId containerId) throws YarnException, IOException { + return null; + } + + @Override + public CommitResponse commitLastReInitialization(ContainerId containerId) + throws YarnException, IOException { + return null; + } } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestContainerResourceIncreaseRPC.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestContainerResourceIncreaseRPC.java index b6ae283..5aa8fc8 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestContainerResourceIncreaseRPC.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestContainerResourceIncreaseRPC.java @@ -26,12 +26,17 @@ import org.apache.hadoop.security.SecurityUtil; import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.yarn.api.ContainerManagementProtocol; +import org.apache.hadoop.yarn.api.protocolrecords.CommitResponse; 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.ReInitializationRequest; +import org.apache.hadoop.yarn.api.protocolrecords.ReInitializationResponse; import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationRequest; import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RestartResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RollbackResponse; import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerRequest; import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerResponse; import org.apache.hadoop.yarn.api.protocolrecords.StartContainersRequest; @@ -187,5 +192,29 @@ public SignalContainerResponse signalToContainer( ResourceLocalizationRequest request) throws YarnException, IOException { return null; } + + @Override + public ReInitializationResponse reInitializeContainer( + ReInitializationRequest request) throws YarnException, IOException { + return null; + } + + @Override + public RestartResponse restartContainer(ContainerId containerId) + throws YarnException, IOException { + return null; + } + + @Override + public RollbackResponse rollbackLastReInitialization( + ContainerId containerId) throws YarnException, IOException { + return null; + } + + @Override + public CommitResponse commitLastReInitialization(ContainerId containerId) + throws YarnException, IOException { + return null; + } } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/TestRPC.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/TestRPC.java index f54a270..243b2cb 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/TestRPC.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/TestRPC.java @@ -33,13 +33,18 @@ import org.apache.hadoop.yarn.api.ApplicationClientProtocol; import org.apache.hadoop.yarn.api.ContainerManagementProtocol; import org.apache.hadoop.yarn.api.ContainerManagementProtocolPB; +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.GetContainerStatusesRequest; import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationRequest; +import org.apache.hadoop.yarn.api.protocolrecords.ReInitializationRequest; +import org.apache.hadoop.yarn.api.protocolrecords.ReInitializationResponse; import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationRequest; import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RestartResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RollbackResponse; import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerRequest; import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerResponse; import org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest; @@ -355,6 +360,30 @@ public ResourceLocalizationResponse localize( ResourceLocalizationRequest request) throws YarnException, IOException { return null; } + + @Override + public ReInitializationResponse reInitializeContainer( + ReInitializationRequest request) throws YarnException, IOException { + return null; + } + + @Override + public RestartResponse restartContainer(ContainerId containerId) + throws YarnException, IOException { + return null; + } + + @Override + public RollbackResponse rollbackLastReInitialization( + ContainerId containerId) throws YarnException, IOException { + return null; + } + + @Override + public CommitResponse commitLastReInitialization(ContainerId containerId) + throws YarnException, IOException { + return null; + } } public static ContainerTokenIdentifier newContainerTokenIdentifier( diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java index 8a9ad99..f4d88a9 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java @@ -38,12 +38,17 @@ import org.apache.hadoop.service.Service; import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.yarn.api.ContainerManagementProtocol; +import org.apache.hadoop.yarn.api.protocolrecords.CommitResponse; 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.ReInitializationRequest; +import org.apache.hadoop.yarn.api.protocolrecords.ReInitializationResponse; import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationRequest; import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RestartResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RollbackResponse; import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerRequest; import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerResponse; import org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest; @@ -1551,6 +1556,21 @@ public ResourceLocalizationResponse localize( return ResourceLocalizationResponse.newInstance(); } + @Override + public ReInitializationResponse reInitializeContainer( + ReInitializationRequest request) throws YarnException, IOException { + reInitializeContainer(request.getContainerId(), + request.getContainerLaunchContext(), request.getAutoCommit()); + return ReInitializationResponse.newInstance(); + } + + @Override + public RestartResponse restartContainer(ContainerId containerId) + throws YarnException, IOException { + reInitializeContainer(containerId, null, true); + return RestartResponse.newInstance(); + } + /** * ReInitialize a container using a new Launch Context. If the * retryFailureContext is not provided, The container is @@ -1572,7 +1592,9 @@ public void reInitializeContainer(ContainerId containerId, ReInitOp.RE_INIT); ResourceSet resourceSet = new ResourceSet(); try { - resourceSet.addResources(reInitLaunchContext.getLocalResources()); + if (reInitLaunchContext != null) { + resourceSet.addResources(reInitLaunchContext.getLocalResources()); + } dispatcher.getEventHandler().handle( new ContainerReInitEvent(containerId, reInitLaunchContext, resourceSet, autoCommit)); @@ -1587,9 +1609,11 @@ public void reInitializeContainer(ContainerId containerId, /** * Rollback the last reInitialization, if possible. * @param containerId Container ID. + * @return Rollback Response. * @throws YarnException Yarn Exception. */ - public void rollbackReInitialization(ContainerId containerId) + @Override + public RollbackResponse rollbackLastReInitialization(ContainerId containerId) throws YarnException { Container container = preUpgradeOrLocalizeCheck(containerId, ReInitOp.ROLLBACK); @@ -1599,14 +1623,17 @@ public void rollbackReInitialization(ContainerId containerId) } else { throw new YarnException("Nothing to rollback to !!"); } + return RollbackResponse.newInstance(); } /** * Commit last reInitialization after which no rollback will be possible. * @param containerId Container ID. + * @return Commit Response. * @throws YarnException Yarn Exception. */ - public void commitReInitialization(ContainerId containerId) + @Override + public CommitResponse commitLastReInitialization(ContainerId containerId) throws YarnException { Container container = preUpgradeOrLocalizeCheck(containerId, ReInitOp.COMMIT); @@ -1615,6 +1642,7 @@ public void commitReInitialization(ContainerId containerId) } else { throw new YarnException("Nothing to Commit !!"); } + return CommitResponse.newInstance(); } private Container preUpgradeOrLocalizeCheck(ContainerId containerId, diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/ContainerImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/ContainerImpl.java index 0707df0..95b7b5b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/ContainerImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/ContainerImpl.java @@ -943,9 +943,11 @@ public void transition(ContainerImpl container, ContainerEvent event) { protected ReInitializationContext createReInitContext( ContainerImpl container, ContainerEvent event) { ContainerReInitEvent reInitEvent = (ContainerReInitEvent)event; + ContainerLaunchContext launchContext = + reInitEvent.getReInitLaunchContext() == null ? + container.launchContext : null; return new ReInitializationContext( - reInitEvent.getReInitLaunchContext(), - reInitEvent.getResourceSet(), + launchContext, reInitEvent.getResourceSet(), // If AutoCommit is turned on, then no rollback can happen... // So don't need to store the previous context. (reInitEvent.isAutoCommit() ? null : container.launchContext), diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestContainerManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestContainerManager.java index 72049e6..b915a95 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestContainerManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestContainerManager.java @@ -369,7 +369,7 @@ public void testContainerLaunchAndStop() throws IOException, DefaultContainerExecutor.containerIsAlive(pid)); } - private String[] testContainerUpgradeSuccess(boolean autoCommit) + private String[] testContainerReInitSuccess(boolean autoCommit) throws IOException, InterruptedException, YarnException { containerManager.start(); // ////// Construct the Container-id @@ -412,10 +412,10 @@ public void testContainerLaunchAndStop() throws IOException, @Test public void testContainerUpgradeSuccessAutoCommit() throws IOException, InterruptedException, YarnException { - testContainerUpgradeSuccess(true); + testContainerReInitSuccess(true); // Should not be able to Commit (since already auto committed) try { - containerManager.commitReInitialization(createContainerId(0)); + containerManager.commitLastReInitialization(createContainerId(0)); Assert.fail(); } catch (Exception e) { Assert.assertTrue(e.getMessage().contains("Nothing to Commit")); @@ -425,12 +425,12 @@ public void testContainerUpgradeSuccessAutoCommit() throws IOException, @Test public void testContainerUpgradeSuccessExplicitCommit() throws IOException, InterruptedException, YarnException { - testContainerUpgradeSuccess(false); + testContainerReInitSuccess(false); ContainerId cId = createContainerId(0); - containerManager.commitReInitialization(cId); + containerManager.commitLastReInitialization(cId); // Should not be able to Rollback once committed try { - containerManager.rollbackReInitialization(cId); + containerManager.rollbackLastReInitialization(cId); Assert.fail(); } catch (Exception e) { Assert.assertTrue(e.getMessage().contains("Nothing to rollback to")); @@ -440,7 +440,7 @@ public void testContainerUpgradeSuccessExplicitCommit() throws IOException, @Test public void testContainerUpgradeSuccessExplicitRollback() throws IOException, InterruptedException, YarnException { - String[] pids = testContainerUpgradeSuccess(false); + String[] pids = testContainerReInitSuccess(false); // Delete the old start File.. File oldStartFile = new File(tmpDir, "start_file_o.txt").getAbsoluteFile(); @@ -448,7 +448,7 @@ public void testContainerUpgradeSuccessExplicitRollback() throws IOException, ContainerId cId = createContainerId(0); // Explicit Rollback - containerManager.rollbackReInitialization(cId); + containerManager.rollbackLastReInitialization(cId); // Original should be dead anyway Assert.assertFalse("Original Process is still alive!", diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/NodeManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/NodeManager.java index 4416010..252e0b0 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/NodeManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/NodeManager.java @@ -25,10 +25,15 @@ import java.util.List; import java.util.Map; +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.ReInitializationRequest; +import org.apache.hadoop.yarn.api.protocolrecords.ReInitializationResponse; import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationRequest; import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RestartResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RollbackResponse; import org.junit.Assert; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -332,4 +337,28 @@ public ResourceLocalizationResponse localize( ResourceLocalizationRequest request) throws YarnException, IOException { return null; } + + @Override + public ReInitializationResponse reInitializeContainer( + ReInitializationRequest request) throws YarnException, IOException { + return null; + } + + @Override + public RestartResponse restartContainer(ContainerId containerId) + throws YarnException, IOException { + return null; + } + + @Override + public RollbackResponse rollbackLastReInitialization(ContainerId containerId) + throws YarnException, IOException { + return null; + } + + @Override + public CommitResponse commitLastReInitialization(ContainerId containerId) + throws YarnException, IOException { + return null; + } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestAMAuthorization.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestAMAuthorization.java index f325cd5..59fbacb 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestAMAuthorization.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestAMAuthorization.java @@ -41,14 +41,19 @@ import org.apache.hadoop.security.token.TokenIdentifier; import org.apache.hadoop.yarn.api.ApplicationMasterProtocol; 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.GetContainerStatusesRequest; import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesResponse; +import org.apache.hadoop.yarn.api.protocolrecords.ReInitializationRequest; +import org.apache.hadoop.yarn.api.protocolrecords.ReInitializationResponse; import org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterRequest; import org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse; import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationRequest; import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RestartResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RollbackResponse; import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerRequest; import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerResponse; import org.apache.hadoop.yarn.api.protocolrecords.StartContainersRequest; @@ -57,6 +62,7 @@ import org.apache.hadoop.yarn.api.protocolrecords.StopContainersResponse; import org.apache.hadoop.yarn.api.records.ApplicationAccessType; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; +import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.ipc.YarnRPC; @@ -176,6 +182,30 @@ public ResourceLocalizationResponse localize( ResourceLocalizationRequest request) throws YarnException, IOException { return null; } + + @Override + public ReInitializationResponse reInitializeContainer( + ReInitializationRequest request) throws YarnException, IOException { + return null; + } + + @Override + public RestartResponse restartContainer(ContainerId containerId) + throws YarnException, IOException { + return null; + } + + @Override + public RollbackResponse rollbackLastReInitialization( + ContainerId containerId) throws YarnException, IOException { + return null; + } + + @Override + public CommitResponse commitLastReInitialization(ContainerId containerId) + throws YarnException, IOException { + return null; + } } public static class MockRMWithAMS extends MockRMWithCustomAMLauncher { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationMasterLauncher.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationMasterLauncher.java index 15b8ade..bcb69ea 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationMasterLauncher.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationMasterLauncher.java @@ -33,12 +33,17 @@ import org.apache.hadoop.yarn.api.ApplicationConstants; import org.apache.hadoop.yarn.api.ContainerManagementProtocol; import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse; +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.GetContainerStatusesRequest; import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesResponse; +import org.apache.hadoop.yarn.api.protocolrecords.ReInitializationRequest; +import org.apache.hadoop.yarn.api.protocolrecords.ReInitializationResponse; import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationRequest; import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RestartResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RollbackResponse; import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerRequest; import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerResponse; import org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest; @@ -164,6 +169,30 @@ public ResourceLocalizationResponse localize( ResourceLocalizationRequest request) throws YarnException, IOException { return null; } + + @Override + public ReInitializationResponse reInitializeContainer( + ReInitializationRequest request) throws YarnException, IOException { + return null; + } + + @Override + public RestartResponse restartContainer(ContainerId containerId) + throws YarnException, IOException { + return null; + } + + @Override + public RollbackResponse rollbackLastReInitialization( + ContainerId containerId) throws YarnException, IOException { + return null; + } + + @Override + public CommitResponse commitLastReInitialization(ContainerId containerId) + throws YarnException, IOException { + return null; + } } @Test