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 [11/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/Priority.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Priority.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Priority.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Priority.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,9 @@
+package org.apache.hadoop.yarn.api.records;
+
+public interface Priority extends Comparable<Priority> {
+  
+  public abstract int getPriority();
+  
+  public abstract void setPriority(int priority);
+  
+}

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ProtoBase.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ProtoBase.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ProtoBase.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ProtoBase.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,43 @@
+package org.apache.hadoop.yarn.api.records;
+
+import java.nio.ByteBuffer;
+
+import org.apache.hadoop.yarn.util.ProtoUtils;
+
+import com.google.protobuf.ByteString;
+import com.google.protobuf.Message;
+
+public abstract class ProtoBase <T extends Message> {
+  
+  public abstract T getProto();
+
+  //TODO Force a comparator?
+  
+  @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+", " ");
+  }
+  
+  protected final ByteBuffer convertFromProtoFormat(ByteString byteString) {
+    return ProtoUtils.convertFromProtoFormat(byteString);
+  }
+
+  protected final ByteString convertToProtoFormat(ByteBuffer byteBuffer) {
+    return ProtoUtils.convertToProtoFormat(byteBuffer);
+  }
+}

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Resource.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Resource.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Resource.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Resource.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,9 @@
+package org.apache.hadoop.yarn.api.records;
+
+public interface Resource extends Comparable<Resource> {
+  public abstract int getMemory();
+  
+  public abstract void setMemory(int memory);
+
+  
+}

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ResourceRequest.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ResourceRequest.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ResourceRequest.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ResourceRequest.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,15 @@
+package org.apache.hadoop.yarn.api.records;
+
+public interface ResourceRequest extends Comparable<ResourceRequest>{
+  public abstract Priority getPriority();
+  public abstract String getHostName();
+  public abstract Resource getCapability();
+  public abstract int getNumContainers();
+  
+  public abstract void setPriority(Priority priority);
+  public abstract void setHostName(String hostName);
+  public abstract void setCapability(Resource capability);
+  public abstract void setNumContainers(int numContainers);
+  
+
+}

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/URL.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/URL.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/URL.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/URL.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,13 @@
+package org.apache.hadoop.yarn.api.records;
+
+public interface URL {
+  public abstract String getScheme();
+  public abstract String getHost();
+  public abstract int getPort();
+  public abstract String getFile();
+  
+  public abstract void setScheme(String scheme);
+  public abstract void setHost(String host);
+  public abstract void setPort(int port);
+  public abstract void setFile(String file);
+}

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/YarnClusterMetrics.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/YarnClusterMetrics.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/YarnClusterMetrics.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/YarnClusterMetrics.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,9 @@
+package org.apache.hadoop.yarn.api.records;
+
+public interface YarnClusterMetrics {
+  
+  public abstract int getNumNodeManagers();
+  
+  public abstract void setNumNodeManagers(int numNodeManagers);
+
+}

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/YarnContainerTags.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/YarnContainerTags.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/YarnContainerTags.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/YarnContainerTags.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,5 @@
+package org.apache.hadoop.yarn.api.records;
+
+public enum YarnContainerTags {
+  YARN_ENV_TAG, YARN_WORK_DIR
+}

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/AMResponsePBImpl.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/AMResponsePBImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/AMResponsePBImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/AMResponsePBImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,188 @@
+package org.apache.hadoop.yarn.api.records.impl.pb;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.hadoop.yarn.api.records.AMResponse;
+import org.apache.hadoop.yarn.api.records.Container;
+import org.apache.hadoop.yarn.api.records.ProtoBase;
+import org.apache.hadoop.yarn.proto.YarnProtos.AMResponseProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.AMResponseProtoOrBuilder;
+import org.apache.hadoop.yarn.proto.YarnProtos.ContainerProto;
+
+
+    
+public class AMResponsePBImpl extends ProtoBase<AMResponseProto> implements AMResponse {
+  AMResponseProto proto = AMResponseProto.getDefaultInstance();
+  AMResponseProto.Builder builder = null;
+  boolean viaProto = false;
+  
+  private List<Container> containerList = null;
+//  private boolean hasLocalContainerList = false;
+  
+  
+  public AMResponsePBImpl() {
+    builder = AMResponseProto.newBuilder();
+  }
+
+  public AMResponsePBImpl(AMResponseProto proto) {
+    this.proto = proto;
+    viaProto = true;
+  }
+  
+  public AMResponseProto getProto() {
+      mergeLocalToProto();
+    proto = viaProto ? proto : builder.build();
+    viaProto = true;
+    return proto;
+  }
+  
+  private void mergeLocalToBuilder() {
+    if (this.containerList != null) {
+      addLocalContainersToProto();
+    }
+  }
+  
+  private void mergeLocalToProto() {
+    if (viaProto) 
+      maybeInitBuilder();
+    mergeLocalToBuilder();
+    proto = builder.build();
+    viaProto = true;
+  }
+
+  private void maybeInitBuilder() {
+    if (viaProto || builder == null) {
+      builder = AMResponseProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+    
+  
+  @Override
+  public boolean getReboot() {
+    AMResponseProtoOrBuilder p = viaProto ? proto : builder;
+    return (p.getReboot());
+  }
+
+  @Override
+  public void setReboot(boolean reboot) {
+    maybeInitBuilder();
+    builder.setReboot((reboot));
+  }
+  @Override
+  public int getResponseId() {
+    AMResponseProtoOrBuilder p = viaProto ? proto : builder;
+    return (p.getResponseId());
+  }
+
+  @Override
+  public void setResponseId(int responseId) {
+    maybeInitBuilder();
+    builder.setResponseId((responseId));
+  }
+  @Override
+  public List<Container> getContainerList() {
+    initLocalContainerList();
+    return this.containerList;
+  }
+  
+  @Override
+  public Container getContainer(int index) {
+    initLocalContainerList();
+    return this.containerList.get(index);
+  }
+  @Override
+  public int getContainerCount() {
+    initLocalContainerList();
+    return this.containerList.size();
+  }
+  
+  //Once this is called. containerList will never be null - untill a getProto is called.
+  private void initLocalContainerList() {
+    if (this.containerList != null) {
+      return;
+    }
+    AMResponseProtoOrBuilder p = viaProto ? proto : builder;
+    List<ContainerProto> list = p.getContainersList();
+    containerList = new ArrayList<Container>();
+
+    for (ContainerProto c : list) {
+      containerList.add(convertFromProtoFormat(c));
+    }
+  }
+
+  @Override
+  public void addAllContainers(final List<Container> containers) {
+    if (containers == null) 
+      return;
+    initLocalContainerList();
+    containerList.addAll(containers);
+  }
+
+  private void addLocalContainersToProto() {
+    maybeInitBuilder();
+    builder.clearContainers();
+    if (containerList == null)
+      return;
+    Iterable<ContainerProto> iterable = new Iterable<ContainerProto>() {
+      @Override
+      public Iterator<ContainerProto> iterator() {
+        return new Iterator<ContainerProto>() {
+
+          Iterator<Container> iter = containerList.iterator();
+
+          @Override
+          public boolean hasNext() {
+            return iter.hasNext();
+          }
+
+          @Override
+          public ContainerProto next() {
+            return convertToProtoFormat(iter.next());
+          }
+
+          @Override
+          public void remove() {
+            throw new UnsupportedOperationException();
+
+          }
+        };
+
+      }
+    };
+    builder.addAllContainers(iterable);
+  }
+  
+  @Override
+  public void addContainer(Container containers) {
+    initLocalContainerList();
+    if (containers == null) 
+      return;
+    this.containerList.add(containers);
+  }
+  
+  @Override
+  public void removeContainer(int index) {
+    initLocalContainerList();
+    this.containerList.remove(index);
+  }
+  @Override
+  public void clearContainers() {
+    initLocalContainerList();
+    this.containerList.clear();
+  }
+
+  private ContainerPBImpl convertFromProtoFormat(ContainerProto p) {
+    return new ContainerPBImpl(p);
+  }
+
+  private ContainerProto convertToProtoFormat(Container t) {
+    return ((ContainerPBImpl)t).getProto();
+  }
+
+
+
+}  

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationIdPBImpl.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/ApplicationIdPBImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationIdPBImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationIdPBImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,71 @@
+package org.apache.hadoop.yarn.api.records.impl.pb;
+
+
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ProtoBase;
+import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProtoOrBuilder;
+
+
+    
+public class ApplicationIdPBImpl extends ProtoBase<ApplicationIdProto> implements ApplicationId {
+  ApplicationIdProto proto = ApplicationIdProto.getDefaultInstance();
+  ApplicationIdProto.Builder builder = null;
+  boolean viaProto = false;
+  
+  public ApplicationIdPBImpl() {
+    builder = ApplicationIdProto.newBuilder();
+  }
+
+  public ApplicationIdPBImpl(ApplicationIdProto proto) {
+    this.proto = proto;
+    viaProto = true;
+  }
+
+  public ApplicationIdProto getProto() {
+    proto = viaProto ? proto : builder.build();
+    viaProto = true;
+    return proto;
+  }
+
+  private void maybeInitBuilder() {
+    if (viaProto || builder == null) {
+      builder = ApplicationIdProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+    
+  
+  @Override
+  public int getId() {
+    ApplicationIdProtoOrBuilder p = viaProto ? proto : builder;
+    return (p.getId());
+  }
+
+  @Override
+  public void setId(int id) {
+    maybeInitBuilder();
+    builder.setId((id));
+  }
+  @Override
+  public long getClusterTimestamp() {
+    ApplicationIdProtoOrBuilder p = viaProto ? proto : builder;
+    return (p.getClusterTimestamp());
+  }
+
+  @Override
+  public void setClusterTimestamp(long clusterTimestamp) {
+    maybeInitBuilder();
+    builder.setClusterTimestamp((clusterTimestamp));
+  }
+
+  @Override
+  public int compareTo(ApplicationId other) {
+    if (this.getId() - other.getId() == 0) {
+      return this.getClusterTimestamp() > other.getClusterTimestamp() ? 1 : 
+        this.getClusterTimestamp() < other.getClusterTimestamp() ? -1 : 0;
+    } else {
+      return this.getId() - other.getId();
+    }
+  }
+}  

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationMasterPBImpl.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/ApplicationMasterPBImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationMasterPBImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationMasterPBImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,218 @@
+package org.apache.hadoop.yarn.api.records.impl.pb;
+
+
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationMaster;
+import org.apache.hadoop.yarn.api.records.ApplicationState;
+import org.apache.hadoop.yarn.api.records.ApplicationStatus;
+import org.apache.hadoop.yarn.api.records.ProtoBase;
+import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationMasterProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationMasterProtoOrBuilder;
+import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationStateProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationStatusProto;
+import org.apache.hadoop.yarn.util.ProtoUtils;
+
+
+    
+public class ApplicationMasterPBImpl extends ProtoBase<ApplicationMasterProto> implements ApplicationMaster {
+  ApplicationMasterProto proto = ApplicationMasterProto.getDefaultInstance();
+  ApplicationMasterProto.Builder builder = null;
+  boolean viaProto = false;
+  
+  private ApplicationId applicationId = null;
+  private ApplicationStatus applicationStatus = null;
+  
+  
+  public ApplicationMasterPBImpl() {
+    builder = ApplicationMasterProto.newBuilder();
+  }
+
+  public ApplicationMasterPBImpl(ApplicationMasterProto proto) {
+    this.proto = proto;
+    viaProto = true;
+  }
+  
+  public ApplicationMasterProto getProto() {
+  
+      mergeLocalToProto();
+    proto = viaProto ? proto : builder.build();
+    viaProto = true;
+    return proto;
+  }
+
+  private void mergeLocalToBuilder() {
+    if (this.applicationId != null && !((ApplicationIdPBImpl)this.applicationId).getProto().equals(builder.getApplicationId())) {
+      builder.setApplicationId(convertToProtoFormat(this.applicationId));
+    }
+
+    if (this.applicationStatus != null && !((ApplicationStatusPBImpl)this.applicationStatus).getProto().equals(builder.getStatus())) {
+      builder.setStatus(convertToProtoFormat(this.applicationStatus));
+    }
+  }
+
+  private void mergeLocalToProto() {
+    if (viaProto) 
+      maybeInitBuilder();
+    mergeLocalToBuilder();
+    proto = builder.build();
+    
+    viaProto = true;
+  }
+  
+  private void maybeInitBuilder() {
+    if (viaProto || builder == null) {
+      builder = ApplicationMasterProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+    
+  
+  @Override
+  public ApplicationState getState() {
+    ApplicationMasterProtoOrBuilder p = viaProto ? proto : builder;
+    if (!p.hasState()) {
+      return null;
+    }
+    return convertFromProtoFormat(p.getState());
+  }
+
+  @Override
+  public void setState(ApplicationState state) {
+    maybeInitBuilder();
+    if (state == null) {
+      builder.clearState();
+      return;
+    }
+    builder.setState(convertToProtoFormat(state));
+  }
+  @Override
+  public String getHost() {
+    ApplicationMasterProtoOrBuilder 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 ApplicationId getApplicationId() {
+    ApplicationMasterProtoOrBuilder p = viaProto ? proto : builder;
+    if (this.applicationId != null) {
+      return applicationId;
+    } // Else via proto
+    if (!p.hasApplicationId()) {
+      return null;
+    }
+    applicationId = convertFromProtoFormat(p.getApplicationId());
+    
+    return applicationId;
+  }
+
+  @Override
+  public void setApplicationId(ApplicationId applicationId) {
+    maybeInitBuilder();
+    if (applicationId == null)
+      builder.clearApplicationId();
+    this.applicationId = applicationId;
+    
+  }
+  @Override
+  public int getRpcPort() {
+    ApplicationMasterProtoOrBuilder p = viaProto ? proto : builder;
+    return (p.getRpcPort());
+  }
+
+  @Override
+  public void setRpcPort(int rpcPort) {
+    maybeInitBuilder();
+    builder.setRpcPort((rpcPort));
+  }
+  @Override
+  public int getHttpPort() {
+    ApplicationMasterProtoOrBuilder p = viaProto ? proto : builder;
+    return (p.getHttpPort());
+  }
+
+  @Override
+  public void setHttpPort(int httpPort) {
+    maybeInitBuilder();
+    builder.setHttpPort((httpPort));
+  }
+  @Override
+  public ApplicationStatus getStatus() {
+    ApplicationMasterProtoOrBuilder p = viaProto ? proto : builder;
+    if (this.applicationStatus != null) {
+      return this.applicationStatus;
+    } // Else via proto
+    if (!p.hasStatus()) {
+      return null;
+    }
+    this.applicationStatus = convertFromProtoFormat(p.getStatus());
+    
+    return this.applicationStatus;
+  }
+
+  @Override
+  public void setStatus(ApplicationStatus status) {
+    maybeInitBuilder();
+    if (status == null)
+      builder.clearStatus();
+    this.applicationStatus = status;
+    
+  }
+  @Override
+  public String getClientToken() {
+    ApplicationMasterProtoOrBuilder p = viaProto ? proto : builder;
+    if (!p.hasClientToken()) {
+      return null;
+    }
+    return (p.getClientToken());
+  }
+
+  @Override
+  public void setClientToken(String clientToken) {
+    maybeInitBuilder();
+    if (clientToken == null) {
+      builder.clearClientToken();
+      return;
+    }
+    builder.setClientToken((clientToken));
+  }
+
+  private ApplicationStateProto convertToProtoFormat(ApplicationState e) {
+    return ProtoUtils.convertToProtoFormat(e);
+  }
+
+  private ApplicationState convertFromProtoFormat(ApplicationStateProto e) {
+    return ProtoUtils.convertFromProtoFormat(e);
+  }
+
+  private ApplicationIdPBImpl convertFromProtoFormat(ApplicationIdProto p) {
+    return new ApplicationIdPBImpl(p);
+  }
+
+  private ApplicationIdProto convertToProtoFormat(ApplicationId t) {
+    return ((ApplicationIdPBImpl)t).getProto();
+  }
+
+  private ApplicationStatusPBImpl convertFromProtoFormat(ApplicationStatusProto p) {
+    return new ApplicationStatusPBImpl(p);
+  }
+
+  private ApplicationStatusProto convertToProtoFormat(ApplicationStatus t) {
+    return ((ApplicationStatusPBImpl)t).getProto();
+  }
+
+
+
+}  

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationStatusPBImpl.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/ApplicationStatusPBImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationStatusPBImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationStatusPBImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,129 @@
+package org.apache.hadoop.yarn.api.records.impl.pb;
+
+
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationStatus;
+import org.apache.hadoop.yarn.api.records.ProtoBase;
+import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationStatusProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationStatusProtoOrBuilder;
+
+
+    
+public class ApplicationStatusPBImpl extends ProtoBase<ApplicationStatusProto> implements ApplicationStatus {
+  ApplicationStatusProto proto = ApplicationStatusProto.getDefaultInstance();
+  ApplicationStatusProto.Builder builder = null;
+  boolean viaProto = false;
+  
+  private ApplicationId applicationId = null;
+  
+  
+  
+  public ApplicationStatusPBImpl() {
+    builder = ApplicationStatusProto.newBuilder();
+  }
+
+  public ApplicationStatusPBImpl(ApplicationStatusProto proto) {
+    this.proto = proto;
+    viaProto = true;
+  }
+  
+  public ApplicationStatusProto getProto() {
+  
+      mergeLocalToProto();
+    proto = viaProto ? proto : builder.build();
+    viaProto = true;
+    return proto;
+  }
+
+  private void mergeLocalToBuilder() {
+    if (this.applicationId != null && !((ApplicationIdPBImpl)this.applicationId).getProto().equals(builder.getApplicationId())) {
+      builder.setApplicationId(convertToProtoFormat(this.applicationId));
+    }
+  }
+
+  private void mergeLocalToProto() {
+    if (viaProto) 
+      maybeInitBuilder();
+    mergeLocalToBuilder();
+    proto = builder.build();
+    
+    viaProto = true;
+  }
+
+  private void maybeInitBuilder() {
+    if (viaProto || builder == null) {
+      builder = ApplicationStatusProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+    
+  
+  @Override
+  public int getResponseId() {
+    ApplicationStatusProtoOrBuilder p = viaProto ? proto : builder;
+    return (p.getResponseId());
+  }
+
+  @Override
+  public void setResponseId(int responseId) {
+    maybeInitBuilder();
+    builder.setResponseId((responseId));
+  }
+  @Override
+  public ApplicationId getApplicationId() {
+    ApplicationStatusProtoOrBuilder p = viaProto ? proto : builder;
+    if (this.applicationId != null) {
+      return applicationId;
+    } // Else via proto
+    if (!p.hasApplicationId()) {
+      return null;
+    }
+    applicationId = convertFromProtoFormat(p.getApplicationId());
+    
+    return applicationId;
+  }
+
+  @Override
+  public void setApplicationId(ApplicationId applicationId) {
+    maybeInitBuilder();
+    if (applicationId == null) {
+      builder.clearApplicationId();
+    }
+    this.applicationId = applicationId;
+    
+  }
+  @Override
+  public float getProgress() {
+    ApplicationStatusProtoOrBuilder p = viaProto ? proto : builder;
+    return (p.getProgress());
+  }
+
+  @Override
+  public void setProgress(float progress) {
+    maybeInitBuilder();
+    builder.setProgress((progress));
+  }
+  @Override
+  public long getLastSeen() {
+    ApplicationStatusProtoOrBuilder p = viaProto ? proto : builder;
+    return (p.getLastSeen());
+  }
+
+  @Override
+  public void setLastSeen(long lastSeen) {
+    maybeInitBuilder();
+    builder.setLastSeen((lastSeen));
+  }
+
+  private ApplicationIdPBImpl convertFromProtoFormat(ApplicationIdProto p) {
+    return new ApplicationIdPBImpl(p);
+  }
+
+  private ApplicationIdProto convertToProtoFormat(ApplicationId t) {
+    return ((ApplicationIdPBImpl)t).getProto();
+  }
+
+
+
+}  

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationSubmissionContextPBImpl.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/ApplicationSubmissionContextPBImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationSubmissionContextPBImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationSubmissionContextPBImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,642 @@
+package org.apache.hadoop.yarn.api.records.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.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
+import org.apache.hadoop.yarn.api.records.LocalResource;
+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.URL;
+import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationSubmissionContextProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationSubmissionContextProtoOrBuilder;
+import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.StringLocalResourceMapProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.StringStringMapProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.StringURLMapProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.URLProto;
+
+
+    
+public class ApplicationSubmissionContextPBImpl extends ProtoBase<ApplicationSubmissionContextProto> implements ApplicationSubmissionContext {
+  ApplicationSubmissionContextProto proto = ApplicationSubmissionContextProto.getDefaultInstance();
+  ApplicationSubmissionContextProto.Builder builder = null;
+  boolean viaProto = false;
+  
+  private ApplicationId applicationId = null;
+  private Resource masterCapability = null;
+  private Map<String, URL> resources = null;
+  private Map<String, LocalResource> resourcesTodo = null;
+  private List<String> fsTokenList = null;
+  private ByteBuffer fsTokenTodo = null;
+  private Map<String, String> environment = null;
+  private List<String> commandList = null;
+  private Priority priority = null;
+  
+  
+  
+  public ApplicationSubmissionContextPBImpl() {
+    builder = ApplicationSubmissionContextProto.newBuilder();
+  }
+
+  public ApplicationSubmissionContextPBImpl(ApplicationSubmissionContextProto proto) {
+    this.proto = proto;
+    viaProto = true;
+  }
+  
+  public ApplicationSubmissionContextProto getProto() {
+      mergeLocalToProto();
+    proto = viaProto ? proto : builder.build();
+    viaProto = true;
+    return proto;
+  }
+
+  private void mergeLocalToBuilder() {
+    if (this.applicationId != null) {
+      builder.setApplicationId(convertToProtoFormat(this.applicationId));
+    }
+    if (this.masterCapability != null) {
+      builder.setMasterCapability(convertToProtoFormat(this.masterCapability));
+    }
+    if (this.resources != null) {
+      addResourcesToProto();
+    }
+    if (this.resourcesTodo != null) {
+      addResourcesTodoToProto();
+    }
+    if (this.fsTokenList != null) {
+      addFsTokenListToProto();
+    }
+    if (this.fsTokenTodo != null) {
+      builder.setFsTokensTodo(convertToProtoFormat(this.fsTokenTodo));
+    }
+    if (this.environment != null) {
+      addEnvironmentToProto();
+    }
+    if (this.commandList != null) {
+      addCommandsToProto();
+    }
+    if (this.priority != null) {
+      builder.setPriority(convertToProtoFormat(this.priority));
+    }
+  }
+
+  private void mergeLocalToProto() {
+    if (viaProto) 
+      maybeInitBuilder();
+    mergeLocalToBuilder();
+    proto = builder.build();
+    viaProto = true;
+  }
+
+  private void maybeInitBuilder() {
+    if (viaProto || builder == null) {
+      builder = ApplicationSubmissionContextProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+    
+  
+  @Override
+  public Priority getPriority() {
+    ApplicationSubmissionContextProtoOrBuilder 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 ApplicationId getApplicationId() {
+    ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
+    if (this.applicationId != null) {
+      return applicationId;
+    } // Else via proto
+    if (!p.hasApplicationId()) {
+      return null;
+    }
+    applicationId = convertFromProtoFormat(p.getApplicationId());
+    return applicationId;
+  }
+
+  @Override
+  public void setApplicationId(ApplicationId applicationId) {
+    maybeInitBuilder();
+    if (applicationId == null)
+      builder.clearApplicationId();
+    this.applicationId = applicationId;
+  }
+  @Override
+  public String getApplicationName() {
+    ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
+    if (!p.hasApplicationName()) {
+      return null;
+    }
+    return (p.getApplicationName());
+  }
+
+  @Override
+  public void setApplicationName(String applicationName) {
+    maybeInitBuilder();
+    if (applicationName == null) {
+      builder.clearApplicationName();
+      return;
+    }
+    builder.setApplicationName((applicationName));
+  }
+  @Override
+  public Resource getMasterCapability() {
+    ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
+    if (this.masterCapability != null) {
+      return masterCapability;
+    } // Else via proto
+    if (!p.hasMasterCapability()) {
+      return null;
+    }
+    masterCapability = convertFromProtoFormat(p.getMasterCapability());
+    return this.masterCapability;
+  }
+
+  @Override
+  public void setMasterCapability(Resource masterCapability) {
+    maybeInitBuilder();
+    if (masterCapability == null)
+      builder.clearMasterCapability();
+    this.masterCapability = masterCapability;
+  }
+  @Override
+  public Map<String, URL> getAllResources() {
+    initResources();
+    return this.resources;
+  }
+  @Override
+  public URL getResource(String key) {
+    initResources();
+    return this.resources.get(key);
+  }
+  
+  private void initResources() {
+    if (this.resources != null) {
+      return;
+    }
+    ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
+    List<StringURLMapProto> mapAsList = p.getResourcesList();
+    this.resources = new HashMap<String, URL>();
+    
+    for (StringURLMapProto c : mapAsList) {
+      this.resources.put(c.getKey(), convertFromProtoFormat(c.getValue()));
+    }
+  }
+  
+  @Override
+  public void addAllResources(final Map<String, URL> resources) {
+    if (resources == null)
+      return;
+    initResources();
+    this.resources.putAll(resources);
+  }
+  
+  private void addResourcesToProto() {
+    maybeInitBuilder();
+    builder.clearResources();
+    if (this.resources == null)
+      return;
+    Iterable<StringURLMapProto> iterable = new Iterable<StringURLMapProto>() {
+      
+      @Override
+      public Iterator<StringURLMapProto> iterator() {
+        return new Iterator<StringURLMapProto>() {
+          
+          Iterator<String> keyIter = resources.keySet().iterator();
+          
+          @Override
+          public void remove() {
+            throw new UnsupportedOperationException();
+          }
+          
+          @Override
+          public StringURLMapProto next() {
+            String key = keyIter.next();
+            return StringURLMapProto.newBuilder().setKey(key).setValue(convertToProtoFormat(resources.get(key))).build();
+          }
+          
+          @Override
+          public boolean hasNext() {
+            return keyIter.hasNext();
+          }
+        };
+      }
+    };
+    builder.addAllResources(iterable);
+  }
+  @Override
+  public void setResource(String key, URL val) {
+    initResources();
+    this.resources.put(key, val);
+  }
+  @Override
+  public void removeResource(String key) {
+    initResources();
+    this.resources.remove(key);
+  }
+  @Override
+  public void clearResources() {
+    initResources();
+    this.resources.clear();
+  }
+  @Override
+  public Map<String, LocalResource> getAllResourcesTodo() {
+    initResourcesTodo();
+    return this.resourcesTodo;
+  }
+  @Override
+  public LocalResource getResourceTodo(String key) {
+    initResourcesTodo();
+    return this.resourcesTodo.get(key);
+  }
+  
+  private void initResourcesTodo() {
+    if (this.resourcesTodo != null) {
+      return;
+    }
+    ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
+    List<StringLocalResourceMapProto> mapAsList = p.getResourcesTodoList();
+    this.resourcesTodo = new HashMap<String, LocalResource>();
+    
+    for (StringLocalResourceMapProto c : mapAsList) {
+      this.resourcesTodo.put(c.getKey(), convertFromProtoFormat(c.getValue()));
+    }
+  }
+  
+  @Override
+  public void addAllResourcesTodo(final Map<String, LocalResource> resourcesTodo) {
+    if (resourcesTodo == null) 
+      return;
+    initResourcesTodo();
+    this.resourcesTodo.putAll(resourcesTodo);
+  }
+  
+  private void addResourcesTodoToProto() {
+    maybeInitBuilder();
+    builder.clearResourcesTodo();
+    if (resourcesTodo == null)
+      return;
+    Iterable<StringLocalResourceMapProto> iterable = new Iterable<StringLocalResourceMapProto>() {
+      
+      @Override
+      public Iterator<StringLocalResourceMapProto> iterator() {
+        return new Iterator<StringLocalResourceMapProto>() {
+          
+          Iterator<String> keyIter = resourcesTodo.keySet().iterator();
+          
+          @Override
+          public void remove() {
+            throw new UnsupportedOperationException();
+          }
+          
+          @Override
+          public StringLocalResourceMapProto next() {
+            String key = keyIter.next();
+            return StringLocalResourceMapProto.newBuilder().setKey(key).setValue(convertToProtoFormat(resourcesTodo.get(key))).build();
+          }
+          
+          @Override
+          public boolean hasNext() {
+            return keyIter.hasNext();
+          }
+        };
+      }
+    };
+    builder.addAllResourcesTodo(iterable);
+  }
+  @Override
+  public void setResourceTodo(String key, LocalResource val) {
+    initResourcesTodo();
+    this.resourcesTodo.put(key, val);
+  }
+  @Override
+  public void removeResourceTodo(String key) {
+    initResourcesTodo();
+    this.resourcesTodo.remove(key);
+  }
+  @Override
+  public void clearResourcesTodo() {
+    initResourcesTodo();
+    this.resourcesTodo.clear();
+  }
+  @Override
+  public List<String> getFsTokenList() {
+    initFsTokenList();
+    return this.fsTokenList;
+  }
+  @Override
+  public String getFsToken(int index) {
+    initFsTokenList();
+    return this.fsTokenList.get(index);
+  }
+  @Override
+  public int getFsTokenCount() {
+    initFsTokenList();
+    return this.fsTokenList.size();
+  }
+  
+  private void initFsTokenList() {
+    if (this.fsTokenList != null) {
+      return;
+    }
+    ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
+    List<String> list = p.getFsTokensList();
+    this.fsTokenList = new ArrayList<String>();
+
+    for (String c : list) {
+      this.fsTokenList.add(c);
+    }
+  }
+  
+  @Override
+  public void addAllFsTokens(final List<String> fsTokens) {
+    if (fsTokens == null) 
+      return;
+    initFsTokenList();
+    this.fsTokenList.addAll(fsTokens);
+  }
+  
+  private void addFsTokenListToProto() {
+    maybeInitBuilder();
+    builder.clearFsTokens();
+    builder.addAllFsTokens(this.fsTokenList);
+  }
+
+  @Override
+  public void addFsToken(String fsTokens) {
+    initFsTokenList();
+    this.fsTokenList.add(fsTokens);
+  }
+  @Override
+  public void removeFsToken(int index) {
+    initFsTokenList();
+    this.fsTokenList.remove(index);
+  }
+  @Override
+  public void clearFsTokens() {
+    initFsTokenList();
+    this.fsTokenList.clear();
+  }
+  @Override
+  public ByteBuffer getFsTokensTodo() {
+    ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
+    if (this.fsTokenTodo != null) {
+      return this.fsTokenTodo;
+    }
+    if (!p.hasFsTokensTodo()) {
+      return null;
+    }
+    this.fsTokenTodo = convertFromProtoFormat(p.getFsTokensTodo());
+    return this.fsTokenTodo;
+  }
+
+  @Override
+  public void setFsTokensTodo(ByteBuffer fsTokensTodo) {
+    maybeInitBuilder();
+    if (fsTokensTodo == null) 
+      builder.clearFsTokensTodo();
+    this.fsTokenTodo = fsTokensTodo;
+  }
+  @Override
+  public Map<String, String> getAllEnvironment() {
+    initEnvironment();
+    return this.environment;
+  }
+  @Override
+  public String getEnvironment(String key) {
+    initEnvironment();
+    return this.environment.get(key);
+  }
+  
+  private void initEnvironment() {
+    if (this.environment != null) {
+      return;
+    }
+    ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
+    List<StringStringMapProto> mapAsList = p.getEnvironmentList();
+    this.environment = new HashMap<String, String>();
+    
+    for (StringStringMapProto c : mapAsList) {
+      this.environment.put(c.getKey(), c.getValue());
+    }
+  }
+  
+  @Override
+  public void addAllEnvironment(Map<String, String> environment) {
+    if (environment == null)
+      return;
+    initEnvironment();
+    this.environment.putAll(environment);
+  }
+  
+  private void addEnvironmentToProto() {
+    maybeInitBuilder();
+    builder.clearEnvironment();
+    if (environment == null)
+      return;
+    Iterable<StringStringMapProto> iterable = new Iterable<StringStringMapProto>() {
+      
+      @Override
+      public Iterator<StringStringMapProto> iterator() {
+        return new Iterator<StringStringMapProto>() {
+          
+          Iterator<String> keyIter = environment.keySet().iterator();
+          
+          @Override
+          public void remove() {
+            throw new UnsupportedOperationException();
+          }
+          
+          @Override
+          public StringStringMapProto next() {
+            String key = keyIter.next();
+            return StringStringMapProto.newBuilder().setKey(key).setValue((environment.get(key))).build();
+          }
+          
+          @Override
+          public boolean hasNext() {
+            return keyIter.hasNext();
+          }
+        };
+      }
+    };
+    builder.addAllEnvironment(iterable);
+  }
+  @Override
+  public void setEnvironment(String key, String val) {
+    initEnvironment();
+    this.environment.put(key, val);
+  }
+  @Override
+  public void removeEnvironment(String key) {
+    initEnvironment();
+    this.environment.remove(key);
+  }
+  @Override
+  public void clearEnvironment() {
+    initEnvironment();
+    this.environment.clear();
+  }
+  @Override
+  public List<String> getCommandList() {
+    initCommandList();
+    return this.commandList;
+  }
+  @Override
+  public String getCommand(int index) {
+    initCommandList();
+    return this.commandList.get(index);
+  }
+  @Override
+  public int getCommandCount() {
+    initCommandList();
+    return this.commandList.size();
+  }
+  
+  private void initCommandList() {
+    if (this.commandList != null) {
+      return;
+    }
+    ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
+    List<String> list = p.getCommandList();
+    this.commandList = new ArrayList<String>();
+
+    for (String c : list) {
+      this.commandList.add(c);
+    }
+  }
+  
+  @Override
+  public void addAllCommands(final List<String> command) {
+    if (command == null)
+      return;
+    initCommandList();
+    this.commandList.addAll(command);
+  }
+  
+  private void addCommandsToProto() {
+    maybeInitBuilder();
+    builder.clearCommand();
+    if (this.commandList == null) 
+      return;
+    builder.addAllCommand(this.commandList);
+  }
+  @Override
+  public void addCommand(String command) {
+    initCommandList();
+    this.commandList.add(command);
+  }
+  @Override
+  public void removeCommand(int index) {
+    initCommandList();
+    this.commandList.remove(index);
+  }
+  @Override
+  public void clearCommands() {
+    initCommandList();
+    this.commandList.clear();
+  }
+  @Override
+  public String getQueue() {
+    ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
+    if (!p.hasQueue()) {
+      return null;
+    }
+    return (p.getQueue());
+  }
+
+  @Override
+  public void setQueue(String queue) {
+    maybeInitBuilder();
+    if (queue == null) {
+      builder.clearQueue();
+      return;
+    }
+    builder.setQueue((queue));
+  }
+  @Override
+  public String getUser() {
+    ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
+    if (!p.hasUser()) {
+      return null;
+    }
+    return (p.getUser());
+  }
+
+  @Override
+  public void setUser(String user) {
+    maybeInitBuilder();
+    if (user == null) {
+      builder.clearUser();
+      return;
+    }
+    builder.setUser((user));
+  }
+
+  private PriorityPBImpl convertFromProtoFormat(PriorityProto p) {
+    return new PriorityPBImpl(p);
+  }
+
+  private PriorityProto convertToProtoFormat(Priority t) {
+    return ((PriorityPBImpl)t).getProto();
+  }
+
+  private ApplicationIdPBImpl convertFromProtoFormat(ApplicationIdProto p) {
+    return new ApplicationIdPBImpl(p);
+  }
+
+  private ApplicationIdProto convertToProtoFormat(ApplicationId t) {
+    return ((ApplicationIdPBImpl)t).getProto();
+  }
+
+  private ResourcePBImpl convertFromProtoFormat(ResourceProto p) {
+    return new ResourcePBImpl(p);
+  }
+
+  private ResourceProto convertToProtoFormat(Resource t) {
+    return ((ResourcePBImpl)t).getProto();
+  }
+
+  private URLPBImpl convertFromProtoFormat(URLProto p) {
+    return new URLPBImpl(p);
+  }
+
+  private URLProto convertToProtoFormat(URL t) {
+    return ((URLPBImpl)t).getProto();
+  }
+
+  private LocalResourcePBImpl convertFromProtoFormat(LocalResourceProto p) {
+    return new LocalResourcePBImpl(p);
+  }
+
+  private LocalResourceProto convertToProtoFormat(LocalResource t) {
+    return ((LocalResourcePBImpl)t).getProto();
+  }
+
+}  

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerIdPBImpl.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/ContainerIdPBImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerIdPBImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerIdPBImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,121 @@
+package org.apache.hadoop.yarn.api.records.impl.pb;
+
+
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.api.records.ProtoBase;
+import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProtoOrBuilder;
+
+
+    
+public class ContainerIdPBImpl extends ProtoBase<ContainerIdProto> implements ContainerId {
+  ContainerIdProto proto = ContainerIdProto.getDefaultInstance();
+  ContainerIdProto.Builder builder = null;
+  boolean viaProto = false;
+  
+  private ApplicationId applicationId = null;
+  
+  public ContainerIdPBImpl() {
+    builder = ContainerIdProto.newBuilder();
+  }
+
+  public ContainerIdPBImpl(ContainerIdProto proto) {
+    this.proto = proto;
+    viaProto = true;
+  }
+  
+  public ContainerIdProto getProto() {
+    mergeLocalToProto();
+    proto = viaProto ? proto : builder.build();
+    viaProto = true;
+    return proto;
+  }
+
+  private void mergeLocalToBuilder() {
+    if (this.applicationId != null && !((ApplicationIdPBImpl)applicationId).getProto().equals(builder.getAppId())) {
+      builder.setAppId(convertToProtoFormat(this.applicationId));
+    }
+  }
+
+  private void mergeLocalToProto() {
+    if (viaProto) 
+      maybeInitBuilder();
+    mergeLocalToBuilder();
+    proto = builder.build();
+    viaProto = true;
+  }
+
+  private void maybeInitBuilder() {
+    if (viaProto || builder == null) {
+      builder = ContainerIdProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+    
+  
+  @Override
+  public int getId() {
+    ContainerIdProtoOrBuilder p = viaProto ? proto : builder;
+    return (p.getId());
+  }
+
+  @Override
+  public void setId(int id) {
+    maybeInitBuilder();
+    builder.setId((id));
+  }
+  @Override
+  public ApplicationId getAppId() {
+    ContainerIdProtoOrBuilder p = viaProto ? proto : builder;
+    if (this.applicationId != null) {
+      return this.applicationId;
+    }
+    if (!p.hasAppId()) {
+      return null;
+    }
+    this.applicationId = convertFromProtoFormat(p.getAppId());
+    return this.applicationId;
+  }
+
+  @Override
+  public void setAppId(ApplicationId appId) {
+    maybeInitBuilder();
+    if (appId == null) 
+      builder.clearAppId();
+    this.applicationId = appId;
+  }
+
+  private ApplicationIdPBImpl convertFromProtoFormat(ApplicationIdProto p) {
+    return new ApplicationIdPBImpl(p);
+  }
+
+  private ApplicationIdProto convertToProtoFormat(ApplicationId t) {
+    return ((ApplicationIdPBImpl)t).getProto();
+  }
+
+  @Override
+  public int hashCode() {
+    return getProto().hashCode();
+  }
+
+  @Override
+  public boolean equals(Object other) {
+    if (other.getClass().isAssignableFrom(this.getClass())) {
+      return this.getProto().equals(this.getClass().cast(other).getProto());
+    }
+    return false;
+  }
+
+  @Override
+  public int compareTo(ContainerId other) {
+    if (this.getAppId().compareTo(other.getAppId()) == 0) {
+      return this.getId() - other.getId();
+    } else {
+      return this.getAppId().compareTo(other.getAppId());
+    }
+    
+  }
+
+}  

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerLaunchContextPBImpl.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/ContainerLaunchContextPBImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerLaunchContextPBImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerLaunchContextPBImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,498 @@
+package org.apache.hadoop.yarn.api.records.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.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.api.records.ContainerLaunchContext;
+import org.apache.hadoop.yarn.api.records.LocalResource;
+import org.apache.hadoop.yarn.api.records.ProtoBase;
+import org.apache.hadoop.yarn.api.records.Resource;
+import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProtoOrBuilder;
+import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.StringBytesMapProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.StringLocalResourceMapProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.StringStringMapProto;
+
+
+    
+public class ContainerLaunchContextPBImpl extends ProtoBase<ContainerLaunchContextProto> implements ContainerLaunchContext {
+  ContainerLaunchContextProto proto = ContainerLaunchContextProto.getDefaultInstance();
+  ContainerLaunchContextProto.Builder builder = null;
+  boolean viaProto = false;
+  
+  private ContainerId containerId = null;
+  private Resource resource = null;
+  private Map<String, LocalResource> localResources = null;
+  private ByteBuffer containerTokens = null;
+  private Map<String, ByteBuffer> serviceData = null;
+  private Map<String, String> env = null;
+  private List<String> commands = null;
+  
+  
+  public ContainerLaunchContextPBImpl() {
+    builder = ContainerLaunchContextProto.newBuilder();
+  }
+
+  public ContainerLaunchContextPBImpl(ContainerLaunchContextProto proto) {
+    this.proto = proto;
+    viaProto = true;
+  }
+  
+  public ContainerLaunchContextProto getProto() {
+      mergeLocalToProto();
+    proto = viaProto ? proto : builder.build();
+    viaProto = true;
+    return proto;
+  }
+  
+  private void mergeLocalToBuilder() {
+    if (this.containerId != null && !((ContainerIdPBImpl)containerId).getProto().equals(builder.getContainerId())) {
+      builder.setContainerId(convertToProtoFormat(this.containerId));
+    }
+    if (this.resource != null && !((ResourcePBImpl)this.resource).getProto().equals(builder.getResource())) {
+      builder.setResource(convertToProtoFormat(this.resource));
+    }
+    if (this.localResources != null) {
+      addLocalResourcesToProto();
+    }
+    if (this.containerTokens != null) {
+      builder.setContainerTokens(convertToProtoFormat(this.containerTokens));
+    }
+    if (this.serviceData != null) {
+      addServiceDataToProto();
+    }
+    if (this.env != null) {
+      addEnvToProto();
+    }
+    if (this.commands != null) {
+      addCommandsToProto();
+    }
+  }
+  
+  private void mergeLocalToProto() {
+    if (viaProto) 
+      maybeInitBuilder();
+    mergeLocalToBuilder();
+    proto = builder.build();
+    viaProto = true;
+  }
+
+  private void maybeInitBuilder() {
+    if (viaProto || builder == null) {
+      builder = ContainerLaunchContextProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+    
+  
+  @Override
+  public Resource getResource() {
+    ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder;
+    if (this.resource != null) {
+      return this.resource;
+    }
+    if (!p.hasResource()) {
+      return null;
+    }
+    this.resource = convertFromProtoFormat(p.getResource());
+    return this.resource;
+  }
+
+  @Override
+  public void setResource(Resource resource) {
+    maybeInitBuilder();
+    if (resource == null) 
+      builder.clearResource();
+    this.resource = resource;
+  }
+  @Override
+  public List<String> getCommandList() {
+    initCommands();
+    return this.commands;
+  }
+  @Override
+  public String getCommand(int index) {
+    initCommands();
+    return this.commands.get(index);
+  }
+  @Override
+  public int getCommandCount() {
+    initCommands();
+    return this.commands.size();
+  }
+  
+  private void initCommands() {
+    if (this.commands != null) {
+      return;
+    }
+    ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder;
+    List<String> list = p.getCommandList();
+    this.commands = new ArrayList<String>();
+
+    for (String c : list) {
+      this.commands.add(c);
+    }
+  }
+  
+  @Override
+  public void addAllCommands(final List<String> command) {
+    if (command == null)
+      return;
+    initCommands();
+    this.commands.addAll(command);
+  }
+  
+  private void addCommandsToProto() {
+    maybeInitBuilder();
+    builder.clearCommand();
+    if (this.commands == null) 
+      return;
+    builder.addAllCommand(this.commands);
+  }
+  @Override
+  public void addCommand(String command) {
+    initCommands();
+    this.commands.add(command);
+  }
+  @Override
+  public void removeCommand(int index) {
+    initCommands();
+    this.commands.remove(index);
+  }
+  @Override
+  public void clearCommands() {
+    initCommands();
+    this.commands.clear();
+  }
+  @Override
+  public String getUser() {
+    ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder;
+    if (!p.hasUser()) {
+      return null;
+    }
+    return (p.getUser());
+  }
+
+  @Override
+  public void setUser(String user) {
+    maybeInitBuilder();
+    if (user == null) {
+      builder.clearUser();
+      return;
+    }
+    builder.setUser((user));
+  }
+  @Override
+  public ContainerId getContainerId() {
+    ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder;
+    if (this.containerId != null) {
+      return this.containerId;
+    }
+    if (!p.hasContainerId()) {
+      return null;
+    }
+    this.containerId = convertFromProtoFormat(p.getContainerId());
+    return this.containerId;
+  }
+
+  @Override
+  public void setContainerId(ContainerId containerId) {
+    maybeInitBuilder();
+    if (containerId == null) 
+      builder.clearContainerId();
+    this.containerId = containerId;
+  }
+  @Override
+  public Map<String, LocalResource> getAllLocalResources() {
+    initLocalResources();
+    return this.localResources;
+  }
+  @Override
+  public LocalResource getLocalResource(String key) {
+    initLocalResources();
+    return this.localResources.get(key);
+  }
+  
+  private void initLocalResources() {
+    if (this.localResources != null) {
+      return;
+    }
+    ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder;
+    List<StringLocalResourceMapProto> list = p.getLocalResourcesList();
+    this.localResources = new HashMap<String, LocalResource>();
+
+    for (StringLocalResourceMapProto c : list) {
+      this.localResources.put(c.getKey(), convertFromProtoFormat(c.getValue()));
+    }
+  }
+  
+  @Override
+  public void addAllLocalResources(final Map<String, LocalResource> localResources) {
+    if (localResources == null)
+      return;
+    initLocalResources();
+    this.localResources.putAll(localResources);
+  }
+  
+  private void addLocalResourcesToProto() {
+    maybeInitBuilder();
+    builder.clearLocalResources();
+    if (localResources == null)
+      return;
+    Iterable<StringLocalResourceMapProto> iterable = new Iterable<StringLocalResourceMapProto>() {
+      
+      @Override
+      public Iterator<StringLocalResourceMapProto> iterator() {
+        return new Iterator<StringLocalResourceMapProto>() {
+          
+          Iterator<String> keyIter = localResources.keySet().iterator();
+          
+          @Override
+          public void remove() {
+            throw new UnsupportedOperationException();
+          }
+          
+          @Override
+          public StringLocalResourceMapProto next() {
+            String key = keyIter.next();
+            return StringLocalResourceMapProto.newBuilder().setKey(key).setValue(convertToProtoFormat(localResources.get(key))).build();
+          }
+          
+          @Override
+          public boolean hasNext() {
+            return keyIter.hasNext();
+          }
+        };
+      }
+    };
+    builder.addAllLocalResources(iterable);
+  }
+  @Override
+  public void setLocalResource(String key, LocalResource val) {
+    initLocalResources();
+    this.localResources.put(key, val);
+  }
+  @Override
+  public void removeLocalResource(String key) {
+    initLocalResources();
+    this.localResources.remove(key);
+  }
+  @Override
+  public void clearLocalResources() {
+    initLocalResources();
+    this.localResources.clear();
+  }
+  @Override
+  public ByteBuffer getContainerTokens() {
+    ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder;
+    if (this.containerTokens != null) {
+      return this.containerTokens;
+    }
+    if (!p.hasContainerTokens()) {
+      return null;
+    }
+    this.containerTokens =  convertFromProtoFormat(p.getContainerTokens());
+    return this.containerTokens;
+  }
+
+  @Override
+  public void setContainerTokens(ByteBuffer containerTokens) {
+    maybeInitBuilder();
+    if (containerTokens == null)
+      builder.clearContainerTokens();
+    this.containerTokens = containerTokens;
+  }
+  @Override
+  public Map<String, ByteBuffer> getAllServiceData() {
+    initServiceData();
+    return this.serviceData;
+  }
+  @Override
+  public ByteBuffer getServiceData(String key) {
+    initServiceData();
+    return this.serviceData.get(key);
+  }
+  
+  private void initServiceData() {
+    if (this.serviceData != null) {
+      return;
+    }
+    ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder;
+    List<StringBytesMapProto> list = p.getServiceDataList();
+    this.serviceData = new HashMap<String, ByteBuffer>();
+
+    for (StringBytesMapProto c : list) {
+      this.serviceData.put(c.getKey(), convertFromProtoFormat(c.getValue()));
+    }
+  }
+  
+  @Override
+  public void addAllServiceData(final Map<String, ByteBuffer> serviceData) {
+    if (serviceData == null)
+      return;
+    initServiceData();
+    this.serviceData.putAll(serviceData);
+  }
+  
+  private void addServiceDataToProto() {
+    maybeInitBuilder();
+    builder.clearServiceData();
+    if (serviceData == null)
+      return;
+    Iterable<StringBytesMapProto> iterable = new Iterable<StringBytesMapProto>() {
+      
+      @Override
+      public Iterator<StringBytesMapProto> iterator() {
+        return new Iterator<StringBytesMapProto>() {
+          
+          Iterator<String> keyIter = serviceData.keySet().iterator();
+          
+          @Override
+          public void remove() {
+            throw new UnsupportedOperationException();
+          }
+          
+          @Override
+          public StringBytesMapProto next() {
+            String key = keyIter.next();
+            return StringBytesMapProto.newBuilder().setKey(key).setValue(convertToProtoFormat(serviceData.get(key))).build();
+          }
+          
+          @Override
+          public boolean hasNext() {
+            return keyIter.hasNext();
+          }
+        };
+      }
+    };
+    builder.addAllServiceData(iterable);
+  }
+  @Override
+  public void setServiceData(String key, ByteBuffer val) {
+    initServiceData();
+    this.serviceData.put(key, val);
+  }
+  @Override
+  public void removeServiceData(String key) {
+    initServiceData();
+    this.serviceData.remove(key);
+  }
+  @Override
+  public void clearServiceData() {
+    initServiceData();
+    this.serviceData.clear();
+  }
+  @Override
+  public Map<String, String> getAllEnv() {
+    initEnv();
+    return this.env;
+  }
+  @Override
+  public String getEnv(String key) {
+    initEnv();
+    return this.env.get(key);
+  }
+  
+  private void initEnv() {
+    if (this.env != null) {
+      return;
+    }
+    ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder;
+    List<StringStringMapProto> list = p.getEnvList();
+    this.env = new HashMap<String, String>();
+
+    for (StringStringMapProto c : list) {
+      this.env.put(c.getKey(), c.getValue());
+    }
+  }
+  
+  @Override
+  public void addAllEnv(final Map<String, String> env) {
+    if (env == null)
+      return;
+    initEnv();
+    this.env.putAll(env);
+  }
+  
+  private void addEnvToProto() {
+    maybeInitBuilder();
+    builder.clearEnv();
+    if (env == null)
+      return;
+    Iterable<StringStringMapProto> iterable = new Iterable<StringStringMapProto>() {
+      
+      @Override
+      public Iterator<StringStringMapProto> iterator() {
+        return new Iterator<StringStringMapProto>() {
+          
+          Iterator<String> keyIter = env.keySet().iterator();
+          
+          @Override
+          public void remove() {
+            throw new UnsupportedOperationException();
+          }
+          
+          @Override
+          public StringStringMapProto next() {
+            String key = keyIter.next();
+            return StringStringMapProto.newBuilder().setKey(key).setValue((env.get(key))).build();
+          }
+          
+          @Override
+          public boolean hasNext() {
+            return keyIter.hasNext();
+          }
+        };
+      }
+    };
+    builder.addAllEnv(iterable);
+  }
+  @Override
+  public void setEnv(String key, String val) {
+    initEnv();
+    this.env.put(key, val);
+  }
+  @Override
+  public void removeEnv(String key) {
+    initEnv();
+    this.env.remove(key);
+  }
+  @Override
+  public void clearEnv() {
+    initEnv();
+    this.env.clear();
+  }
+
+  private ResourcePBImpl convertFromProtoFormat(ResourceProto p) {
+    return new ResourcePBImpl(p);
+  }
+
+  private ResourceProto convertToProtoFormat(Resource t) {
+    return ((ResourcePBImpl)t).getProto();
+  }
+
+  private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) {
+    return new ContainerIdPBImpl(p);
+  }
+
+  private ContainerIdProto convertToProtoFormat(ContainerId t) {
+    return ((ContainerIdPBImpl)t).getProto();
+  }
+
+  private LocalResourcePBImpl convertFromProtoFormat(LocalResourceProto p) {
+    return new LocalResourcePBImpl(p);
+  }
+
+  private LocalResourceProto convertToProtoFormat(LocalResource t) {
+    return ((LocalResourcePBImpl)t).getProto();
+  }
+}  

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerPBImpl.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/ContainerPBImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerPBImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerPBImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,229 @@
+package org.apache.hadoop.yarn.api.records.impl.pb;
+
+
+import org.apache.hadoop.yarn.api.records.Container;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.api.records.ContainerState;
+import org.apache.hadoop.yarn.api.records.ContainerToken;
+import org.apache.hadoop.yarn.api.records.ProtoBase;
+import org.apache.hadoop.yarn.api.records.Resource;
+import org.apache.hadoop.yarn.api.records.impl.pb.ContainerIdPBImpl;
+import org.apache.hadoop.yarn.api.records.impl.pb.ContainerTokenPBImpl;
+import org.apache.hadoop.yarn.api.records.impl.pb.ResourcePBImpl;
+import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ContainerProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ContainerProtoOrBuilder;
+import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStateProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ContainerTokenProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto;
+import org.apache.hadoop.yarn.util.ProtoUtils;
+
+
+    
+public class ContainerPBImpl extends ProtoBase<ContainerProto> implements Container {
+  ContainerProto proto = ContainerProto.getDefaultInstance();
+  ContainerProto.Builder builder = null;
+  boolean viaProto = false;
+  
+  private ContainerId containerId = null;
+  private Resource resource = null;
+  private ContainerToken containerToken = null;
+  
+  
+  public ContainerPBImpl() {
+    builder = ContainerProto.newBuilder();
+  }
+
+  public ContainerPBImpl(ContainerProto proto) {
+    this.proto = proto;
+    viaProto = true;
+  }
+  
+  public ContainerProto getProto() {
+  
+    mergeLocalToProto();
+    proto = viaProto ? proto : builder.build();
+    viaProto = true;
+    return proto;
+  }
+
+  private void mergeLocalToBuilder() {
+    if (this.containerId != null &&  !((ContainerIdPBImpl)containerId).getProto().equals(builder.getId())) {
+      builder.setId(convertToProtoFormat(this.containerId));
+    }
+    if (this.resource != null && !((ResourcePBImpl)this.resource).getProto().equals(builder.getResource())) {
+      builder.setResource(convertToProtoFormat(this.resource));
+    }
+    if (this.containerToken != null && !((ContainerTokenPBImpl)this.containerToken).getProto().equals(builder.getContainerToken())) {
+      builder.setContainerToken(convertToProtoFormat(this.containerToken));
+    }
+  }
+
+  private void mergeLocalToProto() {
+    if (viaProto) 
+      maybeInitBuilder();
+    mergeLocalToBuilder();
+    proto = builder.build();
+    viaProto = true;
+  }
+
+  private void maybeInitBuilder() {
+    if (viaProto || builder == null) {
+      builder = ContainerProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+    
+  
+  @Override
+  public ContainerState getState() {
+    ContainerProtoOrBuilder p = viaProto ? proto : builder;
+    if (!p.hasState()) {
+      return null;
+    }
+    return convertFromProtoFormat(p.getState());
+  }
+
+  @Override
+  public void setState(ContainerState state) {
+    maybeInitBuilder();
+    if (state == null) {
+      builder.clearState();
+      return;
+    }
+    builder.setState(convertToProtoFormat(state));
+  }
+  @Override
+  public ContainerId getId() {
+    ContainerProtoOrBuilder p = viaProto ? proto : builder;
+    if (this.containerId != null) {
+      return this.containerId;
+    }
+    if (!p.hasId()) {
+      return null;
+    }
+    this.containerId = convertFromProtoFormat(p.getId());
+    return this.containerId;
+  }
+
+  @Override
+  public void setId(ContainerId id) {
+    maybeInitBuilder();
+    if (id == null)
+      builder.clearId();
+    this.containerId = id;
+  }
+  @Override
+  public String getHostName() {
+    ContainerProtoOrBuilder 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 getResource() {
+    ContainerProtoOrBuilder p = viaProto ? proto : builder;
+    if (this.resource != null) {
+      return this.resource;
+    }
+    if (!p.hasResource()) {
+      return null;
+    }
+    this.resource = convertFromProtoFormat(p.getResource());
+    return this.resource;
+  }
+
+  @Override
+  public void setResource(Resource resource) {
+    maybeInitBuilder();
+    if (resource == null)
+      builder.clearResource();
+    this.resource = resource;
+  }
+  @Override
+  public ContainerToken getContainerToken() {
+    ContainerProtoOrBuilder p = viaProto ? proto : builder;
+    if (this.containerToken != null) {
+      return this.containerToken;
+    }
+    if (!p.hasContainerToken()) {
+      return null;
+    }
+    this.containerToken = convertFromProtoFormat(p.getContainerToken());
+    return this.containerToken;
+  }
+
+  @Override
+  public void setContainerToken(ContainerToken containerToken) {
+    maybeInitBuilder();
+    if (containerToken == null) 
+      builder.clearContainerToken();
+    this.containerToken = containerToken;
+  }
+
+  private ContainerStateProto convertToProtoFormat(ContainerState e) {
+    return ProtoUtils.convertToProtoFormat(e);
+  }
+
+  private ContainerState convertFromProtoFormat(ContainerStateProto e) {
+    return ProtoUtils.convertFromProtoFormat(e);
+  }
+
+  private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) {
+    return new ContainerIdPBImpl(p);
+  }
+
+  private ContainerIdProto convertToProtoFormat(ContainerId t) {
+    return ((ContainerIdPBImpl)t).getProto();
+  }
+
+  private ResourcePBImpl convertFromProtoFormat(ResourceProto p) {
+    return new ResourcePBImpl(p);
+  }
+
+  private ResourceProto convertToProtoFormat(Resource t) {
+    return ((ResourcePBImpl)t).getProto();
+  }
+
+  private ContainerTokenPBImpl convertFromProtoFormat(ContainerTokenProto p) {
+    return new ContainerTokenPBImpl(p);
+  }
+
+  private ContainerTokenProto convertToProtoFormat(ContainerToken t) {
+    return ((ContainerTokenPBImpl)t).getProto();
+  }
+
+  //TODO Comparator
+  @Override
+  public int compareTo(Container other) {
+    if (this.getId().compareTo(other.getId()) == 0) {
+      if (this.getHostName().compareTo(other.getHostName()) == 0) {
+        if (this.getResource().compareTo(other.getResource()) == 0) {
+          if (this.getState().compareTo(other.getState()) == 0) {
+            //ContainerToken
+            return this.getState().compareTo(other.getState());
+          } else {
+            return this.getState().compareTo(other.getState());
+          }
+        } else {
+          return this.getResource().compareTo(other.getResource());
+        }
+      } else {
+        return this.getHostName().compareTo(other.getHostName());
+      }
+    } else {
+      return this.getId().compareTo(other.getId());
+    }
+  }
+}  

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerStatusPBImpl.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/ContainerStatusPBImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerStatusPBImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerStatusPBImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,130 @@
+package org.apache.hadoop.yarn.api.records.impl.pb;
+
+
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.api.records.ContainerState;
+import org.apache.hadoop.yarn.api.records.ContainerStatus;
+import org.apache.hadoop.yarn.api.records.ProtoBase;
+import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStateProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStatusProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStatusProtoOrBuilder;
+import org.apache.hadoop.yarn.util.ProtoUtils;
+
+
+    
+public class ContainerStatusPBImpl extends ProtoBase<ContainerStatusProto> implements ContainerStatus {
+  ContainerStatusProto proto = ContainerStatusProto.getDefaultInstance();
+  ContainerStatusProto.Builder builder = null;
+  boolean viaProto = false;
+  
+  private ContainerId containerId = null;
+  
+  
+  public ContainerStatusPBImpl() {
+    builder = ContainerStatusProto.newBuilder();
+  }
+
+  public ContainerStatusPBImpl(ContainerStatusProto proto) {
+    this.proto = proto;
+    viaProto = true;
+  }
+  
+  public ContainerStatusProto getProto() {
+      mergeLocalToProto();
+    proto = viaProto ? proto : builder.build();
+    viaProto = true;
+    return proto;
+  }
+
+  private void mergeLocalToBuilder() {
+    if (containerId != null) {
+      builder.setContainerId(convertToProtoFormat(this.containerId));
+    }
+  }
+
+  private void mergeLocalToProto() {
+    if (viaProto) 
+      maybeInitBuilder();
+    mergeLocalToBuilder();
+    proto = builder.build();
+    viaProto = true;
+  }
+
+  private void maybeInitBuilder() {
+    if (viaProto || builder == null) {
+      builder = ContainerStatusProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+    
+  
+  @Override
+  public ContainerState getState() {
+    ContainerStatusProtoOrBuilder p = viaProto ? proto : builder;
+    if (!p.hasState()) {
+      return null;
+    }
+    return convertFromProtoFormat(p.getState());
+  }
+
+  @Override
+  public void setState(ContainerState state) {
+    maybeInitBuilder();
+    if (state == null) {
+      builder.clearState();
+      return;
+    }
+    builder.setState(convertToProtoFormat(state));
+  }
+  @Override
+  public ContainerId getContainerId() {
+    ContainerStatusProtoOrBuilder p = viaProto ? proto : builder;
+    if (this.containerId != null) {
+      return this.containerId;
+    }
+    if (!p.hasContainerId()) {
+      return null;
+    }
+    this.containerId =  convertFromProtoFormat(p.getContainerId());
+    return this.containerId;
+  }
+
+  @Override
+  public void setContainerId(ContainerId containerId) {
+    maybeInitBuilder();
+    if (containerId == null) 
+      builder.clearContainerId();
+    this.containerId = containerId;
+  }
+  @Override
+  public int getExitStatus() {
+    ContainerStatusProtoOrBuilder p = viaProto ? proto : builder;
+    return (p.getExitStatus());
+  }
+
+  @Override
+  public void setExitStatus(int exitStatus) {
+    maybeInitBuilder();
+    builder.setExitStatus((exitStatus));
+  }
+
+  private ContainerStateProto convertToProtoFormat(ContainerState e) {
+    return ProtoUtils.convertToProtoFormat(e);
+  }
+
+  private ContainerState convertFromProtoFormat(ContainerStateProto e) {
+    return ProtoUtils.convertFromProtoFormat(e);
+  }
+
+  private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) {
+    return new ContainerIdPBImpl(p);
+  }
+
+  private ContainerIdProto convertToProtoFormat(ContainerId t) {
+    return ((ContainerIdPBImpl)t).getProto();
+  }
+
+
+
+}  

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerTokenPBImpl.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/ContainerTokenPBImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerTokenPBImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerTokenPBImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,140 @@
+package org.apache.hadoop.yarn.api.records.impl.pb;
+
+
+import java.nio.ByteBuffer;
+
+import org.apache.hadoop.yarn.api.records.ContainerToken;
+import org.apache.hadoop.yarn.api.records.ProtoBase;
+import org.apache.hadoop.yarn.proto.YarnProtos.ContainerTokenProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.ContainerTokenProtoOrBuilder;
+
+
+    
+public class ContainerTokenPBImpl extends ProtoBase<ContainerTokenProto> implements ContainerToken {
+  ContainerTokenProto proto = ContainerTokenProto.getDefaultInstance();
+  ContainerTokenProto.Builder builder = null;
+  boolean viaProto = false;
+  
+  private ByteBuffer identifier;
+  private ByteBuffer password;
+  
+  
+  public ContainerTokenPBImpl() {
+    builder = ContainerTokenProto.newBuilder();
+  }
+
+  public ContainerTokenPBImpl(ContainerTokenProto proto) {
+    this.proto = proto;
+    viaProto = true;
+  }
+  
+  public ContainerTokenProto getProto() {
+      mergeLocalToProto();
+    proto = viaProto ? proto : builder.build();
+    viaProto = true;
+    return proto;
+  }
+
+  private void mergeLocalToBuilder() {
+    if (this.identifier != null) {
+      builder.setIdentifier(convertToProtoFormat(this.identifier));
+    }
+    if (this.password != null) {
+      builder.setPassword(convertToProtoFormat(this.password));
+    }
+  }
+
+  private void mergeLocalToProto() {
+    if (viaProto) 
+      maybeInitBuilder();
+    mergeLocalToBuilder();
+    proto = builder.build();
+    viaProto = true;
+  }
+
+  private void maybeInitBuilder() {
+    if (viaProto || builder == null) {
+      builder = ContainerTokenProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+    
+  
+  @Override
+  public ByteBuffer getIdentifier() {
+    ContainerTokenProtoOrBuilder p = viaProto ? proto : builder;
+    if (this.identifier != null) {
+      return this.identifier;
+    }
+    if (!p.hasIdentifier()) {
+      return null;
+    }
+    this.identifier = convertFromProtoFormat(p.getIdentifier());
+    return this.identifier;
+  }
+
+  @Override
+  public void setIdentifier(ByteBuffer identifier) {
+    maybeInitBuilder();
+    if (identifier == null) 
+      builder.clearIdentifier();
+    this.identifier = identifier;
+  }
+  @Override
+  public ByteBuffer getPassword() {
+    ContainerTokenProtoOrBuilder p = viaProto ? proto : builder;
+    if (this.password != null) {
+      return this.password;
+    }
+    if (!p.hasPassword()) {
+      return null;
+    }
+    this.password =  convertFromProtoFormat(p.getPassword());
+    return this.password;
+  }
+
+  @Override
+  public void setPassword(ByteBuffer password) {
+    maybeInitBuilder();
+    if (password == null) 
+      builder.clearPassword();
+    this.password = password;
+  }
+  @Override
+  public String getKind() {
+    ContainerTokenProtoOrBuilder p = viaProto ? proto : builder;
+    if (!p.hasKind()) {
+      return null;
+    }
+    return (p.getKind());
+  }
+
+  @Override
+  public void setKind(String kind) {
+    maybeInitBuilder();
+    if (kind == null) {
+      builder.clearKind();
+      return;
+    }
+    builder.setKind((kind));
+  }
+  @Override
+  public String getService() {
+    ContainerTokenProtoOrBuilder p = viaProto ? proto : builder;
+    if (!p.hasService()) {
+      return null;
+    }
+    return (p.getService());
+  }
+
+  @Override
+  public void setService(String service) {
+    maybeInitBuilder();
+    if (service == null) {
+      builder.clearService();
+      return;
+    }
+    builder.setService((service));
+  }
+
+}  

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/LocalResourcePBImpl.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/LocalResourcePBImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/LocalResourcePBImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/LocalResourcePBImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,169 @@
+package org.apache.hadoop.yarn.api.records.impl.pb;
+
+
+import org.apache.hadoop.yarn.api.records.LocalResource;
+import org.apache.hadoop.yarn.api.records.LocalResourceType;
+import org.apache.hadoop.yarn.api.records.LocalResourceVisibility;
+import org.apache.hadoop.yarn.api.records.ProtoBase;
+import org.apache.hadoop.yarn.api.records.URL;
+import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProtoOrBuilder;
+import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceTypeProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceVisibilityProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.URLProto;
+import org.apache.hadoop.yarn.util.ProtoUtils;
+
+
+    
+public class LocalResourcePBImpl extends ProtoBase<LocalResourceProto> implements LocalResource {
+  LocalResourceProto proto = LocalResourceProto.getDefaultInstance();
+  LocalResourceProto.Builder builder = null;
+  boolean viaProto = false;
+  
+  private URL url = null;
+  
+  
+  public LocalResourcePBImpl() {
+    builder = LocalResourceProto.newBuilder();
+  }
+
+  public LocalResourcePBImpl(LocalResourceProto proto) {
+    this.proto = proto;
+    viaProto = true;
+  }
+  
+  public LocalResourceProto getProto() {
+      mergeLocalToProto();
+    proto = viaProto ? proto : builder.build();
+    viaProto = true;
+    return proto;
+  }
+
+  private void mergeLocalToBuilder() {
+    if (this.url != null) {
+      builder.setResource(convertToProtoFormat(this.url));
+    }
+  }
+
+  private void mergeLocalToProto() {
+    if (viaProto) 
+      maybeInitBuilder();
+    mergeLocalToBuilder();
+    proto = builder.build();
+    viaProto = true;
+  }
+
+  private void maybeInitBuilder() {
+    if (viaProto || builder == null) {
+      builder = LocalResourceProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+    
+  
+  @Override
+  public long getSize() {
+    LocalResourceProtoOrBuilder p = viaProto ? proto : builder;
+    return (p.getSize());
+  }
+
+  @Override
+  public void setSize(long size) {
+    maybeInitBuilder();
+    builder.setSize((size));
+  }
+  @Override
+  public long getTimestamp() {
+    LocalResourceProtoOrBuilder p = viaProto ? proto : builder;
+    return (p.getTimestamp());
+  }
+
+  @Override
+  public void setTimestamp(long timestamp) {
+    maybeInitBuilder();
+    builder.setTimestamp((timestamp));
+  }
+  @Override
+  public LocalResourceType getType() {
+    LocalResourceProtoOrBuilder p = viaProto ? proto : builder;
+    if (!p.hasType()) {
+      return null;
+    }
+    return convertFromProtoFormat(p.getType());
+  }
+
+  @Override
+  public void setType(LocalResourceType type) {
+    maybeInitBuilder();
+    if (type == null) {
+      builder.clearType();
+      return;
+    }
+    builder.setType(convertToProtoFormat(type));
+  }
+  @Override
+  public URL getResource() {
+    LocalResourceProtoOrBuilder p = viaProto ? proto : builder;
+    if (this.url != null) {
+      return this.url;
+    }
+    if (!p.hasResource()) {
+      return null;
+    }
+    this.url = convertFromProtoFormat(p.getResource());
+    return this.url;
+  }
+
+  @Override
+  public void setResource(URL resource) {
+    maybeInitBuilder();
+    if (resource == null) 
+      builder.clearResource();
+    this.url = resource;
+  }
+  @Override
+  public LocalResourceVisibility getVisibility() {
+    LocalResourceProtoOrBuilder p = viaProto ? proto : builder;
+    if (!p.hasVisibility()) {
+      return null;
+    }
+    return convertFromProtoFormat(p.getVisibility());
+  }
+
+  @Override
+  public void setVisibility(LocalResourceVisibility visibility) {
+    maybeInitBuilder();
+    if (visibility == null) {
+      builder.clearVisibility();
+      return;
+    }
+    builder.setVisibility(convertToProtoFormat(visibility));
+  }
+
+  private LocalResourceTypeProto convertToProtoFormat(LocalResourceType e) {
+    return ProtoUtils.convertToProtoFormat(e);
+  }
+
+  private LocalResourceType convertFromProtoFormat(LocalResourceTypeProto e) {
+    return ProtoUtils.convertFromProtoFormat(e);
+  }
+
+  private URLPBImpl convertFromProtoFormat(URLProto p) {
+    return new URLPBImpl(p);
+  }
+
+  private URLProto convertToProtoFormat(URL t) {
+    return ((URLPBImpl)t).getProto();
+  }
+
+  private LocalResourceVisibilityProto convertToProtoFormat(LocalResourceVisibility e) {
+    return ProtoUtils.convertToProtoFormat(e);
+  }
+
+  private LocalResourceVisibility convertFromProtoFormat(LocalResourceVisibilityProto e) {
+    return ProtoUtils.convertFromProtoFormat(e);
+  }
+
+
+
+}  

Added: hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PriorityPBImpl.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/PriorityPBImpl.java?rev=1087462&view=auto
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PriorityPBImpl.java (added)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/PriorityPBImpl.java Thu Mar 31 22:23:22 2011
@@ -0,0 +1,58 @@
+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.proto.YarnProtos.PriorityProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProtoOrBuilder;
+
+
+    
+public class PriorityPBImpl extends ProtoBase<PriorityProto> implements Priority {
+  PriorityProto proto = PriorityProto.getDefaultInstance();
+  PriorityProto.Builder builder = null;
+  boolean viaProto = false;
+  
+  public PriorityPBImpl() {
+    builder = PriorityProto.newBuilder();
+  }
+
+  public PriorityPBImpl(PriorityProto proto) {
+    this.proto = proto;
+    viaProto = true;
+  }
+  
+  public PriorityProto getProto() {
+    proto = viaProto ? proto : builder.build();
+    viaProto = true;
+    return proto;
+  }
+
+  private void maybeInitBuilder() {
+    if (viaProto || builder == null) {
+      builder = PriorityProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+    
+  
+  @Override
+  public int getPriority() {
+    PriorityProtoOrBuilder p = viaProto ? proto : builder;
+    return (p.getPriority());
+  }
+
+  @Override
+  public void setPriority(int priority) {
+    maybeInitBuilder();
+    builder.setPriority((priority));
+  }
+
+  
+  @Override
+  public int compareTo(Priority other) {
+    return this.getPriority() - other.getPriority();
+  }
+
+
+}  



Mime
View raw message