hadoop-yarn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vino...@apache.org
Subject svn commit: r1506391 [2/4] - in /hadoop/common/trunk/hadoop-yarn-project: ./ hadoop-yarn/dev-support/ hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrec...
Date Wed, 24 Jul 2013 03:41:05 GMT
Modified: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ContainerManagementProtocolPBServiceImpl.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ContainerManagementProtocolPBServiceImpl.java?rev=1506391&r1=1506390&r2=1506391&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ContainerManagementProtocolPBServiceImpl.java (original)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ContainerManagementProtocolPBServiceImpl.java Wed Jul 24 03:41:03 2013
@@ -23,22 +23,22 @@ import java.io.IOException;
 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.GetContainerStatusResponse;
-import org.apache.hadoop.yarn.api.protocolrecords.StartContainerResponse;
-import org.apache.hadoop.yarn.api.protocolrecords.StopContainerResponse;
-import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetContainerStatusRequestPBImpl;
-import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetContainerStatusResponsePBImpl;
-import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.StartContainerRequestPBImpl;
-import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.StartContainerResponsePBImpl;
-import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.StopContainerRequestPBImpl;
-import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.StopContainerResponsePBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesResponse;
+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.GetContainerStatusesRequestPBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetContainerStatusesResponsePBImpl;
+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.exceptions.YarnException;
-import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusRequestProto;
-import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusResponseProto;
-import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainerRequestProto;
-import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainerResponseProto;
-import org.apache.hadoop.yarn.proto.YarnServiceProtos.StopContainerRequestProto;
-import org.apache.hadoop.yarn.proto.YarnServiceProtos.StopContainerResponseProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusesRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusesResponseProto;
+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 com.google.protobuf.RpcController;
 import com.google.protobuf.ServiceException;
@@ -53,12 +53,12 @@ public class ContainerManagementProtocol
   }
 
   @Override
