diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/SignalContainerRequest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/SignalContainerRequest.java
new file mode 100644
index 0000000..1207154
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/SignalContainerRequest.java
@@ -0,0 +1,95 @@
+/**
+ * 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.records.SignalContainerCommand;
+import org.apache.hadoop.yarn.util.Records;
+
+/**
+ *
The request sent by the client to the ResourceManager
+ * or by the ApplicationMaster to the NodeManager
+ * to signal a container.
+ *
+ */
+@Public
+@Stable
+public abstract class SignalContainerRequest {
+
+ @Public
+ @Stable
+ public static SignalContainerRequest newInstance(ContainerId containerId,
+ SignalContainerCommand signalContainerCommand,
+ String diagnostics) {
+ SignalContainerRequest request =
+ Records.newRecord(SignalContainerRequest.class);
+ request.setContainerId(containerId);
+ request.setCommand(signalContainerCommand);
+ request.setDiagnostics(diagnostics);
+ return request;
+ }
+
+ /**
+ * Get the ContainerId of the container to signal.
+ * @return ContainerId of the container to signal.
+ */
+ @Public
+ @Stable
+ public abstract ContainerId getContainerId();
+
+ /**
+ * Set the ContainerId of the container to signal.
+ */
+ @Public
+ @Stable
+ public abstract void setContainerId(ContainerId containerId);
+
+ /**
+ * Get the SignalContainerCommand of the signal request.
+ * @return SignalContainerCommand of the signal request.
+ */
+ @Public
+ @Stable
+ public abstract SignalContainerCommand getCommand();
+
+ /**
+ * Set the SignalContainerCommand of the signal request.
+ */
+ @Public
+ @Stable
+ public abstract void setCommand(SignalContainerCommand command);
+
+ /**
+ * Get the diagnostics string of the signal request.
+ * @return diagnostics of the signal request.
+ */
+ @Public
+ @Stable
+ public abstract String getDiagnostics();
+
+ /**
+ * Set the diagnostics string of the signal request.
+ */
+ @Public
+ @Stable
+ public abstract void setDiagnostics(String diagnostics);
+
+}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/SignalContainersRequest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/SignalContainersRequest.java
new file mode 100644
index 0000000..ab79b5f
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/SignalContainersRequest.java
@@ -0,0 +1,64 @@
+/**
+ * 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 java.util.List;
+
+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;
+
+/**
+ *
+ * The request which contains a list of {@link SignalContainerRequest}
+ *
+ *
+ */
+@Public
+@Stable
+public abstract class SignalContainersRequest {
+
+ @Public
+ @Stable
+ public static SignalContainersRequest newInstance(
+ List requests) {
+ SignalContainersRequest request =
+ Records.newRecord(SignalContainersRequest.class);
+ request.setSignalContainerRequests(requests);
+ return request;
+ }
+
+ /**
+ * Get a list of {@link SignalContainerRequest} to signal containers.
+ * @return a list of {@link SignalContainerRequest} to signal containers.
+ */
+ @Public
+ @Stable
+ public abstract List getSignalContainerRequests();
+
+ /**
+ * Set a list of {@link SignalContainerRequest} to signal containers.
+ * @param request a list of {@link SignalContainerRequest} to signal containers
+ */
+ @Public
+ @Stable
+ public abstract void setSignalContainerRequests(
+ List request);
+}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/SignalContainersResponse.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/SignalContainersResponse.java
new file mode 100644
index 0000000..0751aa6
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/SignalContainersResponse.java
@@ -0,0 +1,87 @@
+/**
+ * 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 java.util.List;
+import java.util.Map;
+
+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.ContainerManagementProtocol;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.api.records.SerializedException;
+import org.apache.hadoop.yarn.util.Records;
+
+/**
+ * The response sent by the ResourceManager to the client
+ * or by the NodeManager to the
+ * ApplicationMaster when asked to signal containers.
+ *
+ *
+ */
+@Public
+@Stable
+public abstract class SignalContainersResponse {
+ @Private
+ @Unstable
+ public static SignalContainersResponse newInstance(
+ List succeededRequests,
+ Map failedRequests) {
+ SignalContainersResponse response =
+ Records.newRecord(SignalContainersResponse.class);
+ response.setFailedRequests(failedRequests);
+ response.setSuccessfullySignaledContainers(succeededRequests);
+ return response;
+ }
+
+ /**
+ * Get the list of containerIds of successfully signaled containers.
+ * @return the list of containerIds of successfully signaled containers.
+ */
+ @Public
+ @Stable
+ public abstract List getSuccessfullySignaledContainers();
+
+ /**
+ * Set the list of containerIds of successfully signaled containers.
+ */
+ @Private
+ @Unstable
+ public abstract void setSuccessfullySignaledContainers(
+ List succeededRequests);
+
+ /**
+ * Get the containerId-to-exception map in which the exception indicates error
+ * from per container for failed requests
+ */
+ @Public
+ @Stable
+ public abstract Map getFailedRequests();
+
+ /**
+ * Set the containerId-to-exception map in which the exception indicates error
+ * from per container for failed requests
+ */
+ @Private
+ @Unstable
+ public abstract void setFailedRequests(
+ Map failedRequests);
+}
\ No newline at end of file
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/SignalContainerCommand.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/SignalContainerCommand.java
new file mode 100644
index 0000000..e9cc31e
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/SignalContainerCommand.java
@@ -0,0 +1,52 @@
+/**
+* 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.records;
+
+import org.apache.hadoop.classification.InterfaceAudience.Public;
+import org.apache.hadoop.classification.InterfaceStability.Stable;
+
+/**
+ * Enumeration of various signal container commands.
+ */
+@Public
+@Stable
+public enum SignalContainerCommand {
+
+ /**
+ * On Linux, it is equivalent to 0.
+ */
+ NULL,
+
+ /**
+ * Used to capture thread dump.
+ * On Linux, it is equivalent to SIGQUIT.
+ */
+ OUTPUT_THREAD_DUMP,
+
+ /** Gracefully shutdown a container.
+ * On Linux, it is equivalent to SIGTERM.
+ */
+ GRACEFUL_SHUTDOWN,
+
+ /** Forcefully shutdown a container.
+ * On Linux, it is equivalent to SIGKILL.
+ */
+ FORCEFUL_SHUTDOWN,
+
+}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto
index 48aac9d..be476ea 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto
@@ -329,6 +329,13 @@ message QueueUserACLInfoProto {
repeated QueueACLProto userAcls = 2;
}
+enum SignalContainerCommandProto {
+ NULL = 1;
+ OUTPUT_THREAD_DUMP = 2;
+ GRACEFUL_SHUTDOWN = 3;
+ FORCEFUL_SHUTDOWN = 4;
+}
+
////////////////////////////////////////////////////////////////////////
////// From container_manager //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
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 a1f6d2e..08a7c8b 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
@@ -187,6 +187,12 @@ message GetQueueUserAclsInfoResponseProto {
repeated QueueUserACLInfoProto queueUserAcls = 1;
}
+message SignalContainerRequestProto {
+ optional ContainerIdProto container_id = 1;
+ optional SignalContainerCommandProto command = 2;
+ optional string diagnostics = 3;
+}
+
//////////////////////////////////////////////////////
/////// client_NM_Protocol ///////////////////////////
@@ -221,6 +227,11 @@ message StartContainersRequestProto {
repeated StartContainerRequestProto start_container_request = 1;
}
+//// bulk API records
+message SignalContainersRequestProto {
+ repeated SignalContainerRequestProto signal_container_request = 1;
+}
+
message ContainerExceptionMapProto {
optional ContainerIdProto container_id = 1;
optional SerializedExceptionProto exception = 2;
@@ -241,6 +252,11 @@ message StopContainersResponseProto {
repeated ContainerExceptionMapProto failed_requests = 2;
}
+message SignalContainersResponseProto {
+ repeated ContainerIdProto succeeded_requests = 1;
+ repeated ContainerExceptionMapProto failed_requests = 2;
+}
+
message GetContainerStatusesRequestProto {
repeated ContainerIdProto container_id = 1;
}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/SignalContainerRequestPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/SignalContainerRequestPBImpl.java
new file mode 100644
index 0000000..4b552c3
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/SignalContainerRequestPBImpl.java
@@ -0,0 +1,195 @@
+/**
+ * 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.SignalContainerRequest;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.api.records.impl.pb.ContainerIdPBImpl;
+import org.apache.hadoop.yarn.api.records.SignalContainerCommand;
+import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.SignalContainerCommandProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.SignalContainerRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.SignalContainerRequestProtoOrBuilder;
+
+
+public class SignalContainerRequestPBImpl
+ extends SignalContainerRequest {
+ SignalContainerRequestProto proto =
+ SignalContainerRequestProto.getDefaultInstance();
+ SignalContainerRequestProto.Builder builder = null;
+ boolean viaProto = false;
+
+ private ContainerId containerId;
+ private SignalContainerCommand command = null;
+ private String diagnostics;
+
+ private static SignalContainerCommand convertFromProtoFormat(
+ SignalContainerCommandProto p) {
+ return SignalContainerCommand.valueOf(p.name());
+ }
+
+ private static SignalContainerCommandProto convertToProtoFormat(
+ SignalContainerCommand p) {
+ return SignalContainerCommandProto.valueOf(p.name());
+ }
+
+ public SignalContainerRequestPBImpl() {
+ builder = SignalContainerRequestProto.newBuilder();
+ }
+
+ public SignalContainerRequestPBImpl(SignalContainerRequestProto proto) {
+ this.proto = proto;
+ viaProto = true;
+ }
+
+ public SignalContainerRequestProto getProto() {
+ mergeLocalToProto();
+ proto = viaProto ? proto : builder.build();
+ viaProto = true;
+ return proto;
+ }
+
+ private void mergeLocalToBuilder() {
+ if (this.containerId != null) {
+ builder.setContainerId(convertToProtoFormat(this.containerId));
+ }
+
+ if (this.command != null) {
+ builder.setCommand(convertToProtoFormat(this.command));
+ }
+
+ if (diagnostics != null) {
+ builder.setDiagnostics(diagnostics);
+ }
+ }
+
+ private void mergeLocalToProto() {
+ if (viaProto)
+ maybeInitBuilder();
+ mergeLocalToBuilder();
+ proto = builder.build();
+ viaProto = true;
+ }
+
+ private void maybeInitBuilder() {
+ if (viaProto || builder == null) {
+ builder = SignalContainerRequestProto.newBuilder(proto);
+ }
+ viaProto = false;
+ }
+
+ @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());
+ }
+
+ @Override
+ public ContainerId getContainerId() {
+ SignalContainerRequestProtoOrBuilder p = viaProto ? proto : builder;
+ if (this.containerId != null) {
+ return this.containerId;
+ }
+ if (!p.hasContainerId()) {
+ return null;
+ }
+ this.containerId = convertFromProtoFormat(p.getContainerId());
+ return this.containerId;
+ }
+
+ @Override
+ public void setContainerId(ContainerId containerId) {
+ maybeInitBuilder();
+ if (containerId == null) {
+ builder.clearContainerId();
+ }
+ this.containerId = containerId;
+ }
+
+ private void initCommand() {
+ if (this.command != null) {
+ return;
+ }
+ SignalContainerRequestProtoOrBuilder p = viaProto ? proto : builder;
+ if(p.hasCommand()) {
+ this.command = convertFromProtoFormat(p.getCommand());
+ }
+ }
+
+ @Override
+ public SignalContainerCommand getCommand() {
+ initCommand();
+ return command;
+ }
+
+ @Override
+ public void setCommand(SignalContainerCommand command) {
+ maybeInitBuilder();
+ if (command == null) {
+ builder.clearCommand();
+ }
+ this.command = command;
+ }
+
+ @Override
+ public String getDiagnostics() {
+ if (diagnostics != null) {
+ return diagnostics;
+ }
+ final SignalContainerRequestProtoOrBuilder p = viaProto ? proto : builder;
+ if (p.hasDiagnostics()) {
+ diagnostics = p.getDiagnostics();
+ }
+ return diagnostics;
+ }
+
+ @Override
+ public void setDiagnostics(String diagnostics) {
+ maybeInitBuilder();
+ if (diagnostics == null) {
+ builder.clearDiagnostics();
+ }
+ this.diagnostics = diagnostics;
+ }
+
+ private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) {
+ return new ContainerIdPBImpl(p);
+ }
+
+ private ContainerIdProto convertToProtoFormat(ContainerId t) {
+ return ((ContainerIdPBImpl)t).getProto();
+ }
+
+}
\ No newline at end of file
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/SignalContainersRequestPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/SignalContainersRequestPBImpl.java
new file mode 100644
index 0000000..716b6ad
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/SignalContainersRequestPBImpl.java
@@ -0,0 +1,139 @@
+/**
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hadoop.yarn.api.protocolrecords.SignalContainerRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.SignalContainersRequest;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.SignalContainerRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.SignalContainersRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.SignalContainersRequestProtoOrBuilder;
+
+public class SignalContainersRequestPBImpl extends SignalContainersRequest {
+ SignalContainersRequestProto proto = SignalContainersRequestProto
+ .getDefaultInstance();
+ SignalContainersRequestProto.Builder builder = null;
+ boolean viaProto = false;
+
+ private List requests = null;
+
+ public SignalContainersRequestPBImpl() {
+ builder = SignalContainersRequestProto.newBuilder();
+ }
+
+ public SignalContainersRequestPBImpl(SignalContainersRequestProto proto) {
+ this.proto = proto;
+ viaProto = true;
+ }
+
+ public SignalContainersRequestProto getProto() {
+ mergeLocalToProto();
+ 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;
+ }
+
+ private void mergeLocalToProto() {
+ if (viaProto)
+ maybeInitBuilder();
+ mergeLocalToBuilder();
+ proto = builder.build();
+ viaProto = true;
+ }
+
+ private void mergeLocalToBuilder() {
+ if (requests != null) {
+ addLocalRequestsToProto();
+ }
+ }
+
+
+ private void maybeInitBuilder() {
+ if (viaProto || builder == null) {
+ builder = SignalContainersRequestProto.newBuilder(proto);
+ }
+ viaProto = false;
+ }
+
+ private void addLocalRequestsToProto() {
+ maybeInitBuilder();
+ builder.clearSignalContainerRequest();
+ List protoList =
+ new ArrayList();
+ for (SignalContainerRequest r : this.requests) {
+ protoList.add(convertToProtoFormat(r));
+ }
+ builder.addAllSignalContainerRequest(protoList);
+ }
+
+ private void initLocalRequests() {
+ SignalContainersRequestProtoOrBuilder p = viaProto ? proto : builder;
+ List requestList =
+ p.getSignalContainerRequestList();
+ this.requests = new ArrayList();
+ for (SignalContainerRequestProto r : requestList) {
+ this.requests.add(convertFromProtoFormat(r));
+ }
+ }
+
+ @Override
+ public void setSignalContainerRequests(List requests) {
+ maybeInitBuilder();
+ if (requests == null) {
+ builder.clearSignalContainerRequest();
+ }
+ this.requests = requests;
+ }
+
+ @Override
+ public List getSignalContainerRequests() {
+ if (this.requests != null) {
+ return this.requests;
+ }
+ initLocalRequests();
+ return this.requests;
+ }
+
+ private SignalContainerRequestPBImpl convertFromProtoFormat(
+ SignalContainerRequestProto p) {
+ return new SignalContainerRequestPBImpl(p);
+ }
+
+ private SignalContainerRequestProto convertToProtoFormat(
+ SignalContainerRequest t) {
+ return ((SignalContainerRequestPBImpl) t).getProto();
+ }
+}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/SignalContainersResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/SignalContainersResponsePBImpl.java
new file mode 100644
index 0000000..c94ba77
--- /dev/null
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/SignalContainersResponsePBImpl.java
@@ -0,0 +1,235 @@
+/**
+ * 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 java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.hadoop.classification.InterfaceAudience.Private;
+import org.apache.hadoop.classification.InterfaceStability.Unstable;
+import org.apache.hadoop.yarn.api.protocolrecords.SignalContainersResponse;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.api.records.SerializedException;
+import org.apache.hadoop.yarn.api.records.impl.pb.ContainerIdPBImpl;
+import org.apache.hadoop.yarn.api.records.impl.pb.SerializedExceptionPBImpl;
+import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.SerializedExceptionProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.ContainerExceptionMapProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.SignalContainersResponseProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.SignalContainersResponseProtoOrBuilder;
+
+import com.google.protobuf.TextFormat;
+
+@Private
+@Unstable
+public class SignalContainersResponsePBImpl extends SignalContainersResponse {
+ SignalContainersResponseProto proto = SignalContainersResponseProto
+ .getDefaultInstance();
+ SignalContainersResponseProto.Builder builder = null;
+ boolean viaProto = false;
+ private List succeededRequests = null;
+ private Map failedRequests = null;
+
+ public SignalContainersResponsePBImpl() {
+ builder = SignalContainersResponseProto.newBuilder();
+ }
+
+ public SignalContainersResponsePBImpl(SignalContainersResponseProto proto) {
+ this.proto = proto;
+ viaProto = true;
+ }
+
+ public SignalContainersResponseProto getProto() {
+ mergeLocalToProto();
+ 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());
+ }
+
+ private void mergeLocalToProto() {
+ if (viaProto) {
+ maybeInitBuilder();
+ }
+ mergeLocalToBuilder();
+ proto = builder.build();
+ viaProto = true;
+ }
+
+ private void maybeInitBuilder() {
+ if (viaProto || builder == null) {
+ builder = SignalContainersResponseProto.newBuilder(proto);
+ }
+ viaProto = false;
+ }
+
+ private void mergeLocalToBuilder() {
+
+ if (this.succeededRequests != null) {
+ addSucceededRequestSignalroto();
+ }
+ if (this.failedRequests != null) {
+ addFailedRequestSignalroto();
+ }
+ }
+
+ private void addSucceededRequestSignalroto() {
+ maybeInitBuilder();
+ builder.clearSucceededRequests();
+ if (this.succeededRequests == null) {
+ return;
+ }
+ Iterable iterable = new Iterable() {
+ @Override
+ public Iterator iterator() {
+ return new Iterator() {
+
+ Iterator iter = succeededRequests.iterator();
+
+ @Override
+ public boolean hasNext() {
+ return iter.hasNext();
+ }
+
+ @Override
+ public ContainerIdProto next() {
+ return convertToProtoFormat(iter.next());
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+
+ }
+ };
+ }
+ };
+ builder.addAllSucceededRequests(iterable);
+ }
+
+ private void addFailedRequestSignalroto() {
+ maybeInitBuilder();
+ builder.clearFailedRequests();
+ if (this.failedRequests == null)
+ return;
+ List protoList =
+ new ArrayList();
+
+ for (Map.Entry entry : this.failedRequests
+ .entrySet()) {
+ protoList.add(ContainerExceptionMapProto.newBuilder()
+ .setContainerId(convertToProtoFormat(entry.getKey()))
+ .setException(convertToProtoFormat(entry.getValue())).build());
+ }
+ builder.addAllFailedRequests(protoList);
+ }
+
+ private void initSucceededRequests() {
+ if (this.succeededRequests != null)
+ return;
+ SignalContainersResponseProtoOrBuilder p = viaProto ? proto : builder;
+ List list = p.getSucceededRequestsList();
+ this.succeededRequests = new ArrayList();
+ for (ContainerIdProto c : list) {
+ this.succeededRequests.add(convertFromProtoFormat(c));
+ }
+ }
+
+ private void initFailedRequests() {
+ if (this.failedRequests != null) {
+ return;
+ }
+ SignalContainersResponseProtoOrBuilder p = viaProto ? proto : builder;
+ List protoList = p.getFailedRequestsList();
+ this.failedRequests = new HashMap();
+ for (ContainerExceptionMapProto ce : protoList) {
+ this.failedRequests.put(convertFromProtoFormat(ce.getContainerId()),
+ convertFromProtoFormat(ce.getException()));
+ }
+ }
+
+ @Override
+ public List getSuccessfullySignaledContainers() {
+ initSucceededRequests();
+ return this.succeededRequests;
+ }
+
+ @Override
+ public void setSuccessfullySignaledContainers(List succeededRequests) {
+ maybeInitBuilder();
+ if (succeededRequests == null) {
+ builder.clearSucceededRequests();
+ }
+ this.succeededRequests = succeededRequests;
+ }
+
+ @Override
+ public Map getFailedRequests() {
+ initFailedRequests();
+ return this.failedRequests;
+ }
+
+ @Override
+ public void setFailedRequests(
+ Map failedRequests) {
+ maybeInitBuilder();
+ if (failedRequests == null)
+ builder.clearFailedRequests();
+ this.failedRequests = failedRequests;
+ }
+
+ private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) {
+ return new ContainerIdPBImpl(p);
+ }
+
+ private ContainerIdProto convertToProtoFormat(ContainerId t) {
+ return ((ContainerIdPBImpl) t).getProto();
+ }
+
+ private SerializedExceptionPBImpl convertFromProtoFormat(
+ SerializedExceptionProto p) {
+ return new SerializedExceptionPBImpl(p);
+ }
+
+ private SerializedExceptionProto convertToProtoFormat(SerializedException t) {
+ return ((SerializedExceptionPBImpl) t).getProto();
+ }
+}