YARN-711. Copied BuilderUtil methods in individual API records as BuilderUtils is going to be dismantled. Contributed by Jian He.

svn merge --ignore-ancestry -c 1485888 ../../trunk/


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1485890 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Vinod Kumar Vavilapalli 2013-05-23 22:48:13 +00:00
parent 7f66f9ccf6
commit 4bf02c3be8
43 changed files with 755 additions and 852 deletions

View File

@ -192,6 +192,9 @@ Release 2.0.5-beta - UNRELEASED
YARN-708. Moved RecordFactory classes to hadoop-yarn-api, and put some YARN-708. Moved RecordFactory classes to hadoop-yarn-api, and put some
miscellaneous fixes to the interfaces. (Siddharth Seth via vinodkv) miscellaneous fixes to the interfaces. (Siddharth Seth via vinodkv)
YARN-711. Copied BuilderUtil methods in individual API records as
BuilderUtils is going to be dismantled. (Jian He via vinodkv)
OPTIMIZATIONS OPTIMIZATIONS
BUG FIXES BUG FIXES

View File

@ -24,6 +24,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceAudience.Public; import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Stable; import org.apache.hadoop.classification.InterfaceStability.Stable;
import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.yarn.util.Records;
/** /**
* <p><code>ApplicationAttemptId</code> denotes the particular <em>attempt</em> * <p><code>ApplicationAttemptId</code> denotes the particular <em>attempt</em>
@ -40,6 +41,16 @@ public abstract class ApplicationAttemptId implements
public static final String appAttemptIdStrPrefix = "appattempt_"; public static final String appAttemptIdStrPrefix = "appattempt_";
@Private
public static ApplicationAttemptId newInstance(ApplicationId appId,
int attemptId) {
ApplicationAttemptId appAttemptId =
Records.newRecord(ApplicationAttemptId.class);
appAttemptId.setApplicationId(appId);
appAttemptId.setAttemptId(attemptId);
return appAttemptId;
}
/** /**
* Get the <code>ApplicationId</code> of the <code>ApplicationAttempId</code>. * Get the <code>ApplicationId</code> of the <code>ApplicationAttempId</code>.
* @return <code>ApplicationId</code> of the <code>ApplicationAttempId</code> * @return <code>ApplicationId</code> of the <code>ApplicationAttempId</code>

View File

@ -1,60 +0,0 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.yarn.api.records;
import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceStability.Unstable;
/**
* <em>For internal use only...</em>
*/
@Private
@Unstable
public interface ApplicationMaster {
ApplicationId getApplicationId();
void setApplicationId(ApplicationId appId);
String getHost();
void setHost(String host);
int getRpcPort();
void setRpcPort(int rpcPort);
String getTrackingUrl();
void setTrackingUrl(String url);
ApplicationStatus getStatus();
void setStatus(ApplicationStatus status);
YarnApplicationState getState();
void setState(YarnApplicationState state);
ClientToken getClientToken();
void setClientToken(ClientToken clientToken);
int getAMFailCount();
void setAMFailCount(int amFailCount);
int getContainerCount();
void setContainerCount(int containerCount);
String getDiagnostics();
void setDiagnostics(String diagnostics);
}

View File

@ -23,6 +23,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Stable; import org.apache.hadoop.classification.InterfaceStability.Stable;
import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.yarn.api.ClientRMProtocol; import org.apache.hadoop.yarn.api.ClientRMProtocol;
import org.apache.hadoop.yarn.util.Records;
/** /**
* <p><code>ApplicationReport</code> is a report of an application.</p> * <p><code>ApplicationReport</code> is a report of an application.</p>
@ -47,7 +48,37 @@ import org.apache.hadoop.yarn.api.ClientRMProtocol;
*/ */
@Public @Public
@Stable @Stable
public interface ApplicationReport { public abstract class ApplicationReport {
@Private
public static ApplicationReport newInstance(ApplicationId applicationId,
ApplicationAttemptId applicationAttemptId, String user, String queue,
String name, String host, int rpcPort, ClientToken clientToken,
YarnApplicationState state, String diagnostics, String url,
long startTime, long finishTime, FinalApplicationStatus finalStatus,
ApplicationResourceUsageReport appResources, String origTrackingUrl,
float progress, String applicationType) {
ApplicationReport report = Records.newRecord(ApplicationReport.class);
report.setApplicationId(applicationId);
report.setCurrentApplicationAttemptId(applicationAttemptId);
report.setUser(user);
report.setQueue(queue);
report.setName(name);
report.setHost(host);
report.setRpcPort(rpcPort);
report.setClientToken(clientToken);
report.setYarnApplicationState(state);
report.setDiagnostics(diagnostics);
report.setTrackingUrl(url);
report.setStartTime(startTime);
report.setFinishTime(finishTime);
report.setFinalApplicationStatus(finalStatus);
report.setApplicationResourceUsageReport(appResources);
report.setOriginalTrackingUrl(origTrackingUrl);
report.setProgress(progress);
report.setApplicationType(applicationType);
return report;
}
/** /**
* Get the <code>ApplicationId</code> of the application. * Get the <code>ApplicationId</code> of the application.
@ -55,11 +86,11 @@ public interface ApplicationReport {
*/ */
@Public @Public
@Stable @Stable
ApplicationId getApplicationId(); public abstract ApplicationId getApplicationId();
@Private @Private
@Unstable @Unstable
void setApplicationId(ApplicationId applicationId); public abstract void setApplicationId(ApplicationId applicationId);
/** /**
* Get the <code>ApplicationAttemptId</code> of the current * Get the <code>ApplicationAttemptId</code> of the current
@ -68,11 +99,11 @@ public interface ApplicationReport {
*/ */
@Private @Private
@Unstable @Unstable
ApplicationAttemptId getCurrentApplicationAttemptId(); public abstract ApplicationAttemptId getCurrentApplicationAttemptId();
@Private @Private
@Unstable @Unstable
void setCurrentApplicationAttemptId(ApplicationAttemptId applicationAttemptId); public abstract void setCurrentApplicationAttemptId(ApplicationAttemptId applicationAttemptId);
/** /**
* Get the <em>user</em> who submitted the application. * Get the <em>user</em> who submitted the application.
@ -80,11 +111,11 @@ public interface ApplicationReport {
*/ */
@Public @Public
@Stable @Stable
String getUser(); public abstract String getUser();
@Private @Private
@Unstable @Unstable
void setUser(String user); public abstract void setUser(String user);
/** /**
* Get the <em>queue</em> to which the application was submitted. * Get the <em>queue</em> to which the application was submitted.
@ -92,11 +123,11 @@ public interface ApplicationReport {
*/ */
@Public @Public
@Stable @Stable
String getQueue(); public abstract String getQueue();
@Private @Private
@Unstable @Unstable
void setQueue(String queue); public abstract void setQueue(String queue);
/** /**
* Get the user-defined <em>name</em> of the application. * Get the user-defined <em>name</em> of the application.
@ -104,11 +135,11 @@ public interface ApplicationReport {
*/ */
@Public @Public
@Stable @Stable
String getName(); public abstract String getName();
@Private @Private
@Unstable @Unstable
void setName(String name); public abstract void setName(String name);
/** /**
* Get the <em>host</em> on which the <code>ApplicationMaster</code> * Get the <em>host</em> on which the <code>ApplicationMaster</code>
@ -118,11 +149,11 @@ public interface ApplicationReport {
*/ */
@Public @Public
@Stable @Stable
String getHost(); public abstract String getHost();
@Private @Private
@Unstable @Unstable
void setHost(String host); public abstract void setHost(String host);
/** /**
* Get the <em>RPC port</em> of the <code>ApplicationMaster</code>. * Get the <em>RPC port</em> of the <code>ApplicationMaster</code>.
@ -130,11 +161,11 @@ public interface ApplicationReport {
*/ */
@Public @Public
@Stable @Stable
int getRpcPort(); public abstract int getRpcPort();
@Private @Private
@Unstable @Unstable
void setRpcPort(int rpcPort); public abstract void setRpcPort(int rpcPort);
/** /**
* Get the <em>client token</em> for communicating with the * Get the <em>client token</em> for communicating with the
@ -144,11 +175,11 @@ public interface ApplicationReport {
*/ */
@Public @Public
@Stable @Stable
ClientToken getClientToken(); public abstract ClientToken getClientToken();
@Private @Private
@Unstable @Unstable
void setClientToken(ClientToken clientToken); public abstract void setClientToken(ClientToken clientToken);
/** /**
* Get the <code>YarnApplicationState</code> of the application. * Get the <code>YarnApplicationState</code> of the application.
@ -156,11 +187,11 @@ public interface ApplicationReport {
*/ */
@Public @Public
@Stable @Stable
YarnApplicationState getYarnApplicationState(); public abstract YarnApplicationState getYarnApplicationState();
@Private @Private
@Unstable @Unstable
void setYarnApplicationState(YarnApplicationState state); public abstract void setYarnApplicationState(YarnApplicationState state);
/** /**
* Get the <em>diagnositic information</em> of the application in case of * Get the <em>diagnositic information</em> of the application in case of
@ -170,11 +201,11 @@ public interface ApplicationReport {
*/ */
@Public @Public
@Stable @Stable
String getDiagnostics(); public abstract String getDiagnostics();
@Private @Private
@Unstable @Unstable
void setDiagnostics(String diagnostics); public abstract void setDiagnostics(String diagnostics);
/** /**
* Get the <em>tracking url</em> for the application. * Get the <em>tracking url</em> for the application.
@ -182,11 +213,11 @@ public interface ApplicationReport {
*/ */
@Public @Public
@Stable @Stable
String getTrackingUrl(); public abstract String getTrackingUrl();
@Private @Private
@Unstable @Unstable
void setTrackingUrl(String url); public abstract void setTrackingUrl(String url);
/** /**
* Get the original not-proxied <em>tracking url</em> for the application. * Get the original not-proxied <em>tracking url</em> for the application.
@ -195,11 +226,11 @@ public interface ApplicationReport {
*/ */
@Private @Private
@Unstable @Unstable
String getOriginalTrackingUrl(); public abstract String getOriginalTrackingUrl();
@Private @Private
@Unstable @Unstable
void setOriginalTrackingUrl(String url); public abstract void setOriginalTrackingUrl(String url);
/** /**
* Get the <em>start time</em> of the application. * Get the <em>start time</em> of the application.
@ -207,11 +238,11 @@ public interface ApplicationReport {
*/ */
@Public @Public
@Stable @Stable
long getStartTime(); public abstract long getStartTime();
@Private @Private
@Unstable @Unstable
void setStartTime(long startTime); public abstract void setStartTime(long startTime);
/** /**
* Get the <em>finish time</em> of the application. * Get the <em>finish time</em> of the application.
@ -219,11 +250,11 @@ public interface ApplicationReport {
*/ */
@Public @Public
@Stable @Stable
long getFinishTime(); public abstract long getFinishTime();
@Private @Private
@Unstable @Unstable
void setFinishTime(long finishTime); public abstract void setFinishTime(long finishTime);
/** /**
@ -232,11 +263,11 @@ public interface ApplicationReport {
*/ */
@Public @Public
@Stable @Stable
FinalApplicationStatus getFinalApplicationStatus(); public abstract FinalApplicationStatus getFinalApplicationStatus();
@Private @Private
@Unstable @Unstable
void setFinalApplicationStatus(FinalApplicationStatus finishState); public abstract void setFinalApplicationStatus(FinalApplicationStatus finishState);
/** /**
* Retrieve the structure containing the job resources for this application * Retrieve the structure containing the job resources for this application
@ -244,7 +275,7 @@ public interface ApplicationReport {
*/ */
@Public @Public
@Stable @Stable
ApplicationResourceUsageReport getApplicationResourceUsageReport(); public abstract ApplicationResourceUsageReport getApplicationResourceUsageReport();
/** /**
* Store the structure containing the job resources for this application * Store the structure containing the job resources for this application
@ -252,7 +283,7 @@ public interface ApplicationReport {
*/ */
@Private @Private
@Unstable @Unstable
void setApplicationResourceUsageReport(ApplicationResourceUsageReport appResources); public abstract void setApplicationResourceUsageReport(ApplicationResourceUsageReport appResources);
/** /**
* Get the application's progress ( range 0.0 to 1.0 ) * Get the application's progress ( range 0.0 to 1.0 )
@ -260,11 +291,11 @@ public interface ApplicationReport {
*/ */
@Public @Public
@Stable @Stable
float getProgress(); public abstract float getProgress();
@Private @Private
@Unstable @Unstable
void setProgress(float progress); public abstract void setProgress(float progress);
/** /**
* Get the application's Type * Get the application's Type
@ -272,9 +303,9 @@ public interface ApplicationReport {
*/ */
@Public @Public
@Stable @Stable
String getApplicationType(); public abstract String getApplicationType();
@Private @Private
@Unstable @Unstable
void setApplicationType(String applicationType); public abstract void setApplicationType(String applicationType);
} }