-  public GetContainerStatusResponseProto getContainerStatus(RpcController arg0,
-      GetContainerStatusRequestProto proto) throws ServiceException {
-    GetContainerStatusRequestPBImpl request = new GetContainerStatusRequestPBImpl(proto);
+  public StartContainersResponseProto startContainers(RpcController arg0,
+      StartContainersRequestProto proto) throws ServiceException {
+    StartContainersRequestPBImpl request = new StartContainersRequestPBImpl(proto);
     try {
-      GetContainerStatusResponse response = real.getContainerStatus(request);
-      return ((GetContainerStatusResponsePBImpl)response).getProto();
+      StartContainersResponse response = real.startContainers(request);
+      return ((StartContainersResponsePBImpl)response).getProto();
     } catch (YarnException e) {
       throw new ServiceException(e);
     } catch (IOException e) {
@@ -67,12 +67,12 @@ public class ContainerManagementProtocol
   }
 
   @Override
-  public StartContainerResponseProto startContainer(RpcController arg0,
-      StartContainerRequestProto proto) throws ServiceException {
-    StartContainerRequestPBImpl request = new StartContainerRequestPBImpl(proto);
+  public StopContainersResponseProto stopContainers(RpcController arg0,
+      StopContainersRequestProto proto) throws ServiceException {
+    StopContainersRequestPBImpl request = new StopContainersRequestPBImpl(proto);
     try {
-      StartContainerResponse response = real.startContainer(request);
-      return ((StartContainerResponsePBImpl)response).getProto();
+      StopContainersResponse response = real.stopContainers(request);
+      return ((StopContainersResponsePBImpl)response).getProto();
     } catch (YarnException e) {
       throw new ServiceException(e);
     } catch (IOException e) {
@@ -81,17 +81,17 @@ public class ContainerManagementProtocol
   }
 
   @Override
-  public StopContainerResponseProto stopContainer(RpcController arg0,
-      StopContainerRequestProto proto) throws ServiceException {
-    StopContainerRequestPBImpl request = new StopContainerRequestPBImpl(proto);
+  public GetContainerStatusesResponseProto getContainerStatuses(
+      RpcController arg0, GetContainerStatusesRequestProto proto)
+      throws ServiceException {
+    GetContainerStatusesRequestPBImpl request = new GetContainerStatusesRequestPBImpl(proto);
     try {
-      StopContainerResponse response = real.stopContainer(request);
-      return ((StopContainerResponsePBImpl)response).getProto();
+      GetContainerStatusesResponse response = real.getContainerStatuses(request);
+      return ((GetContainerStatusesResponsePBImpl)response).getProto();
     } catch (YarnException e) {
       throw new ServiceException(e);
     } catch (IOException e) {
       throw new ServiceException(e);
     }
   }
-
 }

Added: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainerStatusesRequestPBImpl.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainerStatusesRequestPBImpl.java?rev=1506391&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainerStatusesRequestPBImpl.java (added)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainerStatusesRequestPBImpl.java Wed Jul 24 03:41:03 2013
@@ -0,0 +1,149 @@
+/**
+ * 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.classification.InterfaceAudience.Private;
+import org.apache.hadoop.classification.InterfaceStability.Unstable;
+import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesRequest;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.api.records.impl.pb.ContainerIdPBImpl;
+import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusesRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusesRequestProtoOrBuilder;
+
+@Private
+@Unstable
+public class GetContainerStatusesRequestPBImpl extends
+    GetContainerStatusesRequest {
+  GetContainerStatusesRequestProto proto = GetContainerStatusesRequestProto
+    .getDefaultInstance();
+  GetContainerStatusesRequestProto.Builder builder = null;
+  boolean viaProto = false;
+
+  private List<ContainerId> containerIds = null;
+
+  public GetContainerStatusesRequestPBImpl() {
+    builder = GetContainerStatusesRequestProto.newBuilder();
+  }
+
+  public GetContainerStatusesRequestPBImpl(
+      GetContainerStatusesRequestProto proto) {
+    this.proto = proto;
+    viaProto = true;
+  }
+
+  public GetContainerStatusesRequestProto 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 getProto().toString().replaceAll("\\n", ", ")
+      .replaceAll("\\s+", " ");
+  }
+
+  private void mergeLocalToBuilder() {
+    if (this.containerIds != null) {
+      addLocalContainerIdsToProto();
+    }
+  }
+
+  private void mergeLocalToProto() {
+    if (viaProto)
+      maybeInitBuilder();
+    mergeLocalToBuilder();
+    proto = builder.build();
+    viaProto = true;
+  }
+
+  private void maybeInitBuilder() {
+    if (viaProto || builder == null) {
+      builder = GetContainerStatusesRequestProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+
+  private void addLocalContainerIdsToProto() {
+    maybeInitBuilder();
+    builder.clearContainerId();
+    if (this.containerIds == null)
+      return;
+    List<ContainerIdProto> protoList = new ArrayList<ContainerIdProto>();
+    for (ContainerId id : containerIds) {
+      protoList.add(convertToProtoFormat(id));
+    }
+    builder.addAllContainerId(protoList);
+  }
+
+  private void initLocalContainerIds() {
+    if (this.containerIds != null) {
+      return;
+    }
+    GetContainerStatusesRequestProtoOrBuilder p = viaProto ? proto : builder;
+    List<ContainerIdProto> containerIds = p.getContainerIdList();
+    this.containerIds = new ArrayList<ContainerId>();
+    for (ContainerIdProto id : containerIds) {
+      this.containerIds.add(convertFromProtoFormat(id));
+    }
+  }
+
+  @Override
+  public List<ContainerId> getContainerIds() {
+    initLocalContainerIds();
+    return this.containerIds;
+  }
+
+  @Override
+  public void setContainerIds(List<ContainerId> containerIds) {
+    maybeInitBuilder();
+    if (containerIds == null)
+      builder.clearContainerId();
+    this.containerIds = containerIds;
+  }
+
+  private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) {
+    return new ContainerIdPBImpl(p);
+  }
+
+  private ContainerIdProto convertToProtoFormat(ContainerId t) {
+    return ((ContainerIdPBImpl) t).getProto();
+  }
+
+}

Added: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainerStatusesResponsePBImpl.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainerStatusesResponsePBImpl.java?rev=1506391&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainerStatusesResponsePBImpl.java (added)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetContainerStatusesResponsePBImpl.java Wed Jul 24 03:41:03 2013
@@ -0,0 +1,223 @@
+/**
+ * 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.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.GetContainerStatusesResponse;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.api.records.ContainerStatus;
+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.ContainerStatusPBImpl;
+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.ContainerStatusProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.SerializedExceptionProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.ContainerExceptionMapProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusesResponseProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusesResponseProtoOrBuilder;
+
+@Private
+@Unstable
+public class GetContainerStatusesResponsePBImpl extends
+    GetContainerStatusesResponse {
+  GetContainerStatusesResponseProto proto = GetContainerStatusesResponseProto
+    .getDefaultInstance();
+  GetContainerStatusesResponseProto.Builder builder = null;
+  boolean viaProto = false;
+
+  private List<ContainerStatus> containerStatuses = null;
+  private Map<ContainerId, SerializedException> failedRequests = null;
+
+  public GetContainerStatusesResponsePBImpl() {
+    builder = GetContainerStatusesResponseProto.newBuilder();
+  }
+
+  public GetContainerStatusesResponsePBImpl(
+      GetContainerStatusesResponseProto proto) {
+    this.proto = proto;
+    viaProto = true;
+  }
+
+  public GetContainerStatusesResponseProto 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 getProto().toString().replaceAll("\\n", ", ")
+      .replaceAll("\\s+", " ");
+  }
+
+  private void mergeLocalToBuilder() {
+    if (this.containerStatuses != null) {
+      addLocalContainerStatusesToProto();
+    }
+    if (this.failedRequests != null) {
+      addFailedRequestsToProto();
+    }
+  }
+
+  private void mergeLocalToProto() {
+    if (viaProto)
+      maybeInitBuilder();
+    mergeLocalToBuilder();
+    proto = builder.build();
+    viaProto = true;
+  }
+
+  private void maybeInitBuilder() {
+    if (viaProto || builder == null) {
+      builder = GetContainerStatusesResponseProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+
+  private void addLocalContainerStatusesToProto() {
+    maybeInitBuilder();
+    builder.clearStatus();
+    if (this.containerStatuses == null)
+      return;
+    List<ContainerStatusProto> protoList =
+        new ArrayList<ContainerStatusProto>();
+    for (ContainerStatus status : containerStatuses) {
+      protoList.add(convertToProtoFormat(status));
+    }
+    builder.addAllStatus(protoList);
+  }
+
+  private void addFailedRequestsToProto() {
+    maybeInitBuilder();
+    builder.clearFailedRequests();
+    if (this.failedRequests == null)
+      return;
+    List<ContainerExceptionMapProto> protoList =
+        new ArrayList<ContainerExceptionMapProto>();
+    for (Map.Entry<ContainerId, SerializedException> entry : this.failedRequests
+      .entrySet()) {
+      protoList.add(ContainerExceptionMapProto.newBuilder()
+        .setContainerId(convertToProtoFormat(entry.getKey()))
+        .setException(convertToProtoFormat(entry.getValue())).build());
+    }
+    builder.addAllFailedRequests(protoList);
+  }
+
+  private void initLocalContainerStatuses() {
+    if (this.containerStatuses != null) {
+      return;
+    }
+    GetContainerStatusesResponseProtoOrBuilder p = viaProto ? proto : builder;
+    List<ContainerStatusProto> statuses = p.getStatusList();
+    this.containerStatuses = new ArrayList<ContainerStatus>();
+    for (ContainerStatusProto status : statuses) {
+      this.containerStatuses.add(convertFromProtoFormat(status));
+    }
+  }
+
+  private void initFailedRequests() {
+    if (this.failedRequests != null) {
+      return;
+    }
+    GetContainerStatusesResponseProtoOrBuilder p = viaProto ? proto : builder;
+    List<ContainerExceptionMapProto> protoList = p.getFailedRequestsList();
+    this.failedRequests = new HashMap<ContainerId, SerializedException>();
+    for (ContainerExceptionMapProto ce : protoList) {
+      this.failedRequests.put(convertFromProtoFormat(ce.getContainerId()),
+        convertFromProtoFormat(ce.getException()));
+    }
+  }
+
+  @Override
+  public List<ContainerStatus> getContainerStatuses() {
+    initLocalContainerStatuses();
+    return this.containerStatuses;
+  }
+
+  @Override
+  public void setContainerStatuses(List<ContainerStatus> statuses) {
+    maybeInitBuilder();
+    if (statuses == null)
+      builder.clearStatus();
+    this.containerStatuses = statuses;
+  }
+
+  @Override
+  public Map<ContainerId, SerializedException> getFailedRequests() {
+    initFailedRequests();
+    return this.failedRequests;
+  }
+
+  @Override
+  public void setFailedRequests(
+      Map<ContainerId, SerializedException> failedRequests) {
+    maybeInitBuilder();
+    if (failedRequests == null)
+      builder.clearFailedRequests();
+    this.failedRequests = failedRequests;
+  }
+
+  private ContainerStatusPBImpl convertFromProtoFormat(ContainerStatusProto p) {
+    return new ContainerStatusPBImpl(p);
+  }
+
+  private ContainerStatusProto convertToProtoFormat(ContainerStatus t) {
+    return ((ContainerStatusPBImpl) t).getProto();
+  }
+
+  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();
+  }
+}

Added: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainersRequestPBImpl.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainersRequestPBImpl.java?rev=1506391&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainersRequestPBImpl.java (added)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainersRequestPBImpl.java Wed Jul 24 03:41:03 2013
@@ -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.StartContainerRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.StartContainersRequest;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainerRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainersRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainersRequestProtoOrBuilder;
+
+public class StartContainersRequestPBImpl extends StartContainersRequest {
+  StartContainersRequestProto proto = StartContainersRequestProto
+    .getDefaultInstance();
+  StartContainersRequestProto.Builder builder = null;
+  boolean viaProto = false;
+
+  private List<StartContainerRequest> requests = null;
+
+  public StartContainersRequestPBImpl() {
+    builder = StartContainersRequestProto.newBuilder();
+  }
+
+  public StartContainersRequestPBImpl(StartContainersRequestProto proto) {
+    this.proto = proto;
+    viaProto = true;
+  }
+
+  public StartContainersRequestProto 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 = StartContainersRequestProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+
+  private void addLocalRequestsToProto() {
+    maybeInitBuilder();
+    builder.clearStartContainerRequest();
+    List<StartContainerRequestProto> protoList =
+        new ArrayList<StartContainerRequestProto>();
+    for (StartContainerRequest r : this.requests) {
+      protoList.add(convertToProtoFormat(r));
+    }
+    builder.addAllStartContainerRequest(protoList);
+  }
+
+  private void initLocalRequests() {
+    StartContainersRequestProtoOrBuilder p = viaProto ? proto : builder;
+    List<StartContainerRequestProto> requestList =
+        p.getStartContainerRequestList();
+    this.requests = new ArrayList<StartContainerRequest>();
+    for (StartContainerRequestProto r : requestList) {
+      this.requests.add(convertFromProtoFormat(r));
+    }
+  }
+
+  @Override
+  public void setStartContainerRequests(List<StartContainerRequest> requests) {
+    maybeInitBuilder();
+    if (requests == null) {
+      builder.clearStartContainerRequest();
+    }
+    this.requests = requests;
+  }
+
+  @Override
+  public List<StartContainerRequest> getStartContainerRequests() {
+    if (this.requests != null) {
+      return this.requests;
+    }
+    initLocalRequests();
+    return this.requests;
+  }
+
+  private StartContainerRequestPBImpl convertFromProtoFormat(
+      StartContainerRequestProto p) {
+    return new StartContainerRequestPBImpl(p);
+  }
+
+  private StartContainerRequestProto convertToProtoFormat(
+      StartContainerRequest t) {
+    return ((StartContainerRequestPBImpl) t).getProto();
+  }
+}

Added: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainersResponsePBImpl.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainersResponsePBImpl.java?rev=1506391&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainersResponsePBImpl.java (added)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StartContainersResponsePBImpl.java Wed Jul 24 03:41:03 2013
@@ -0,0 +1,319 @@
+/**
+ * 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.nio.ByteBuffer;
+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.StartContainersResponse;
+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.ProtoUtils;
+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.YarnProtos.StringBytesMapProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.ContainerExceptionMapProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainersResponseProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainersResponseProtoOrBuilder;
+
+import com.google.protobuf.ByteString;
+
+@Private
+@Unstable
+public class StartContainersResponsePBImpl extends StartContainersResponse {
+  StartContainersResponseProto proto = StartContainersResponseProto
+    .getDefaultInstance();
+  StartContainersResponseProto.Builder builder = null;
+  boolean viaProto = false;
+
+  private Map<String, ByteBuffer> servicesMetaData = null;
+  private List<ContainerId> succeededContainers = null;
+  private Map<ContainerId, SerializedException> failedContainers = null;
+
+  public StartContainersResponsePBImpl() {
+    builder = StartContainersResponseProto.newBuilder();
+  }
+
+  public StartContainersResponsePBImpl(StartContainersResponseProto proto) {
+    this.proto = proto;
+    viaProto = true;
+  }
+
+  public StartContainersResponseProto 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 getProto().toString().replaceAll("\\n", ", ")
+      .replaceAll("\\s+", " ");
+  }
+
+  private void mergeLocalToBuilder() {
+    if (this.servicesMetaData != null) {
+      addServicesMetaDataToProto();
+    }
+    if (this.succeededContainers != null) {
+      addSucceededContainersToProto();
+    }
+    if (this.failedContainers != null) {
+      addFailedContainersToProto();
+    }
+  }
+
+  protected final ByteBuffer convertFromProtoFormat(ByteString byteString) {
+    return ProtoUtils.convertFromProtoFormat(byteString);
+  }
+
+  protected final ByteString convertToProtoFormat(ByteBuffer byteBuffer) {
+    return ProtoUtils.convertToProtoFormat(byteBuffer);
+  }
+
+  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();
+  }
+
+  private void mergeLocalToProto() {
+    if (viaProto) {
+      maybeInitBuilder();
+    }
+    mergeLocalToBuilder();
+    proto = builder.build();
+    viaProto = true;
+  }
+
+  private void maybeInitBuilder() {
+    if (viaProto || builder == null) {
+      builder = StartContainersResponseProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+
+  @Override
+  public Map<String, ByteBuffer> getAllServicesMetaData() {
+    initServicesMetaData();
+    return this.servicesMetaData;
+  }
+
+  @Override
+  public void setAllServicesMetaData(Map<String, ByteBuffer> servicesMetaData) {
+    if (servicesMetaData == null) {
+      return;
+    }
+    initServicesMetaData();
+    this.servicesMetaData.clear();
+    this.servicesMetaData.putAll(servicesMetaData);
+  }
+
+  private void initServicesMetaData() {
+    if (this.servicesMetaData != null) {
+      return;
+    }
+    StartContainersResponseProtoOrBuilder p = viaProto ? proto : builder;
+    List<StringBytesMapProto> list = p.getServicesMetaDataList();
+    this.servicesMetaData = new HashMap<String, ByteBuffer>();
+
+    for (StringBytesMapProto c : list) {
+      this.servicesMetaData.put(c.getKey(),
+        convertFromProtoFormat(c.getValue()));
+    }
+  }
+
+  private void addServicesMetaDataToProto() {
+    maybeInitBuilder();
+    builder.clearServicesMetaData();
+    if (servicesMetaData == null)
+      return;
+    Iterable<StringBytesMapProto> iterable =
+        new Iterable<StringBytesMapProto>() {
+
+          @Override
+          public Iterator<StringBytesMapProto> iterator() {
+            return new Iterator<StringBytesMapProto>() {
+
+              Iterator<String> keyIter = servicesMetaData.keySet().iterator();
+
+              @Override
+              public void remove() {
+                throw new UnsupportedOperationException();
+              }
+
+              @Override
+              public StringBytesMapProto next() {
+                String key = keyIter.next();
+                return StringBytesMapProto.newBuilder().setKey(key)
+                  .setValue(convertToProtoFormat(servicesMetaData.get(key)))
+                  .build();
+              }
+
+              @Override
+              public boolean hasNext() {
+                return keyIter.hasNext();
+              }
+            };
+          }
+        };
+    builder.addAllServicesMetaData(iterable);
+  }
+
+  private void addFailedContainersToProto() {
+    maybeInitBuilder();
+    builder.clearFailedRequests();
+    if (this.failedContainers == null)
+      return;
+    List<ContainerExceptionMapProto> protoList =
+        new ArrayList<ContainerExceptionMapProto>();
+
+    for (Map.Entry<ContainerId, SerializedException> entry : this.failedContainers
+      .entrySet()) {
+      protoList.add(ContainerExceptionMapProto.newBuilder()
+        .setContainerId(convertToProtoFormat(entry.getKey()))
+        .setException(convertToProtoFormat(entry.getValue())).build());
+    }
+    builder.addAllFailedRequests(protoList);
+  }
+
+  private void addSucceededContainersToProto() {
+    maybeInitBuilder();
+    builder.clearSucceededRequests();
+    if (this.succeededContainers == null) {
+      return;
+    }
+    Iterable<ContainerIdProto> iterable = new Iterable<ContainerIdProto>() {
+      @Override
+      public Iterator<ContainerIdProto> iterator() {
+        return new Iterator<ContainerIdProto>() {
+
+          Iterator<ContainerId> iter = succeededContainers.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 initSucceededContainers() {
+    if (this.succeededContainers != null)
+      return;
+    StartContainersResponseProtoOrBuilder p = viaProto ? proto : builder;
+    List<ContainerIdProto> list = p.getSucceededRequestsList();
+    this.succeededContainers = new ArrayList<ContainerId>();
+    for (ContainerIdProto c : list) {
+      this.succeededContainers.add(convertFromProtoFormat(c));
+    }
+  }
+
+  @Override
+  public List<ContainerId> getSuccessfullyStartedContainers() {
+    initSucceededContainers();
+    return this.succeededContainers;
+  }
+
+  @Override
+  public void setSuccessfullyStartedContainers(
+      List<ContainerId> succeededContainers) {
+    maybeInitBuilder();
+    if (succeededContainers == null) {
+      builder.clearSucceededRequests();
+    }
+    this.succeededContainers = succeededContainers;
+  }
+
+  private void initFailedContainers() {
+    if (this.failedContainers != null) {
+      return;
+    }
+    StartContainersResponseProtoOrBuilder p = viaProto ? proto : builder;
+    List<ContainerExceptionMapProto> protoList = p.getFailedRequestsList();
+    this.failedContainers = new HashMap<ContainerId, SerializedException>();
+    for (ContainerExceptionMapProto ce : protoList) {
+      this.failedContainers.put(convertFromProtoFormat(ce.getContainerId()),
+        convertFromProtoFormat(ce.getException()));
+    }
+  }
+
+  @Override
+  public Map<ContainerId, SerializedException> getFailedRequests() {
+    initFailedContainers();
+    return this.failedContainers;
+  }
+
+  @Override
+  public void setFailedRequests(
+      Map<ContainerId, SerializedException> failedContainers) {
+    maybeInitBuilder();
+    if (failedContainers == null)
+      builder.clearFailedRequests();
+    this.failedContainers = failedContainers;
+  }
+}

Added: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StopContainersRequestPBImpl.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StopContainersRequestPBImpl.java?rev=1506391&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StopContainersRequestPBImpl.java (added)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StopContainersRequestPBImpl.java Wed Jul 24 03:41:03 2013
@@ -0,0 +1,146 @@
+/**
+ * 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.classification.InterfaceAudience.Private;
+import org.apache.hadoop.classification.InterfaceStability.Unstable;
+import org.apache.hadoop.yarn.api.protocolrecords.StopContainersRequest;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.api.records.impl.pb.ContainerIdPBImpl;
+import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.StopContainersRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.StopContainersRequestProtoOrBuilder;
+
+@Private
+@Unstable
+public class StopContainersRequestPBImpl extends StopContainersRequest {
+  StopContainersRequestProto proto = StopContainersRequestProto
+    .getDefaultInstance();
+  StopContainersRequestProto.Builder builder = null;
+  boolean viaProto = false;
+
+  private List<ContainerId> containerIds = null;
+
+  public StopContainersRequestPBImpl() {
+    builder = StopContainersRequestProto.newBuilder();
+  }
+
+  public StopContainersRequestPBImpl(StopContainersRequestProto proto) {
+    this.proto = proto;
+    viaProto = true;
+  }
+
+  public StopContainersRequestProto 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 getProto().toString().replaceAll("\\n", ", ")
+      .replaceAll("\\s+", " ");
+  }
+
+  private void mergeLocalToBuilder() {
+    if (this.containerIds != null) {
+      addLocalContainerIdsToProto();
+    }
+  }
+
+  private void mergeLocalToProto() {
+    if (viaProto)
+      maybeInitBuilder();
+    mergeLocalToBuilder();
+    proto = builder.build();
+    viaProto = true;
+  }
+
+  private void maybeInitBuilder() {
+    if (viaProto || builder == null) {
+      builder = StopContainersRequestProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+
+  private void addLocalContainerIdsToProto() {
+    maybeInitBuilder();
+    builder.clearContainerId();
+    if (this.containerIds == null)
+      return;
+    List<ContainerIdProto> protoList = new ArrayList<ContainerIdProto>();
+    for (ContainerId id : containerIds) {
+      protoList.add(convertToProtoFormat(id));
+    }
+    builder.addAllContainerId(protoList);
+  }
+
+  private void initLocalContainerIds() {
+    if (this.containerIds != null) {
+      return;
+    }
+    StopContainersRequestProtoOrBuilder p = viaProto ? proto : builder;
+    List<ContainerIdProto> containerIds = p.getContainerIdList();
+    this.containerIds = new ArrayList<ContainerId>();
+    for (ContainerIdProto id : containerIds) {
+      this.containerIds.add(convertFromProtoFormat(id));
+    }
+  }
+
+  @Override
+  public List<ContainerId> getContainerIds() {
+    initLocalContainerIds();
+    return this.containerIds;
+  }
+
+  @Override
+  public void setContainerIds(List<ContainerId> containerIds) {
+    maybeInitBuilder();
+    if (containerIds == null)
+      builder.clearContainerId();
+    this.containerIds = containerIds;
+  }
+
+  private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) {
+    return new ContainerIdPBImpl(p);
+  }
+
+  private ContainerIdProto convertToProtoFormat(ContainerId t) {
+    return ((ContainerIdPBImpl) t).getProto();
+  }
+}

Added: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StopContainersResponsePBImpl.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StopContainersResponsePBImpl.java?rev=1506391&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StopContainersResponsePBImpl.java (added)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/StopContainersResponsePBImpl.java Wed Jul 24 03:41:03 2013
@@ -0,0 +1,234 @@
+/**
+ * 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.StopContainersResponse;
+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.StopContainersResponseProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.StopContainersResponseProtoOrBuilder;
+
+@Private
+@Unstable
+public class StopContainersResponsePBImpl extends StopContainersResponse {
+  StopContainersResponseProto proto = StopContainersResponseProto
+    .getDefaultInstance();
+  StopContainersResponseProto.Builder builder = null;
+  boolean viaProto = false;
+  private List<ContainerId> succeededRequests = null;
+  private Map<ContainerId, SerializedException> failedRequests = null;
+
+  public StopContainersResponsePBImpl() {
+    builder = StopContainersResponseProto.newBuilder();
+  }
+
+  public StopContainersResponsePBImpl(StopContainersResponseProto proto) {
+    this.proto = proto;
+    viaProto = true;
+  }
+
+  public StopContainersResponseProto 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 getProto().toString().replaceAll("\\n", ", ")
+      .replaceAll("\\s+", " ");
+  }
+
+  private void mergeLocalToProto() {
+    if (viaProto) {
+      maybeInitBuilder();
+    }
+    mergeLocalToBuilder();
+    proto = builder.build();
+    viaProto = true;
+  }
+
+  private void maybeInitBuilder() {
+    if (viaProto || builder == null) {
+      builder = StopContainersResponseProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+
+  private void mergeLocalToBuilder() {
+
+    if (this.succeededRequests != null) {
+      addSucceededRequestsToProto();
+    }
+    if (this.failedRequests != null) {
+      addFailedRequestsToProto();
+    }
+  }
+
+  private void addSucceededRequestsToProto() {
+    maybeInitBuilder();
+    builder.clearSucceededRequests();
+    if (this.succeededRequests == null) {
+      return;
+    }
+    Iterable<ContainerIdProto> iterable = new Iterable<ContainerIdProto>() {
+      @Override
+      public Iterator<ContainerIdProto> iterator() {
+        return new Iterator<ContainerIdProto>() {
+
+          Iterator<ContainerId> 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 addFailedRequestsToProto() {
+    maybeInitBuilder();
+    builder.clearFailedRequests();
+    if (this.failedRequests == null)
+      return;
+    List<ContainerExceptionMapProto> protoList =
+        new ArrayList<ContainerExceptionMapProto>();
+
+    for (Map.Entry<ContainerId, SerializedException> 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;
+    StopContainersResponseProtoOrBuilder p = viaProto ? proto : builder;
+    List<ContainerIdProto> list = p.getSucceededRequestsList();
+    this.succeededRequests = new ArrayList<ContainerId>();
+    for (ContainerIdProto c : list) {
+      this.succeededRequests.add(convertFromProtoFormat(c));
+    }
+  }
+
+  private void initFailedRequests() {
+    if (this.failedRequests != null) {
+      return;
+    }
+    StopContainersResponseProtoOrBuilder p = viaProto ? proto : builder;
+    List<ContainerExceptionMapProto> protoList = p.getFailedRequestsList();
+    this.failedRequests = new HashMap<ContainerId, SerializedException>();
+    for (ContainerExceptionMapProto ce : protoList) {
+      this.failedRequests.put(convertFromProtoFormat(ce.getContainerId()),
+        convertFromProtoFormat(ce.getException()));
+    }
+  }
+
+  @Override
+  public List<ContainerId> getSuccessfullyStoppedContainers() {
+    initSucceededRequests();
+    return this.succeededRequests;
+  }
+
+  @Override
+  public void setSuccessfullyStoppedContainers(List<ContainerId> succeededRequests) {
+    maybeInitBuilder();
+    if (succeededRequests == null) {
+      builder.clearSucceededRequests();
+    }
+    this.succeededRequests = succeededRequests;
+  }
+
+  @Override
+  public Map<ContainerId, SerializedException> getFailedRequests() {
+    initFailedRequests();
+    return this.failedRequests;
+  }
+
+  @Override
+  public void setFailedRequests(
+      Map<ContainerId, SerializedException> 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();
+  }
+}

Added: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/SerializedExceptionPBImpl.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/SerializedExceptionPBImpl.java?rev=1506391&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/SerializedExceptionPBImpl.java (added)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/SerializedExceptionPBImpl.java Wed Jul 24 03:41:03 2013
@@ -0,0 +1,169 @@
+/**
+ * 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.impl.pb;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.hadoop.yarn.api.records.SerializedException;
+import org.apache.hadoop.yarn.exceptions.YarnException;
+import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
+import org.apache.hadoop.yarn.proto.YarnProtos.SerializedExceptionProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.SerializedExceptionProtoOrBuilder;
+
+public class SerializedExceptionPBImpl extends SerializedException {
+
+  SerializedExceptionProto proto = SerializedExceptionProto
+      .getDefaultInstance();
+  SerializedExceptionProto.Builder builder = null;
+  boolean viaProto = false;
+
+  public SerializedExceptionPBImpl() {
+  }
+
+  public SerializedExceptionPBImpl(SerializedExceptionProto proto) {
+    this.proto = proto;
+    viaProto = true;
+  }
+
+  private SerializedExceptionPBImpl(Throwable t) {
+    init(t);
+  }
+
+  public void init(String message) {
+    maybeInitBuilder();
+    builder.setMessage(message);
+  }
+
+  public void init(Throwable t) {
+    maybeInitBuilder();
+    if (t == null) {
+      return;
+    }
+
+    if (t.getCause() == null) {
+    } else {
+      builder.setCause(new SerializedExceptionPBImpl(t.getCause()).getProto());
+    }
+    StringWriter sw = new StringWriter();
+    PrintWriter pw = new PrintWriter(sw);
+    t.printStackTrace(pw);
+    pw.close();
+    if (sw.toString() != null)
+      builder.setTrace(sw.toString());
+    if (t.getMessage() != null)
+      builder.setMessage(t.getMessage());
+    builder.setClassName(t.getClass().getCanonicalName());
+  }
+
+  public void init(String message, Throwable t) {
+    init(t);
+    if (message != null)
+      builder.setMessage(message);
+  }
+
+  @SuppressWarnings("unchecked")
+  @Override
+  public Throwable deSerialize() {
+
+    SerializedException cause = getCause();
+    SerializedExceptionProtoOrBuilder p = viaProto ? proto : builder;
+    Class<?> realClass = null;
+    try {
+      realClass = Class.forName(p.getClassName());
+    } catch (ClassNotFoundException e) {
+      throw new YarnRuntimeException(e);
+    }
+    Class classType = null;
+    if (YarnException.class.isAssignableFrom(realClass)) {
+      classType = YarnException.class;
+    } else if (IOException.class.isAssignableFrom(realClass)) {
+      classType = IOException.class;
+    } else if (RuntimeException.class.isAssignableFrom(realClass)) {
+      classType = RuntimeException.class;
+    } else {
+      classType = Exception.class;
+    }
+    return instantiateException(realClass.asSubclass(classType), getMessage(),
+      cause == null ? null : cause.deSerialize());
+  }
+
+  @Override
+  public String getMessage() {
+    SerializedExceptionProtoOrBuilder p = viaProto ? proto : builder;
+    return p.getMessage();
+  }
+
+  @Override
+  public String getRemoteTrace() {
+    SerializedExceptionProtoOrBuilder p = viaProto ? proto : builder;
+    return p.getTrace();
+  }
+
+  @Override
+  public SerializedException getCause() {
+    SerializedExceptionProtoOrBuilder p = viaProto ? proto : builder;
+    if (p.hasCause()) {
+      return new SerializedExceptionPBImpl(p.getCause());
+    } else {
+      return null;
+    }
+  }
+
+  public SerializedExceptionProto getProto() {
+    proto = viaProto ? proto : builder.build();
+    viaProto = true;
+    return proto;
+  }
+
+  private void maybeInitBuilder() {
+    if (viaProto || builder == null) {
+      builder = SerializedExceptionProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+
+  private static <T extends Throwable> T instantiateException(
+      Class<? extends T> cls, String message, Throwable cause) {
+    Constructor<? extends T> cn;
+    T ex = null;
+    try {
+      cn = cls.getConstructor(String.class);
+      cn.setAccessible(true);
+      ex = cn.newInstance(message);
+      ex.initCause(cause);
+    } catch (SecurityException e) {
+      throw new YarnRuntimeException(e);
+    } catch (NoSuchMethodException e) {
+      throw new YarnRuntimeException(e);
+    } catch (IllegalArgumentException e) {
+      throw new YarnRuntimeException(e);
+    } catch (InstantiationException e) {
+      throw new YarnRuntimeException(e);
+    } catch (IllegalAccessException e) {
+      throw new YarnRuntimeException(e);
+    } catch (InvocationTargetException e) {
+      throw new YarnRuntimeException(e);
+    }
+    return ex;
+  }
+}
\ No newline at end of file

Modified: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestContainerLaunchRPC.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestContainerLaunchRPC.java?rev=1506391&r1=1506390&r2=1506391&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestContainerLaunchRPC.java (original)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestContainerLaunchRPC.java Wed Jul 24 03:41:03 2013
@@ -21,6 +21,8 @@ package org.apache.hadoop.yarn;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.SocketTimeoutException;
+import java.util.ArrayList;
+import java.util.List;
 
 import junit.framework.Assert;
 
@@ -31,12 +33,13 @@ import org.apache.hadoop.ipc.Server;
 import org.apache.hadoop.net.NetUtils;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.hadoop.yarn.api.ContainerManagementProtocol;
-import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusRequest;
-import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesResponse;
 import org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest;
-import org.apache.hadoop.yarn.api.protocolrecords.StartContainerResponse;
-import org.apache.hadoop.yarn.api.protocolrecords.StopContainerRequest;
-import org.apache.hadoop.yarn.api.protocolrecords.StopContainerResponse;
+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.records.ApplicationAttemptId;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ContainerId;
@@ -104,12 +107,15 @@ public class TestContainerLaunchRPC {
           TestRPC.newContainerToken(nodeId, "password".getBytes(),
             containerTokenIdentifier);
 
-      StartContainerRequest scRequest = recordFactory
-          .newRecordInstance(StartContainerRequest.class);
-      scRequest.setContainerLaunchContext(containerLaunchContext);
-      scRequest.setContainerToken(containerToken);
+      StartContainerRequest scRequest =
+          StartContainerRequest.newInstance(containerLaunchContext,
+            containerToken);
+      List<StartContainerRequest> list = new ArrayList<StartContainerRequest>();
+      list.add(scRequest);
+      StartContainersRequest allRequests =
+          StartContainersRequest.newInstance(list);
       try {
-        proxy.startContainer(scRequest);
+        proxy.startContainers(allRequests);
       } catch (Exception e) {
         LOG.info(StringUtils.stringifyException(e));
         Assert.assertEquals("Error, exception is not: "
@@ -129,17 +135,8 @@ public class TestContainerLaunchRPC {
     private ContainerStatus status = null;
 
     @Override
-    public GetContainerStatusResponse getContainerStatus(
-        GetContainerStatusRequest request) throws YarnException {
-      GetContainerStatusResponse response = recordFactory
-          .newRecordInstance(GetContainerStatusResponse.class);
-      response.setStatus(status);
-      return response;
-    }
-
-    @Override
-    public StartContainerResponse startContainer(StartContainerRequest request)
-        throws YarnException, IOException {
+    public StartContainersResponse startContainers(
+        StartContainersRequest requests) throws YarnException, IOException {
       try {
         // make the thread sleep to look like its not going to respond
         Thread.sleep(10000);
@@ -151,11 +148,22 @@ public class TestContainerLaunchRPC {
     }
 
     @Override
-    public StopContainerResponse stopContainer(StopContainerRequest request)
-        throws YarnException {
+    public StopContainersResponse
+        stopContainers(StopContainersRequest requests) throws YarnException,
+            IOException {
       Exception e = new Exception("Dummy function", new Exception(
           "Dummy function cause"));
       throw new YarnException(e);
     }
+
+    @Override
+    public GetContainerStatusesResponse getContainerStatuses(
+        GetContainerStatusesRequest request) throws YarnException, IOException {
+      List<ContainerStatus> list = new ArrayList<ContainerStatus>();
+      list.add(status);
+      GetContainerStatusesResponse response =
+          GetContainerStatusesResponse.newInstance(list, null);
+      return null;
+    }
   }
 }

Modified: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestRPC.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestRPC.java?rev=1506391&r1=1506390&r2=1506391&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestRPC.java (original)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestRPC.java Wed Jul 24 03:41:03 2013
@@ -20,6 +20,8 @@ package org.apache.hadoop.yarn;
 
 import java.io.IOException;
 import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.List;
 
 import junit.framework.Assert;
 
@@ -33,13 +35,14 @@ import org.apache.hadoop.security.Securi
 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.GetContainerStatusRequest;
-import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusResponse;
+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.StartContainerRequest;
-import org.apache.hadoop.yarn.api.protocolrecords.StartContainerResponse;
-import org.apache.hadoop.yarn.api.protocolrecords.StopContainerRequest;
-import org.apache.hadoop.yarn.api.protocolrecords.StopContainerResponse;
+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.records.ApplicationAttemptId;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ContainerId;
@@ -122,9 +125,6 @@ public class TestRPC {
         ApplicationAttemptId.newInstance(applicationId, 0);
     ContainerId containerId =
         ContainerId.newInstance(applicationAttemptId, 100);
-    StartContainerRequest scRequest =
-        recordFactory.newRecordInstance(StartContainerRequest.class);
-    scRequest.setContainerLaunchContext(containerLaunchContext);
     NodeId nodeId = NodeId.newInstance("localhost", 1234);
     Resource resource = Resource.newInstance(1234, 2);
     ContainerTokenIdentifier containerTokenIdentifier =
@@ -132,22 +132,32 @@ public class TestRPC {
           resource, System.currentTimeMillis() + 10000, 42, 42);
     Token containerToken = newContainerToken(nodeId, "password".getBytes(),
           containerTokenIdentifier);
-    scRequest.setContainerToken(containerToken);
-    proxy.startContainer(scRequest);
-    
-    GetContainerStatusRequest gcsRequest = 
-        recordFactory.newRecordInstance(GetContainerStatusRequest.class);
-    gcsRequest.setContainerId(containerId);
-    GetContainerStatusResponse response =  proxy.getContainerStatus(gcsRequest);
-    ContainerStatus status = response.getStatus();
-    
+
+    StartContainerRequest scRequest =
+        StartContainerRequest.newInstance(containerLaunchContext,
+          containerToken);
+    List<StartContainerRequest> list = new ArrayList<StartContainerRequest>();
+    list.add(scRequest);
+    StartContainersRequest allRequests =
+        StartContainersRequest.newInstance(list);
+    proxy.startContainers(allRequests);
+
+    List<ContainerId> containerIds = new ArrayList<ContainerId>();
+    containerIds.add(containerId);
+    GetContainerStatusesRequest gcsRequest =
+        GetContainerStatusesRequest.newInstance(containerIds);
+    GetContainerStatusesResponse response =
+        proxy.getContainerStatuses(gcsRequest);
+    List<ContainerStatus> statuses = response.getContainerStatuses();
+
     //test remote exception
     boolean exception = false;
     try {
-      StopContainerRequest stopRequest = recordFactory.newRecordInstance(StopContainerRequest.class);
-      stopRequest.setContainerId(containerId);
-      proxy.stopContainer(stopRequest);
-    } catch (YarnException e) {
+      StopContainersRequest stopRequest =
+          recordFactory.newRecordInstance(StopContainersRequest.class);
+      stopRequest.setContainerIds(containerIds);
+      proxy.stopContainers(stopRequest);
+      } catch (YarnException e) {
       exception = true;
       Assert.assertTrue(e.getMessage().contains(EXCEPTION_MSG));
       Assert.assertTrue(e.getMessage().contains(EXCEPTION_CAUSE));
@@ -158,46 +168,51 @@ public class TestRPC {
     Assert.assertTrue(exception);
     
     server.stop();
-    Assert.assertNotNull(status);
-    Assert.assertEquals(ContainerState.RUNNING, status.getState());
+    Assert.assertNotNull(statuses.get(0));
+    Assert.assertEquals(ContainerState.RUNNING, statuses.get(0).getState());
   }
 
   public class DummyContainerManager implements ContainerManagementProtocol {
 
-    private ContainerStatus status = null;    
-    
+    private List<ContainerStatus> statuses = new ArrayList<ContainerStatus>();
+
     @Override
-    public GetContainerStatusResponse getContainerStatus(
-        GetContainerStatusRequest request)
+    public GetContainerStatusesResponse getContainerStatuses(
+        GetContainerStatusesRequest request)
     throws YarnException {
-      GetContainerStatusResponse response = 
-          recordFactory.newRecordInstance(GetContainerStatusResponse.class);
-      response.setStatus(status);
+      GetContainerStatusesResponse response = 
+          recordFactory.newRecordInstance(GetContainerStatusesResponse.class);
+      response.setContainerStatuses(statuses);
       return response;
     }
 
     @Override
-    public StartContainerResponse startContainer(StartContainerRequest request) 
-        throws YarnException {
-      Token containerToken = request.getContainerToken();
-      ContainerTokenIdentifier tokenId = null;
-
-      try {
-        tokenId = newContainerTokenIdentifier(containerToken);
-      } catch (IOException e) {
-        throw RPCUtil.getRemoteException(e);
+    public StartContainersResponse startContainers(
+        StartContainersRequest requests) throws YarnException {
+      StartContainersResponse response =
+          recordFactory.newRecordInstance(StartContainersResponse.class);
+      for (StartContainerRequest request : requests.getStartContainerRequests()) {
+        Token containerToken = request.getContainerToken();
+        ContainerTokenIdentifier tokenId = null;
+
+        try {
+          tokenId = newContainerTokenIdentifier(containerToken);
+        } catch (IOException e) {
+          throw RPCUtil.getRemoteException(e);
+        }
+        ContainerStatus status =
+            recordFactory.newRecordInstance(ContainerStatus.class);
+        status.setState(ContainerState.RUNNING);
+        status.setContainerId(tokenId.getContainerID());
+        status.setExitStatus(0);
+        statuses.add(status);
+
       }
-      StartContainerResponse response = 
-          recordFactory.newRecordInstance(StartContainerResponse.class);
-      status = recordFactory.newRecordInstance(ContainerStatus.class);
-      status.setState(ContainerState.RUNNING);
-      status.setContainerId(tokenId.getContainerID());
-      status.setExitStatus(0);
       return response;
     }
 
     @Override
-    public StopContainerResponse stopContainer(StopContainerRequest request) 
+    public StopContainersResponse stopContainers(StopContainersRequest request) 
     throws YarnException {
       Exception e = new Exception(EXCEPTION_MSG, 
           new Exception(EXCEPTION_CAUSE));

Modified: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/utils/YarnServerBuilderUtils.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/utils/YarnServerBuilderUtils.java?rev=1506391&r1=1506390&r2=1506391&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/utils/YarnServerBuilderUtils.java (original)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/utils/YarnServerBuilderUtils.java Wed Jul 24 03:41:03 2013
@@ -22,12 +22,12 @@ import java.util.List;
 
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.api.records.SerializedException;
 import org.apache.hadoop.yarn.factories.RecordFactory;
 import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
 import org.apache.hadoop.yarn.server.api.protocolrecords.NodeHeartbeatResponse;
 import org.apache.hadoop.yarn.server.api.records.MasterKey;
 import org.apache.hadoop.yarn.server.api.records.NodeAction;
-import org.apache.hadoop.yarn.server.api.records.SerializedException;
 import org.apache.hadoop.yarn.util.Records;
 
 /**
@@ -59,10 +59,4 @@ public class YarnServerBuilderUtils {
     }
     return response;
   }
-  
-  public static SerializedException newSerializedException(Throwable e) {
-    SerializedException se = Records.newRecord(SerializedException.class);
-    se.init(e);
-    return se;
-  }
 }

Modified: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/TestYarnServerApiClasses.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/TestYarnServerApiClasses.java?rev=1506391&r1=1506390&r2=1506391&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/TestYarnServerApiClasses.java (original)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/TestYarnServerApiClasses.java Wed Jul 24 03:41:03 2013
@@ -34,6 +34,7 @@ import org.apache.hadoop.yarn.api.record
 import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationAttemptIdPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl;
 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.factory.providers.RecordFactoryProvider;
 import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.NodeHeartbeatRequestPBImpl;
 import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.NodeHeartbeatResponsePBImpl;
@@ -45,7 +46,6 @@ import org.apache.hadoop.yarn.server.api
 import org.apache.hadoop.yarn.server.api.records.NodeStatus;
 import org.apache.hadoop.yarn.server.api.records.impl.pb.MasterKeyPBImpl;
 import org.apache.hadoop.yarn.server.api.records.impl.pb.NodeStatusPBImpl;
-import org.apache.hadoop.yarn.server.api.records.impl.pb.SerializedExceptionPBImpl;
 import org.junit.Test;
 
 /**

Modified: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/api/protocolrecords/LocalResourceStatus.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/api/protocolrecords/LocalResourceStatus.java?rev=1506391&r1=1506390&r2=1506391&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/api/protocolrecords/LocalResourceStatus.java (original)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/api/protocolrecords/LocalResourceStatus.java Wed Jul 24 03:41:03 2013
@@ -18,8 +18,8 @@
 package org.apache.hadoop.yarn.server.nodemanager.api.protocolrecords;
 
 import org.apache.hadoop.yarn.api.records.LocalResource;
+import org.apache.hadoop.yarn.api.records.SerializedException;
 import org.apache.hadoop.yarn.api.records.URL;
-import org.apache.hadoop.yarn.server.api.records.SerializedException;
 
 public interface LocalResourceStatus {
   public LocalResource getResource();

Modified: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/api/protocolrecords/impl/pb/LocalResourceStatusPBImpl.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/api/protocolrecords/impl/pb/LocalResourceStatusPBImpl.java?rev=1506391&r1=1506390&r2=1506391&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/api/protocolrecords/impl/pb/LocalResourceStatusPBImpl.java (original)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/api/protocolrecords/impl/pb/LocalResourceStatusPBImpl.java Wed Jul 24 03:41:03 2013
@@ -18,9 +18,11 @@
 package org.apache.hadoop.yarn.server.nodemanager.api.protocolrecords.impl.pb;
 
 import org.apache.hadoop.yarn.api.records.LocalResource;
+import org.apache.hadoop.yarn.api.records.SerializedException;
 import org.apache.hadoop.yarn.api.records.URL;
 import org.apache.hadoop.yarn.api.records.impl.pb.LocalResourcePBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.ProtoBase;
+import org.apache.hadoop.yarn.api.records.impl.pb.SerializedExceptionPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.URLPBImpl;
 import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.SerializedExceptionProto;
@@ -28,8 +30,6 @@ import org.apache.hadoop.yarn.proto.Yarn
 import org.apache.hadoop.yarn.proto.YarnServerNodemanagerServiceProtos.LocalResourceStatusProto;
 import org.apache.hadoop.yarn.proto.YarnServerNodemanagerServiceProtos.LocalResourceStatusProtoOrBuilder;
 import org.apache.hadoop.yarn.proto.YarnServerNodemanagerServiceProtos.ResourceStatusTypeProto;
-import org.apache.hadoop.yarn.server.api.records.SerializedException;
-import org.apache.hadoop.yarn.server.api.records.impl.pb.SerializedExceptionPBImpl;
 import org.apache.hadoop.yarn.server.nodemanager.api.protocolrecords.LocalResourceStatus;
 import org.apache.hadoop.yarn.server.nodemanager.api.protocolrecords.ResourceStatusType;
 



Mime
View raw message