hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acmur...@apache.org
Subject svn commit: r1087462 [12/20] - in /hadoop/mapreduce/branches/MR-279: ./ mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapred/ mr-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/jobhistory/ mr-client/...
Date Thu, 31 Mar 2011 22:23:34 GMT
Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourcePBImpl.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourcePBImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourcePBImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourcePBImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,57 @@
+package org.apache.hadoop.yarn.api.records.impl.pb;
+
+
+import org.apache.hadoop.yarn.api.records.ProtoBase;
+import org.apache.hadoop.yarn.api.records.Resource;
+import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProtoOrBuilder;
+
+
+    
+public class ResourcePBImpl extends ProtoBase<ResourceProto> implements Resource {
+  ResourceProto proto = ResourceProto.getDefaultInstance();
+  ResourceProto.Builder builder = null;
+  boolean viaProto = false;
+  
+  public ResourcePBImpl() {
+    builder = ResourceProto.newBuilder();
+  }
+
+  public ResourcePBImpl(ResourceProto proto) {
+    this.proto = proto;
+    viaProto = true;
+  }
+  
+  public ResourceProto getProto() {
+    proto = viaProto ? proto : builder.build();
+    viaProto = true;
+    return proto;
+  }
+
+  private void maybeInitBuilder() {
+    if (viaProto || builder == null) {
+      builder = ResourceProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+    
+  
+  @Override
+  public int getMemory() {
+    ResourceProtoOrBuilder p = viaProto ? proto : builder;
+    return (p.getMemory());
+  }
+
+  @Override
+  public void setMemory(int memory) {
+    maybeInitBuilder();
+    builder.setMemory((memory));
+  }
+
+  @Override
+  public int compareTo(Resource other) {
+    return this.getMemory() - other.getMemory();
+  }
+  
+  
+}  

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourceRequestPBImpl.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourceRequestPBImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourceRequestPBImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourceRequestPBImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,174 @@
+package org.apache.hadoop.yarn.api.records.impl.pb;
+
+
+import org.apache.hadoop.yarn.api.records.Priority;
+import org.apache.hadoop.yarn.api.records.ProtoBase;
+import org.apache.hadoop.yarn.api.records.Resource;
+import org.apache.hadoop.yarn.api.records.ResourceRequest;
+import org.apache.hadoop.yarn.api.records.impl.pb.PriorityPBImpl;
+import org.apache.hadoop.yarn.api.records.impl.pb.ResourcePBImpl;
+import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ResourceRequestProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ResourceRequestProtoOrBuilder;
+
+
+    
+public class ResourceRequestPBImpl extends ProtoBase<ResourceRequestProto> implements  ResourceRequest {
+  ResourceRequestProto proto = ResourceRequestProto.getDefaultInstance();
+  ResourceRequestProto.Builder builder = null;
+  boolean viaProto = false;
+  
+  private Priority priority = null;
+  private Resource capability = null;
+  
+  
+  public ResourceRequestPBImpl() {
+    builder = ResourceRequestProto.newBuilder();
+  }
+
+  public ResourceRequestPBImpl(ResourceRequestProto proto) {
+    this.proto = proto;
+    viaProto = true;
+  }
+  
+  public ResourceRequestProto getProto() {
+      mergeLocalToProto();
+    proto = viaProto ? proto : builder.build();
+    viaProto = true;
+    return proto;
+  }
+
+  private void mergeLocalToBuilder() {
+    if (this.priority != null) {
+      builder.setPriority(convertToProtoFormat(this.priority));
+    }
+    if (this.capability != null) {
+      builder.setCapability(convertToProtoFormat(this.capability));
+    }
+  }
+
+  private void mergeLocalToProto() {
+    if (viaProto) 
+      maybeInitBuilder();
+    mergeLocalToBuilder();
+    proto = builder.build();
+    viaProto = true;
+  }
+
+  private void maybeInitBuilder() {
+    if (viaProto || builder == null) {
+      builder = ResourceRequestProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+    
+  
+  @Override
+  public Priority getPriority() {
+    ResourceRequestProtoOrBuilder p = viaProto ? proto : builder;
+    if (this.priority != null) {
+      return this.priority;
+    }
+    if (!p.hasPriority()) {
+      return null;
+    }
+    this.priority = convertFromProtoFormat(p.getPriority());
+    return this.priority;
+  }
+
+  @Override
+  public void setPriority(Priority priority) {
+    maybeInitBuilder();
+    if (priority == null) 
+      builder.clearPriority();
+    this.priority = priority;
+  }
+  @Override
+  public String getHostName() {
+    ResourceRequestProtoOrBuilder p = viaProto ? proto : builder;
+    if (!p.hasHostName()) {
+      return null;
+    }
+    return (p.getHostName());
+  }
+
+  @Override
+  public void setHostName(String hostName) {
+    maybeInitBuilder();
+    if (hostName == null) {
+      builder.clearHostName();
+      return;
+    }
+    builder.setHostName((hostName));
+  }
+  @Override
+  public Resource getCapability() {
+    ResourceRequestProtoOrBuilder p = viaProto ? proto : builder;
+    if (this.capability != null) {
+      return this.capability;
+    }
+    if (!p.hasCapability()) {
+      return null;
+    }
+    this.capability = convertFromProtoFormat(p.getCapability());
+    return this.capability;
+  }
+
+  @Override
+  public void setCapability(Resource capability) {
+    maybeInitBuilder();
+    if (capability == null) 
+      builder.clearCapability();
+    this.capability = capability;
+  }
+  @Override
+  public int getNumContainers() {
+    ResourceRequestProtoOrBuilder p = viaProto ? proto : builder;
+    return (p.getNumContainers());
+  }
+
+  @Override
+  public void setNumContainers(int numContainers) {
+    maybeInitBuilder();
+    builder.setNumContainers((numContainers));
+  }
+
+  private PriorityPBImpl convertFromProtoFormat(PriorityProto p) {
+    return new PriorityPBImpl(p);
+  }
+
+  private PriorityProto convertToProtoFormat(Priority t) {
+    return ((PriorityPBImpl)t).getProto();
+  }
+
+  private ResourcePBImpl convertFromProtoFormat(ResourceProto p) {
+    return new ResourcePBImpl(p);
+  }
+
+  private ResourceProto convertToProtoFormat(Resource t) {
+    return ((ResourcePBImpl)t).getProto();
+  }
+
+  @Override
+  public int compareTo(ResourceRequest other) {
+    if (this.getPriority().compareTo(other.getPriority()) == 0) {
+      if (this.getHostName().equals(other.getHostName())) {
+        if (this.getCapability().equals(other.getCapability())) {
+          if (this.getNumContainers() == other.getNumContainers()) {
+            return 0;
+          } else {
+            return this.getNumContainers() - other.getNumContainers();
+          }
+        } else {
+          return this.getCapability().compareTo(other.getCapability());
+        }
+      } else {
+        return this.getHostName().compareTo(other.getHostName());
+      }
+    } else {
+      return this.getPriority().compareTo(other.getPriority());
+    }
+  }
+
+}  

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/URLPBImpl.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/URLPBImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/URLPBImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/URLPBImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,107 @@
+package org.apache.hadoop.yarn.api.records.impl.pb;
+
+
+import org.apache.hadoop.yarn.api.records.ProtoBase;
+import org.apache.hadoop.yarn.api.records.URL;
+import org.apache.hadoop.yarn.proto.YarnProtos.URLProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.URLProtoOrBuilder;
+
+
+    
+public class URLPBImpl extends ProtoBase<URLProto> implements URL {
+  URLProto proto = URLProto.getDefaultInstance();
+  URLProto.Builder builder = null;
+  boolean viaProto = false;
+  
+  public URLPBImpl() {
+    builder = URLProto.newBuilder();
+  }
+
+  public URLPBImpl(URLProto proto) {
+    this.proto = proto;
+    viaProto = true;
+  }
+  
+  public URLProto getProto() {
+    proto = viaProto ? proto : builder.build();
+    viaProto = true;
+    return proto;
+  }
+
+  private void maybeInitBuilder() {
+    if (viaProto || builder == null) {
+      builder = URLProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+    
+  
+  @Override
+  public String getFile() {
+    URLProtoOrBuilder p = viaProto ? proto : builder;
+    if (!p.hasFile()) {
+      return null;
+    }
+    return (p.getFile());
+  }
+
+  @Override
+  public void setFile(String file) {
+    maybeInitBuilder();
+    if (file == null) { 
+      builder.clearFile();
+      return;
+    }
+    builder.setFile((file));
+  }
+  @Override
+  public String getScheme() {
+    URLProtoOrBuilder p = viaProto ? proto : builder;
+    if (!p.hasScheme()) {
+      return null;
+    }
+    return (p.getScheme());
+  }
+
+  @Override
+  public void setScheme(String scheme) {
+    maybeInitBuilder();
+    if (scheme == null) { 
+      builder.clearScheme();
+      return;
+    }
+    builder.setScheme((scheme));
+  }
+  @Override
+  public String getHost() {
+    URLProtoOrBuilder p = viaProto ? proto : builder;
+    if (!p.hasHost()) {
+      return null;
+    }
+    return (p.getHost());
+  }
+
+  @Override
+  public void setHost(String host) {
+    maybeInitBuilder();
+    if (host == null) { 
+      builder.clearHost();
+      return;
+    }
+    builder.setHost((host));
+  }
+  @Override
+  public int getPort() {
+    URLProtoOrBuilder p = viaProto ? proto : builder;
+    return (p.getPort());
+  }
+
+  @Override
+  public void setPort(int port) {
+    maybeInitBuilder();
+    builder.setPort((port));
+  }
+
+
+
+}  

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/YarnClusterMetricsPBImpl.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/YarnClusterMetricsPBImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/YarnClusterMetricsPBImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/YarnClusterMetricsPBImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,53 @@
+package org.apache.hadoop.yarn.api.records.impl.pb;
+
+
+import org.apache.hadoop.yarn.api.records.ProtoBase;
+import org.apache.hadoop.yarn.api.records.YarnClusterMetrics;
+import org.apache.hadoop.yarn.proto.YarnProtos.YarnClusterMetricsProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.YarnClusterMetricsProtoOrBuilder;
+
+
+    
+public class YarnClusterMetricsPBImpl extends ProtoBase<YarnClusterMetricsProto> implements YarnClusterMetrics {
+  YarnClusterMetricsProto proto = YarnClusterMetricsProto.getDefaultInstance();
+  YarnClusterMetricsProto.Builder builder = null;
+  boolean viaProto = false;
+  
+  public YarnClusterMetricsPBImpl() {
+    builder = YarnClusterMetricsProto.newBuilder();
+  }
+
+  public YarnClusterMetricsPBImpl(YarnClusterMetricsProto proto) {
+    this.proto = proto;
+    viaProto = true;
+  }
+  
+  public YarnClusterMetricsProto getProto() {
+    proto = viaProto ? proto : builder.build();
+    viaProto = true;
+    return proto;
+  }
+
+  private void maybeInitBuilder() {
+    if (viaProto || builder == null) {
+      builder = YarnClusterMetricsProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+    
+  
+  @Override
+  public int getNumNodeManagers() {
+    YarnClusterMetricsProtoOrBuilder p = viaProto ? proto : builder;
+    return (p.getNumNodeManagers());
+  }
+
+  @Override
+  public void setNumNodeManagers(int numNodeManagers) {
+    maybeInitBuilder();
+    builder.setNumNodeManagers((numNodeManagers));
+  }
+
+
+
+}  

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/exceptions/YarnRemoteException.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/exceptions/YarnRemoteException.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/exceptions/YarnRemoteException.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/exceptions/YarnRemoteException.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,27 @@
+package org.apache.hadoop.yarn.exceptions;
+
+import java.io.IOException;
+
+public abstract class YarnRemoteException extends IOException {
+  private static final long serialVersionUID = 1L;
+  
+  public YarnRemoteException() {
+    super();
+  }
+  
+  public YarnRemoteException(String message, Throwable cause) {
+    super(message, cause);
+  }
+  
+  public YarnRemoteException(Throwable cause) {
+    super(cause);
+  }
+  
+  public YarnRemoteException(String message) {
+    super(message);
+  }
+  
+  public abstract String getRemoteTrace();
+  
+  public abstract YarnRemoteException getCause();
+}
\ No newline at end of file

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/exceptions/impl/pb/YarnRemoteExceptionPBImpl.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/exceptions/impl/pb/YarnRemoteExceptionPBImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/exceptions/impl/pb/YarnRemoteExceptionPBImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/exceptions/impl/pb/YarnRemoteExceptionPBImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,90 @@
+package org.apache.hadoop.yarn.exceptions.impl.pb;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
+import org.apache.hadoop.yarn.proto.YarnProtos.YarnRemoteExceptionProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.YarnRemoteExceptionProtoOrBuilder;
+
+public class YarnRemoteExceptionPBImpl extends YarnRemoteException {
+
+  private static final long serialVersionUID = 1L;
+
+  YarnRemoteExceptionProto proto = YarnRemoteExceptionProto.getDefaultInstance();
+  YarnRemoteExceptionProto.Builder builder = null;
+  boolean viaProto = false;
+
+  public YarnRemoteExceptionPBImpl() {
+  }
+
+  public YarnRemoteExceptionPBImpl(YarnRemoteExceptionProto proto) {
+    this.proto = proto;
+    viaProto = true;
+  }
+  
+  public YarnRemoteExceptionPBImpl(String message) {
+    super(message);
+    maybeInitBuilder();
+    builder.setMessage(super.getMessage());
+  }
+
+  public YarnRemoteExceptionPBImpl(Throwable t) {
+    super(t);
+    maybeInitBuilder();
+
+    if (t.getCause() == null) { 
+    } else {
+      builder.setCause(new YarnRemoteExceptionPBImpl(t.getCause()).getProto());
+      builder.setClassName(t.getClass().getName());
+    }
+    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());
+  }
+  
+  public YarnRemoteExceptionPBImpl(String message, Throwable t) {
+    this(t);
+    if (message != null) 
+      builder.setMessage(message);
+  }
+  @Override
+  public String getMessage() {
+    YarnRemoteExceptionProtoOrBuilder p = viaProto ? proto : builder;
+    return p.getMessage();
+  }
+  
+  @Override
+  public String getRemoteTrace() {
+    YarnRemoteExceptionProtoOrBuilder p = viaProto ? proto : builder;
+    return p.getTrace();
+  }
+
+  @Override
+  public YarnRemoteException getCause() {
+    YarnRemoteExceptionProtoOrBuilder p = viaProto ? proto : builder;
+    if (p.hasCause()) {
+      return new YarnRemoteExceptionPBImpl(p.getCause());
+    } else {
+      return null;
+    }
+  }
+
+  public YarnRemoteExceptionProto getProto() {
+    proto = viaProto ? proto : builder.build();
+    viaProto = true;
+    return proto;
+  }
+
+  private void maybeInitBuilder() {
+    if (viaProto || builder == null) {
+      builder = YarnRemoteExceptionProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+}
\ No newline at end of file

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/util/ProtoUtils.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/util/ProtoUtils.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/util/ProtoUtils.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/util/ProtoUtils.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,92 @@
+package org.apache.hadoop.yarn.util;
+
+import java.nio.ByteBuffer;
+
+import org.apache.hadoop.yarn.api.records.ApplicationState;
+import org.apache.hadoop.yarn.api.records.ContainerState;
+import org.apache.hadoop.yarn.api.records.LocalResourceType;
+import org.apache.hadoop.yarn.api.records.LocalResourceVisibility;
+import org.apache.hadoop.yarn.api.records.YarnContainerTags;
+import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationStateProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStateProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceTypeProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceVisibilityProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.YarnContainerTagsProto;
+
+import com.google.protobuf.ByteString;
+
+public class ProtoUtils {
+  
+  
+  /*
+   * ContainerState
+   */
+  private static String CONTAINER_STATE_PREFIX = "C_";
+  public static ContainerStateProto convertToProtoFormat(ContainerState e) {
+    return ContainerStateProto.valueOf(CONTAINER_STATE_PREFIX + e.name());
+  }
+  public static ContainerState convertFromProtoFormat(ContainerStateProto e) {
+    return ContainerState.valueOf(e.name().replace(CONTAINER_STATE_PREFIX, ""));
+  }
+  
+
+  /*
+   * ApplicationState
+   */
+  public static ApplicationStateProto convertToProtoFormat(ApplicationState e) {
+    return ApplicationStateProto.valueOf(e.name());
+  }
+  public static ApplicationState convertFromProtoFormat(ApplicationStateProto e) {
+    return ApplicationState.valueOf(e.name());
+  }
+  
+  /*
+   * LocalResourceType
+   */
+  public static LocalResourceTypeProto convertToProtoFormat(LocalResourceType e) {
+    return LocalResourceTypeProto.valueOf(e.name());
+  }
+  public static LocalResourceType convertFromProtoFormat(LocalResourceTypeProto e) {
+    return LocalResourceType.valueOf(e.name());
+  }
+  
+  /*
+   * LocalResourceVisibility
+   */
+  public static LocalResourceVisibilityProto convertToProtoFormat(LocalResourceVisibility e) {
+    return LocalResourceVisibilityProto.valueOf(e.name());
+  }
+  public static LocalResourceVisibility convertFromProtoFormat(LocalResourceVisibilityProto e) {
+    return LocalResourceVisibility.valueOf(e.name());
+  }
+  
+  /*
+   * YarnContainerTags
+   */
+  public static YarnContainerTagsProto convertToProtoFormat(YarnContainerTags e) {
+    return YarnContainerTagsProto.valueOf(e.name());
+  }
+  public static YarnContainerTags convertFromProtoFormat(YarnContainerTagsProto e) {
+    return YarnContainerTags.valueOf(e.name());
+  }
+  
+  /*
+   * ByteBuffer
+   */
+  public static ByteBuffer convertFromProtoFormat(ByteString byteString) {
+    int capacity = byteString.asReadOnlyByteBuffer().rewind().remaining();
+    byte[] b = new byte[capacity];
+    byteString.asReadOnlyByteBuffer().get(b, 0, capacity);
+    return ByteBuffer.wrap(b);
+  }
+
+  public static ByteString convertToProtoFormat(ByteBuffer byteBuffer) {
+//    return ByteString.copyFrom((ByteBuffer)byteBuffer.duplicate().rewind());
+    int oldPos = byteBuffer.position();
+    byteBuffer.rewind();
+    ByteString bs = ByteString.copyFrom(byteBuffer);
+    byteBuffer.position(oldPos);
+    return bs;
+  }
+  
+}

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/proto/AM_RM_protocol.proto
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/proto/AM_RM_protocol.proto?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/proto/AM_RM_protocol.proto (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/proto/AM_RM_protocol.proto Thu Mar 31 22:23:22 2011
@@ -0,0 +1,13 @@
+option java_package = "org.apache.hadoop.yarn.proto";
+option java_outer_classname = "AMRMProtocol";
+option java_generic_services = true;
+option java_generate_equals_and_hash = true;
+
+import "yarn_service_protos.proto";
+
+
+service AMRMProtocolService {
+  rpc registerApplicationMaster (RegisterApplicationMasterRequestProto) returns (RegisterApplicationMasterResponseProto);
+  rpc finishApplicationMaster (FinishApplicationMasterRequestProto) returns (FinishApplicationMasterResponseProto);
+  rpc allocate (AllocateRequestProto) returns (AllocateResponseProto);
+}

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/proto/client_RM_protocol.proto
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/proto/client_RM_protocol.proto?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/proto/client_RM_protocol.proto (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/proto/client_RM_protocol.proto Thu Mar 31 22:23:22 2011
@@ -0,0 +1,20 @@
+option java_package = "org.apache.hadoop.yarn.proto";
+option java_outer_classname = "ClientRMProtocol";
+option java_generic_services = true;
+option java_generate_equals_and_hash = true;
+
+import "yarn_service_protos.proto";
+
+
+
+
+
+
+service ClientRMProtocolService {
+  rpc getNewApplicationId (GetNewApplicationIdRequestProto) returns (GetNewApplicationIdResponseProto);
+  rpc getApplicationMaster (GetApplicationMasterRequestProto) returns (GetApplicationMasterResponseProto);
+  rpc submitApplication (SubmitApplicationRequestProto) returns (SubmitApplicationResponseProto);
+  rpc finishApplication (FinishApplicationRequestProto) returns (FinishApplicationResponseProto);
+  rpc getClusterMetrics (GetClusterMetricsRequestProto) returns (GetClusterMetricsResponseProto);
+}
+

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/proto/container_manager.proto
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/proto/container_manager.proto?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/proto/container_manager.proto (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/proto/container_manager.proto Thu Mar 31 22:23:22 2011
@@ -0,0 +1,17 @@
+option java_package = "org.apache.hadoop.yarn.proto";
+option java_outer_classname = "ContainerManager";
+option java_generic_services = true;
+option java_generate_equals_and_hash = true;
+
+import "yarn_service_protos.proto";
+
+
+
+
+
+service ContainerManagerService {
+  rpc startContainer(StartContainerRequestProto) returns (StartContainerResponseProto);
+  rpc stopContainer(StopContainerRequestProto) returns (StopContainerResponseProto);
+  rpc cleanupContainer(CleanupContainerRequestProto) returns (CleanupContainerResponseProto);
+  rpc getContainerStatus(GetContainerStatusRequestProto) returns (GetContainerStatusResponseProto);
+}

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/proto/yarn_protos.proto
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/proto/yarn_protos.proto?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/proto/yarn_protos.proto (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/proto/yarn_protos.proto Thu Mar 31 22:23:22 2011
@@ -0,0 +1,202 @@
+option java_package = "org.apache.hadoop.yarn.proto";
+option java_outer_classname = "YarnProtos";
+option java_generic_services = true;
+option java_generate_equals_and_hash = true;
+
+message YarnRemoteExceptionProto {
+  optional string message = 1;
+  optional string trace = 2;
+  optional string class_name = 3;
+  optional YarnRemoteExceptionProto cause = 4;
+}
+
+message ApplicationIdProto {
+  optional int32 id = 1;
+  optional int64 cluster_timestamp = 2;
+}
+
+message ContainerIdProto {
+  optional ApplicationIdProto app_id = 1;
+  optional int32 id = 2;
+}
+
+message ResourceProto {
+  optional int32 memory = 1;
+}
+
+enum ContainerStateProto {
+  C_INITIALIZING = 1;
+  C_RUNNING = 2;
+  C_COMPLETE = 3;
+}
+
+message ContainerTokenProto {
+  optional bytes identifier = 1;
+  optional bytes password = 2;
+  optional string kind = 3;
+  optional string service = 4;
+}
+
+message ContainerProto {
+  optional ContainerIdProto id = 1;
+  optional string host_name = 2;
+  optional ResourceProto resource = 3;
+  optional ContainerStateProto state = 4;
+  optional ContainerTokenProto container_token =5;
+}
+
+enum ApplicationStateProto {
+  PENDING = 1;
+  ALLOCATING = 2;
+  ALLOCATED = 3;
+  EXPIRED_PENDING=12;
+  LAUNCHING = 4;
+  LAUNCHED = 5;
+  RUNNING = 6;
+  PAUSED = 7;
+  CLEANUP = 8;
+  COMPLETED = 9;
+  KILLED = 10;
+  FAILED = 11;
+}
+
+message ApplicationStatusProto {
+  optional int32 response_id = 1;
+  optional ApplicationIdProto application_id = 2;
+  optional float progress = 3;
+  optional int64 last_seen = 4;
+}
+
+message ApplicationMasterProto {
+  optional ApplicationIdProto application_id = 1;
+  optional string host = 2;
+  optional int32 rpc_port = 3;
+  optional int32 http_port = 4;
+  optional ApplicationStatusProto status = 5;
+  optional ApplicationStateProto state = 6;
+  optional string client_token = 7;
+}
+
+message URLProto {
+  optional string scheme = 1;
+  optional string host = 2; 
+  optional int32 port = 3;
+  optional string file = 4;
+}
+
+enum LocalResourceVisibilityProto {
+  PUBLIC = 1;
+  PRIVATE = 2;
+  APPLICATION = 3;
+}
+
+enum LocalResourceTypeProto {
+  ARCHIVE = 1;
+  FILE = 2;
+}
+
+message LocalResourceProto {
+  optional URLProto resource = 1;
+  optional int64 size = 2;
+  optional int64 timestamp = 3;
+  optional LocalResourceTypeProto type = 4;
+  optional LocalResourceVisibilityProto visibility= 5;
+}
+
+
+
+
+////////////////////////////////////////////////////////////////////////
+////// From AM_RM_Protocol /////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////
+message ResourceRequestProto {
+  optional PriorityProto priority = 1;
+  optional string host_name = 2;
+  optional ResourceProto capability = 3;
+  optional int32 num_containers = 4;
+}
+
+message AMResponseProto {
+  optional bool reboot = 1;
+  optional int32 response_id = 2;
+  repeated ContainerProto containers = 3;
+}
+
+
+////////////////////////////////////////////////////////////////////////
+////// From client_RM_Protocol /////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////
+message ApplicationSubmissionContextProto {
+  optional ApplicationIdProto application_id = 1;
+  optional string application_name = 2;
+  optional ResourceProto master_capability = 3;
+  repeated StringURLMapProto resources = 4;
+  repeated StringLocalResourceMapProto resources_todo = 5;
+  repeated string fs_tokens = 6;
+  optional bytes fs_tokens_todo = 7;
+  repeated StringStringMapProto environment = 8;
+  repeated string command = 9;
+  optional string queue = 10;
+  optional PriorityProto priority = 11;
+  optional string user = 12;
+}
+
+message YarnClusterMetricsProto {
+  optional int32 num_node_managers = 1;
+}
+
+
+////////////////////////////////////////////////////////////////////////
+////// From container_manager //////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////
+enum YarnContainerTagsProto {
+  YARN_ENV_TAG = 1;
+  YARN_WORK_DIR = 2;
+}
+
+message ContainerLaunchContextProto {
+  optional ContainerIdProto container_id = 1;
+  optional string user = 2;
+  optional ResourceProto resource = 3;
+  repeated StringLocalResourceMapProto localResources = 4;
+  optional bytes container_tokens = 5;
+  repeated StringBytesMapProto service_data = 6;
+  repeated StringStringMapProto env = 7;
+  repeated string command = 8;
+}
+
+message ContainerStatusProto {
+  optional ContainerIdProto container_id = 1;
+  optional ContainerStateProto state = 2;
+  optional int32 exit_status = 3;
+}
+
+
+
+////////////////////////////////////////////////////////////////////////
+////// From common//////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////
+message PriorityProto {
+  optional int32 priority = 1;
+}
+
+message StringURLMapProto {
+  optional string key = 1;
+  optional URLProto value = 2;
+}
+
+message StringLocalResourceMapProto {
+  optional string key = 1;
+  optional LocalResourceProto value = 2;
+}
+
+message StringStringMapProto {
+  optional string key = 1;
+  optional string value = 2;
+}
+
+message StringBytesMapProto {
+  optional string key = 1;
+  optional bytes value = 2;
+}
+

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/proto/yarn_service_protos.proto
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/proto/yarn_service_protos.proto?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/proto/yarn_service_protos.proto (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/proto/yarn_service_protos.proto Thu Mar 31 22:23:22 2011
@@ -0,0 +1,110 @@
+option java_package = "org.apache.hadoop.yarn.proto";
+option java_outer_classname = "YarnServiceProtos";
+option java_generic_services = true;
+option java_generate_equals_and_hash = true;
+
+import "yarn_protos.proto";
+
+//////////////////////////////////////////////////////
+/////// AM_RM_Protocol ///////////////////////////////
+//////////////////////////////////////////////////////
+message RegisterApplicationMasterRequestProto {
+  optional ApplicationMasterProto application_master = 1;
+}
+
+message RegisterApplicationMasterResponseProto {
+}
+
+message FinishApplicationMasterRequestProto {
+  optional ApplicationMasterProto application_master = 1;
+}
+
+message FinishApplicationMasterResponseProto {
+}
+
+message AllocateRequestProto {
+  optional ApplicationStatusProto application_status = 1;
+  repeated ResourceRequestProto ask = 2;
+  repeated ContainerProto release = 3;
+}
+
+message AllocateResponseProto {
+  optional AMResponseProto AM_response = 1;
+}
+
+
+
+//////////////////////////////////////////////////////
+/////// client_RM_Protocol ///////////////////////////
+//////////////////////////////////////////////////////
+
+message GetNewApplicationIdRequestProto {
+}
+
+message GetNewApplicationIdResponseProto {
+  optional ApplicationIdProto application_id = 1;
+}
+
+message GetApplicationMasterRequestProto {
+  optional ApplicationIdProto application_id = 1;
+}
+
+message GetApplicationMasterResponseProto {
+  optional ApplicationMasterProto application_master = 1;
+}
+
+message SubmitApplicationRequestProto {
+  optional ApplicationSubmissionContextProto application_submission_context= 1;
+}
+
+message SubmitApplicationResponseProto {
+}
+
+message FinishApplicationRequestProto {
+  optional ApplicationIdProto application_id = 1;
+}
+
+message FinishApplicationResponseProto {
+}
+
+message GetClusterMetricsRequestProto {
+}
+
+message GetClusterMetricsResponseProto {
+  optional YarnClusterMetricsProto cluster_metrics = 1;
+}
+
+
+
+//////////////////////////////////////////////////////
+/////// client_RM_Protocol ///////////////////////////
+//////////////////////////////////////////////////////
+
+message StartContainerRequestProto {
+  optional ContainerLaunchContextProto container_launch_context = 1;
+}
+
+message StartContainerResponseProto {
+}
+
+message StopContainerRequestProto {
+  optional ContainerIdProto container_id = 1;
+}
+
+message StopContainerResponseProto {
+}
+
+message CleanupContainerRequestProto {
+  optional ContainerIdProto container_id = 1;
+}
+
+message CleanupContainerResponseProto {
+}
+
+message GetContainerStatusRequestProto {
+  optional ContainerIdProto container_id = 1;
+}
+
+message GetContainerStatusResponseProto {
+  optional ContainerStatusProto status = 1;
+}

Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-common/pom.xml
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-common/pom.xml?rev=1087462&r1=1087461&r2=1087462&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-common/pom.xml (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-common/pom.xml Thu Mar 31 22:23:22 2011
@@ -22,6 +22,11 @@
       <artifactId>yarn-api</artifactId>
       <version>${yarn.version}</version>
     </dependency>
+    <dependency>
+          <groupId>com.google.protobuf</groupId>
+          <artifactId>protobuf-java</artifactId>
+          <version>2.4.0a</version>
+      </dependency>
   </dependencies>
 
   <build>
@@ -39,6 +44,76 @@
          </execution>
        </executions>
      </plugin>
+     
+          <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>create_generate_src_dirctory</id>
+            <phase>initialize</phase>
+            <configuration>
+              <tasks>
+                <mkdir dir="target/generated-sources/proto" />
+              </tasks>
+            </configuration>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>exec-maven-plugin</artifactId>
+        <version>1.2</version>
+        <executions>
+          <execution>
+            <id>generate-sources</id>
+            <phase>generate-sources</phase>
+            <configuration>
+              <executable>protoc</executable>
+              <arguments>
+                <argument>-I../yarn-api/src/main/proto/</argument>
+                <argument>-Isrc/main/proto/</argument>
+                <argument>--java_out=target/generated-sources/proto</argument>
+                <argument>src/main/proto/yarnprototunnelrpc.proto</argument>
+              </arguments>
+            </configuration>
+            <goals>
+              <goal>exec</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <version>1.5</version>
+        <executions>
+          <execution>
+            <id>add-source</id>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>add-source</goal>
+            </goals>
+            <configuration>
+              <sources>
+                <source>target/generated-sources/proto</source>
+              </sources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+     
+     
+     
+     
+     
+     
+     
     </plugins>
   </build>
 </project>

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/client/AMRMProtocolPBClientImpl.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/client/AMRMProtocolPBClientImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/client/AMRMProtocolPBClientImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/client/AMRMProtocolPBClientImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,94 @@
+package org.apache.hadoop.yarn.api.impl.pb.client;
+
+import java.io.IOException;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.net.InetSocketAddress;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.ipc.RPC;
+import org.apache.hadoop.yarn.api.AMRMProtocol;
+import org.apache.hadoop.yarn.api.protocolrecords.AllocateRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationMasterRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationMasterResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.AllocateRequestPBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.AllocateResponsePBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.FinishApplicationMasterRequestPBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.FinishApplicationMasterResponsePBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.RegisterApplicationMasterRequestPBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.RegisterApplicationMasterResponsePBImpl;
+import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
+import org.apache.hadoop.yarn.ipc.ProtoOverHadoopRpcEngine;
+import org.apache.hadoop.yarn.proto.AMRMProtocol.AMRMProtocolService;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.AllocateRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.FinishApplicationMasterRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.RegisterApplicationMasterRequestProto;
+
+import com.google.protobuf.ServiceException;
+
+public class AMRMProtocolPBClientImpl implements AMRMProtocol {
+
+  private AMRMProtocolService.BlockingInterface proxy;
+  
+  public AMRMProtocolPBClientImpl(long clientVersion, InetSocketAddress addr, Configuration conf) throws IOException {
+    RPC.setProtocolEngine(conf, AMRMProtocolService.BlockingInterface.class, ProtoOverHadoopRpcEngine.class);
+    proxy = (AMRMProtocolService.BlockingInterface)RPC.getProxy(
+        AMRMProtocolService.BlockingInterface.class, clientVersion, addr, conf);
+  }
+  
+  
+  @Override
+  public AllocateResponse allocate(AllocateRequest request)
+      throws YarnRemoteException {
+    AllocateRequestProto requestProto = ((AllocateRequestPBImpl)request).getProto();
+    try {
+      return new AllocateResponsePBImpl(proxy.allocate(null, requestProto));
+    } catch (ServiceException e) {
+      if (e.getCause() instanceof YarnRemoteException) {
+        throw (YarnRemoteException)e.getCause();
+      } else if (e.getCause() instanceof UndeclaredThrowableException) {
+        throw (UndeclaredThrowableException)e.getCause();
+      } else {
+        throw new UndeclaredThrowableException(e);
+      }
+    }
+  }
+
+  
+  
+  @Override
+  public FinishApplicationMasterResponse finishApplicationMaster(
+      FinishApplicationMasterRequest request) throws YarnRemoteException {
+    FinishApplicationMasterRequestProto requestProto = ((FinishApplicationMasterRequestPBImpl)request).getProto();
+    try {
+      return new FinishApplicationMasterResponsePBImpl(proxy.finishApplicationMaster(null, requestProto));
+    } catch (ServiceException e) {
+      if (e.getCause() instanceof YarnRemoteException) {
+        throw (YarnRemoteException)e.getCause();
+      } else if (e.getCause() instanceof UndeclaredThrowableException) {
+        throw (UndeclaredThrowableException)e.getCause();
+      } else {
+        throw new UndeclaredThrowableException(e);
+      }
+    }
+  }
+
+  @Override
+  public RegisterApplicationMasterResponse registerApplicationMaster(
+      RegisterApplicationMasterRequest request) throws YarnRemoteException {
+    RegisterApplicationMasterRequestProto requestProto = ((RegisterApplicationMasterRequestPBImpl)request).getProto();
+    try {
+      return new RegisterApplicationMasterResponsePBImpl(proxy.registerApplicationMaster(null, requestProto));
+    } catch (ServiceException e) {
+      if (e.getCause() instanceof YarnRemoteException) {
+        throw (YarnRemoteException)e.getCause();
+      } else if (e.getCause() instanceof UndeclaredThrowableException) {
+        throw (UndeclaredThrowableException)e.getCause();
+      } else {
+        throw new UndeclaredThrowableException(e);
+      }
+    }
+  }
+}

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/client/ClientRMProtocolPBClientImpl.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/client/ClientRMProtocolPBClientImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/client/ClientRMProtocolPBClientImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/client/ClientRMProtocolPBClientImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,136 @@
+package org.apache.hadoop.yarn.api.impl.pb.client;
+
+import java.io.IOException;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.net.InetSocketAddress;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.ipc.RPC;
+import org.apache.hadoop.yarn.api.ClientRMProtocol;
+import org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationMasterRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationMasterResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationIdRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationIdResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.FinishApplicationRequestPBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.FinishApplicationResponsePBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetApplicationMasterRequestPBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetApplicationMasterResponsePBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetClusterMetricsRequestPBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetClusterMetricsResponsePBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetNewApplicationIdRequestPBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetNewApplicationIdResponsePBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.SubmitApplicationRequestPBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.SubmitApplicationResponsePBImpl;
+import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
+import org.apache.hadoop.yarn.ipc.ProtoOverHadoopRpcEngine;
+import org.apache.hadoop.yarn.proto.ClientRMProtocol.ClientRMProtocolService;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.FinishApplicationRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationMasterRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterMetricsRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetNewApplicationIdRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.SubmitApplicationRequestProto;
+
+import com.google.protobuf.ServiceException;
+
+public class ClientRMProtocolPBClientImpl implements ClientRMProtocol {
+
+  private ClientRMProtocolService.BlockingInterface proxy;
+  
+  public ClientRMProtocolPBClientImpl(long clientVersion, InetSocketAddress addr, Configuration conf) throws IOException {
+    RPC.setProtocolEngine(conf, ClientRMProtocolService.BlockingInterface.class, ProtoOverHadoopRpcEngine.class);
+    proxy = (ClientRMProtocolService.BlockingInterface)RPC.getProxy(
+        ClientRMProtocolService.BlockingInterface.class, clientVersion, addr, conf);
+  }
+  
+  @Override
+  public FinishApplicationResponse finishApplication(
+      FinishApplicationRequest request) throws YarnRemoteException {
+    FinishApplicationRequestProto requestProto = ((FinishApplicationRequestPBImpl)request).getProto();
+    try {
+      return new FinishApplicationResponsePBImpl(proxy.finishApplication(null, requestProto));
+    } catch (ServiceException e) {
+      if (e.getCause() instanceof YarnRemoteException) {
+        throw (YarnRemoteException)e.getCause();
+      } else if (e.getCause() instanceof UndeclaredThrowableException) {
+        throw (UndeclaredThrowableException)e.getCause();
+      } else {
+        throw new UndeclaredThrowableException(e);
+      }
+    }
+  }
+
+  @Override
+  public GetApplicationMasterResponse getApplicationMaster(
+      GetApplicationMasterRequest request) throws YarnRemoteException {
+    GetApplicationMasterRequestProto requestProto = ((GetApplicationMasterRequestPBImpl)request).getProto();
+    try {
+      return new GetApplicationMasterResponsePBImpl(proxy.getApplicationMaster(null, requestProto));
+    } catch (ServiceException e) {
+      if (e.getCause() instanceof YarnRemoteException) {
+        throw (YarnRemoteException)e.getCause();
+      } else if (e.getCause() instanceof UndeclaredThrowableException) {
+        throw (UndeclaredThrowableException)e.getCause();
+      } else {
+        throw new UndeclaredThrowableException(e);
+      }
+    }
+  }
+
+  @Override
+  public GetClusterMetricsResponse getClusterMetrics(
+      GetClusterMetricsRequest request) throws YarnRemoteException {
+    GetClusterMetricsRequestProto requestProto = ((GetClusterMetricsRequestPBImpl)request).getProto();
+    try {
+      return new GetClusterMetricsResponsePBImpl(proxy.getClusterMetrics(null, requestProto));
+    } catch (ServiceException e) {
+      if (e.getCause() instanceof YarnRemoteException) {
+        throw (YarnRemoteException)e.getCause();
+      } else if (e.getCause() instanceof UndeclaredThrowableException) {
+        throw (UndeclaredThrowableException)e.getCause();
+      } else {
+        throw new UndeclaredThrowableException(e);
+      }
+    }
+  }
+
+  @Override
+  public GetNewApplicationIdResponse getNewApplicationId(
+      GetNewApplicationIdRequest request) throws YarnRemoteException {
+    GetNewApplicationIdRequestProto requestProto = ((GetNewApplicationIdRequestPBImpl)request).getProto();
+    try {
+      return new GetNewApplicationIdResponsePBImpl(proxy.getNewApplicationId(null, requestProto));
+    } catch (ServiceException e) {
+      if (e.getCause() instanceof YarnRemoteException) {
+        throw (YarnRemoteException)e.getCause();
+      } else if (e.getCause() instanceof UndeclaredThrowableException) {
+        throw (UndeclaredThrowableException)e.getCause();
+      } else {
+        throw new UndeclaredThrowableException(e);
+      }
+    }
+  }
+
+  @Override
+  public SubmitApplicationResponse submitApplication(
+      SubmitApplicationRequest request) throws YarnRemoteException {
+    SubmitApplicationRequestProto requestProto = ((SubmitApplicationRequestPBImpl)request).getProto();
+    try {
+      return new SubmitApplicationResponsePBImpl(proxy.submitApplication(null, requestProto));
+    } catch (ServiceException e) {
+      if (e.getCause() instanceof YarnRemoteException) {
+        throw (YarnRemoteException)e.getCause();
+      } else if (e.getCause() instanceof UndeclaredThrowableException) {
+        throw (UndeclaredThrowableException)e.getCause();
+      } else {
+        throw new UndeclaredThrowableException(e);
+      }
+    }
+  }
+
+}

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/client/ContainerManagerPBClientImpl.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/client/ContainerManagerPBClientImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/client/ContainerManagerPBClientImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/client/ContainerManagerPBClientImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,114 @@
+package org.apache.hadoop.yarn.api.impl.pb.client;
+
+import java.io.IOException;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.net.InetSocketAddress;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.ipc.RPC;
+import org.apache.hadoop.yarn.api.ContainerManager;
+import org.apache.hadoop.yarn.api.protocolrecords.CleanupContainerRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.CleanupContainerResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusResponse;
+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.impl.pb.CleanupContainerRequestPBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.CleanupContainerResponsePBImpl;
+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.exceptions.YarnRemoteException;
+import org.apache.hadoop.yarn.ipc.ProtoOverHadoopRpcEngine;
+import org.apache.hadoop.yarn.proto.ContainerManager.ContainerManagerService;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.CleanupContainerRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainerRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.StopContainerRequestProto;
+
+import com.google.protobuf.ServiceException;
+
+public class ContainerManagerPBClientImpl implements ContainerManager {
+
+  private ContainerManagerService.BlockingInterface proxy;
+  
+  public ContainerManagerPBClientImpl(long clientVersion, InetSocketAddress addr, Configuration conf) throws IOException {
+    RPC.setProtocolEngine(conf, ContainerManagerService.BlockingInterface.class, ProtoOverHadoopRpcEngine.class);
+    proxy = (ContainerManagerService.BlockingInterface)RPC.getProxy(
+        ContainerManagerService.BlockingInterface.class, clientVersion, addr, conf);
+  }
+  
+  @Override
+  public CleanupContainerResponse cleanupContainer(CleanupContainerRequest request)
+      throws YarnRemoteException {
+    CleanupContainerRequestProto requestProto = ((CleanupContainerRequestPBImpl)request).getProto();
+    try {
+      return new CleanupContainerResponsePBImpl(proxy.cleanupContainer(null, requestProto));
+    } catch (ServiceException e) {
+      if (e.getCause() instanceof YarnRemoteException) {
+        throw (YarnRemoteException)e.getCause();
+      } else if (e.getCause() instanceof UndeclaredThrowableException) {
+        throw (UndeclaredThrowableException)e.getCause();
+      } else {
+        throw new UndeclaredThrowableException(e);
+      }
+    }
+  }
+
+  @Override
+  public GetContainerStatusResponse getContainerStatus(
+      GetContainerStatusRequest request) throws YarnRemoteException {
+    GetContainerStatusRequestProto requestProto = ((GetContainerStatusRequestPBImpl)request).getProto();
+    try {
+      return new GetContainerStatusResponsePBImpl(proxy.getContainerStatus(null, requestProto));
+    } catch (ServiceException e) {
+      if (e.getCause() instanceof YarnRemoteException) {
+        throw (YarnRemoteException)e.getCause();
+      } else if (e.getCause() instanceof UndeclaredThrowableException) {
+        throw (UndeclaredThrowableException)e.getCause();
+      } else {
+        throw new UndeclaredThrowableException(e);
+      }
+    }
+  }
+
+  @Override
+  public StartContainerResponse startContainer(StartContainerRequest request)
+      throws YarnRemoteException {
+    StartContainerRequestProto requestProto = ((StartContainerRequestPBImpl)request).getProto();
+    try {
+      return new StartContainerResponsePBImpl(proxy.startContainer(null, requestProto));
+    } catch (ServiceException e) {
+      if (e.getCause() instanceof YarnRemoteException) {
+        throw (YarnRemoteException)e.getCause();
+      } else if (e.getCause() instanceof UndeclaredThrowableException) {
+        throw (UndeclaredThrowableException)e.getCause();
+      } else {
+        throw new UndeclaredThrowableException(e);
+      }
+    }
+  }
+
+  @Override
+  public StopContainerResponse stopContainer(StopContainerRequest request)
+      throws YarnRemoteException {
+    StopContainerRequestProto requestProto = ((StopContainerRequestPBImpl)request).getProto();
+    try {
+      return new StopContainerResponsePBImpl(proxy.stopContainer(null, requestProto));
+    } catch (ServiceException e) {
+      if (e.getCause() instanceof YarnRemoteException) {
+        throw (YarnRemoteException)e.getCause();
+      } else if (e.getCause() instanceof UndeclaredThrowableException) {
+        throw (UndeclaredThrowableException)e.getCause();
+      } else {
+        throw new UndeclaredThrowableException(e);
+      }
+    }
+  }
+
+}

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/AMRMProtocolPBServiceImpl.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/AMRMProtocolPBServiceImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/AMRMProtocolPBServiceImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/AMRMProtocolPBServiceImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,70 @@
+package org.apache.hadoop.yarn.api.impl.pb.service;
+
+import org.apache.hadoop.yarn.api.AMRMProtocol;
+import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationMasterResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.AllocateRequestPBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.AllocateResponsePBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.FinishApplicationMasterRequestPBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.FinishApplicationMasterResponsePBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.RegisterApplicationMasterRequestPBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.RegisterApplicationMasterResponsePBImpl;
+import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
+import org.apache.hadoop.yarn.proto.AMRMProtocol.AMRMProtocolService.BlockingInterface;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.AllocateRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.AllocateResponseProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.FinishApplicationMasterRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.FinishApplicationMasterResponseProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.RegisterApplicationMasterRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.RegisterApplicationMasterResponseProto;
+
+import com.google.protobuf.RpcController;
+import com.google.protobuf.ServiceException;
+
+public class AMRMProtocolPBServiceImpl implements BlockingInterface {
+
+  private AMRMProtocol real;
+  
+  public AMRMProtocolPBServiceImpl(AMRMProtocol impl) {
+    this.real = impl;
+  }
+  
+  @Override
+  public AllocateResponseProto allocate(RpcController arg0,
+      AllocateRequestProto proto) throws ServiceException {
+    AllocateRequestPBImpl request = new AllocateRequestPBImpl(proto);
+    try {
+      AllocateResponse response = real.allocate(request);
+      return ((AllocateResponsePBImpl)response).getProto();
+    } catch (YarnRemoteException e) {
+      throw new ServiceException(e);
+    }
+  }
+
+  @Override
+  public FinishApplicationMasterResponseProto finishApplicationMaster(
+      RpcController arg0, FinishApplicationMasterRequestProto proto)
+      throws ServiceException {
+    FinishApplicationMasterRequestPBImpl request = new FinishApplicationMasterRequestPBImpl(proto);
+    try {
+      FinishApplicationMasterResponse response = real.finishApplicationMaster(request);
+      return ((FinishApplicationMasterResponsePBImpl)response).getProto();
+    } catch (YarnRemoteException e) {
+      throw new ServiceException(e);
+    }
+  }
+
+  @Override
+  public RegisterApplicationMasterResponseProto registerApplicationMaster(
+      RpcController arg0, RegisterApplicationMasterRequestProto proto)
+      throws ServiceException {
+    RegisterApplicationMasterRequestPBImpl request = new RegisterApplicationMasterRequestPBImpl(proto);
+    try {
+      RegisterApplicationMasterResponse response = real.registerApplicationMaster(request);
+      return ((RegisterApplicationMasterResponsePBImpl)response).getProto();
+    } catch (YarnRemoteException e) {
+      throw new ServiceException(e);
+    }
+  }
+}

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ClientRMProtocolPBServiceImpl.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ClientRMProtocolPBServiceImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ClientRMProtocolPBServiceImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ClientRMProtocolPBServiceImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,105 @@
+package org.apache.hadoop.yarn.api.impl.pb.service;
+
+import org.apache.hadoop.yarn.api.ClientRMProtocol;
+import org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationMasterResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationIdResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.FinishApplicationRequestPBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.FinishApplicationResponsePBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetApplicationMasterRequestPBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetApplicationMasterResponsePBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetClusterMetricsRequestPBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetClusterMetricsResponsePBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetNewApplicationIdRequestPBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetNewApplicationIdResponsePBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.SubmitApplicationRequestPBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.SubmitApplicationResponsePBImpl;
+import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
+import org.apache.hadoop.yarn.proto.ClientRMProtocol.ClientRMProtocolService.BlockingInterface;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.FinishApplicationRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.FinishApplicationResponseProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationMasterRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationMasterResponseProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterMetricsRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetClusterMetricsResponseProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetNewApplicationIdRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetNewApplicationIdResponseProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.SubmitApplicationRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.SubmitApplicationResponseProto;
+
+import com.google.protobuf.RpcController;
+import com.google.protobuf.ServiceException;
+
+public class ClientRMProtocolPBServiceImpl implements BlockingInterface {
+
+  private ClientRMProtocol real;
+  
+  public ClientRMProtocolPBServiceImpl(ClientRMProtocol impl) {
+    this.real = impl;
+  }
+  
+  @Override
+  public FinishApplicationResponseProto finishApplication(RpcController arg0,
+      FinishApplicationRequestProto proto) throws ServiceException {
+    FinishApplicationRequestPBImpl request = new FinishApplicationRequestPBImpl(proto);
+    try {
+      FinishApplicationResponse response = real.finishApplication(request);
+      return ((FinishApplicationResponsePBImpl)response).getProto();
+    } catch (YarnRemoteException e) {
+      throw new ServiceException(e);
+    }
+  }
+
+  @Override
+  public GetApplicationMasterResponseProto getApplicationMaster(
+      RpcController arg0, GetApplicationMasterRequestProto proto)
+      throws ServiceException {
+    GetApplicationMasterRequestPBImpl request = new GetApplicationMasterRequestPBImpl(proto);
+    try {
+      GetApplicationMasterResponse response = real.getApplicationMaster(request);
+      return ((GetApplicationMasterResponsePBImpl)response).getProto();
+    } catch (YarnRemoteException e) {
+      throw new ServiceException(e);
+    }
+  }
+
+  @Override
+  public GetClusterMetricsResponseProto getClusterMetrics(RpcController arg0,
+      GetClusterMetricsRequestProto proto) throws ServiceException {
+    GetClusterMetricsRequestPBImpl request = new GetClusterMetricsRequestPBImpl(proto);
+    try {
+      GetClusterMetricsResponse response = real.getClusterMetrics(request);
+      return ((GetClusterMetricsResponsePBImpl)response).getProto();
+    } catch (YarnRemoteException e) {
+      throw new ServiceException(e);
+    }
+  }
+
+  @Override
+  public GetNewApplicationIdResponseProto getNewApplicationId(
+      RpcController arg0, GetNewApplicationIdRequestProto proto)
+      throws ServiceException {
+    GetNewApplicationIdRequestPBImpl request = new GetNewApplicationIdRequestPBImpl(proto);
+    try {
+      GetNewApplicationIdResponse response = real.getNewApplicationId(request);
+      return ((GetNewApplicationIdResponsePBImpl)response).getProto();
+    } catch (YarnRemoteException e) {
+      throw new ServiceException(e);
+    }
+  }
+
+  @Override
+  public SubmitApplicationResponseProto submitApplication(RpcController arg0,
+      SubmitApplicationRequestProto proto) throws ServiceException {
+    SubmitApplicationRequestPBImpl request = new SubmitApplicationRequestPBImpl(proto);
+    try {
+      SubmitApplicationResponse response = real.submitApplication(request);
+      return ((SubmitApplicationResponsePBImpl)response).getProto();
+    } catch (YarnRemoteException e) {
+      throw new ServiceException(e);
+    }
+  }
+
+}

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ContainerManagerPBServiceImpl.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ContainerManagerPBServiceImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ContainerManagerPBServiceImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ContainerManagerPBServiceImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,86 @@
+package org.apache.hadoop.yarn.api.impl.pb.service;
+
+import org.apache.hadoop.yarn.api.ContainerManager;
+import org.apache.hadoop.yarn.api.protocolrecords.CleanupContainerResponse;
+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.CleanupContainerRequestPBImpl;
+import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.CleanupContainerResponsePBImpl;
+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.exceptions.YarnRemoteException;
+import org.apache.hadoop.yarn.proto.ContainerManager.ContainerManagerService.BlockingInterface;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.CleanupContainerRequestProto;
+import org.apache.hadoop.yarn.proto.YarnServiceProtos.CleanupContainerResponseProto;
+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 com.google.protobuf.RpcController;
+import com.google.protobuf.ServiceException;
+
+public class ContainerManagerPBServiceImpl implements BlockingInterface {
+
+  private ContainerManager real;
+  
+  public ContainerManagerPBServiceImpl(ContainerManager impl) {
+    this.real = impl;
+  }
+  
+  @Override
+  public CleanupContainerResponseProto cleanupContainer(RpcController arg0,
+      CleanupContainerRequestProto proto) throws ServiceException {
+    CleanupContainerRequestPBImpl request = new CleanupContainerRequestPBImpl(proto);
+    try {
+      CleanupContainerResponse response = real.cleanupContainer(request);
+      return ((CleanupContainerResponsePBImpl)response).getProto();
+    } catch (YarnRemoteException e) {
+      throw new ServiceException(e);
+    }
+  }
+
+  @Override
+  public GetContainerStatusResponseProto getContainerStatus(RpcController arg0,
+      GetContainerStatusRequestProto proto) throws ServiceException {
+    GetContainerStatusRequestPBImpl request = new GetContainerStatusRequestPBImpl(proto);
+    try {
+      GetContainerStatusResponse response = real.getContainerStatus(request);
+      return ((GetContainerStatusResponsePBImpl)response).getProto();
+    } catch (YarnRemoteException e) {
+      throw new ServiceException(e);
+    }
+  }
+
+  @Override
+  public StartContainerResponseProto startContainer(RpcController arg0,
+      StartContainerRequestProto proto) throws ServiceException {
+    StartContainerRequestPBImpl request = new StartContainerRequestPBImpl(proto);
+    try {
+      StartContainerResponse response = real.startContainer(request);
+      return ((StartContainerResponsePBImpl)response).getProto();
+    } catch (YarnRemoteException e) {
+      throw new ServiceException(e);
+    }
+  }
+
+  @Override
+  public StopContainerResponseProto stopContainer(RpcController arg0,
+      StopContainerRequestProto proto) throws ServiceException {
+    StopContainerRequestPBImpl request = new StopContainerRequestPBImpl(proto);
+    try {
+      StopContainerResponse response = real.stopContainer(request);
+      return ((StopContainerResponsePBImpl)response).getProto();
+    } catch (YarnRemoteException e) {
+      throw new ServiceException(e);
+    }
+  }
+
+}

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/RecordFactory.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/RecordFactory.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/RecordFactory.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/RecordFactory.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,8 @@
+package org.apache.hadoop.yarn.factories;
+
+import org.apache.hadoop.yarn.YarnException;
+
+
+public interface RecordFactory {
+  public <T> T newRecordInstance(Class<T> clazz) throws YarnException;
+}

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/RpcClientFactory.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/RpcClientFactory.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/RpcClientFactory.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/RpcClientFactory.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,12 @@
+package org.apache.hadoop.yarn.factories;
+
+import java.net.InetSocketAddress;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.yarn.YarnException;
+
+public interface RpcClientFactory {
+  
+  public Object getClient(Class<?> protocol, long clientVersion, InetSocketAddress addr, Configuration conf) throws YarnException;
+
+}
\ No newline at end of file

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/RpcServerFactory.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/RpcServerFactory.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/RpcServerFactory.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/RpcServerFactory.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,17 @@
+package org.apache.hadoop.yarn.factories;
+
+import java.net.InetSocketAddress;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.ipc.RPC.Server;
+import org.apache.hadoop.security.token.SecretManager;
+import org.apache.hadoop.security.token.TokenIdentifier;
+import org.apache.hadoop.yarn.YarnException;
+
+public interface RpcServerFactory {
+  
+  public Server getServer(Class<?> protocol, Object instance,
+      InetSocketAddress addr, Configuration conf,
+      SecretManager<? extends TokenIdentifier> secretManager)
+      throws YarnException;
+}
\ No newline at end of file

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/YarnRemoteExceptionFactory.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/YarnRemoteExceptionFactory.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/YarnRemoteExceptionFactory.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/YarnRemoteExceptionFactory.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,9 @@
+package org.apache.hadoop.yarn.factories;
+
+import org.apache.hadoop.yarn.exceptions.YarnRemoteException;
+
+public interface YarnRemoteExceptionFactory {
+  public YarnRemoteException createYarnRemoteException(String message);
+  public YarnRemoteException createYarnRemoteException(String message, Throwable t);
+  public YarnRemoteException createYarnRemoteException(Throwable t);
+}

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/impl/pb/RecordFactoryPBImpl.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/impl/pb/RecordFactoryPBImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/impl/pb/RecordFactoryPBImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/impl/pb/RecordFactoryPBImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,78 @@
+package org.apache.hadoop.yarn.factories.impl.pb;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.yarn.YarnException;
+import org.apache.hadoop.yarn.factories.RecordFactory;
+
+public class RecordFactoryPBImpl implements RecordFactory {
+
+  private static final String PB_IMPL_PACKAGE_SUFFIX = "impl.pb";
+  private static final String PB_IMPL_CLASS_SUFFIX = "PBImpl";
+
+  private static final RecordFactoryPBImpl self = new RecordFactoryPBImpl();
+  private Configuration localConf = new Configuration();
+  private Map<Class<?>, Constructor<?>> cache = new HashMap<Class<?>, Constructor<?>>();
+
+  private RecordFactoryPBImpl() {
+  }
+  
+  public static RecordFactory get() {
+    return self;
+  }
+  
+  @Override
+  public <T> T newRecordInstance(Class<T> clazz) throws YarnException {
+    
+    Constructor<?> constructor = null;
+    if (cache.get(clazz) == null) {
+      Class<?> pbClazz = null;
+      try {
+        pbClazz = localConf.getClassByName(getPBImplClassName(clazz));
+      } catch (ClassNotFoundException e) {
+        throw new YarnException("Failed to load class: ["
+            + getPBImplClassName(clazz) + "]", e);
+      }
+      try {
+        constructor = pbClazz.getConstructor(null);
+        constructor.setAccessible(true);
+        cache.put(clazz, constructor);
+      } catch (NoSuchMethodException e) {
+        throw new YarnException("Could not find 0 argument constructor", e);
+      }
+    } else {
+      constructor = cache.get(clazz);
+    }
+    try {
+      Object retObject = constructor.newInstance();
+      return (T)retObject;
+    } catch (InvocationTargetException e) {
+      throw new YarnException(e);
+    } catch (IllegalAccessException e) {
+      throw new YarnException(e);
+    } catch (InstantiationException e) {
+      throw new YarnException(e);
+    }
+  }
+
+  private String getPBImplClassName(Class<?> clazz) {
+    String srcPackagePart = getPackageName(clazz);
+    String srcClassName = getClassName(clazz);
+    String destPackagePart = srcPackagePart + "." + PB_IMPL_PACKAGE_SUFFIX;
+    String destClassPart = srcClassName + PB_IMPL_CLASS_SUFFIX;
+    return destPackagePart + "." + destClassPart;
+  }
+  
+  private String getClassName(Class<?> clazz) {
+    String fqName = clazz.getName();
+    return (fqName.substring(fqName.lastIndexOf(".") + 1, fqName.length()));
+  }
+  
+  private String getPackageName(Class<?> clazz) {
+    return clazz.getPackage().getName();
+  }
+}

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/impl/pb/RpcClientFactoryPBImpl.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/impl/pb/RpcClientFactoryPBImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/impl/pb/RpcClientFactoryPBImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/impl/pb/RpcClientFactoryPBImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,81 @@
+package org.apache.hadoop.yarn.factories.impl.pb;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.net.InetSocketAddress;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.yarn.YarnException;
+import org.apache.hadoop.yarn.factories.RpcClientFactory;
+
+public class RpcClientFactoryPBImpl implements RpcClientFactory {
+
+  private static final String PB_IMPL_PACKAGE_SUFFIX = "impl.pb.client";
+  private static final String PB_IMPL_CLASS_SUFFIX = "PBClientImpl";
+  
+  private static final RpcClientFactoryPBImpl self = new RpcClientFactoryPBImpl();
+  private Configuration localConf = new Configuration();
+  private Map<Class<?>, Constructor<?>> cache = new HashMap<Class<?>, Constructor<?>>();
+  
+  public static RpcClientFactoryPBImpl get() {
+    return RpcClientFactoryPBImpl.self;
+  }
+  
+  private RpcClientFactoryPBImpl() {
+  }
+  
+  public Object getClient(Class<?> protocol, long clientVersion, InetSocketAddress addr, Configuration conf) throws YarnException {
+   
+    Constructor<?> constructor = null;
+    if (cache.get(protocol) == null) {
+      Class<?> pbClazz = null;
+      try {
+        pbClazz = localConf.getClassByName(getPBImplClassName(protocol));
+      } catch (ClassNotFoundException e) {
+        throw new YarnException("Failed to load class: ["
+            + getPBImplClassName(protocol) + "]", e);
+      }
+      try {
+        constructor = pbClazz.getConstructor(Long.TYPE, InetSocketAddress.class, Configuration.class);
+        constructor.setAccessible(true);
+        cache.put(protocol, constructor);
+      } catch (NoSuchMethodException e) {
+        throw new YarnException("Could not find constructor with params: " + Long.TYPE + ", " + InetSocketAddress.class + ", " + Configuration.class, e);
+      }
+    } else {
+      constructor = cache.get(protocol);
+    }
+
+    try {
+      Object retObject = constructor.newInstance(clientVersion, addr, conf);
+      return retObject;
+    } catch (InvocationTargetException e) {
+      throw new YarnException(e);
+    } catch (IllegalAccessException e) {
+      throw new YarnException(e);
+    } catch (InstantiationException e) {
+      throw new YarnException(e);
+    }
+  }
+  
+  
+  
+  private String getPBImplClassName(Class<?> clazz) {
+    String srcPackagePart = getPackageName(clazz);
+    String srcClassName = getClassName(clazz);
+    String destPackagePart = srcPackagePart + "." + PB_IMPL_PACKAGE_SUFFIX;
+    String destClassPart = srcClassName + PB_IMPL_CLASS_SUFFIX;
+    return destPackagePart + "." + destClassPart;
+  }
+  
+  private String getClassName(Class<?> clazz) {
+    String fqName = clazz.getName();
+    return (fqName.substring(fqName.lastIndexOf(".") + 1, fqName.length()));
+  }
+  
+  private String getPackageName(Class<?> clazz) {
+    return clazz.getPackage().getName();
+  }
+}
\ No newline at end of file

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/impl/pb/RpcServerFactoryPBImpl.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/impl/pb/RpcServerFactoryPBImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/impl/pb/RpcServerFactoryPBImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/factories/impl/pb/RpcServerFactoryPBImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,141 @@
+package org.apache.hadoop.yarn.factories.impl.pb;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.InetSocketAddress;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.ipc.RPC;
+import org.apache.hadoop.ipc.RPC.Server;
+import org.apache.hadoop.security.token.SecretManager;
+import org.apache.hadoop.security.token.TokenIdentifier;
+import org.apache.hadoop.yarn.YarnException;
+import org.apache.hadoop.yarn.factories.RpcServerFactory;
+import org.apache.hadoop.yarn.ipc.ProtoOverHadoopRpcEngine;
+
+import com.google.protobuf.BlockingService;
+
+public class RpcServerFactoryPBImpl implements RpcServerFactory {
+
+  private static final String PROTO_GEN_PACKAGE_NAME = "org.apache.hadoop.yarn.proto";
+  private static final String PROTO_GEN_CLASS_SUFFIX = "Service";
+  private static final String PB_IMPL_PACKAGE_SUFFIX = "impl.pb.service";
+  private static final String PB_IMPL_CLASS_SUFFIX = "PBServiceImpl";
+  
+  private static final RpcServerFactoryPBImpl self = new RpcServerFactoryPBImpl();
+
+  private Configuration localConf = new Configuration();
+  private Map<Class<?>, Constructor<?>> serviceCache = new HashMap<Class<?>, Constructor<?>>();
+  private Map<Class<?>, Method> protoCache = new HashMap<Class<?>, Method>();
+  
+  public static RpcServerFactoryPBImpl get() {
+    return RpcServerFactoryPBImpl.self;
+  }
+  
+
+  private RpcServerFactoryPBImpl() {
+  }
+  
+  @Override
+  public Server getServer(Class<?> protocol, Object instance,
+      InetSocketAddress addr, Configuration conf,
+      SecretManager<? extends TokenIdentifier> secretManager)
+      throws YarnException {
+    
+    Constructor<?> constructor = null;
+    if (serviceCache.get(protocol) == null) {
+      Class<?> pbServiceImplClazz = null;
+      try {
+        pbServiceImplClazz = localConf
+            .getClassByName(getPbServiceImplClassName(protocol));
+      } catch (ClassNotFoundException e) {
+        throw new YarnException("Failed to load class: ["
+            + getPbServiceImplClassName(protocol) + "]", e);
+      }
+      try {
+        constructor = pbServiceImplClazz.getConstructor(protocol);
+        constructor.setAccessible(true);
+        serviceCache.put(protocol, constructor);
+      } catch (NoSuchMethodException e) {
+        throw new YarnException("Could not find constructor with params: "
+            + Long.TYPE + ", " + InetSocketAddress.class + ", "
+            + Configuration.class, e);
+      }
+    } else {
+      constructor = serviceCache.get(protocol);
+    }
+    
+    Object service = null;
+    try {
+      service = constructor.newInstance(instance);
+    } catch (InvocationTargetException e) {
+      throw new YarnException(e);
+    } catch (IllegalAccessException e) {
+      throw new YarnException(e);
+    } catch (InstantiationException e) {
+      throw new YarnException(e);
+    }
+
+    Method method = null;
+    if (protoCache.get(protocol) == null) {
+      Class<?> protoClazz = null;
+      try {
+        protoClazz = localConf.getClassByName(getProtoClassName(protocol));
+      } catch (ClassNotFoundException e) {
+        throw new YarnException("Failed to load class: ["
+            + getProtoClassName(protocol) + "]", e);
+      }
+      try {
+        method = protoClazz.getMethod("newReflectiveBlockingService", service.getClass().getInterfaces()[0]);
+        method.setAccessible(true);
+        protoCache.put(protocol, method);
+      } catch (NoSuchMethodException e) {
+        throw new YarnException(e);
+      }
+    } else {
+      method = protoCache.get(protocol);
+    }
+    
+    try {
+      return createServer(addr, conf, secretManager, (BlockingService)method.invoke(null, service));
+    } catch (InvocationTargetException e) {
+      throw new YarnException(e);
+    } catch (IllegalAccessException e) {
+      throw new YarnException(e);
+    } catch (IOException e) {
+      throw new YarnException(e);
+    }
+  }
+  
+  private String getProtoClassName(Class<?> clazz) {
+    String srcClassName = getClassName(clazz);
+    return PROTO_GEN_PACKAGE_NAME + "." + srcClassName + "$" + srcClassName + PROTO_GEN_CLASS_SUFFIX;  
+  }
+  
+  private String getPbServiceImplClassName(Class<?> clazz) {
+    String srcPackagePart = getPackageName(clazz);
+    String srcClassName = getClassName(clazz);
+    String destPackagePart = srcPackagePart + "." + PB_IMPL_PACKAGE_SUFFIX;
+    String destClassPart = srcClassName + PB_IMPL_CLASS_SUFFIX;
+    return destPackagePart + "." + destClassPart;
+  }
+  
+  private String getClassName(Class<?> clazz) {
+    String fqName = clazz.getName();
+    return (fqName.substring(fqName.lastIndexOf(".") + 1, fqName.length()));
+  }
+  
+  private String getPackageName(Class<?> clazz) {
+    return clazz.getPackage().getName();
+  }
+
+  private Server createServer(InetSocketAddress addr, Configuration conf, SecretManager<? extends TokenIdentifier> secretManager, BlockingService blockingService) throws IOException {
+    RPC.setProtocolEngine(conf, BlockingService.class, ProtoOverHadoopRpcEngine.class);
+    Server server = RPC.getServer(BlockingService.class, blockingService, addr.getHostName(), addr.getPort(), 1, false, conf, secretManager);
+    return server;
+  }
+}



Mime
View raw message