View File

@ -18,21 +18,32 @@
package org.apache.hadoop.yarn.api.records; package org.apache.hadoop.yarn.api.records;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import org.apache.hadoop.classification.InterfaceAudience.Private; import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceAudience.Public; import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Stable; import org.apache.hadoop.classification.InterfaceStability.Stable;
import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.yarn.util.Records;
/** /**
* Contains various scheduling metrics to be reported by UI and CLI. * Contains various scheduling metrics to be reported by UI and CLI.
*/ */
@Public @Public
@Stable @Stable
public interface ApplicationResourceUsageReport { public abstract class ApplicationResourceUsageReport {
@Private
public static ApplicationResourceUsageReport newInstance(
int numUsedContainers, int numReservedContainers, Resource usedResources,
Resource reservedResources, Resource neededResources) {
ApplicationResourceUsageReport report =
Records.newRecord(ApplicationResourceUsageReport.class);
report.setNumUsedContainers(numUsedContainers);
report.setNumReservedContainers(numReservedContainers);
report.setUsedResources(usedResources);
report.setReservedResources(reservedResources);
report.setNeededResources(neededResources);
return report;
}
/** /**
* Get the number of used containers * Get the number of used containers
@ -40,7 +51,7 @@ public interface ApplicationResourceUsageReport {
*/ */
@Public @Public
@Stable @Stable
int getNumUsedContainers(); public abstract int getNumUsedContainers();
/** /**
* Set the number of used containers * Set the number of used containers
@ -48,7 +59,7 @@ public interface ApplicationResourceUsageReport {
*/ */
@Private @Private
@Unstable @Unstable
void setNumUsedContainers(int num_containers); public abstract void setNumUsedContainers(int num_containers);
/** /**
* Get the number of reserved containers * Get the number of reserved containers
@ -56,7 +67,7 @@ public interface ApplicationResourceUsageReport {
*/ */
@Public @Public
@Stable @Stable
int getNumReservedContainers(); public abstract int getNumReservedContainers();
/** /**
* Set the number of reserved containers * Set the number of reserved containers
@ -64,7 +75,7 @@ public interface ApplicationResourceUsageReport {
*/ */
@Private @Private
@Unstable @Unstable
void setNumReservedContainers(int num_reserved_containers); public abstract void setNumReservedContainers(int num_reserved_containers);
/** /**
* Get the used <code>Resource</code> * Get the used <code>Resource</code>
@ -72,11 +83,11 @@ public interface ApplicationResourceUsageReport {
*/ */
@Public @Public
@Stable @Stable
Resource getUsedResources(); public abstract Resource getUsedResources();
@Private @Private
@Unstable @Unstable
void setUsedResources(Resource resources); public abstract void setUsedResources(Resource resources);
/** /**
* Get the reserved <code>Resource</code> * Get the reserved <code>Resource</code>
@ -84,11 +95,11 @@ public interface ApplicationResourceUsageReport {
*/ */
@Public @Public
@Stable @Stable
Resource getReservedResources(); public abstract Resource getReservedResources();
@Private @Private
@Unstable @Unstable
void setReservedResources(Resource reserved_resources); public abstract void setReservedResources(Resource reserved_resources);
/** /**
* Get the needed <code>Resource</code> * Get the needed <code>Resource</code>
@ -96,9 +107,9 @@ public interface ApplicationResourceUsageReport {
*/ */
@Public @Public
@Stable @Stable
Resource getNeededResources(); public abstract Resource getNeededResources();
@Private @Private
@Unstable @Unstable
void setNeededResources(Resource needed_resources); public abstract void setNeededResources(Resource needed_resources);
} }

View File

@ -1,38 +0,0 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.yarn.api.records;
import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceStability.Unstable;
/**
* <em>For internal use only...</em>
*/
@Private
@Unstable
public interface ApplicationStatus {
ApplicationAttemptId getApplicationAttemptId();
void setApplicationAttemptId(ApplicationAttemptId applicationAttemptId);
int getResponseId();
void setResponseId(int id);
float getProgress();
void setProgress(float progress);
}

View File

@ -23,6 +23,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Stable; import org.apache.hadoop.classification.InterfaceStability.Stable;
import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.yarn.api.ClientRMProtocol; import org.apache.hadoop.yarn.api.ClientRMProtocol;
import org.apache.hadoop.yarn.util.Records;
/** /**
* <p><code>ApplicationSubmissionContext</code> represents all of the * <p><code>ApplicationSubmissionContext</code> represents all of the
@ -47,14 +48,49 @@ import org.apache.hadoop.yarn.api.ClientRMProtocol;
*/ */
@Public @Public
@Stable @Stable
public interface ApplicationSubmissionContext { public abstract class ApplicationSubmissionContext {
@Public
@Stable
public static ApplicationSubmissionContext newInstance(
ApplicationId applicationId, String applicationName, String queue,
Priority priority, ContainerLaunchContext amContainer,
boolean isUnmanagedAM, boolean cancelTokensWhenComplete,
int maxAppAttempts, Resource resource, String applicationType) {
ApplicationSubmissionContext context =
Records.newRecord(ApplicationSubmissionContext.class);
context.setApplicationId(applicationId);
context.setApplicationName(applicationName);
context.setQueue(queue);
context.setPriority(priority);
context.setAMContainerSpec(amContainer);
context.setUnmanagedAM(isUnmanagedAM);
context.setCancelTokensWhenComplete(cancelTokensWhenComplete);
context.setMaxAppAttempts(maxAppAttempts);
context.setResource(resource);
context.setApplicationType(applicationType);
return context;
}
@Public
@Stable
public static ApplicationSubmissionContext newInstance(
ApplicationId applicationId, String applicationName, String queue,
Priority priority, ContainerLaunchContext amContainer,
boolean isUnmanagedAM, boolean cancelTokensWhenComplete,
int maxAppAttempts, Resource resource) {
return newInstance(applicationId, applicationName, queue, priority,
amContainer, isUnmanagedAM, cancelTokensWhenComplete, maxAppAttempts,
resource, null);
}
/** /**
* Get the <code>ApplicationId</code> of the submitted application. * Get the <code>ApplicationId</code> of the submitted application.
* @return <code>ApplicationId</code> of the submitted application * @return <code>ApplicationId</code> of the submitted application
*/ */
@Public @Public
@Stable @Stable
public ApplicationId getApplicationId(); public abstract ApplicationId getApplicationId();
/** /**
* Set the <code>ApplicationId</code> of the submitted application. * Set the <code>ApplicationId</code> of the submitted application.
@ -63,7 +99,7 @@ public interface ApplicationSubmissionContext {
*/ */
@Public @Public
@Stable @Stable
public void setApplicationId(ApplicationId applicationId); public abstract void setApplicationId(ApplicationId applicationId);
/** /**
* Get the application <em>name</em>. * Get the application <em>name</em>.
@ -71,7 +107,7 @@ public interface ApplicationSubmissionContext {
*/ */
@Public @Public
@Stable @Stable
public String getApplicationName(); public abstract String getApplicationName();
/** /**
* Set the application <em>name</em>. * Set the application <em>name</em>.
@ -79,7 +115,7 @@ public interface ApplicationSubmissionContext {
*/ */
@Public @Public
@Stable @Stable
public void setApplicationName(String applicationName); public abstract void setApplicationName(String applicationName);
/** /**
* Get the <em>queue</em> to which the application is being submitted. * Get the <em>queue</em> to which the application is being submitted.
@ -87,7 +123,7 @@ public interface ApplicationSubmissionContext {
*/ */
@Public @Public
@Stable @Stable
public String getQueue(); public abstract String getQueue();
/** /**
* Set the <em>queue</em> to which the application is being submitted * Set the <em>queue</em> to which the application is being submitted
@ -95,7 +131,7 @@ public interface ApplicationSubmissionContext {
*/ */
@Public @Public
@Stable @Stable
public void setQueue(String queue); public abstract void setQueue(String queue);
/** /**
* Get the <code>Priority</code> of the application. * Get the <code>Priority</code> of the application.
@ -103,7 +139,7 @@ public interface ApplicationSubmissionContext {
*/ */
@Public @Public
@Stable @Stable
public Priority getPriority(); public abstract Priority getPriority();
/** /**
* Set the <code>Priority</code> of the application. * Set the <code>Priority</code> of the application.
@ -111,7 +147,7 @@ public interface ApplicationSubmissionContext {
*/ */
@Public @Public
@Stable @Stable
public void setPriority(Priority priority); public abstract void setPriority(Priority priority);
/** /**
* Get the <code>ContainerLaunchContext</code> to describe the * Get the <code>ContainerLaunchContext</code> to describe the
@ -122,7 +158,7 @@ public interface ApplicationSubmissionContext {
*/ */
@Public @Public
@Stable @Stable
public ContainerLaunchContext getAMContainerSpec(); public abstract ContainerLaunchContext getAMContainerSpec();
/** /**
* Set the <code>ContainerLaunchContext</code> to describe the * Set the <code>ContainerLaunchContext</code> to describe the
@ -133,7 +169,7 @@ public interface ApplicationSubmissionContext {
*/ */
@Public @Public
@Stable @Stable
public void setAMContainerSpec(ContainerLaunchContext amContainer); public abstract void setAMContainerSpec(ContainerLaunchContext amContainer);
/** /**
* Get if the RM should manage the execution of the AM. * Get if the RM should manage the execution of the AM.
@ -148,21 +184,21 @@ public interface ApplicationSubmissionContext {
*/ */
@Public @Public
@Unstable @Unstable
public boolean getUnmanagedAM(); public abstract boolean getUnmanagedAM();
/** /**
* @param value true if RM should not manage the AM * @param value true if RM should not manage the AM
*/ */
@Public @Public
@Unstable @Unstable
public void setUnmanagedAM(boolean value); public abstract void setUnmanagedAM(boolean value);
/** /**
* @return true if tokens should be canceled when the app completes. * @return true if tokens should be canceled when the app completes.
*/ */
@LimitedPrivate("mapreduce") @LimitedPrivate("mapreduce")
@Unstable @Unstable
public boolean getCancelTokensWhenComplete(); public abstract boolean getCancelTokensWhenComplete();
/** /**
* Set to false if tokens should not be canceled when the app finished else * Set to false if tokens should not be canceled when the app finished else
@ -172,14 +208,14 @@ public interface ApplicationSubmissionContext {
*/ */
@LimitedPrivate("mapreduce") @LimitedPrivate("mapreduce")
@Unstable @Unstable
public void setCancelTokensWhenComplete(boolean cancel); public abstract void setCancelTokensWhenComplete(boolean cancel);
/** /**
* @return the number of max attempts of the application to be submitted * @return the number of max attempts of the application to be submitted
*/ */
@Public @Public
@Unstable @Unstable
public int getMaxAppAttempts(); public abstract int getMaxAppAttempts();
/** /**
* Set the number of max attempts of the application to be submitted. WARNING: * Set the number of max attempts of the application to be submitted. WARNING:
@ -190,15 +226,15 @@ public interface ApplicationSubmissionContext {
*/ */
@Public @Public
@Unstable @Unstable
public void setMaxAppAttempts(int maxAppAttempts); public abstract void setMaxAppAttempts(int maxAppAttempts);
@Public @Public
@Stable @Stable
public Resource getResource(); public abstract Resource getResource();
@Public @Public
@Stable @Stable
public void setResource(Resource resource); public abstract void setResource(Resource resource);
/** /**
* Get the <em>applicationType</em> is the application type * Get the <em>applicationType</em> is the application type
@ -207,7 +243,7 @@ public interface ApplicationSubmissionContext {
*/ */
@Public @Public
@Stable @Stable
public String getApplicationType(); public abstract String getApplicationType();
/** /**
* Set the <em>applicationType</em> is the application type * Set the <em>applicationType</em> is the application type
@ -217,5 +253,5 @@ public interface ApplicationSubmissionContext {
*/ */
@Public @Public
@Stable @Stable
public void setApplicationType(String applicationType); public abstract void setApplicationType(String applicationType);
} }

View File

@ -24,6 +24,7 @@ import org.apache.hadoop.classification.InterfaceStability.Stable;
import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.yarn.api.AMRMProtocol; import org.apache.hadoop.yarn.api.AMRMProtocol;
import org.apache.hadoop.yarn.api.ContainerManager; import org.apache.hadoop.yarn.api.ContainerManager;
import org.apache.hadoop.yarn.util.Records;
/** /**
* <p><code>Container</code> represents an allocated resource in the cluster. * <p><code>Container</code> represents an allocated resource in the cluster.
@ -63,18 +64,34 @@ import org.apache.hadoop.yarn.api.ContainerManager;
*/ */
@Public @Public
@Stable @Stable
public interface Container extends Comparable<Container> { public abstract class Container implements Comparable<Container> {
@Private
public static Container newInstance(ContainerId containerId, NodeId nodeId,
String nodeHttpAddress, Resource resource, Priority priority,
ContainerToken containerToken, long rmIdentifier) {
Container container = Records.newRecord(Container.class);
container.setId(containerId);
container.setNodeId(nodeId);
container.setNodeHttpAddress(nodeHttpAddress);
container.setResource(resource);
container.setPriority(priority);
container.setContainerToken(containerToken);
container.setRMIdentifier(rmIdentifier);
return container;
}
/** /**
* Get the globally unique identifier for the container. * Get the globally unique identifier for the container.
* @return globally unique identifier for the container * @return globally unique identifier for the container
*/ */
@Public @Public
@Stable @Stable
ContainerId getId(); public abstract ContainerId getId();
@Private @Private
@Unstable @Unstable
void setId(ContainerId id); public abstract void setId(ContainerId id);
/** /**
* Get the identifier of the node on which the container is allocated. * Get the identifier of the node on which the container is allocated.
@ -82,11 +99,11 @@ public interface Container extends Comparable<Container> {
*/ */
@Public @Public
@Stable @Stable
NodeId getNodeId(); public abstract NodeId getNodeId();
@Private @Private
@Unstable @Unstable
void setNodeId(NodeId nodeId); public abstract void setNodeId(NodeId nodeId);
/** /**
* Get the http uri of the node on which the container is allocated. * Get the http uri of the node on which the container is allocated.
@ -94,11 +111,11 @@ public interface Container extends Comparable<Container> {
*/ */
@Public @Public
@Stable @Stable
String getNodeHttpAddress(); public abstract String getNodeHttpAddress();
@Private @Private
@Unstable @Unstable
void setNodeHttpAddress(String nodeHttpAddress); public abstract void setNodeHttpAddress(String nodeHttpAddress);
/** /**
* Get the <code>Resource</code> allocated to the container. * Get the <code>Resource</code> allocated to the container.
@ -106,11 +123,11 @@ public interface Container extends Comparable<Container> {
*/ */
@Public @Public
@Stable @Stable
Resource getResource(); public abstract Resource getResource();
@Private @Private
@Unstable @Unstable
void setResource(Resource resource); public abstract void setResource(Resource resource);
/** /**
* Get the <code>Priority</code> at which the <code>Container</code> was * Get the <code>Priority</code> at which the <code>Container</code> was
@ -118,11 +135,11 @@ public interface Container extends Comparable<Container> {
* @return <code>Priority</code> at which the <code>Container</code> was * @return <code>Priority</code> at which the <code>Container</code> was
* allocated * allocated
*/ */
Priority getPriority(); public abstract Priority getPriority();
@Private @Private
@Unstable @Unstable
void setPriority(Priority priority); public abstract void setPriority(Priority priority);
/** /**
* Get the <code>ContainerToken</code> for the container. * Get the <code>ContainerToken</code> for the container.
@ -130,11 +147,11 @@ public interface Container extends Comparable<Container> {
*/ */
@Public @Public
@Stable @Stable
ContainerToken getContainerToken(); public abstract ContainerToken getContainerToken();
@Private @Private
@Unstable @Unstable
void setContainerToken(ContainerToken containerToken); public abstract void setContainerToken(ContainerToken containerToken);
/** /**
* Get the RMIdentifier of RM in which containers are allocated * Get the RMIdentifier of RM in which containers are allocated
@ -142,9 +159,9 @@ public interface Container extends Comparable<Container> {
*/ */
@Private @Private
@Unstable @Unstable
long getRMIdentifer(); public abstract long getRMIdentifer();
@Private @Private
@Unstable @Unstable
void setRMIdentifier(long rmIdentifier); public abstract void setRMIdentifier(long rmIdentifier);
} }

View File

@ -24,6 +24,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceAudience.Public; import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Stable; import org.apache.hadoop.classification.InterfaceStability.Stable;
import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.yarn.util.Records;
/** /**
* <p><code>ContainerId</code> represents a globally unique identifier * <p><code>ContainerId</code> represents a globally unique identifier
@ -32,6 +33,16 @@ import org.apache.hadoop.classification.InterfaceStability.Unstable;
@Public @Public
@Stable @Stable
public abstract class ContainerId implements Comparable<ContainerId>{ public abstract class ContainerId implements Comparable<ContainerId>{
@Private
public static ContainerId newInstance(ApplicationAttemptId appAttemptId,
int containerId) {
ContainerId id = Records.newRecord(ContainerId.class);
id.setId(containerId);
id.setApplicationAttemptId(appAttemptId);
return id;
}
/** /**
* Get the <code>ApplicationAttemptId</code> of the application to which * Get the <code>ApplicationAttemptId</code> of the application to which
* the <code>Container</code> was assigned. * the <code>Container</code> was assigned.

View File

@ -25,6 +25,7 @@ import java.util.Map;
import org.apache.hadoop.classification.InterfaceAudience.Public; import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Stable; import org.apache.hadoop.classification.InterfaceStability.Stable;
import org.apache.hadoop.yarn.api.ContainerManager; import org.apache.hadoop.yarn.api.ContainerManager;
import org.apache.hadoop.yarn.util.Records;
/** /**
* <p><code>ContainerLaunchContext</code> represents all of the information * <p><code>ContainerLaunchContext</code> represents all of the information
@ -50,14 +51,34 @@ import org.apache.hadoop.yarn.api.ContainerManager;
*/ */
@Public @Public
@Stable @Stable
public interface ContainerLaunchContext { public abstract class ContainerLaunchContext {
@Public
@Stable
public static ContainerLaunchContext newInstance(
String user, Map<String, LocalResource> localResources,
Map<String, String> environment, List<String> commands,
Map<String, ByteBuffer> serviceData, ByteBuffer tokens,
Map<ApplicationAccessType, String> acls) {
ContainerLaunchContext container =
Records.newRecord(ContainerLaunchContext.class);
container.setUser(user);
container.setLocalResources(localResources);
container.setEnvironment(environment);
container.setCommands(commands);
container.setServiceData(serviceData);
container.setTokens(tokens);
container.setApplicationACLs(acls);
return container;
}
/** /**
* Get the <em>user</em> to whom the container has been allocated. * Get the <em>user</em> to whom the container has been allocated.
* @return the <em>user</em> to whom the container has been allocated * @return the <em>user</em> to whom the container has been allocated
*/ */
@Public @Public
@Stable @Stable
String getUser(); public abstract String getUser();
/** /**
* Set the <em>user</em> to whom the container has been allocated * Set the <em>user</em> to whom the container has been allocated
@ -65,7 +86,7 @@ public interface ContainerLaunchContext {
*/ */
@Public @Public
@Stable @Stable
void setUser(String user); public abstract void setUser(String user);
/** /**
* Get all the tokens needed by this container. It may include file-system * Get all the tokens needed by this container. It may include file-system
@ -77,7 +98,7 @@ public interface ContainerLaunchContext {
*/ */
@Public @Public
@Stable @Stable
ByteBuffer getTokens(); public abstract ByteBuffer getTokens();
/** /**
* Set security tokens needed by this container. * Set security tokens needed by this container.
@ -85,7 +106,7 @@ public interface ContainerLaunchContext {
*/ */
@Public @Public
@Stable @Stable
void setTokens(ByteBuffer tokens); public abstract void setTokens(ByteBuffer tokens);
/** /**
* Get <code>LocalResource</code> required by the container. * Get <code>LocalResource</code> required by the container.
@ -93,7 +114,7 @@ public interface ContainerLaunchContext {
*/ */
@Public @Public
@Stable @Stable
Map<String, LocalResource> getLocalResources(); public abstract Map<String, LocalResource> getLocalResources();
/** /**
* Set <code>LocalResource</code> required by the container. All pre-existing * Set <code>LocalResource</code> required by the container. All pre-existing
@ -102,7 +123,7 @@ public interface ContainerLaunchContext {
*/ */
@Public @Public
@Stable @Stable
void setLocalResources(Map<String, LocalResource> localResources); public abstract void setLocalResources(Map<String, LocalResource> localResources);
/** /**
* Get application-specific binary <em>service data</em>. * Get application-specific binary <em>service data</em>.
@ -110,7 +131,7 @@ public interface ContainerLaunchContext {
*/ */
@Public @Public
@Stable @Stable
Map<String, ByteBuffer> getServiceData(); public abstract Map<String, ByteBuffer> getServiceData();
/** /**
* Set application-specific binary <em>service data</em>. All pre-existing Map * Set application-specific binary <em>service data</em>. All pre-existing Map
@ -119,7 +140,7 @@ public interface ContainerLaunchContext {
*/ */
@Public @Public
@Stable @Stable
void setServiceData(Map<String, ByteBuffer> serviceData); public abstract void setServiceData(Map<String, ByteBuffer> serviceData);
/** /**
* Get <em>environment variables</em> for the container. * Get <em>environment variables</em> for the container.
@ -127,7 +148,7 @@ public interface ContainerLaunchContext {
*/ */
@Public @Public
@Stable @Stable
Map<String, String> getEnvironment(); public abstract Map<String, String> getEnvironment();
/** /**
* Add <em>environment variables</em> for the container. All pre-existing Map * Add <em>environment variables</em> for the container. All pre-existing Map
@ -136,7 +157,7 @@ public interface ContainerLaunchContext {
*/ */
@Public @Public
@Stable @Stable
void setEnvironment(Map<String, String> environment); public abstract void setEnvironment(Map<String, String> environment);
/** /**
* Get the list of <em>commands</em> for launching the container. * Get the list of <em>commands</em> for launching the container.
@ -144,7 +165,7 @@ public interface ContainerLaunchContext {
*/ */
@Public @Public
@Stable @Stable
List<String> getCommands(); public abstract List<String> getCommands();
/** /**
* Add the list of <em>commands</em> for launching the container. All * Add the list of <em>commands</em> for launching the container. All
@ -153,7 +174,7 @@ public interface ContainerLaunchContext {
*/ */
@Public @Public
@Stable @Stable
void setCommands(List<String> commands); public abstract void setCommands(List<String> commands);
/** /**
* Get the <code>ApplicationACL</code>s for the application. * Get the <code>ApplicationACL</code>s for the application.
@ -161,7 +182,7 @@ public interface ContainerLaunchContext {
*/ */
@Public @Public
@Stable @Stable
public Map<ApplicationAccessType, String> getApplicationACLs(); public abstract Map<ApplicationAccessType, String> getApplicationACLs();
/** /**
* Set the <code>ApplicationACL</code>s for the application. All pre-existing * Set the <code>ApplicationACL</code>s for the application. All pre-existing
@ -170,5 +191,5 @@ public interface ContainerLaunchContext {
*/ */
@Public @Public
@Stable @Stable
public void setApplicationACLs(Map<ApplicationAccessType, String> acls); public abstract void setApplicationACLs(Map<ApplicationAccessType, String> acls);
} }

View File

@ -22,6 +22,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceAudience.Public; import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Stable; import org.apache.hadoop.classification.InterfaceStability.Stable;
import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.yarn.util.Records;
/** /**
* <p><code>ContainerStatus</code> represents the current status of a * <p><code>ContainerStatus</code> represents the current status of a
@ -38,18 +39,30 @@ import org.apache.hadoop.classification.InterfaceStability.Unstable;
*/ */
@Public @Public
@Stable @Stable
public interface ContainerStatus { public abstract class ContainerStatus {
@Private
public static ContainerStatus newInstance(ContainerId containerId,
ContainerState containerState, String diagnostics, int exitStatus) {
ContainerStatus containerStatus = Records.newRecord(ContainerStatus.class);
containerStatus.setState(containerState);
containerStatus.setContainerId(containerId);
containerStatus.setDiagnostics(diagnostics);
containerStatus.setExitStatus(exitStatus);
return containerStatus;
}
/** /**
* Get the <code>ContainerId</code> of the container. * Get the <code>ContainerId</code> of the container.
* @return <code>ContainerId</code> of the container * @return <code>ContainerId</code> of the container
*/ */
@Public @Public
@Stable @Stable
ContainerId getContainerId(); public abstract ContainerId getContainerId();
@Private @Private
@Unstable @Unstable
void setContainerId(ContainerId containerId); public abstract void setContainerId(ContainerId containerId);
/** /**
* Get the <code>ContainerState</code> of the container. * Get the <code>ContainerState</code> of the container.
@ -57,11 +70,11 @@ public interface ContainerStatus {
*/ */
@Public @Public
@Stable @Stable
ContainerState getState(); public abstract ContainerState getState();
@Private @Private
@Unstable @Unstable
void setState(ContainerState state); public abstract void setState(ContainerState state);
/** /**
* <p>Get the <em>exit status</em> for the container.</p> * <p>Get the <em>exit status</em> for the container.</p>
@ -84,11 +97,11 @@ public interface ContainerStatus {
*/ */
@Public @Public
@Stable @Stable
int getExitStatus(); public abstract int getExitStatus();
@Private @Private
@Unstable @Unstable
void setExitStatus(int exitStatus); public abstract void setExitStatus(int exitStatus);
/** /**
* Get <em>diagnostic messages</em> for failed containers. * Get <em>diagnostic messages</em> for failed containers.
@ -96,9 +109,9 @@ public interface ContainerStatus {
*/ */
@Public @Public
@Stable @Stable
String getDiagnostics(); public abstract String getDiagnostics();
@Private @Private
@Unstable @Unstable
void setDiagnostics(String diagnostics); public abstract void setDiagnostics(String diagnostics);
} }

View File

@ -21,6 +21,7 @@ package org.apache.hadoop.yarn.api.records;
import org.apache.hadoop.classification.InterfaceAudience.Public; import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Stable; import org.apache.hadoop.classification.InterfaceStability.Stable;
import org.apache.hadoop.yarn.api.ContainerManager; import org.apache.hadoop.yarn.api.ContainerManager;
import org.apache.hadoop.yarn.util.Records;
/** /**
* <p><code>LocalResource</code> represents a local resource required to * <p><code>LocalResource</code> represents a local resource required to
@ -40,56 +41,79 @@ import org.apache.hadoop.yarn.api.ContainerManager;
*/ */
@Public @Public
@Stable @Stable
public interface LocalResource { public abstract class LocalResource {
@Public
@Stable
public static LocalResource newInstance(URL url, LocalResourceType type,
LocalResourceVisibility visibility, long size, long timestamp,
String pattern) {
LocalResource resource = Records.newRecord(LocalResource.class);
resource.setResource(url);
resource.setType(type);
resource.setVisibility(visibility);
resource.setSize(size);
resource.setTimestamp(timestamp);
resource.setPattern(pattern);
return resource;
}
@Public
@Stable
public static LocalResource newInstance(URL url, LocalResourceType type,
LocalResourceVisibility visibility, long size, long timestamp) {
return newInstance(url, type, visibility, size, timestamp, null);
}
/** /**
* Get the <em>location</em> of the resource to be localized. * Get the <em>location</em> of the resource to be localized.
* @return <em>location</em> of the resource to be localized * @return <em>location</em> of the resource to be localized
*/ */
public URL getResource(); public abstract URL getResource();
/** /**
* Set <em>location</em> of the resource to be localized. * Set <em>location</em> of the resource to be localized.
* @param resource <em>location</em> of the resource to be localized * @param resource <em>location</em> of the resource to be localized
*/ */
public void setResource(URL resource); public abstract void setResource(URL resource);
/** /**
* Get the <em>size</em> of the resource to be localized. * Get the <em>size</em> of the resource to be localized.
* @return <em>size</em> of the resource to be localized * @return <em>size</em> of the resource to be localized
*/ */
public long getSize(); public abstract long getSize();
/** /**
* Set the <em>size</em> of the resource to be localized. * Set the <em>size</em> of the resource to be localized.
* @param size <em>size</em> of the resource to be localized * @param size <em>size</em> of the resource to be localized
*/ */
public void setSize(long size); public abstract void setSize(long size);
/** /**
* Get the original <em>timestamp</em> of the resource to be localized, used * Get the original <em>timestamp</em> of the resource to be localized, used
* for verification. * for verification.
* @return <em>timestamp</em> of the resource to be localized * @return <em>timestamp</em> of the resource to be localized
*/ */
public long getTimestamp(); public abstract long getTimestamp();
/** /**
* Set the <em>timestamp</em> of the resource to be localized, used * Set the <em>timestamp</em> of the resource to be localized, used
* for verification. * for verification.
* @param timestamp <em>timestamp</em> of the resource to be localized * @param timestamp <em>timestamp</em> of the resource to be localized
*/ */
public void setTimestamp(long timestamp); public abstract void setTimestamp(long timestamp);
/** /**
* Get the <code>LocalResourceType</code> of the resource to be localized. * Get the <code>LocalResourceType</code> of the resource to be localized.
* @return <code>LocalResourceType</code> of the resource to be localized * @return <code>LocalResourceType</code> of the resource to be localized
*/ */
public LocalResourceType getType(); public abstract LocalResourceType getType();
/** /**
* Set the <code>LocalResourceType</code> of the resource to be localized. * Set the <code>LocalResourceType</code> of the resource to be localized.
* @param type <code>LocalResourceType</code> of the resource to be localized * @param type <code>LocalResourceType</code> of the resource to be localized
*/ */
public void setType(LocalResourceType type); public abstract void setType(LocalResourceType type);
/** /**
* Get the <code>LocalResourceVisibility</code> of the resource to be * Get the <code>LocalResourceVisibility</code> of the resource to be
@ -97,7 +121,7 @@ public interface LocalResource {
* @return <code>LocalResourceVisibility</code> of the resource to be * @return <code>LocalResourceVisibility</code> of the resource to be
* localized * localized
*/ */
public LocalResourceVisibility getVisibility(); public abstract LocalResourceVisibility getVisibility();
/** /**
* Set the <code>LocalResourceVisibility</code> of the resource to be * Set the <code>LocalResourceVisibility</code> of the resource to be
@ -105,7 +129,7 @@ public interface LocalResource {
* @param visibility <code>LocalResourceVisibility</code> of the resource to be * @param visibility <code>LocalResourceVisibility</code> of the resource to be
* localized * localized
*/ */
public void setVisibility(LocalResourceVisibility visibility); public abstract void setVisibility(LocalResourceVisibility visibility);
/** /**
* Get the <em>pattern</em> that should be used to extract entries from the * Get the <em>pattern</em> that should be used to extract entries from the
@ -113,7 +137,7 @@ public interface LocalResource {
* @return <em>pattern</em> that should be used to extract entries from the * @return <em>pattern</em> that should be used to extract entries from the
* archive. * archive.
*/ */
public String getPattern(); public abstract String getPattern();
/** /**
* Set the <em>pattern</em> that should be used to extract entries from the * Set the <em>pattern</em> that should be used to extract entries from the
@ -121,5 +145,5 @@ public interface LocalResource {
* @param pattern <em>pattern</em> that should be used to extract entries * @param pattern <em>pattern</em> that should be used to extract entries
* from the archive. * from the archive.
*/ */
public void setPattern(String pattern); public abstract void setPattern(String pattern);
} }

View File

@ -22,6 +22,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Stable; import org.apache.hadoop.classification.InterfaceStability.Stable;
import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.yarn.api.ClientRMProtocol; import org.apache.hadoop.yarn.api.ClientRMProtocol;
import org.apache.hadoop.yarn.util.Records;
/** /**
* <p><code>NodeHealthStatus</code> is a summary of the health status of the * <p><code>NodeHealthStatus</code> is a summary of the health status of the
@ -43,7 +44,17 @@ import org.apache.hadoop.yarn.api.ClientRMProtocol;
*/ */
@Public @Public
@Stable @Stable
public interface NodeHealthStatus { public abstract class NodeHealthStatus {
@Private
public static NodeHealthStatus newInstance(boolean isNodeHealthy,
String healthReport, long lastHealthReport) {
NodeHealthStatus status = Records.newRecord(NodeHealthStatus.class);
status.setIsNodeHealthy(isNodeHealthy);
status.setHealthReport(healthReport);
status.setLastHealthReportTime(lastHealthReport);
return status;
}
/** /**
* Is the node healthy? * Is the node healthy?
@ -51,11 +62,11 @@ public interface NodeHealthStatus {
*/ */
@Public @Public
@Stable @Stable
boolean getIsNodeHealthy(); public abstract boolean getIsNodeHealthy();
@Private @Private
@Unstable @Unstable
void setIsNodeHealthy(boolean isNodeHealthy); public abstract void setIsNodeHealthy(boolean isNodeHealthy);
/** /**
* Get the <em>diagnostic health report</em> of the node. * Get the <em>diagnostic health report</em> of the node.
@ -63,11 +74,11 @@ public interface NodeHealthStatus {
*/ */
@Public @Public
@Stable @Stable
String getHealthReport(); public abstract String getHealthReport();
@Private @Private
@Unstable @Unstable
void setHealthReport(String healthReport); public abstract void setHealthReport(String healthReport);
/** /**
* Get the <em>last timestamp</em> at which the health report was received. * Get the <em>last timestamp</em> at which the health report was received.
@ -75,9 +86,9 @@ public interface NodeHealthStatus {
*/ */
@Public @Public
@Stable @Stable
long getLastHealthReportTime(); public abstract long getLastHealthReportTime();
@Private @Private
@Unstable @Unstable
void setLastHealthReportTime(long lastHealthReport); public abstract void setLastHealthReportTime(long lastHealthReport);
} }

View File

@ -22,6 +22,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceAudience.Public; import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Stable; import org.apache.hadoop.classification.InterfaceStability.Stable;
import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.yarn.util.Records;
/** /**
* <p><code>NodeId</code> is the unique identifier for a node.</p> * <p><code>NodeId</code> is the unique identifier for a node.</p>
@ -34,6 +35,14 @@ import org.apache.hadoop.classification.InterfaceStability.Unstable;
@Stable @Stable
public abstract class NodeId implements Comparable<NodeId> { public abstract class NodeId implements Comparable<NodeId> {
@Private
public static NodeId newInstance(String host, int port) {
NodeId nodeId = Records.newRecord(NodeId.class);
nodeId.setHost(host);
nodeId.setPort(port);
return nodeId;
}
/** /**
* Get the <em>hostname</em> of the node. * Get the <em>hostname</em> of the node.
* @return <em>hostname</em> of the node * @return <em>hostname</em> of the node

View File

@ -23,6 +23,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Stable; import org.apache.hadoop.classification.InterfaceStability.Stable;
import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.yarn.api.ClientRMProtocol; import org.apache.hadoop.yarn.api.ClientRMProtocol;
import org.apache.hadoop.yarn.util.Records;
/** /**
* <p><code>NodeReport</code> is a summary of runtime information of a * <p><code>NodeReport</code> is a summary of runtime information of a
@ -45,26 +46,43 @@ import org.apache.hadoop.yarn.api.ClientRMProtocol;
*/ */
@Public @Public
@Stable @Stable
public interface NodeReport { public abstract class NodeReport {
@Private
public static NodeReport newInstance(NodeId nodeId, NodeState nodeState,
String httpAddress, String rackName, Resource used, Resource capability,
int numContainers, NodeHealthStatus nodeHealthStatus) {
NodeReport nodeReport = Records.newRecord(NodeReport.class);
nodeReport.setNodeId(nodeId);
nodeReport.setNodeState(nodeState);
nodeReport.setHttpAddress(httpAddress);
nodeReport.setRackName(rackName);
nodeReport.setUsed(used);
nodeReport.setCapability(capability);
nodeReport.setNumContainers(numContainers);
nodeReport.setNodeHealthStatus(nodeHealthStatus);
return nodeReport;
}
/** /**
* Get the <code>NodeId</code> of the node. * Get the <code>NodeId</code> of the node.
* @return <code>NodeId</code> of the node * @return <code>NodeId</code> of the node
*/ */
NodeId getNodeId(); public abstract NodeId getNodeId();
@Private @Private
@Unstable @Unstable
void setNodeId(NodeId nodeId); public abstract void setNodeId(NodeId nodeId);
/** /**
* Get the <code>NodeState</code> of the node. * Get the <code>NodeState</code> of the node.
* @return <code>NodeState</code> of the node * @return <code>NodeState</code> of the node
*/ */
NodeState getNodeState(); public abstract NodeState getNodeState();
@Private @Private
@Unstable @Unstable
void setNodeState(NodeState nodeState); public abstract void setNodeState(NodeState nodeState);
/** /**
* Get the <em>http address</em> of the node. * Get the <em>http address</em> of the node.
@ -72,11 +90,11 @@ public interface NodeReport {
*/ */
@Public @Public
@Stable @Stable
String getHttpAddress(); public abstract String getHttpAddress();
@Private @Private
@Unstable @Unstable
void setHttpAddress(String httpAddress); public abstract void setHttpAddress(String httpAddress);
/** /**
* Get the <em>rack name</em> for the node. * Get the <em>rack name</em> for the node.
@ -84,11 +102,11 @@ public interface NodeReport {
*/ */
@Public @Public
@Stable @Stable
String getRackName(); public abstract String getRackName();
@Private @Private
@Unstable @Unstable
void setRackName(String rackName); public abstract void setRackName(String rackName);
/** /**
* Get <em>used</em> <code>Resource</code> on the node. * Get <em>used</em> <code>Resource</code> on the node.
@ -96,11 +114,11 @@ public interface NodeReport {
*/ */
@Public @Public
@Stable @Stable
Resource getUsed(); public abstract Resource getUsed();
@Private @Private
@Unstable @Unstable
void setUsed(Resource used); public abstract void setUsed(Resource used);
/** /**
* Get the <em>total</em> <code>Resource</code> on the node. * Get the <em>total</em> <code>Resource</code> on the node.
@ -108,11 +126,11 @@ public interface NodeReport {
*/ */
@Public @Public
@Stable @Stable
Resource getCapability(); public abstract Resource getCapability();
@Private @Private
@Unstable @Unstable
void setCapability(Resource capability); public abstract void setCapability(Resource capability);
/** /**
* Get the <em>number of running containers</em> on the node. * Get the <em>number of running containers</em> on the node.
@ -120,11 +138,11 @@ public interface NodeReport {
*/ */
@Public @Public
@Stable @Stable
int getNumContainers(); public abstract int getNumContainers();
@Private @Private
@Unstable @Unstable
void setNumContainers(int numContainers); public abstract void setNumContainers(int numContainers);
/** /**
* Get the <code>NodeHealthStatus</code> of the node. * Get the <code>NodeHealthStatus</code> of the node.
@ -132,9 +150,9 @@ public interface NodeReport {
*/ */
@Public @Public
@Stable @Stable
NodeHealthStatus getNodeHealthStatus(); public abstract NodeHealthStatus getNodeHealthStatus();
@Private @Private
@Unstable @Unstable
void setNodeHealthStatus(NodeHealthStatus nodeHealthStatus); public abstract void setNodeHealthStatus(NodeHealthStatus nodeHealthStatus);
} }

View File

@ -18,6 +18,10 @@
package org.apache.hadoop.yarn.api.records; package org.apache.hadoop.yarn.api.records;
import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Stable;
import org.apache.hadoop.yarn.util.Records;
/** /**
* The priority assigned to a ResourceRequest or Application or Container * The priority assigned to a ResourceRequest or Application or Container
* allocation * allocation
@ -25,6 +29,14 @@ package org.apache.hadoop.yarn.api.records;
*/ */
public abstract class Priority implements Comparable<Priority> { public abstract class Priority implements Comparable<Priority> {
@Public
@Stable
public static Priority newInstance(int p) {
Priority priority = Records.newRecord(Priority.class);
priority.setPriority(p);
return priority;
}
/** /**
* Get the assigned priority * Get the assigned priority
* @return the assigned priority * @return the assigned priority

View File

@ -25,6 +25,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Stable; import org.apache.hadoop.classification.InterfaceStability.Stable;
import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.yarn.api.ClientRMProtocol; import org.apache.hadoop.yarn.api.ClientRMProtocol;
import org.apache.hadoop.yarn.util.Records;
/** /**
* <p>QueueInfo is a report of the runtime information of the queue.</p> * <p>QueueInfo is a report of the runtime information of the queue.</p>
@ -46,18 +47,35 @@ import org.apache.hadoop.yarn.api.ClientRMProtocol;
*/ */
@Public @Public
@Stable @Stable
public interface QueueInfo { public abstract class QueueInfo {
@Private
public static QueueInfo newInstance(String queueName, float capacity,
float maximumCapacity, float currentCapacity,
List<QueueInfo> childQueues, List<ApplicationReport> applications,
QueueState queueState) {
QueueInfo queueInfo = Records.newRecord(QueueInfo.class);
queueInfo.setQueueName(queueName);
queueInfo.setCapacity(capacity);
queueInfo.setMaximumCapacity(maximumCapacity);
queueInfo.setCurrentCapacity(currentCapacity);
queueInfo.setChildQueues(childQueues);
queueInfo.setApplications(applications);
queueInfo.setQueueState(queueState);
return queueInfo;
}
/** /**
* Get the <em>name</em> of the queue. * Get the <em>name</em> of the queue.
* @return <em>name</em> of the queue * @return <em>name</em> of the queue
*/ */
@Public @Public
@Stable @Stable
String getQueueName(); public abstract String getQueueName();
@Private @Private
@Unstable @Unstable
void setQueueName(String queueName); public abstract void setQueueName(String queueName);
/** /**
* Get the <em>configured capacity</em> of the queue. * Get the <em>configured capacity</em> of the queue.
@ -65,11 +83,11 @@ public interface QueueInfo {
*/ */
@Public @Public
@Stable @Stable
float getCapacity(); public abstract float getCapacity();
@Private @Private
@Unstable @Unstable
void setCapacity(float capacity); public abstract void setCapacity(float capacity);
/** /**
* Get the <em>maximum capacity</em> of the queue. * Get the <em>maximum capacity</em> of the queue.
@ -77,11 +95,11 @@ public interface QueueInfo {
*/ */
@Public @Public
@Stable @Stable
float getMaximumCapacity(); public abstract float getMaximumCapacity();
@Private @Private
@Unstable @Unstable
void setMaximumCapacity(float maximumCapacity); public abstract void setMaximumCapacity(float maximumCapacity);
/** /**
* Get the <em>current capacity</em> of the queue. * Get the <em>current capacity</em> of the queue.
@ -89,11 +107,11 @@ public interface QueueInfo {
*/ */
@Public @Public
@Stable @Stable
float getCurrentCapacity(); public abstract float getCurrentCapacity();
@Private @Private
@Unstable @Unstable
void setCurrentCapacity(float currentCapacity); public abstract void setCurrentCapacity(float currentCapacity);
/** /**
* Get the <em>child queues</em> of the queue. * Get the <em>child queues</em> of the queue.
@ -101,11 +119,11 @@ public interface QueueInfo {
*/ */
@Public @Public
@Stable @Stable
List<QueueInfo> getChildQueues(); public abstract List<QueueInfo> getChildQueues();
@Private @Private
@Unstable @Unstable
void setChildQueues(List<QueueInfo> childQueues); public abstract void setChildQueues(List<QueueInfo> childQueues);
/** /**
* Get the <em>running applications</em> of the queue. * Get the <em>running applications</em> of the queue.
@ -113,11 +131,11 @@ public interface QueueInfo {
*/ */
@Public @Public
@Stable @Stable
List<ApplicationReport> getApplications(); public abstract List<ApplicationReport> getApplications();
@Private @Private
@Unstable @Unstable
void setApplications(List<ApplicationReport> applications); public abstract void setApplications(List<ApplicationReport> applications);
/** /**
* Get the <code>QueueState</code> of the queue. * Get the <code>QueueState</code> of the queue.
@ -125,9 +143,9 @@ public interface QueueInfo {
*/ */
@Public @Public
@Stable @Stable
QueueState getQueueState(); public abstract QueueState getQueueState();
@Private @Private
@Unstable @Unstable
void setQueueState(QueueState queueState); public abstract void setQueueState(QueueState queueState);
} }

View File

@ -25,6 +25,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Stable; import org.apache.hadoop.classification.InterfaceStability.Stable;
import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.yarn.api.ClientRMProtocol; import org.apache.hadoop.yarn.api.ClientRMProtocol;
import org.apache.hadoop.yarn.util.Records;
/** /**
* <p><code>QueueUserACLInfo</code> provides information {@link QueueACL} for * <p><code>QueueUserACLInfo</code> provides information {@link QueueACL} for
@ -35,18 +36,28 @@ import org.apache.hadoop.yarn.api.ClientRMProtocol;
*/ */
@Public @Public
@Stable @Stable
public interface QueueUserACLInfo { public abstract class QueueUserACLInfo {
@Private
public static QueueUserACLInfo newInstance(String queueName,
List<QueueACL> acls) {
QueueUserACLInfo info = Records.newRecord(QueueUserACLInfo.class);
info.setQueueName(queueName);
info.setUserAcls(acls);
return info;
}
/** /**
* Get the <em>queue name</em> of the queue. * Get the <em>queue name</em> of the queue.
* @return <em>queue name</em> of the queue * @return <em>queue name</em> of the queue
*/ */
@Public @Public
@Stable @Stable
String getQueueName(); public abstract String getQueueName();
@Private @Private
@Unstable @Unstable
void setQueueName(String queueName); public abstract void setQueueName(String queueName);
/** /**
* Get the list of <code>QueueACL</code> for the given user. * Get the list of <code>QueueACL</code> for the given user.
@ -54,9 +65,9 @@ public interface QueueUserACLInfo {
*/ */
@Public @Public
@Stable @Stable
List<QueueACL> getUserAcls(); public abstract List<QueueACL> getUserAcls();
@Private @Private
@Unstable @Unstable
void setUserAcls(List<QueueACL> acls); public abstract void setUserAcls(List<QueueACL> acls);
} }

View File

@ -22,6 +22,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Evolving; import org.apache.hadoop.classification.InterfaceStability.Evolving;
import org.apache.hadoop.classification.InterfaceStability.Stable; import org.apache.hadoop.classification.InterfaceStability.Stable;
import org.apache.hadoop.yarn.api.AMRMProtocol; import org.apache.hadoop.yarn.api.AMRMProtocol;
import org.apache.hadoop.yarn.util.Records;
/** /**
* <p><code>Resource</code> models a set of computer resources in the * <p><code>Resource</code> models a set of computer resources in the
@ -39,6 +40,15 @@ import org.apache.hadoop.yarn.api.AMRMProtocol;
@Stable @Stable
public abstract class Resource implements Comparable<Resource> { public abstract class Resource implements Comparable<Resource> {
@Public
@Stable
public static Resource newInstance(int memory, int vCores) {
Resource resource = Records.newRecord(Resource.class);
resource.setMemory(memory);
resource.setVirtualCores(vCores);
return resource;
}
/** /**
* Get <em>memory</em> of the resource. * Get <em>memory</em> of the resource.
* @return <em>memory</em> of the resource * @return <em>memory</em> of the resource

View File

@ -21,6 +21,7 @@ package org.apache.hadoop.yarn.api.records;
import org.apache.hadoop.classification.InterfaceAudience.Public; import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Stable; import org.apache.hadoop.classification.InterfaceStability.Stable;
import org.apache.hadoop.yarn.api.AMRMProtocol; import org.apache.hadoop.yarn.api.AMRMProtocol;
import org.apache.hadoop.yarn.util.Records;
/** /**
* <p><code>ResourceRequest</code> represents the request made by an * <p><code>ResourceRequest</code> represents the request made by an
@ -50,6 +51,18 @@ import org.apache.hadoop.yarn.api.AMRMProtocol;
@Stable @Stable
public abstract class ResourceRequest implements Comparable<ResourceRequest> { public abstract class ResourceRequest implements Comparable<ResourceRequest> {
@Public
@Stable
public static ResourceRequest newInstance(Priority priority,
String hostName, Resource capability, int numContainers) {
ResourceRequest request = Records.newRecord(ResourceRequest.class);
request.setPriority(priority);
request.setHostName(hostName);
request.setCapability(capability);
request.setNumContainers(numContainers);
return request;
}
/** /**
* The constant string representing no locality. * The constant string representing no locality.
* It should be used by all references that want to pass an arbitrary host * It should be used by all references that want to pass an arbitrary host

View File

@ -20,13 +20,26 @@ package org.apache.hadoop.yarn.api.records;
import org.apache.hadoop.classification.InterfaceAudience.Public; import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Evolving; import org.apache.hadoop.classification.InterfaceStability.Evolving;
import org.apache.hadoop.classification.InterfaceStability.Stable;
import org.apache.hadoop.yarn.util.Records;
/** /**
* <p><code>URL</code> represents a serializable {@link java.net.URL}.</p> * <p><code>URL</code> represents a serializable {@link java.net.URL}.</p>
*/ */
@Public @Public
@Evolving @Evolving
public interface URL { public abstract class URL {
@Public
@Stable
public static URL newInstance(String scheme, String host, int port, String file) {
URL url = Records.newRecord(URL.class);
url.setScheme(scheme);
url.setHost(host);
url.setPort(port);
url.setFile(file);
return url;
}
/** /**
* Get the scheme of the URL. * Get the scheme of the URL.

View File

@ -22,6 +22,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceAudience.Public; import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Stable; import org.apache.hadoop.classification.InterfaceStability.Stable;
import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.yarn.util.Records;
/** /**
* <p><code>YarnClusterMetrics</code> represents cluster metrics.</p> * <p><code>YarnClusterMetrics</code> represents cluster metrics.</p>
@ -30,7 +31,14 @@ import org.apache.hadoop.classification.InterfaceStability.Unstable;
*/ */
@Public @Public
@Stable @Stable
public interface YarnClusterMetrics { public abstract class YarnClusterMetrics {
@Private
public static YarnClusterMetrics newInstance(int numNodeManagers) {
YarnClusterMetrics metrics = Records.newRecord(YarnClusterMetrics.class);
metrics.setNumNodeManagers(numNodeManagers);
return metrics;
}
/** /**
* Get the number of <code>NodeManager</code>s in the cluster. * Get the number of <code>NodeManager</code>s in the cluster.

View File

@ -1,294 +0,0 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.yarn.api.records.impl.pb;
import org.apache.hadoop.security.proto.SecurityProtos.TokenProto;
import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ApplicationMaster;
import org.apache.hadoop.yarn.api.records.ApplicationStatus;
import org.apache.hadoop.yarn.api.records.ClientToken;
import org.apache.hadoop.yarn.api.records.ProtoBase;
import org.apache.hadoop.yarn.api.records.YarnApplicationState;
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.ApplicationStatusProto;
import org.apache.hadoop.yarn.proto.YarnProtos.YarnApplicationStateProto;
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;
private ClientToken clientToken = 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));
}
if (this.clientToken != null
&& !((ClientTokenPBImpl) this.clientToken).getProto().equals(
builder.getClientToken())) {
builder.setClientToken(convertToProtoFormat(this.clientToken));
}
}
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 YarnApplicationState getState() {
ApplicationMasterProtoOrBuilder p = viaProto ? proto : builder;
if (!p.hasState()) {
return null;
}
return convertFromProtoFormat(p.getState());
}
@Override
public void setState(YarnApplicationState 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 String getTrackingUrl() {
ApplicationMasterProtoOrBuilder p = viaProto ? proto : builder;
return (p.getTrackingUrl());
}
@Override
public void setTrackingUrl(String url) {
maybeInitBuilder();
builder.setTrackingUrl(url);
}
@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 ClientToken getClientToken() {
ApplicationMasterProtoOrBuilder p = viaProto ? proto : builder;
if (this.clientToken != null) {
return this.clientToken;
}
if (!p.hasClientToken()) {
return null;
}
this.clientToken = convertFromProtoFormat(p.getClientToken());
return this.clientToken;
}
@Override
public void setClientToken(ClientToken clientToken) {
maybeInitBuilder();
if (clientToken == null)
builder.clearClientToken();
this.clientToken = clientToken;
}
@Override
public int getAMFailCount() {
ApplicationMasterProtoOrBuilder p = viaProto ? proto : builder;
return (p.getAmFailCount());
}
@Override
public int getContainerCount() {
ApplicationMasterProtoOrBuilder p = viaProto ? proto : builder;
return (p.getContainerCount());
}
@Override
public void setAMFailCount(int amFailCount) {
maybeInitBuilder();
builder.setAmFailCount(amFailCount);
}
@Override
public void setContainerCount(int containerCount) {
maybeInitBuilder();
builder.setContainerCount(containerCount);
}
@Override
public String getDiagnostics() {
ApplicationMasterProtoOrBuilder p = viaProto ? proto : builder;
return p.getDiagnostics();
}
@Override
public void setDiagnostics(String diagnostics) {
maybeInitBuilder();
if (diagnostics == null) {
builder.clearDiagnostics();
return;
}
builder.setDiagnostics(diagnostics);
}
private YarnApplicationStateProto convertToProtoFormat(YarnApplicationState e) {
return ProtoUtils.convertToProtoFormat(e);
}
private YarnApplicationState convertFromProtoFormat(YarnApplicationStateProto 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();
}
private ClientTokenPBImpl convertFromProtoFormat(TokenProto p) {
return new ClientTokenPBImpl(p);
}
private TokenProto convertToProtoFormat(ClientToken t) {
return ((ClientTokenPBImpl)t).getProto();
}
}

View File

@ -25,7 +25,6 @@ import org.apache.hadoop.yarn.api.records.ApplicationReport;
import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport;
import org.apache.hadoop.yarn.api.records.ClientToken; import org.apache.hadoop.yarn.api.records.ClientToken;
import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
import org.apache.hadoop.yarn.api.records.ProtoBase;
import org.apache.hadoop.yarn.api.records.YarnApplicationState; import org.apache.hadoop.yarn.api.records.YarnApplicationState;
import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAttemptIdProto; import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAttemptIdProto;
import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto; import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto;
@ -36,8 +35,7 @@ import org.apache.hadoop.yarn.proto.YarnProtos.FinalApplicationStatusProto;
import org.apache.hadoop.yarn.proto.YarnProtos.YarnApplicationStateProto; import org.apache.hadoop.yarn.proto.YarnProtos.YarnApplicationStateProto;
import org.apache.hadoop.yarn.util.ProtoUtils; import org.apache.hadoop.yarn.util.ProtoUtils;
public class ApplicationReportPBImpl extends ProtoBase<ApplicationReportProto> public class ApplicationReportPBImpl extends ApplicationReport {
implements ApplicationReport {
ApplicationReportProto proto = ApplicationReportProto.getDefaultInstance(); ApplicationReportProto proto = ApplicationReportProto.getDefaultInstance();
ApplicationReportProto.Builder builder = null; ApplicationReportProto.Builder builder = null;
boolean viaProto = false; boolean viaProto = false;
@ -376,7 +374,6 @@ implements ApplicationReport {
builder.setProgress(progress); builder.setProgress(progress);
} }
@Override
public ApplicationReportProto getProto() { public ApplicationReportProto getProto() {
mergeLocalToProto(); mergeLocalToProto();
proto = viaProto ? proto : builder.build(); proto = viaProto ? proto : builder.build();
@ -384,6 +381,26 @@ implements ApplicationReport {
return proto; return proto;
} }
@Override
public int hashCode() {
return getProto().hashCode();
}
@Override
public boolean equals(Object other) {
if (other == null)
return false;
if (other.getClass().isAssignableFrom(this.getClass())) {
return this.getProto().equals(this.getClass().cast(other).getProto());
}
return false;
}
@Override
public String toString() {
return getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " ");
}
private void mergeLocalToBuilder() { private void mergeLocalToBuilder() {
if (this.applicationId != null if (this.applicationId != null
&& !((ApplicationIdPBImpl) this.applicationId).getProto().equals( && !((ApplicationIdPBImpl) this.applicationId).getProto().equals(

View File

@ -19,15 +19,13 @@
package org.apache.hadoop.yarn.api.records.impl.pb; package org.apache.hadoop.yarn.api.records.impl.pb;
import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport;
import org.apache.hadoop.yarn.api.records.ProtoBase;
import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationResourceUsageReportProto; import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationResourceUsageReportProto;
import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationResourceUsageReportProtoOrBuilder; import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationResourceUsageReportProtoOrBuilder;
import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto;
public class ApplicationResourceUsageReportPBImpl public class ApplicationResourceUsageReportPBImpl
extends ProtoBase<ApplicationResourceUsageReportProto> extends ApplicationResourceUsageReport {
implements ApplicationResourceUsageReport {
ApplicationResourceUsageReportProto proto = ApplicationResourceUsageReportProto proto =
ApplicationResourceUsageReportProto.getDefaultInstance(); ApplicationResourceUsageReportProto.getDefaultInstance();
ApplicationResourceUsageReportProto.Builder builder = null; ApplicationResourceUsageReportProto.Builder builder = null;
@ -54,6 +52,26 @@ implements ApplicationResourceUsageReport {
return proto; return proto;
} }
@Override
public int hashCode() {
return getProto().hashCode();
}
@Override
public boolean equals(Object other) {
if (other == null)
return false;
if (other.getClass().isAssignableFrom(this.getClass())) {
return this.getProto().equals(this.getClass().cast(other).getProto());
}
return false;
}
@Override
public String toString() {
return getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " ");
}
private void mergeLocalToBuilder() { private void mergeLocalToBuilder() {
if (this.usedResources != null if (this.usedResources != null
&& !((ResourcePBImpl) this.usedResources).getProto().equals( && !((ResourcePBImpl) this.usedResources).getProto().equals(

View File

@ -1,134 +0,0 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.yarn.api.records.impl.pb;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
import org.apache.hadoop.yarn.api.records.ApplicationStatus;
import org.apache.hadoop.yarn.api.records.ProtoBase;
import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAttemptIdProto;
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 ApplicationAttemptId applicationAttemptId = 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.applicationAttemptId != null && !((ApplicationAttemptIdPBImpl)this.applicationAttemptId).getProto().equals(builder.getApplicationAttemptId())) {
builder.setApplicationAttemptId(convertToProtoFormat(this.applicationAttemptId));
}
}
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 ApplicationAttemptId getApplicationAttemptId() {
ApplicationStatusProtoOrBuilder p = viaProto ? proto : builder;
if (this.applicationAttemptId != null) {
return this.applicationAttemptId;
}
if (!p.hasApplicationAttemptId()) {
return null;
}
this.applicationAttemptId = convertFromProtoFormat(p.getApplicationAttemptId());
return this.applicationAttemptId;
}
@Override
public void setApplicationAttemptId(ApplicationAttemptId applicationAttemptId) {
maybeInitBuilder();
if (applicationAttemptId == null)
builder.clearApplicationAttemptId();
this.applicationAttemptId = applicationAttemptId;
}
@Override
public float getProgress() {
ApplicationStatusProtoOrBuilder p = viaProto ? proto : builder;
return (p.getProgress());
}
@Override
public void setProgress(float progress) {
maybeInitBuilder();
builder.setProgress((progress));
}
private ApplicationAttemptIdPBImpl convertFromProtoFormat(ApplicationAttemptIdProto p) {
return new ApplicationAttemptIdPBImpl(p);
}
private ApplicationAttemptIdProto convertToProtoFormat(ApplicationAttemptId t) {
return ((ApplicationAttemptIdPBImpl)t).getProto();
}
}

View File

@ -22,7 +22,6 @@ import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; import org.apache.hadoop.yarn.api.records.ContainerLaunchContext;
import org.apache.hadoop.yarn.api.records.Priority; 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.Resource;
import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto; import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto;
import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationSubmissionContextProto; import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationSubmissionContextProto;
@ -32,8 +31,7 @@ import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProto;
import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto;
public class ApplicationSubmissionContextPBImpl public class ApplicationSubmissionContextPBImpl
extends ProtoBase<ApplicationSubmissionContextProto> extends ApplicationSubmissionContext {
implements ApplicationSubmissionContext {
ApplicationSubmissionContextProto proto = ApplicationSubmissionContextProto proto =
ApplicationSubmissionContextProto.getDefaultInstance(); ApplicationSubmissionContextProto.getDefaultInstance();
ApplicationSubmissionContextProto.Builder builder = null; ApplicationSubmissionContextProto.Builder builder = null;
@ -61,6 +59,26 @@ implements ApplicationSubmissionContext {
return proto; return proto;
} }
@Override
public int hashCode() {
return getProto().hashCode();
}
@Override
public boolean equals(Object other) {
if (other == null)
return false;
if (other.getClass().isAssignableFrom(this.getClass())) {
return this.getProto().equals(this.getClass().cast(other).getProto());
}
return false;
}
@Override
public String toString() {
return getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " ");
}
private void mergeLocalToBuilder() { private void mergeLocalToBuilder() {
if (this.applicationId != null) { if (this.applicationId != null) {
builder.setApplicationId(convertToProtoFormat(this.applicationId)); builder.setApplicationId(convertToProtoFormat(this.applicationId));

View File

@ -28,7 +28,6 @@ import java.util.Map;
import org.apache.hadoop.yarn.api.records.ApplicationAccessType; import org.apache.hadoop.yarn.api.records.ApplicationAccessType;
import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; import org.apache.hadoop.yarn.api.records.ContainerLaunchContext;
import org.apache.hadoop.yarn.api.records.LocalResource; import org.apache.hadoop.yarn.api.records.LocalResource;
import org.apache.hadoop.yarn.api.records.ProtoBase;
import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationACLMapProto; import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationACLMapProto;
import org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProto;
import org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProtoOrBuilder; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProtoOrBuilder;
@ -38,9 +37,10 @@ import org.apache.hadoop.yarn.proto.YarnProtos.StringLocalResourceMapProto;
import org.apache.hadoop.yarn.proto.YarnProtos.StringStringMapProto; import org.apache.hadoop.yarn.proto.YarnProtos.StringStringMapProto;
import org.apache.hadoop.yarn.util.ProtoUtils; import org.apache.hadoop.yarn.util.ProtoUtils;
import com.google.protobuf.ByteString;
public class ContainerLaunchContextPBImpl public class ContainerLaunchContextPBImpl
extends ProtoBase<ContainerLaunchContextProto> extends ContainerLaunchContext {
implements ContainerLaunchContext {
ContainerLaunchContextProto proto = ContainerLaunchContextProto proto =
ContainerLaunchContextProto.getDefaultInstance(); ContainerLaunchContextProto.getDefaultInstance();
ContainerLaunchContextProto.Builder builder = null; ContainerLaunchContextProto.Builder builder = null;
@ -69,6 +69,34 @@ implements ContainerLaunchContext {
return proto; return proto;
} }
@Override
public int hashCode() {
return getProto().hashCode();
}
@Override
public boolean equals(Object other) {
if (other == null)
return false;
if (other.getClass().isAssignableFrom(this.getClass())) {
return this.getProto().equals(this.getClass().cast(other).getProto());
}
return false;
}
@Override
public String toString() {
return getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " ");
}
protected final ByteBuffer convertFromProtoFormat(ByteString byteString) {
return ProtoUtils.convertFromProtoFormat(byteString);
}
protected final ByteString convertToProtoFormat(ByteBuffer byteBuffer) {
return ProtoUtils.convertToProtoFormat(byteBuffer);
}
private void mergeLocalToBuilder() { private void mergeLocalToBuilder() {
if (this.localResources != null) { if (this.localResources != null) {
addLocalResourcesToProto(); addLocalResourcesToProto();

View File

@ -24,7 +24,6 @@ import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.ContainerToken; import org.apache.hadoop.yarn.api.records.ContainerToken;
import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.api.records.NodeId;
import org.apache.hadoop.yarn.api.records.Priority; 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.Resource;
import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto;
import org.apache.hadoop.yarn.proto.YarnProtos.ContainerProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerProto;
@ -33,7 +32,7 @@ import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto;
import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProto; import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProto;
import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto;
public class ContainerPBImpl extends ProtoBase<ContainerProto> implements Container { public class ContainerPBImpl extends Container {
ContainerProto proto = ContainerProto.getDefaultInstance(); ContainerProto proto = ContainerProto.getDefaultInstance();
ContainerProto.Builder builder = null; ContainerProto.Builder builder = null;
@ -62,6 +61,21 @@ public class ContainerPBImpl extends ProtoBase<ContainerProto> implements Contai
return proto; return proto;
} }
@Override
public int hashCode() {
return getProto().hashCode();
}
@Override
public boolean equals(Object other) {
if (other == null)
return false;
if (other.getClass().isAssignableFrom(this.getClass())) {
return this.getProto().equals(this.getClass().cast(other).getProto());
}
return false;
}
private void mergeLocalToBuilder() { private void mergeLocalToBuilder() {
if (this.containerId != null if (this.containerId != null
&& !((ContainerIdPBImpl) containerId).getProto().equals( && !((ContainerIdPBImpl) containerId).getProto().equals(

View File

@ -22,7 +22,6 @@ package org.apache.hadoop.yarn.api.records.impl.pb;
import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.ContainerState; import org.apache.hadoop.yarn.api.records.ContainerState;
import org.apache.hadoop.yarn.api.records.ContainerStatus; 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.ContainerIdProto;
import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStateProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStateProto;
import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStatusProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStatusProto;
@ -31,8 +30,7 @@ import org.apache.hadoop.yarn.util.ProtoUtils;
public class ContainerStatusPBImpl extends ProtoBase<ContainerStatusProto> public class ContainerStatusPBImpl extends ContainerStatus {
implements ContainerStatus {
ContainerStatusProto proto = ContainerStatusProto.getDefaultInstance(); ContainerStatusProto proto = ContainerStatusProto.getDefaultInstance();
ContainerStatusProto.Builder builder = null; ContainerStatusProto.Builder builder = null;
boolean viaProto = false; boolean viaProto = false;
@ -56,6 +54,26 @@ implements ContainerStatus {
return proto; return proto;
} }
@Override
public int hashCode() {
return getProto().hashCode();
}
@Override
public boolean equals(Object other) {
if (other == null)
return false;
if (other.getClass().isAssignableFrom(this.getClass())) {
return this.getProto().equals(this.getClass().cast(other).getProto());
}
return false;
}
@Override
public String toString() {
return getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " ");
}
private void mergeLocalToBuilder() { private void mergeLocalToBuilder() {
if (containerId != null) { if (containerId != null) {
builder.setContainerId(convertToProtoFormat(this.containerId)); builder.setContainerId(convertToProtoFormat(this.containerId));

View File

@ -21,7 +21,6 @@ package org.apache.hadoop.yarn.api.records.impl.pb;
import org.apache.hadoop.yarn.api.records.LocalResource; import org.apache.hadoop.yarn.api.records.LocalResource;
import org.apache.hadoop.yarn.api.records.LocalResourceType; import org.apache.hadoop.yarn.api.records.LocalResourceType;
import org.apache.hadoop.yarn.api.records.LocalResourceVisibility; 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.api.records.URL;
import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProto; import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProto;
import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProtoOrBuilder; import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProtoOrBuilder;
@ -32,8 +31,7 @@ import org.apache.hadoop.yarn.util.ProtoUtils;
public class LocalResourcePBImpl extends ProtoBase<LocalResourceProto> public class LocalResourcePBImpl extends LocalResource {
implements LocalResource {
LocalResourceProto proto = LocalResourceProto.getDefaultInstance(); LocalResourceProto proto = LocalResourceProto.getDefaultInstance();
LocalResourceProto.Builder builder = null; LocalResourceProto.Builder builder = null;
boolean viaProto = false; boolean viaProto = false;
@ -56,6 +54,26 @@ public class LocalResourcePBImpl extends ProtoBase<LocalResourceProto>
return proto; return proto;
} }
@Override
public int hashCode() {
return getProto().hashCode();
}
@Override
public boolean equals(Object other) {
if (other == null)
return false;
if (other.getClass().isAssignableFrom(this.getClass())) {
return this.getProto().equals(this.getClass().cast(other).getProto());
}
return false;
}
@Override
public String toString() {
return getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " ");
}
private synchronized void mergeLocalToBuilder() { private synchronized void mergeLocalToBuilder() {
LocalResourceProtoOrBuilder l = viaProto ? proto : builder; LocalResourceProtoOrBuilder l = viaProto ? proto : builder;
if (this.url != null if (this.url != null

View File

@ -19,12 +19,10 @@
package org.apache.hadoop.yarn.api.records.impl.pb; package org.apache.hadoop.yarn.api.records.impl.pb;
import org.apache.hadoop.yarn.api.records.NodeHealthStatus; import org.apache.hadoop.yarn.api.records.NodeHealthStatus;
import org.apache.hadoop.yarn.api.records.ProtoBase;
import org.apache.hadoop.yarn.proto.YarnProtos.NodeHealthStatusProto; import org.apache.hadoop.yarn.proto.YarnProtos.NodeHealthStatusProto;
import org.apache.hadoop.yarn.proto.YarnProtos.NodeHealthStatusProtoOrBuilder; import org.apache.hadoop.yarn.proto.YarnProtos.NodeHealthStatusProtoOrBuilder;
public class NodeHealthStatusPBImpl extends ProtoBase<NodeHealthStatusProto> public class NodeHealthStatusPBImpl extends NodeHealthStatus {
implements NodeHealthStatus {
private NodeHealthStatusProto.Builder builder; private NodeHealthStatusProto.Builder builder;
private boolean viaProto = false; private boolean viaProto = false;
@ -47,6 +45,26 @@ public class NodeHealthStatusPBImpl extends ProtoBase<NodeHealthStatusProto>
return this.proto; return this.proto;
} }
@Override
public int hashCode() {
return getProto().hashCode();
}
@Override
public boolean equals(Object other) {
if (other == null)
return false;
if (other.getClass().isAssignableFrom(this.getClass())) {
return this.getProto().equals(this.getClass().cast(other).getProto());
}
return false;
}
@Override
public String toString() {
return getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " ");
}
private void mergeLocalToProto() { private void mergeLocalToProto() {
if (this.viaProto) if (this.viaProto)
maybeInitBuilder(); maybeInitBuilder();

View File

@ -22,7 +22,6 @@ import org.apache.hadoop.yarn.api.records.NodeHealthStatus;
import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.api.records.NodeId;
import org.apache.hadoop.yarn.api.records.NodeReport; import org.apache.hadoop.yarn.api.records.NodeReport;
import org.apache.hadoop.yarn.api.records.NodeState; import org.apache.hadoop.yarn.api.records.NodeState;
import org.apache.hadoop.yarn.api.records.ProtoBase;
import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.proto.YarnProtos.NodeHealthStatusProto; import org.apache.hadoop.yarn.proto.YarnProtos.NodeHealthStatusProto;
import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto; import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto;
@ -31,8 +30,7 @@ import org.apache.hadoop.yarn.proto.YarnProtos.NodeReportProtoOrBuilder;
import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto;
import org.apache.hadoop.yarn.util.ProtoUtils; import org.apache.hadoop.yarn.util.ProtoUtils;
public class NodeReportPBImpl extends ProtoBase<NodeReportProto> public class NodeReportPBImpl extends NodeReport {
implements NodeReport {
private NodeReportProto proto = NodeReportProto.getDefaultInstance(); private NodeReportProto proto = NodeReportProto.getDefaultInstance();
private NodeReportProto.Builder builder = null; private NodeReportProto.Builder builder = null;
@ -206,7 +204,6 @@ public class NodeReportPBImpl extends ProtoBase<NodeReportProto>
this.used = used; this.used = used;
} }
@Override
public NodeReportProto getProto() { public NodeReportProto getProto() {
mergeLocalToProto(); mergeLocalToProto();
proto = viaProto ? proto : builder.build(); proto = viaProto ? proto : builder.build();
@ -214,6 +211,26 @@ public class NodeReportPBImpl extends ProtoBase<NodeReportProto>
return proto; return proto;
} }
@Override
public int hashCode() {
return getProto().hashCode();
}
@Override
public boolean equals(Object other) {
if (other == null)
return false;
if (other.getClass().isAssignableFrom(this.getClass())) {
return this.getProto().equals(this.getClass().cast(other).getProto());
}
return false;
}
@Override
public String toString() {
return getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " ");
}
private void mergeLocalToBuilder() { private void mergeLocalToBuilder() {
if (this.nodeId != null if (this.nodeId != null
&& !((NodeIdPBImpl) this.nodeId).getProto().equals( && !((NodeIdPBImpl) this.nodeId).getProto().equals(

View File

@ -23,7 +23,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import org.apache.hadoop.yarn.api.records.ApplicationReport; import org.apache.hadoop.yarn.api.records.ApplicationReport;
import org.apache.hadoop.yarn.api.records.ProtoBase;
import org.apache.hadoop.yarn.api.records.QueueInfo; import org.apache.hadoop.yarn.api.records.QueueInfo;
import org.apache.hadoop.yarn.api.records.QueueState; import org.apache.hadoop.yarn.api.records.QueueState;
import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationReportProto; import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationReportProto;
@ -32,8 +31,7 @@ import org.apache.hadoop.yarn.proto.YarnProtos.QueueInfoProtoOrBuilder;
import org.apache.hadoop.yarn.proto.YarnProtos.QueueStateProto; import org.apache.hadoop.yarn.proto.YarnProtos.QueueStateProto;
import org.apache.hadoop.yarn.util.ProtoUtils; import org.apache.hadoop.yarn.util.ProtoUtils;
public class QueueInfoPBImpl extends ProtoBase<QueueInfoProto> implements public class QueueInfoPBImpl extends QueueInfo {
QueueInfo {
QueueInfoProto proto = QueueInfoProto.getDefaultInstance(); QueueInfoProto proto = QueueInfoProto.getDefaultInstance();
QueueInfoProto.Builder builder = null; QueueInfoProto.Builder builder = null;
@ -150,7 +148,6 @@ public class QueueInfoPBImpl extends ProtoBase<QueueInfoProto> implements
builder.setState(convertToProtoFormat(queueState)); builder.setState(convertToProtoFormat(queueState));
} }
@Override
public QueueInfoProto getProto() { public QueueInfoProto getProto() {
mergeLocalToProto(); mergeLocalToProto();
proto = viaProto ? proto : builder.build(); proto = viaProto ? proto : builder.build();
@ -158,6 +155,26 @@ public class QueueInfoPBImpl extends ProtoBase<QueueInfoProto> implements
return proto; return proto;
} }
@Override
public int hashCode() {
return getProto().hashCode();
}
@Override
public boolean equals(Object other) {
if (other == null)
return false;
if (other.getClass().isAssignableFrom(this.getClass())) {
return this.getProto().equals(this.getClass().cast(other).getProto());
}
return false;
}
@Override
public String toString() {
return getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " ");
}
private void initLocalApplicationsList() { private void initLocalApplicationsList() {
if (this.applicationsList != null) { if (this.applicationsList != null) {
return; return;

View File

@ -23,15 +23,13 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import org.apache.hadoop.yarn.api.records.QueueACL; import org.apache.hadoop.yarn.api.records.QueueACL;
import org.apache.hadoop.yarn.api.records.ProtoBase;
import org.apache.hadoop.yarn.api.records.QueueUserACLInfo; import org.apache.hadoop.yarn.api.records.QueueUserACLInfo;
import org.apache.hadoop.yarn.proto.YarnProtos.QueueACLProto; import org.apache.hadoop.yarn.proto.YarnProtos.QueueACLProto;
import org.apache.hadoop.yarn.proto.YarnProtos.QueueUserACLInfoProto; import org.apache.hadoop.yarn.proto.YarnProtos.QueueUserACLInfoProto;
import org.apache.hadoop.yarn.proto.YarnProtos.QueueUserACLInfoProtoOrBuilder; import org.apache.hadoop.yarn.proto.YarnProtos.QueueUserACLInfoProtoOrBuilder;
import org.apache.hadoop.yarn.util.ProtoUtils; import org.apache.hadoop.yarn.util.ProtoUtils;
public class QueueUserACLInfoPBImpl extends ProtoBase<QueueUserACLInfoProto> public class QueueUserACLInfoPBImpl extends QueueUserACLInfo {
implements QueueUserACLInfo {
QueueUserACLInfoProto proto = QueueUserACLInfoProto.getDefaultInstance(); QueueUserACLInfoProto proto = QueueUserACLInfoProto.getDefaultInstance();
QueueUserACLInfoProto.Builder builder = null; QueueUserACLInfoProto.Builder builder = null;
@ -78,7 +76,6 @@ implements QueueUserACLInfo {
this.userAclsList = userAclsList; this.userAclsList = userAclsList;
} }
@Override
public QueueUserACLInfoProto getProto() { public QueueUserACLInfoProto getProto() {
mergeLocalToProto(); mergeLocalToProto();
proto = viaProto ? proto : builder.build(); proto = viaProto ? proto : builder.build();
@ -86,6 +83,26 @@ implements QueueUserACLInfo {
return proto; return proto;
} }
@Override
public int hashCode() {
return getProto().hashCode();
}
@Override
public boolean equals(Object other) {
if (other == null)
return false;
if (other.getClass().isAssignableFrom(this.getClass())) {
return this.getProto().equals(this.getClass().cast(other).getProto());
}
return false;
}
@Override
public String toString() {
return getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " ");
}
private void initLocalQueueUserAclsList() { private void initLocalQueueUserAclsList() {
if (this.userAclsList != null) { if (this.userAclsList != null) {
return; return;

View File

@ -19,14 +19,13 @@
package org.apache.hadoop.yarn.api.records.impl.pb; 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.api.records.URL;
import org.apache.hadoop.yarn.proto.YarnProtos.URLProto; import org.apache.hadoop.yarn.proto.YarnProtos.URLProto;
import org.apache.hadoop.yarn.proto.YarnProtos.URLProtoOrBuilder; import org.apache.hadoop.yarn.proto.YarnProtos.URLProtoOrBuilder;
public class URLPBImpl extends ProtoBase<URLProto> implements URL { public class URLPBImpl extends URL {
URLProto proto = URLProto.getDefaultInstance(); URLProto proto = URLProto.getDefaultInstance();
URLProto.Builder builder = null; URLProto.Builder builder = null;
boolean viaProto = false; boolean viaProto = false;
@ -46,6 +45,26 @@ public class URLPBImpl extends ProtoBase<URLProto> implements URL {
return proto; return proto;
} }
@Override
public int hashCode() {
return getProto().hashCode();
}
@Override
public boolean equals(Object other) {
if (other == null)
return false;
if (other.getClass().isAssignableFrom(this.getClass())) {
return this.getProto().equals(this.getClass().cast(other).getProto());
}
return false;
}
@Override
public String toString() {
return getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " ");
}
private void maybeInitBuilder() { private void maybeInitBuilder() {
if (viaProto || builder == null) { if (viaProto || builder == null) {
builder = URLProto.newBuilder(proto); builder = URLProto.newBuilder(proto);

View File

@ -19,14 +19,13 @@
package org.apache.hadoop.yarn.api.records.impl.pb; 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.api.records.YarnClusterMetrics;
import org.apache.hadoop.yarn.proto.YarnProtos.YarnClusterMetricsProto; import org.apache.hadoop.yarn.proto.YarnProtos.YarnClusterMetricsProto;
import org.apache.hadoop.yarn.proto.YarnProtos.YarnClusterMetricsProtoOrBuilder; import org.apache.hadoop.yarn.proto.YarnProtos.YarnClusterMetricsProtoOrBuilder;
public class YarnClusterMetricsPBImpl extends ProtoBase<YarnClusterMetricsProto> implements YarnClusterMetrics { public class YarnClusterMetricsPBImpl extends YarnClusterMetrics {
YarnClusterMetricsProto proto = YarnClusterMetricsProto.getDefaultInstance(); YarnClusterMetricsProto proto = YarnClusterMetricsProto.getDefaultInstance();
YarnClusterMetricsProto.Builder builder = null; YarnClusterMetricsProto.Builder builder = null;
boolean viaProto = false; boolean viaProto = false;
@ -46,6 +45,26 @@ public class YarnClusterMetricsPBImpl extends ProtoBase<YarnClusterMetricsProto>
return proto; return proto;
} }
@Override
public int hashCode() {
return getProto().hashCode();
}
@Override
public boolean equals(Object other) {
if (other == null)
return false;
if (other.getClass().isAssignableFrom(this.getClass())) {
return this.getProto().equals(this.getClass().cast(other).getProto());
}
return false;
}
@Override
public String toString() {
return getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " ");
}
private void maybeInitBuilder() { private void maybeInitBuilder() {
if (viaProto || builder == null) { if (viaProto || builder == null) {
builder = YarnClusterMetricsProto.newBuilder(proto); builder = YarnClusterMetricsProto.newBuilder(proto);

View File

@ -28,7 +28,7 @@ import org.apache.hadoop.yarn.api.records.URL;
import org.apache.hadoop.yarn.util.ConverterUtils; import org.apache.hadoop.yarn.util.ConverterUtils;
public class LocalResourceRequest public class LocalResourceRequest
implements LocalResource, Comparable<LocalResourceRequest> { extends LocalResource implements Comparable<LocalResourceRequest> {
private final Path loc; private final Path loc;
private final long timestamp; private final long timestamp;

View File

@ -25,15 +25,11 @@ import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.yarn.MockApps; import org.apache.hadoop.yarn.MockApps;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ApplicationMaster;
import org.apache.hadoop.yarn.api.records.ApplicationReport; import org.apache.hadoop.yarn.api.records.ApplicationReport;
import org.apache.hadoop.yarn.api.records.ApplicationStatus;
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
import org.apache.hadoop.yarn.api.records.ClientToken;
import org.apache.hadoop.yarn.api.records.Container; import org.apache.hadoop.yarn.api.records.Container;
import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
import org.apache.hadoop.yarn.api.records.YarnApplicationState;
import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppEvent; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppEvent;
@ -47,108 +43,6 @@ import com.google.common.collect.Lists;
@InterfaceAudience.Private @InterfaceAudience.Private
public abstract class MockAsm extends MockApps { public abstract class MockAsm extends MockApps {
public static class AppMasterBase implements ApplicationMaster {
@Override
public ApplicationId getApplicationId() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getHost() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getRpcPort() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getTrackingUrl() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public ApplicationStatus getStatus() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public YarnApplicationState getState() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public ClientToken getClientToken() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getAMFailCount() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getContainerCount() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getDiagnostics() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setApplicationId(ApplicationId appId) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setHost(String host) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setRpcPort(int rpcPort) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setTrackingUrl(String url) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setStatus(ApplicationStatus status) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setState(YarnApplicationState state) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setClientToken(ClientToken clientToken) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setAMFailCount(int amFailCount) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setContainerCount(int containerCount) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setDiagnostics(String diagnostics) {
throw new UnsupportedOperationException("Not supported yet.");
}
}
public static class ApplicationBase implements RMApp { public static class ApplicationBase implements RMApp {
@Override @Override
public String getUser() { public String getUser() {

View File

@ -30,7 +30,6 @@ import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest; import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest;
import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ApplicationMaster;
import org.apache.hadoop.yarn.api.records.ApplicationReport; import org.apache.hadoop.yarn.api.records.ApplicationReport;
import org.apache.hadoop.yarn.api.records.YarnApplicationState; import org.apache.hadoop.yarn.api.records.YarnApplicationState;
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;

View File

@ -32,7 +32,6 @@ import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest; import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest;
import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ApplicationMaster;
import org.apache.hadoop.yarn.api.records.YarnApplicationState; import org.apache.hadoop.yarn.api.records.YarnApplicationState;
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
import org.apache.hadoop.yarn.api.records.Container; import org.apache.hadoop.yarn.api.records.Container;

View File

@ -27,7 +27,6 @@ import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.YarnApplicationState; import org.apache.hadoop.yarn.api.records.YarnApplicationState;
import org.apache.hadoop.yarn.api.records.ApplicationStatus;
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
import org.apache.hadoop.yarn.event.EventHandler; import org.apache.hadoop.yarn.event.EventHandler;
import org.apache.hadoop.yarn.factories.RecordFactory; import org.apache.hadoop.yarn.factories.RecordFactory;

View File

@ -27,7 +27,6 @@ import junit.framework.Assert;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ApplicationMaster;
import org.apache.hadoop.yarn.api.records.YarnApplicationState; import org.apache.hadoop.yarn.api.records.YarnApplicationState;
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
import org.apache.hadoop.yarn.api.records.Container; import org.apache.hadoop.yarn.api.records.Container;