YARN-9287. Consecutive StringBuilder append should be reuse. Contributed by Ayush Saxena.

This commit is contained in:
Giovanni Matteo Fumarola 2019-02-25 11:45:37 -08:00
parent f4ae00c530
commit 95372657fc
75 changed files with 565 additions and 544 deletions

View File

@ -127,8 +127,8 @@ public String toString() {
StringBuilder sb = new StringBuilder(64); StringBuilder sb = new StringBuilder(64);
sb.append(APP_ATTEMPT_ID_PREFIX); sb.append(APP_ATTEMPT_ID_PREFIX);
ApplicationId appId = getApplicationId(); ApplicationId appId = getApplicationId();
sb.append(appId.getClusterTimestamp()); sb.append(appId.getClusterTimestamp())
sb.append('_'); .append('_');
FastNumberFormat.format(sb, appId.getId(), APP_ID_MIN_DIGITS); FastNumberFormat.format(sb, appId.getId(), APP_ID_MIN_DIGITS);
sb.append('_'); sb.append('_');
FastNumberFormat.format(sb, getAttemptId(), ATTEMPT_ID_MIN_DIGITS); FastNumberFormat.format(sb, getAttemptId(), ATTEMPT_ID_MIN_DIGITS);

View File

@ -98,9 +98,9 @@ public int compareTo(ApplicationId other) {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(64); StringBuilder sb = new StringBuilder(64);
sb.append(APPLICATION_ID_PREFIX); sb.append(APPLICATION_ID_PREFIX)
sb.append(getClusterTimestamp()); .append(getClusterTimestamp())
sb.append('_'); .append('_');
FastNumberFormat.format(sb, getId(), APP_ID_MIN_DIGITS); FastNumberFormat.format(sb, getId(), APP_ID_MIN_DIGITS);
return sb.toString(); return sb.toString();
} }

View File

@ -172,8 +172,8 @@ public String toString() {
sb.append('_'); sb.append('_');
} }
ApplicationId appId = getApplicationAttemptId().getApplicationId(); ApplicationId appId = getApplicationAttemptId().getApplicationId();
sb.append(appId.getClusterTimestamp()); sb.append(appId.getClusterTimestamp())
sb.append('_'); .append('_');
FastNumberFormat.format(sb, appId.getId(), APP_ID_MIN_DIGITS); FastNumberFormat.format(sb, appId.getId(), APP_ID_MIN_DIGITS);
sb.append('_'); sb.append('_');
FastNumberFormat.format(sb, getApplicationAttemptId().getAttemptId(), FastNumberFormat.format(sb, getApplicationAttemptId().getAttemptId(),

View File

@ -98,11 +98,11 @@ public boolean equals(Object obj) {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("<"); sb.append("<")
sb.append(getName()); .append(getName())
sb.append(":exclusivity="); .append(":exclusivity=")
sb.append(isExclusive()); .append(isExclusive())
sb.append(">"); .append(">");
return sb.toString(); return sb.toString();
} }

View File

@ -103,9 +103,9 @@ public int compareTo(ReservationId other) {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(64); StringBuilder sb = new StringBuilder(64);
sb.append(reserveIdStrPrefix); sb.append(reserveIdStrPrefix)
sb.append(getClusterTimestamp()); .append(getClusterTimestamp())
sb.append('_'); .append('_');
FastNumberFormat.format(sb, getId(), RESERVATION_ID_MIN_DIGITS); FastNumberFormat.format(sb, getId(), RESERVATION_ID_MIN_DIGITS);
return sb.toString(); return sb.toString();
} }

View File

@ -475,10 +475,10 @@ public String toString() {
if (ri.getValue() == 0) { if (ri.getValue() == 0) {
continue; continue;
} }
sb.append(", "); sb.append(", ")
sb.append(ri.getName()).append(": ") .append(ri.getName()).append(": ")
.append(ri.getValue()); .append(ri.getValue())
sb.append(ri.getUnits()); .append(ri.getUnits());
} }
sb.append(">"); sb.append(">");

View File

@ -136,9 +136,9 @@ public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(TIMELINE_ENTITY_GROUPID_STR_PREFIX + "_"); sb.append(TIMELINE_ENTITY_GROUPID_STR_PREFIX + "_");
ApplicationId appId = getApplicationId(); ApplicationId appId = getApplicationId();
sb.append(appId.getClusterTimestamp()).append("_"); sb.append(appId.getClusterTimestamp()).append("_")
sb.append(appId.getId()).append("_"); .append(appId.getId()).append("_")
sb.append(getTimelineEntityGroupId()); .append(getTimelineEntityGroupId());
return sb.toString(); return sb.toString();
} }

View File

@ -77,13 +77,13 @@ public String getId() {
String id = super.getId(); String id = super.getId();
if (id == null) { if (id == null) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(getCluster()); sb.append(getCluster())
sb.append('/'); .append('/')
sb.append(getDate().getTime()); .append(getDate().getTime())
sb.append('/'); .append('/')
sb.append(getUser()); .append(getUser())
sb.append('@'); .append('@')
sb.append(getFlowName()); .append(getFlowName());
id = sb.toString(); id = sb.toString();
setId(id); setId(id);
} }

View File

@ -63,11 +63,11 @@ public String getId() {
String id = super.getId(); String id = super.getId();
if (id == null) { if (id == null) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(getInfo().get(USER_INFO_KEY).toString()); sb.append(getInfo().get(USER_INFO_KEY).toString())
sb.append('@'); .append('@')
sb.append(getInfo().get(FLOW_NAME_INFO_KEY).toString()); .append(getInfo().get(FLOW_NAME_INFO_KEY).toString())
sb.append('/'); .append('/')
sb.append(getInfo().get(FLOW_RUN_ID_INFO_KEY).toString()); .append(getInfo().get(FLOW_RUN_ID_INFO_KEY).toString());
id = sb.toString(); id = sb.toString();
setId(id); setId(id);
} }

View File

@ -129,8 +129,8 @@ private static void verifyAndSetRMHAIdsList(Configuration conf) {
for (String prefix : YarnConfiguration.getServiceAddressConfKeys(conf)) { for (String prefix : YarnConfiguration.getServiceAddressConfKeys(conf)) {
checkAndSetRMRPCAddress(prefix, id, conf); checkAndSetRMRPCAddress(prefix, id, conf);
} }
setValue.append(id); setValue.append(id)
setValue.append(","); .append(",");
} }
conf.set(YarnConfiguration.RM_HA_IDS, conf.set(YarnConfiguration.RM_HA_IDS,
setValue.substring(0, setValue.length() - 1)); setValue.substring(0, setValue.length() - 1));

View File

@ -906,16 +906,16 @@ public boolean run() throws IOException, YarnException {
for (String c : conf.getStrings( for (String c : conf.getStrings(
YarnConfiguration.YARN_APPLICATION_CLASSPATH, YarnConfiguration.YARN_APPLICATION_CLASSPATH,
YarnConfiguration.DEFAULT_YARN_CROSS_PLATFORM_APPLICATION_CLASSPATH)) { YarnConfiguration.DEFAULT_YARN_CROSS_PLATFORM_APPLICATION_CLASSPATH)) {
classPathEnv.append(ApplicationConstants.CLASS_PATH_SEPARATOR); classPathEnv.append(ApplicationConstants.CLASS_PATH_SEPARATOR)
classPathEnv.append(c.trim()); .append(c.trim());
} }
classPathEnv.append(ApplicationConstants.CLASS_PATH_SEPARATOR).append( classPathEnv.append(ApplicationConstants.CLASS_PATH_SEPARATOR).append(
"./log4j.properties"); "./log4j.properties");
// add the runtime classpath needed for tests to work // add the runtime classpath needed for tests to work
if (conf.getBoolean(YarnConfiguration.IS_MINI_YARN_CLUSTER, false)) { if (conf.getBoolean(YarnConfiguration.IS_MINI_YARN_CLUSTER, false)) {
classPathEnv.append(':'); classPathEnv.append(':')
classPathEnv.append(System.getProperty("java.class.path")); .append(System.getProperty("java.class.path"));
} }
env.put("CLASSPATH", classPathEnv.toString()); env.put("CLASSPATH", classPathEnv.toString());

View File

@ -105,14 +105,14 @@ String getRMWebAddress() {
Client client = Client.create(); Client client = Client.create();
client.setFollowRedirects(false); client.setFollowRedirects(false);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(scheme); sb.append(scheme)
sb.append(host); .append(host)
sb.append(path); .append(path);
if (!useKerberos) { if (!useKerberos) {
try { try {
String username = UserGroupInformation.getCurrentUser().getShortUserName(); String username = UserGroupInformation.getCurrentUser().getShortUserName();
sb.append("?user.name="); sb.append("?user.name=")
sb.append(username); .append(username);
} catch (IOException e) { } catch (IOException e) {
LOG.debug("Fail to resolve username: {}", e); LOG.debug("Fail to resolve username: {}", e);
} }
@ -154,11 +154,11 @@ List<String> getRMHAWebAddresses(Configuration conf) {
private String getServicePath(String appName) throws IOException { private String getServicePath(String appName) throws IOException {
String url = getRMWebAddress(); String url = getRMWebAddress();
StringBuilder api = new StringBuilder(); StringBuilder api = new StringBuilder();
api.append(url); api.append(url)
api.append("/app/v1/services"); .append("/app/v1/services");
if (appName != null) { if (appName != null) {
api.append("/"); api.append("/")
api.append(appName); .append(appName);
} }
appendUserNameIfRequired(api); appendUserNameIfRequired(api);
return api.toString(); return api.toString();
@ -168,8 +168,8 @@ private String getInstancesPath(String appName) throws IOException {
Preconditions.checkNotNull(appName); Preconditions.checkNotNull(appName);
String url = getRMWebAddress(); String url = getRMWebAddress();
StringBuilder api = new StringBuilder(); StringBuilder api = new StringBuilder();
api.append(url); api.append(url)
api.append("/app/v1/services/").append(appName).append("/") .append("/app/v1/services/").append(appName).append("/")
.append(RestApiConstants.COMP_INSTANCES); .append(RestApiConstants.COMP_INSTANCES);
appendUserNameIfRequired(api); appendUserNameIfRequired(api);
return api.toString(); return api.toString();
@ -196,8 +196,8 @@ private String getComponentsPath(String appName) throws IOException {
Preconditions.checkNotNull(appName); Preconditions.checkNotNull(appName);
String url = getRMWebAddress(); String url = getRMWebAddress();
StringBuilder api = new StringBuilder(); StringBuilder api = new StringBuilder();
api.append(url); api.append(url)
api.append("/app/v1/services/").append(appName).append("/") .append("/app/v1/services/").append(appName).append("/")
.append(RestApiConstants.COMPONENTS); .append(RestApiConstants.COMPONENTS);
appendUserNameIfRequired(api); appendUserNameIfRequired(api);
return api.toString(); return api.toString();
@ -528,16 +528,16 @@ public String getStatusString(String appIdOrName) throws IOException,
.get(ClientResponse.class); .get(ClientResponse.class);
if (response.getStatus() == 404) { if (response.getStatus() == 404) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(" Service "); sb.append(" Service ")
sb.append(appName); .append(appName)
sb.append(" not found"); .append(" not found");
return sb.toString(); return sb.toString();
} }
if (response.getStatus() != 200) { if (response.getStatus() != 200) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(appName); sb.append(appName)
sb.append(" Failed : HTTP error code : "); .append(" Failed : HTTP error code : ")
sb.append(response.getStatus()); .append(response.getStatus());
return sb.toString(); return sb.toString();
} }
output = response.getEntity(String.class); output = response.getEntity(String.class);
@ -659,9 +659,9 @@ public String getInstances(String appName, List<String> components,
ClientResponse response = getApiClient(uri).get(ClientResponse.class); ClientResponse response = getApiClient(uri).get(ClientResponse.class);
if (response.getStatus() != 200) { if (response.getStatus() != 200) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("Failed: HTTP error code: "); sb.append("Failed: HTTP error code: ")
sb.append(response.getStatus()); .append(response.getStatus())
sb.append(" ErrorMsg: ").append(response.getEntity(String.class)); .append(" ErrorMsg: ").append(response.getEntity(String.class));
return sb.toString(); return sb.toString();
} }
return response.getEntity(String.class); return response.getEntity(String.class);

View File

@ -1112,18 +1112,18 @@ public void syncSysFs(Service yarnApp) {
} else { } else {
requestPath.append("http://"); requestPath.append("http://");
} }
requestPath.append(bareHost); requestPath.append(bareHost)
requestPath.append(":"); .append(":")
requestPath.append(port); .append(port)
requestPath.append("/ws/v1/node/yarn/sysfs/"); .append("/ws/v1/node/yarn/sysfs/")
requestPath.append(UserGroupInformation.getCurrentUser() .append(UserGroupInformation.getCurrentUser()
.getShortUserName()); .getShortUserName())
requestPath.append("/"); .append("/")
requestPath.append(yarnApp.getId()); .append(yarnApp.getId());
if (!useKerberos) { if (!useKerberos) {
requestPath.append("?user.name="); requestPath.append("?user.name=")
requestPath.append(UserGroupInformation.getCurrentUser() .append(UserGroupInformation.getCurrentUser()
.getShortUserName()); .getShortUserName());
} }
Builder builder = HttpUtil.connect(requestPath.toString()); Builder builder = HttpUtil.connect(requestPath.toString());
ClientResponse response = builder.put(ClientResponse.class, spec); ClientResponse response = builder.put(ClientResponse.class, spec);

View File

@ -145,12 +145,11 @@ public int hashCode() {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class Artifact {\n"); sb.append("class Artifact {\n")
.append(" id: ").append(toIndentedString(id)).append("\n")
sb.append(" id: ").append(toIndentedString(id)).append("\n"); .append(" type: ").append(toIndentedString(type)).append("\n")
sb.append(" type: ").append(toIndentedString(type)).append("\n"); .append(" uri: ").append(toIndentedString(uri)).append("\n")
sb.append(" uri: ").append(toIndentedString(uri)).append("\n"); .append("}");
sb.append("}");
return sb.toString(); return sb.toString();
} }

View File

@ -44,9 +44,9 @@ public void setUri(String uri) {
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("BaseResource [uri="); builder.append("BaseResource [uri=")
builder.append(uri); .append(uri)
builder.append("]"); .append("]");
return builder.toString(); return builder.toString();
} }
} }

View File

@ -474,31 +474,33 @@ public int hashCode() {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class Component {\n"); sb.append("class Component {\n")
.append(" name: ").append(toIndentedString(name)).append("\n")
sb.append(" name: ").append(toIndentedString(name)).append("\n"); .append(" state: ").append(toIndentedString(state)).append("\n")
sb.append(" state: ").append(toIndentedString(state)).append("\n"); .append(" dependencies: ").append(toIndentedString(dependencies))
sb.append(" dependencies: ").append(toIndentedString(dependencies)) .append("\n")
.append("\n"); .append(" readinessCheck: ").append(toIndentedString(readinessCheck))
sb.append(" readinessCheck: ").append(toIndentedString(readinessCheck)) .append("\n")
.append("\n"); .append(" artifact: ").append(toIndentedString(artifact))
sb.append(" artifact: ").append(toIndentedString(artifact)).append("\n"); .append("\n")
sb.append(" launchCommand: ").append(toIndentedString(launchCommand)) .append(" launchCommand: ").append(toIndentedString(launchCommand))
.append("\n"); .append("\n")
sb.append(" resource: ").append(toIndentedString(resource)).append("\n"); .append(" resource: ").append(toIndentedString(resource))
sb.append(" numberOfContainers: ") .append("\n")
.append(toIndentedString(numberOfContainers)).append("\n"); .append(" numberOfContainers: ")
sb.append(" containers: ").append(toIndentedString(containers)) .append(toIndentedString(numberOfContainers)).append("\n")
.append("\n"); .append(" containers: ").append(toIndentedString(containers))
sb.append(" runPrivilegedContainer: ") .append("\n")
.append(toIndentedString(runPrivilegedContainer)).append("\n"); .append(" runPrivilegedContainer: ")
sb.append(" placementPolicy: ").append(toIndentedString(placementPolicy)) .append(toIndentedString(runPrivilegedContainer)).append("\n")
.append("\n"); .append(" placementPolicy: ")
sb.append(" configuration: ").append(toIndentedString(configuration)) .append(toIndentedString(placementPolicy))
.append("\n"); .append("\n")
sb.append(" quicklinks: ").append(toIndentedString(quicklinks)) .append(" configuration: ").append(toIndentedString(configuration))
.append("\n"); .append("\n")
sb.append("}"); .append(" quicklinks: ").append(toIndentedString(quicklinks))
.append("\n")
.append("}");
return sb.toString(); return sb.toString();
} }

View File

@ -211,13 +211,15 @@ public int hashCode() {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class ConfigFile {\n"); sb.append("class ConfigFile {\n")
sb.append(" type: ").append(toIndentedString(type)).append("\n"); .append(" type: ").append(toIndentedString(type)).append("\n")
sb.append(" destFile: ").append(toIndentedString(destFile)).append("\n"); .append(" destFile: ").append(toIndentedString(destFile))
sb.append(" srcFile: ").append(toIndentedString(srcFile)).append("\n"); .append("\n")
sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); .append(" srcFile: ").append(toIndentedString(srcFile)).append("\n")
sb.append("}"); .append(" properties: ").append(toIndentedString(properties))
.append("\n")
.append("}");
return sb.toString(); return sb.toString();
} }

View File

@ -173,13 +173,13 @@ public int hashCode() {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class Configuration {\n"); sb.append("class Configuration {\n")
sb.append(" properties: ").append(toIndentedString(properties)) .append(" properties: ").append(toIndentedString(properties))
.append("\n"); .append("\n")
sb.append(" env: ").append(toIndentedString(env)).append("\n"); .append(" env: ").append(toIndentedString(env)).append("\n")
sb.append(" files: ").append(toIndentedString(files)).append("\n"); .append(" files: ").append(toIndentedString(files)).append("\n")
sb.append("}"); .append("}");
return sb.toString(); return sb.toString();
} }

View File

@ -310,21 +310,25 @@ public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class Container {\n"); sb.append("class Container {\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n")
sb.append(" launchTime: ").append(toIndentedString(launchTime)) .append(" launchTime: ").append(toIndentedString(launchTime))
.append("\n"); .append("\n")
sb.append(" ip: ").append(toIndentedString(ip)).append("\n"); .append(" ip: ").append(toIndentedString(ip)).append("\n")
sb.append(" hostname: ").append(toIndentedString(hostname)).append("\n"); .append(" hostname: ").append(toIndentedString(hostname))
sb.append(" bareHost: ").append(toIndentedString(bareHost)).append("\n"); .append("\n")
sb.append(" state: ").append(toIndentedString(state)).append("\n"); .append(" bareHost: ").append(toIndentedString(bareHost))
sb.append(" componentInstanceName: ").append(toIndentedString( .append("\n")
componentInstanceName)) .append(" state: ").append(toIndentedString(state)).append("\n")
.append("\n"); .append(" componentInstanceName: ").append(toIndentedString(
sb.append(" resource: ").append(toIndentedString(resource)).append("\n"); componentInstanceName))
sb.append(" artifact: ").append(toIndentedString(artifact)).append("\n"); .append("\n")
sb.append(" privilegedContainer: ") .append(" resource: ").append(toIndentedString(resource))
.append(toIndentedString(privilegedContainer)).append("\n"); .append("\n")
sb.append("}"); .append(" artifact: ").append(toIndentedString(artifact))
.append("\n")
.append(" privilegedContainer: ")
.append(toIndentedString(privilegedContainer)).append("\n")
.append("}");
return sb.toString(); return sb.toString();
} }

View File

@ -106,12 +106,12 @@ public int hashCode() {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class Error {\n"); sb.append("class Error {\n")
sb.append(" code: ").append(toIndentedString(code)).append("\n"); .append(" code: ").append(toIndentedString(code)).append("\n")
sb.append(" message: ").append(toIndentedString(message)).append("\n"); .append(" message: ").append(toIndentedString(message)).append("\n")
sb.append(" fields: ").append(toIndentedString(fields)).append("\n"); .append(" fields: ").append(toIndentedString(fields)).append("\n")
sb.append("}"); .append("}");
return sb.toString(); return sb.toString();
} }

View File

@ -120,12 +120,12 @@ public int hashCode() {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class KerberosPrincipal {\n"); sb.append("class KerberosPrincipal {\n")
sb.append(" principalName: ").append(toIndentedString(principalName)) .append(" principalName: ").append(toIndentedString(principalName))
.append("\n"); .append("\n")
sb.append(" keytab: ").append(toIndentedString(keytab)).append("\n"); .append(" keytab: ").append(toIndentedString(keytab)).append("\n")
sb.append("}"); .append("}");
return sb.toString(); return sb.toString();
} }

View File

@ -248,22 +248,22 @@ public int hashCode() {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class PlacementConstraint {\n"); sb.append("class PlacementConstraint {\n")
sb.append(" name: ").append(toIndentedString(name)).append("\n"); .append(" name: ").append(toIndentedString(name)).append("\n")
sb.append(" type: ").append(toIndentedString(type)).append("\n"); .append(" type: ").append(toIndentedString(type)).append("\n")
sb.append(" scope: ").append(toIndentedString(scope)).append("\n"); .append(" scope: ").append(toIndentedString(scope)).append("\n")
sb.append(" targetTags: ").append(toIndentedString(targetTags)) .append(" targetTags: ").append(toIndentedString(targetTags))
.append("\n"); .append("\n")
sb.append(" nodeAttributes: ").append(toIndentedString(nodeAttributes)) .append(" nodeAttributes: ").append(toIndentedString(nodeAttributes))
.append("\n"); .append("\n")
sb.append(" nodePartitions: ").append(toIndentedString(nodePartitions)) .append(" nodePartitions: ").append(toIndentedString(nodePartitions))
.append("\n"); .append("\n")
sb.append(" minCardinality: ").append(toIndentedString(minCardinality)) .append(" minCardinality: ").append(toIndentedString(minCardinality))
.append("\n"); .append("\n")
sb.append(" maxCardinality: ").append(toIndentedString(maxCardinality)) .append(" maxCardinality: ").append(toIndentedString(maxCardinality))
.append("\n"); .append("\n")
sb.append("}"); .append("}");
return sb.toString(); return sb.toString();
} }

View File

@ -80,11 +80,11 @@ public int hashCode() {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class PlacementPolicy {\n"); sb.append("class PlacementPolicy {\n")
sb.append(" constraints: ").append(toIndentedString(constraints)) .append(" constraints: ").append(toIndentedString(constraints))
.append("\n"); .append("\n")
sb.append("}"); .append("}");
return sb.toString(); return sb.toString();
} }

View File

@ -173,12 +173,14 @@ public int hashCode() {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class ReadinessCheck {\n"); sb.append("class ReadinessCheck {\n")
sb.append(" type: ").append(toIndentedString(type)).append("\n"); .append(" type: ").append(toIndentedString(type)).append("\n")
sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); .append(" properties: ").append(toIndentedString(properties))
sb.append(" artifact: ").append(toIndentedString(artifact)).append("\n"); .append("\n")
sb.append("}"); .append(" artifact: ").append(toIndentedString(artifact))
.append("\n")
.append("}");
return sb.toString(); return sb.toString();
} }

View File

@ -162,14 +162,14 @@ public int hashCode() {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class Resource {\n"); sb.append("class Resource {\n")
sb.append(" profile: ").append(toIndentedString(profile)).append("\n"); .append(" profile: ").append(toIndentedString(profile)).append("\n")
sb.append(" cpus: ").append(toIndentedString(cpus)).append("\n"); .append(" cpus: ").append(toIndentedString(cpus)).append("\n")
sb.append(" memory: ").append(toIndentedString(memory)).append("\n"); .append(" memory: ").append(toIndentedString(memory)).append("\n")
sb.append(" additional: ").append( .append(" additional: ").append(
toIndentedString(additional)).append("\n"); toIndentedString(additional)).append("\n")
sb.append("}"); .append("}");
return sb.toString(); return sb.toString();
} }

View File

@ -127,13 +127,13 @@ public int hashCode() {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class ResourceInformation {\n"); sb.append("class ResourceInformation {\n")
sb.append(" value: ").append(toIndentedString(value)).append("\n"); .append(" value: ").append(toIndentedString(value)).append("\n")
sb.append(" unit: ").append(toIndentedString(unit)).append("\n"); .append(" unit: ").append(toIndentedString(unit)).append("\n")
sb.append(" attributes: ").append(toIndentedString(attributes)) .append(" attributes: ").append(toIndentedString(attributes))
.append("\n"); .append("\n")
sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); .append(" tags: ").append(toIndentedString(tags)).append("\n")
sb.append("}"); .append("}");
return sb.toString(); return sb.toString();
} }

View File

@ -424,35 +424,38 @@ public int hashCode() {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class Service {\n"); sb.append("class Service {\n")
sb.append(" name: ").append(toIndentedString(name)).append("\n"); .append(" name: ").append(toIndentedString(name)).append("\n")
sb.append(" id: ").append(toIndentedString(id)).append("\n"); .append(" id: ").append(toIndentedString(id)).append("\n")
sb.append(" version: ").append(toIndentedString(version)).append("\n"); .append(" version: ").append(toIndentedString(version)).append("\n")
sb.append(" description: ").append(toIndentedString(description)) .append(" description: ").append(toIndentedString(description))
.append("\n"); .append("\n")
sb.append(" artifact: ").append(toIndentedString(artifact)).append("\n"); .append(" artifact: ").append(toIndentedString(artifact))
sb.append(" resource: ").append(toIndentedString(resource)).append("\n"); .append("\n")
sb.append(" launchTime: ").append(toIndentedString(launchTime)) .append(" resource: ").append(toIndentedString(resource))
.append("\n"); .append("\n")
sb.append(" numberOfRunningContainers: ") .append(" launchTime: ").append(toIndentedString(launchTime))
.append(toIndentedString(numberOfRunningContainers)).append("\n"); .append("\n")
sb.append(" lifetime: ").append(toIndentedString(lifetime)).append("\n"); .append(" numberOfRunningContainers: ")
sb.append(" components: ").append(toIndentedString(components)) .append(toIndentedString(numberOfRunningContainers)).append("\n")
.append("\n"); .append(" lifetime: ").append(toIndentedString(lifetime))
sb.append(" configuration: ").append(toIndentedString(configuration)) .append("\n")
.append("\n"); .append(" components: ").append(toIndentedString(components))
sb.append(" state: ").append(toIndentedString(state)).append("\n"); .append("\n")
sb.append(" quicklinks: ").append(toIndentedString(quicklinks)) .append(" configuration: ").append(toIndentedString(configuration))
.append("\n"); .append("\n")
sb.append(" queue: ").append(toIndentedString(queue)).append("\n"); .append(" state: ").append(toIndentedString(state)).append("\n")
sb.append(" kerberosPrincipal: ") .append(" quicklinks: ").append(toIndentedString(quicklinks))
.append(toIndentedString(kerberosPrincipal)).append("\n"); .append("\n")
sb.append(" dockerClientConfig: ") .append(" queue: ").append(toIndentedString(queue)).append("\n")
.append(toIndentedString(dockerClientConfig)).append("\n"); .append(" kerberosPrincipal: ")
sb.append(" dependencies: ") .append(toIndentedString(kerberosPrincipal)).append("\n")
.append(toIndentedString(dependencies)).append("\n"); .append(" dockerClientConfig: ")
sb.append("}"); .append(toIndentedString(dockerClientConfig)).append("\n")
.append(" dependencies: ")
.append(toIndentedString(dependencies)).append("\n")
.append("}");
return sb.toString(); return sb.toString();
} }

View File

@ -124,13 +124,13 @@ public int hashCode() {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class ServiceStatus {\n"); sb.append("class ServiceStatus {\n")
sb.append(" diagnostics: ").append(toIndentedString(diagnostics)) .append(" diagnostics: ").append(toIndentedString(diagnostics))
.append("\n"); .append("\n")
sb.append(" state: ").append(toIndentedString(state)).append("\n"); .append(" state: ").append(toIndentedString(state)).append("\n")
sb.append(" code: ").append(toIndentedString(code)).append("\n"); .append(" code: ").append(toIndentedString(code)).append("\n")
sb.append("}"); .append("}");
return sb.toString(); return sb.toString();
} }

View File

@ -351,18 +351,18 @@ static void handleComponentInstanceRelaunch(ComponentInstance compInstance,
comp.reInsertPendingInstance(compInstance); comp.reInsertPendingInstance(compInstance);
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append(compInstance.getCompInstanceId()).append(": "); builder.append(compInstance.getCompInstanceId()).append(": ")
builder.append(event.getContainerId()).append( .append(event.getContainerId()).append(
" completed. Reinsert back to pending list and requested "); " completed. Reinsert back to pending list and requested ")
builder.append("a new container.").append(System.lineSeparator()); .append("a new container.").append(System.lineSeparator())
builder.append(" exitStatus=").append( .append(" exitStatus=").append(
failureBeforeLaunch || event.getStatus() == null ? null : failureBeforeLaunch || event.getStatus() == null ? null :
event.getStatus().getExitStatus()); event.getStatus().getExitStatus())
builder.append(", diagnostics="); .append(", diagnostics=")
builder.append(failureBeforeLaunch ? .append(failureBeforeLaunch ?
FAILED_BEFORE_LAUNCH_DIAG : FAILED_BEFORE_LAUNCH_DIAG :
(event.getStatus() != null ? event.getStatus().getDiagnostics() : (event.getStatus() != null ? event.getStatus().getDiagnostics() :
UPGRADE_FAILED)); UPGRADE_FAILED));
if (event.getStatus() != null && event.getStatus().getExitStatus() != 0) { if (event.getStatus() != null && event.getStatus().getExitStatus() != 0) {
LOG.error(builder.toString()); LOG.error(builder.toString());

View File

@ -166,8 +166,8 @@ public ContainerLaunchContext completeContainerLaunch() throws IOException {
if (sb.length() > 0) { if (sb.length() > 0) {
sb.append(","); sb.append(",");
} }
sb.append(mount.getKey()).append(":"); sb.append(mount.getKey()).append(":")
sb.append(mount.getValue()).append(":ro"); .append(mount.getValue()).append(":ro");
} }
env.put(ENV_DOCKER_CONTAINER_MOUNTS, sb.toString()); env.put(ENV_DOCKER_CONTAINER_MOUNTS, sb.toString());
} }

View File

@ -97,8 +97,8 @@ public FileSystem getFileSystem() {
public String toString() { public String toString() {
final StringBuilder sb = final StringBuilder sb =
new StringBuilder("CoreFileSystem{"); new StringBuilder("CoreFileSystem{");
sb.append("fileSystem=").append(fileSystem.getUri()); sb.append("fileSystem=").append(fileSystem.getUri())
sb.append('}'); .append('}');
return sb.toString(); return sb.toString();
} }

View File

@ -178,9 +178,9 @@ public PublishedConfiguration shallowCopy() {
public String toString() { public String toString() {
final StringBuilder sb = final StringBuilder sb =
new StringBuilder("PublishedConfiguration{"); new StringBuilder("PublishedConfiguration{");
sb.append("description='").append(description).append('\''); sb.append("description='").append(description).append('\'')
sb.append(" entries = ").append(entries.size()); .append(" entries = ").append(entries.size())
sb.append('}'); .append('}');
return sb.toString(); return sb.toString();
} }

View File

@ -213,8 +213,8 @@ public static String join(Collection collection,
return trailing ? separator : ""; return trailing ? separator : "";
} }
for (Object o : collection) { for (Object o : collection) {
b.append(o); b.append(o)
b.append(separator); .append(separator);
} }
int length = separator.length(); int length = separator.length();
String s = b.toString(); String s = b.toString();

View File

@ -427,12 +427,13 @@ public String getResourceProfile() {
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("Capability[").append(capability).append("]"); sb.append("Capability[").append(capability).append("]")
sb.append("Priority[").append(priority).append("]"); .append("Priority[").append(priority).append("]")
sb.append("AllocationRequestId[").append(allocationRequestId).append("]"); .append("AllocationRequestId[").append(allocationRequestId)
sb.append("ExecutionTypeRequest[").append(executionTypeRequest) .append("]")
.append("]"); .append("ExecutionTypeRequest[").append(executionTypeRequest)
sb.append("Resource Profile[").append(resourceProfile).append("]"); .append("]")
.append("Resource Profile[").append(resourceProfile).append("]");
return sb.toString(); return sb.toString();
} }

View File

@ -1245,8 +1245,8 @@ private void printResourceUsage(PrintWriter appReportStr,
private String getAllValidApplicationStates() { private String getAllValidApplicationStates() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("The valid application state can be" + " one of the following: "); sb.append("The valid application state can be" + " one of the following: ")
sb.append(ALLSTATES_OPTION + ","); .append(ALLSTATES_OPTION + ",");
for (YarnApplicationState appState : YarnApplicationState.values()) { for (YarnApplicationState appState : YarnApplicationState.values()) {
sb.append(appState + ","); sb.append(appState + ",");
} }

View File

@ -292,8 +292,8 @@ private static void printHelp(String cmd, boolean isHAEnabled) {
if (isHAEnabled) { if (isHAEnabled) {
appendHAUsage(summary); appendHAUsage(summary);
} }
summary.append(" [-help [cmd]]"); summary.append(" [-help [cmd]]")
summary.append("\n"); .append("\n");
StringBuilder helpBuilder = new StringBuilder(); StringBuilder helpBuilder = new StringBuilder();
System.out.println(summary); System.out.println(summary);
@ -513,8 +513,8 @@ private int getGroups(String[] usernames) throws IOException {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(username + " :"); sb.append(username + " :");
for (String group : adminProtocol.getGroupsForUser(username)) { for (String group : adminProtocol.getGroupsForUser(username)) {
sb.append(" "); sb.append(" ")
sb.append(group); .append(group);
} }
System.out.println(sb); System.out.println(sb);
} }

View File

@ -871,43 +871,47 @@ String getHeader(QueueMetrics queueMetrics, NodesInformation nodes) {
String currentTime = DateFormatUtils.ISO_8601_EXTENDED_TIME_FORMAT String currentTime = DateFormatUtils.ISO_8601_EXTENDED_TIME_FORMAT
.format(now); .format(now);
ret.append(CLEAR_LINE); ret.append(CLEAR_LINE)
ret.append(limitLineLength(String.format( .append(limitLineLength(String.format(
"YARN top - %s, up %s, %d active users, queue(s): %s%n", currentTime, "YARN top - %s, up %s, %d active users, queue(s): %s%n",
uptimeStr, queueMetrics.activeUsers, queue), terminalWidth, true)); currentTime, uptimeStr, queueMetrics.activeUsers, queue),
terminalWidth, true));
ret.append(CLEAR_LINE); ret.append(CLEAR_LINE)
ret.append(limitLineLength(String.format( .append(limitLineLength(String.format(
"NodeManager(s): %d total, %d active, %d unhealthy, %d decommissioned," "NodeManager(s)"
+ " %d lost, %d rebooted%n", nodes.totalNodes, nodes.runningNodes, + ": %d total, %d active, %d unhealthy, %d decommissioned,"
nodes.unhealthyNodes, nodes.decommissionedNodes, nodes.lostNodes, + " %d lost, %d rebooted%n",
nodes.rebootedNodes), terminalWidth, true)); nodes.totalNodes, nodes.runningNodes, nodes.unhealthyNodes,
nodes.decommissionedNodes, nodes.lostNodes,
nodes.rebootedNodes), terminalWidth, true));
ret.append(CLEAR_LINE); ret.append(CLEAR_LINE)
ret.append(limitLineLength(String.format( .append(limitLineLength(String.format(
"Queue(s) Applications: %d running, %d submitted, %d pending," "Queue(s) Applications: %d running, %d submitted, %d pending,"
+ " %d completed, %d killed, %d failed%n", queueMetrics.appsRunning, + " %d completed, %d killed, %d failed%n",
queueMetrics.appsSubmitted, queueMetrics.appsPending, queueMetrics.appsRunning, queueMetrics.appsSubmitted,
queueMetrics.appsCompleted, queueMetrics.appsKilled, queueMetrics.appsPending, queueMetrics.appsCompleted,
queueMetrics.appsFailed), terminalWidth, true)); queueMetrics.appsKilled, queueMetrics.appsFailed), terminalWidth,
true));
ret.append(CLEAR_LINE); ret.append(CLEAR_LINE)
ret.append(limitLineLength(String.format("Queue(s) Mem(GB): %d available," .append(limitLineLength(String.format("Queue(s) Mem(GB): %d available,"
+ " %d allocated, %d pending, %d reserved%n", + " %d allocated, %d pending, %d reserved%n",
queueMetrics.availableMemoryGB, queueMetrics.allocatedMemoryGB, queueMetrics.availableMemoryGB, queueMetrics.allocatedMemoryGB,
queueMetrics.pendingMemoryGB, queueMetrics.reservedMemoryGB), queueMetrics.pendingMemoryGB, queueMetrics.reservedMemoryGB),
terminalWidth, true)); terminalWidth, true));
ret.append(CLEAR_LINE); ret.append(CLEAR_LINE)
ret.append(limitLineLength(String.format("Queue(s) VCores: %d available," .append(limitLineLength(String.format("Queue(s) VCores: %d available,"
+ " %d allocated, %d pending, %d reserved%n", + " %d allocated, %d pending, %d reserved%n",
queueMetrics.availableVCores, queueMetrics.allocatedVCores, queueMetrics.availableVCores, queueMetrics.allocatedVCores,
queueMetrics.pendingVCores, queueMetrics.reservedVCores), terminalWidth, queueMetrics.pendingVCores, queueMetrics.reservedVCores),
true)); terminalWidth, true));
ret.append(CLEAR_LINE); ret.append(CLEAR_LINE)
ret.append(limitLineLength(String.format( .append(limitLineLength(String.format(
"Queue(s) Containers: %d allocated, %d pending, %d reserved%n", "Queue(s) Containers: %d allocated, %d pending, %d reserved%n",
queueMetrics.allocatedContainers, queueMetrics.pendingContainers, queueMetrics.allocatedContainers, queueMetrics.pendingContainers,
queueMetrics.reservedContainers), terminalWidth, true)); queueMetrics.reservedContainers), terminalWidth, true));
return ret.toString(); return ret.toString();

View File

@ -404,18 +404,18 @@ private ExecutionTypeProto convertToProtoFormat(ExecutionType e) {
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("Container: ["); sb.append("Container: [")
sb.append("ContainerId: ").append(getId()).append(", "); .append("ContainerId: ").append(getId()).append(", ")
sb.append("AllocationRequestId: ").append(getAllocationRequestId()) .append("AllocationRequestId: ").append(getAllocationRequestId())
.append(", "); .append(", ")
sb.append("Version: ").append(getVersion()).append(", "); .append("Version: ").append(getVersion()).append(", ")
sb.append("NodeId: ").append(getNodeId()).append(", "); .append("NodeId: ").append(getNodeId()).append(", ")
sb.append("NodeHttpAddress: ").append(getNodeHttpAddress()).append(", "); .append("NodeHttpAddress: ").append(getNodeHttpAddress()).append(", ")
sb.append("Resource: ").append(getResource()).append(", "); .append("Resource: ").append(getResource()).append(", ")
sb.append("Priority: ").append(getPriority()).append(", "); .append("Priority: ").append(getPriority()).append(", ")
sb.append("Token: ").append(getContainerToken()).append(", "); .append("Token: ").append(getContainerToken()).append(", ")
sb.append("ExecutionType: ").append(getExecutionType()).append(", "); .append("ExecutionType: ").append(getExecutionType()).append(", ")
sb.append("]"); .append("]");
return sb.toString(); return sb.toString();
} }

View File

@ -90,18 +90,18 @@ public boolean equals(Object other) {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("ContainerStatus: ["); sb.append("ContainerStatus: [")
sb.append("ContainerId: ").append(getContainerId()).append(", "); .append("ContainerId: ").append(getContainerId()).append(", ")
sb.append("ExecutionType: ").append(getExecutionType()).append(", "); .append("ExecutionType: ").append(getExecutionType()).append(", ")
sb.append("State: ").append(getState()).append(", "); .append("State: ").append(getState()).append(", ")
sb.append("Capability: ").append(getCapability()).append(", "); .append("Capability: ").append(getCapability()).append(", ")
sb.append("Diagnostics: ").append(getDiagnostics()).append(", "); .append("Diagnostics: ").append(getDiagnostics()).append(", ")
sb.append("ExitStatus: ").append(getExitStatus()).append(", "); .append("ExitStatus: ").append(getExitStatus()).append(", ")
sb.append("IP: ").append(getIPs()).append(", "); .append("IP: ").append(getIPs()).append(", ")
sb.append("Host: ").append(getHost()).append(", "); .append("Host: ").append(getHost()).append(", ")
sb.append("ExposedPorts: ").append(getExposedPorts()).append(", "); .append("ExposedPorts: ").append(getExposedPorts()).append(", ")
sb.append("ContainerSubState: ").append(getContainerSubState()); .append("ContainerSubState: ").append(getContainerSubState())
sb.append("]"); .append("]");
return sb.toString(); return sb.toString();
} }

View File

@ -77,12 +77,12 @@ public boolean equals(Object other) {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("LocalizationStatus: ["); sb.append("LocalizationStatus: [")
sb.append("ResourceKey: ").append(getResourceKey()).append(", "); .append("ResourceKey: ").append(getResourceKey()).append(", ")
sb.append("LocalizationState: ").append(getLocalizationState()) .append("LocalizationState: ").append(getLocalizationState())
.append(", "); .append(", ")
sb.append("Diagnostics: ").append(getDiagnostics()).append(", "); .append("Diagnostics: ").append(getDiagnostics()).append(", ")
sb.append("]"); .append("]");
return sb.toString(); return sb.toString();
} }

View File

@ -184,9 +184,9 @@ public synchronized void setService(String service) {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("Token { "); sb.append("Token { ")
sb.append("kind: ").append(getKind()).append(", "); .append("kind: ").append(getKind()).append(", ")
sb.append("service: ").append(getService()).append(" }"); .append("service: ").append(getService()).append(" }");
return sb.toString(); return sb.toString();
} }
} }

View File

@ -276,9 +276,9 @@ private void checkRetryWithSleep(int retries, IOException e)
} else { } else {
StringBuilder msg = StringBuilder msg =
new StringBuilder("TimelineClient has reached to max retry times : "); new StringBuilder("TimelineClient has reached to max retry times : ");
msg.append(this.maxServiceRetries); msg.append(this.maxServiceRetries)
msg.append(" for service address: "); .append(" for service address: ")
msg.append(timelineServiceAddress); .append(timelineServiceAddress);
LOG.error(msg.toString()); LOG.error(msg.toString());
throw new IOException(msg.toString(), e); throw new IOException(msg.toString(), e);
} }

View File

@ -89,13 +89,13 @@ public static void outputContainerLog(String containerId, String nodeId,
String containerStr = String.format( String containerStr = String.format(
LogToolUtils.CONTAINER_ON_NODE_PATTERN, LogToolUtils.CONTAINER_ON_NODE_PATTERN,
containerId, nodeId); containerId, nodeId);
sb.append(containerStr + "\n"); sb.append(containerStr + "\n")
sb.append("LogAggregationType: " + logType + "\n"); .append("LogAggregationType: " + logType + "\n")
sb.append(StringUtils.repeat("=", containerStr.length()) + "\n"); .append(StringUtils.repeat("=", containerStr.length()) + "\n")
sb.append("LogType:" + fileName + "\n"); .append("LogType:" + fileName + "\n")
sb.append("LogLastModifiedTime:" + lastModifiedTime + "\n"); .append("LogLastModifiedTime:" + lastModifiedTime + "\n")
sb.append("LogLength:" + Long.toString(fileLength) + "\n"); .append("LogLength:" + Long.toString(fileLength) + "\n")
sb.append("LogContents:\n"); .append("LogContents:\n");
byte[] b = sb.toString().getBytes( byte[] b = sb.toString().getBytes(
Charset.forName("UTF-8")); Charset.forName("UTF-8"));
os.write(b, 0, b.length); os.write(b, 0, b.length);
@ -138,13 +138,13 @@ public static void outputContainerLogThroughZeroCopy(String containerId,
String containerStr = String.format( String containerStr = String.format(
LogToolUtils.CONTAINER_ON_NODE_PATTERN, LogToolUtils.CONTAINER_ON_NODE_PATTERN,
containerId, nodeId); containerId, nodeId);
sb.append(containerStr + "\n"); sb.append(containerStr + "\n")
sb.append("LogAggregationType: " + logType + "\n"); .append("LogAggregationType: " + logType + "\n")
sb.append(StringUtils.repeat("=", containerStr.length()) + "\n"); .append(StringUtils.repeat("=", containerStr.length()) + "\n")
sb.append("LogType:" + fileName + "\n"); .append("LogType:" + fileName + "\n")
sb.append("LogLastModifiedTime:" + lastModifiedTime + "\n"); .append("LogLastModifiedTime:" + lastModifiedTime + "\n")
sb.append("LogLength:" + Long.toString(fileLength) + "\n"); .append("LogLength:" + Long.toString(fileLength) + "\n")
sb.append("LogContents:\n"); .append("LogContents:\n");
byte[] b = sb.toString().getBytes( byte[] b = sb.toString().getBytes(
Charset.forName("UTF-8")); Charset.forName("UTF-8"));
os.write(b, 0, b.length); os.write(b, 0, b.length);

View File

@ -531,9 +531,9 @@ public Object run() throws Exception {
protected String aggregatedLogSuffix(String fileName) { protected String aggregatedLogSuffix(String fileName) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
String endOfFile = "End of LogType:" + fileName; String endOfFile = "End of LogType:" + fileName;
sb.append("\n" + endOfFile + "\n"); sb.append("\n" + endOfFile + "\n")
sb.append(StringUtils.repeat("*", endOfFile.length() + 50) .append(StringUtils.repeat("*", endOfFile.length() + 50)
+ "\n\n"); + "\n\n");
return sb.toString(); return sb.toString();
} }

View File

@ -150,18 +150,19 @@ private static String wrapSafeString(String label) {
public String generateGraphViz(String indent) { public String generateGraphViz(String indent) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (this.parent == null) { if (this.parent == null) {
sb.append("digraph " + name + " {\n"); sb.append("digraph " + name + " {\n")
sb.append(String.format("graph [ label=%s, fontsize=24, fontname=Helvetica];%n", .append(String.format(
wrapSafeString(name))); "graph [ label=%s, fontsize=24, fontname=Helvetica];%n",
sb.append("node [fontsize=12, fontname=Helvetica];\n"); wrapSafeString(name)))
sb.append("edge [fontsize=9, fontcolor=blue, fontname=Arial];\n"); .append("node [fontsize=12, fontname=Helvetica];\n")
.append("edge [fontsize=9, fontcolor=blue, fontname=Arial];\n");
} else { } else {
sb.append("subgraph cluster_" + name + " {\nlabel=\"" + name + "\"\n"); sb.append("subgraph cluster_" + name + " {\nlabel=\"" + name + "\"\n");
} }
for (Graph g : subgraphs) { for (Graph g : subgraphs) {
String ginfo = g.generateGraphViz(indent+" "); String ginfo = g.generateGraphViz(indent+" ");
sb.append(ginfo); sb.append(ginfo)
sb.append("\n"); .append("\n");
} }
for (Node n : nodes) { for (Node n : nodes) {
sb.append(String.format( sb.append(String.format(

View File

@ -979,9 +979,9 @@ public void setMemInfo(String key, String value) {
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("\t").append(this.getName()).append("\n"); sb.append("\t").append(this.getName()).append("\n")
sb.append("\t").append(MemInfo.SIZE.name + ":" + this.getSize()) .append("\t").append(MemInfo.SIZE.name + ":" + this.getSize())
.append(" kB\n"); .append(" kB\n");
sb.append("\t").append(MemInfo.PSS.name + ":" + this.getPss()) sb.append("\t").append(MemInfo.PSS.name + ":" + this.getPss())
.append(" kB\n"); .append(" kB\n");
sb.append("\t").append(MemInfo.RSS.name + ":" + this.getRss()) sb.append("\t").append(MemInfo.RSS.name + ":" + this.getRss())

View File

@ -47,11 +47,12 @@ protected void preHead(Page.HTML<__> html) {
private String tablesInit() { private String tablesInit() {
StringBuilder b = tableInit().append(", aoColumnDefs: ["); StringBuilder b = tableInit().append(", aoColumnDefs: [");
b.append("{'sType': 'string', 'aTargets': [ 0 ]}"); b.append("{'sType': 'string', 'aTargets': [ 0 ]}")
b.append(", {'sType': 'string', 'bSearchable': true, 'aTargets': [ 1 ]}"); .append(", {'sType': 'string', 'bSearchable': true, 'aTargets': [ 1 ]}")
b.append(", {'sType': 'numeric', 'bSearchable': false, 'aTargets': [ 2 ]}"); .append(
b.append(", {'sType': 'date', 'aTargets': [ 3 ] }]"); ", {'sType': 'numeric', 'bSearchable': false, 'aTargets': [ 2 ]}")
b.append(", aaSorting: [[3, 'desc']]}"); .append(", {'sType': 'date', 'aTargets': [ 3 ] }]")
.append(", aaSorting: [[3, 'desc']]}");
return b.toString(); return b.toString();
} }
} }

View File

@ -154,9 +154,9 @@ public boolean equals(Object obj) {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(getType()); sb.append(getType())
sb.append(" : "); .append(" : ")
sb.append(getParams()); .append(getParams());
return sb.toString(); return sb.toString();
} }
} }

View File

@ -516,8 +516,8 @@ public Map<String, SubClusterPolicyConfiguration> invoke(
protected String buildCacheKey(String typeName, String methodName, protected String buildCacheKey(String typeName, String methodName,
String argName) { String argName) {
StringBuilder buffer = new StringBuilder(); StringBuilder buffer = new StringBuilder();
buffer.append(typeName).append("."); buffer.append(typeName).append(".")
buffer.append(methodName); .append(methodName);
if (argName != null) { if (argName != null) {
buffer.append("::"); buffer.append("::");
buffer.append(argName); buffer.append(argName);

View File

@ -71,8 +71,8 @@ public static String getCacheEntryPath(int cacheDepth, String cacheRoot,
// SHARED_CACHE_ROOT/3/c/4/3c4f // SHARED_CACHE_ROOT/3/c/4/3c4f
StringBuilder sb = new StringBuilder(cacheRoot); StringBuilder sb = new StringBuilder(cacheRoot);
for (int i = 0; i < cacheDepth; i++) { for (int i = 0; i < cacheDepth; i++) {
sb.append(Path.SEPARATOR_CHAR); sb.append(Path.SEPARATOR_CHAR)
sb.append(checksum.charAt(i)); .append(checksum.charAt(i));
} }
sb.append(Path.SEPARATOR_CHAR).append(checksum); sb.append(Path.SEPARATOR_CHAR).append(checksum);

View File

@ -331,17 +331,17 @@ public int launchContainer(ContainerStartContext ctx)
+ containerId + " and exit code: " + exitCode , e); + containerId + " and exit code: " + exitCode , e);
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("Exception from container-launch.\n"); builder.append("Exception from container-launch.\n")
builder.append("Container id: ").append(containerId).append("\n"); .append("Container id: ").append(containerId).append("\n")
builder.append("Exit code: ").append(exitCode).append("\n"); .append("Exit code: ").append(exitCode).append("\n");
if (!Optional.fromNullable(e.getMessage()).or("").isEmpty()) { if (!Optional.fromNullable(e.getMessage()).or("").isEmpty()) {
builder.append("Exception message: "); builder.append("Exception message: ")
builder.append(e.getMessage()).append("\n"); .append(e.getMessage()).append("\n");
} }
if (!shExec.getOutput().isEmpty()) { if (!shExec.getOutput().isEmpty()) {
builder.append("Shell output: "); builder.append("Shell output: ")
builder.append(shExec.getOutput()).append("\n"); .append(shExec.getOutput()).append("\n");
} }
String diagnostics = builder.toString(); String diagnostics = builder.toString();
logOutput(diagnostics); logOutput(diagnostics);

View File

@ -597,10 +597,10 @@ private int handleExitCode(ContainerExecutionException e, Container container,
+ containerId + " and exit code: " + exitCode, e); + containerId + " and exit code: " + exitCode, e);
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("Exception from container-launch.\n"); builder.append("Exception from container-launch.\n")
builder.append("Container id: " + containerId + "\n"); .append("Container id: " + containerId + "\n")
builder.append("Exit code: " + exitCode + "\n"); .append("Exit code: " + exitCode + "\n")
builder.append("Exception message: " + e.getMessage() + "\n"); .append("Exception message: " + e.getMessage() + "\n");
if (!Optional.fromNullable(e.getErrorOutput()).or("").isEmpty()) { if (!Optional.fromNullable(e.getErrorOutput()).or("").isEmpty()) {
builder.append("Shell error output: " + e.getErrorOutput() + "\n"); builder.append("Shell error output: " + e.getErrorOutput() + "\n");
} }

View File

@ -779,8 +779,8 @@ public KillApplicationResponse forceKillApplication(
String diagnostics = org.apache.commons.lang3.StringUtils String diagnostics = org.apache.commons.lang3.StringUtils
.trimToNull(request.getDiagnostics()); .trimToNull(request.getDiagnostics());
if (diagnostics != null) { if (diagnostics != null) {
message.append(" with diagnostic message: "); message.append(" with diagnostic message: ")
message.append(diagnostics); .append(diagnostics);
} }
this.rmContext.getDispatcher().getEventHandler() this.rmContext.getDispatcher().getEventHandler()

View File

@ -352,8 +352,8 @@ public void run() {
LOG.info("Error cleaning master ", ie); LOG.info("Error cleaning master ", ie);
} catch (YarnException e) { } catch (YarnException e) {
StringBuilder sb = new StringBuilder("Container "); StringBuilder sb = new StringBuilder("Container ");
sb.append(masterContainer.getId().toString()); sb.append(masterContainer.getId().toString())
sb.append(" is not handled by this NodeManager"); .append(" is not handled by this NodeManager");
if (!e.getMessage().contains(sb.toString())) { if (!e.getMessage().contains(sb.toString())) {
// Ignoring if container is already killed by Node Manager. // Ignoring if container is already killed by Node Manager.
LOG.info("Error cleaning master ", e); LOG.info("Error cleaning master ", e);

View File

@ -127,9 +127,9 @@ public void init(Configuration config, RMContext rmContext,
} }
invariants.put(inv, scriptEngine.compile(inv)); invariants.put(inv, scriptEngine.compile(inv));
sb.append(" ("); sb.append(" (")
sb.append(inv); .append(inv)
sb.append(") "); .append(") ");
} }
// create a single large combined invariant for speed of checking // create a single large combined invariant for speed of checking

View File

@ -194,11 +194,11 @@ protected void internalUpdateAttributesOnNodes(
default: default:
break; break;
} }
logMsg.append(" NM = "); logMsg.append(" NM = ")
logMsg.append(entry.getKey()); .append(entry.getKey())
logMsg.append(", attributes=[ "); .append(", attributes=[ ")
logMsg.append(StringUtils.join(entry.getValue().keySet(), ",")); .append(StringUtils.join(entry.getValue().keySet(), ","))
logMsg.append("] ,"); .append("] ,");
} }
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {

View File

@ -56,15 +56,15 @@ public AbstractResourceUsage() {
} }
/** /**
* Use enum here to make implementation more cleaner and readable. * Use enum here to make implementation more cleaner and readable. Indicates
* Indicates array index for each resource usage type. * array index for each resource usage type.
*/ */
public enum ResourceType { public enum ResourceType {
// CACHED_USED and CACHED_PENDING may be read by anyone, but must only // CACHED_USED and CACHED_PENDING may be read by anyone, but must only
// be written by ordering policies // be written by ordering policies
USED(0), PENDING(1), AMUSED(2), RESERVED(3), CACHED_USED(4), CACHED_PENDING( USED(0), PENDING(1), AMUSED(2), RESERVED(3), CACHED_USED(4), CACHED_PENDING(
5), AMLIMIT(6), MIN_RESOURCE(7), MAX_RESOURCE(8), EFF_MIN_RESOURCE( 5), AMLIMIT(6), MIN_RESOURCE(7), MAX_RESOURCE(
9), EFF_MAX_RESOURCE(10), USERAMLIMIT(11); 8), EFF_MIN_RESOURCE(9), EFF_MAX_RESOURCE(10), USERAMLIMIT(11);
private int idx; private int idx;
@ -94,13 +94,14 @@ public Resource getUsed() {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("{used=" + resArr.get(ResourceType.USED.idx) + ", "); sb.append("{used=" + resArr.get(ResourceType.USED.idx) + ", ")
sb.append("pending=" + resArr.get(ResourceType.PENDING.idx) + ", "); .append("pending=" + resArr.get(ResourceType.PENDING.idx) + ", ")
sb.append("am_used=" + resArr.get(ResourceType.AMUSED.idx) + ", "); .append("am_used=" + resArr.get(ResourceType.AMUSED.idx) + ", ")
sb.append("reserved=" + resArr.get(ResourceType.RESERVED.idx) + ", "); .append("reserved=" + resArr.get(ResourceType.RESERVED.idx) + ", ")
sb.append("min_eff=" + resArr.get(ResourceType.EFF_MIN_RESOURCE.idx) + ", "); .append(
sb.append( "min_eff=" + resArr.get(ResourceType.EFF_MIN_RESOURCE.idx) + ", ")
"max_eff=" + resArr.get(ResourceType.EFF_MAX_RESOURCE.idx) + "}"); .append(
"max_eff=" + resArr.get(ResourceType.EFF_MAX_RESOURCE.idx) + "}");
return sb.toString(); return sb.toString();
} }
} }
@ -134,7 +135,7 @@ protected Resource _getAll(ResourceType type) {
readLock.lock(); readLock.lock();
Resource allOfType = Resources.createResource(0); Resource allOfType = Resources.createResource(0);
for (Map.Entry<String, UsageByLabel> usageEntry : usages.entrySet()) { for (Map.Entry<String, UsageByLabel> usageEntry : usages.entrySet()) {
//all usages types are initialized // all usages types are initialized
Resources.addTo(allOfType, usageEntry.getValue().resArr.get(type.idx)); Resources.addTo(allOfType, usageEntry.getValue().resArr.get(type.idx));
} }
return allOfType; return allOfType;

View File

@ -1357,9 +1357,9 @@ public void updateAMContainerDiagnostics(AMState state,
return; return;
} }
StringBuilder diagnosticMessageBldr = new StringBuilder(); StringBuilder diagnosticMessageBldr = new StringBuilder();
diagnosticMessageBldr.append("["); diagnosticMessageBldr.append("[")
diagnosticMessageBldr.append(fdf.format(System.currentTimeMillis())); .append(fdf.format(System.currentTimeMillis()))
diagnosticMessageBldr.append("] "); .append("] ");
switch (state) { switch (state) {
case INACTIVATED: case INACTIVATED:
diagnosticMessageBldr.append(state.diagnosticMessage); diagnosticMessageBldr.append(state.diagnosticMessage);

View File

@ -94,9 +94,9 @@ public boolean getType() {
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(this.activityNodeName + " "); sb.append(this.activityNodeName + " ")
sb.append(this.appPriority + " "); .append(this.appPriority + " ")
sb.append(this.state + " "); .append(this.state + " ");
if (!this.diagnostic.equals("")) { if (!this.diagnostic.equals("")) {
sb.append(this.diagnostic + "\n"); sb.append(this.diagnostic + "\n");
} }

View File

@ -249,8 +249,8 @@ protected void setupQueueConfigs(Resource clusterResource,
StringBuilder labelStrBuilder = new StringBuilder(); StringBuilder labelStrBuilder = new StringBuilder();
if (accessibleLabels != null) { if (accessibleLabels != null) {
for (String s : accessibleLabels) { for (String s : accessibleLabels) {
labelStrBuilder.append(s); labelStrBuilder.append(s)
labelStrBuilder.append(","); .append(",");
} }
} }

View File

@ -136,8 +136,8 @@ protected void setupQueueConfigs(Resource clusterResource)
StringBuilder labelStrBuilder = new StringBuilder(); StringBuilder labelStrBuilder = new StringBuilder();
if (accessibleLabels != null) { if (accessibleLabels != null) {
for (String s : accessibleLabels) { for (String s : accessibleLabels) {
labelStrBuilder.append(s); labelStrBuilder.append(s)
labelStrBuilder.append(","); .append(",");
} }
} }

View File

@ -69,15 +69,15 @@ public Capacities() {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("{used=" + capacitiesArr[0] + "%, "); sb.append("{used=" + capacitiesArr[0] + "%, ")
sb.append("abs_used=" + capacitiesArr[1] + "%, "); .append("abs_used=" + capacitiesArr[1] + "%, ")
sb.append("max_cap=" + capacitiesArr[2] + "%, "); .append("max_cap=" + capacitiesArr[2] + "%, ")
sb.append("abs_max_cap=" + capacitiesArr[3] + "%, "); .append("abs_max_cap=" + capacitiesArr[3] + "%, ")
sb.append("cap=" + capacitiesArr[4] + "%, "); .append("cap=" + capacitiesArr[4] + "%, ")
sb.append("abs_cap=" + capacitiesArr[5] + "%}"); .append("abs_cap=" + capacitiesArr[5] + "%}")
sb.append("max_am_perc=" + capacitiesArr[6] + "%}"); .append("max_am_perc=" + capacitiesArr[6] + "%}")
sb.append("reserved_cap=" + capacitiesArr[7] + "%}"); .append("reserved_cap=" + capacitiesArr[7] + "%}")
sb.append("abs_reserved_cap=" + capacitiesArr[8] + "%}"); .append("abs_reserved_cap=" + capacitiesArr[8] + "%}");
return sb.toString(); return sb.toString();
} }
} }

View File

@ -53,11 +53,11 @@ public int getCount() {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("<per-allocation-resource="); sb.append("<per-allocation-resource=")
sb.append(getPerAllocationResource()); .append(getPerAllocationResource())
sb.append(",repeat="); .append(",repeat=")
sb.append(getCount()); .append(getCount())
sb.append(">"); .append(">");
return sb.toString(); return sb.toString();
} }
} }

View File

@ -999,25 +999,24 @@ public void nodePartitionUpdated(RMContainer rmContainer, String oldPartition,
protected void getPendingAppDiagnosticMessage( protected void getPendingAppDiagnosticMessage(
StringBuilder diagnosticMessage) { StringBuilder diagnosticMessage) {
LeafQueue queue = getCSLeafQueue(); LeafQueue queue = getCSLeafQueue();
diagnosticMessage.append(" Details : AM Partition = "); diagnosticMessage.append(" Details : AM Partition = ")
diagnosticMessage.append(appAMNodePartitionName.isEmpty() .append(appAMNodePartitionName.isEmpty()
? NodeLabel.DEFAULT_NODE_LABEL_PARTITION : appAMNodePartitionName); ? NodeLabel.DEFAULT_NODE_LABEL_PARTITION : appAMNodePartitionName)
diagnosticMessage.append("; "); .append("; ")
diagnosticMessage.append("AM Resource Request = "); .append("AM Resource Request = ")
diagnosticMessage.append(getAMResource(appAMNodePartitionName)); .append(getAMResource(appAMNodePartitionName))
diagnosticMessage.append("; "); .append("; ")
diagnosticMessage.append("Queue Resource Limit for AM = "); .append("Queue Resource Limit for AM = ")
diagnosticMessage .append(queue.getAMResourceLimitPerPartition(appAMNodePartitionName))
.append(queue.getAMResourceLimitPerPartition(appAMNodePartitionName)); .append("; ")
diagnosticMessage.append("; "); .append("User AM Resource Limit of the queue = ")
diagnosticMessage.append("User AM Resource Limit of the queue = "); .append(queue.getUserAMResourceLimitPerPartition(
diagnosticMessage.append(queue.getUserAMResourceLimitPerPartition( appAMNodePartitionName, getUser()))
appAMNodePartitionName, getUser())); .append("; ")
diagnosticMessage.append("; "); .append("Queue AM Resource Usage = ")
diagnosticMessage.append("Queue AM Resource Usage = "); .append(
diagnosticMessage.append( queue.getQueueResourceUsage().getAMUsed(appAMNodePartitionName))
queue.getQueueResourceUsage().getAMUsed(appAMNodePartitionName)); .append("; ");
diagnosticMessage.append("; ");
} }
protected void getActivedAppDiagnosticMessage( protected void getActivedAppDiagnosticMessage(
@ -1025,39 +1024,39 @@ protected void getActivedAppDiagnosticMessage(
LeafQueue queue = getCSLeafQueue(); LeafQueue queue = getCSLeafQueue();
QueueCapacities queueCapacities = queue.getQueueCapacities(); QueueCapacities queueCapacities = queue.getQueueCapacities();
QueueResourceQuotas queueResourceQuotas = queue.getQueueResourceQuotas(); QueueResourceQuotas queueResourceQuotas = queue.getQueueResourceQuotas();
diagnosticMessage.append(" Details : AM Partition = "); diagnosticMessage.append(" Details : AM Partition = ")
diagnosticMessage.append(appAMNodePartitionName.isEmpty() .append(appAMNodePartitionName.isEmpty()
? NodeLabel.DEFAULT_NODE_LABEL_PARTITION : appAMNodePartitionName); ? NodeLabel.DEFAULT_NODE_LABEL_PARTITION : appAMNodePartitionName)
diagnosticMessage.append(" ; "); .append(" ; ")
diagnosticMessage.append("Partition Resource = "); .append("Partition Resource = ")
diagnosticMessage.append(rmContext.getNodeLabelManager() .append(rmContext.getNodeLabelManager()
.getResourceByLabel(appAMNodePartitionName, Resources.none())); .getResourceByLabel(appAMNodePartitionName, Resources.none()))
diagnosticMessage.append(" ; "); .append(" ; ")
diagnosticMessage.append("Queue's Absolute capacity = "); .append("Queue's Absolute capacity = ")
diagnosticMessage.append( .append(
queueCapacities.getAbsoluteCapacity(appAMNodePartitionName) * 100); queueCapacities.getAbsoluteCapacity(appAMNodePartitionName) * 100)
diagnosticMessage.append(" % ; "); .append(" % ; ")
diagnosticMessage.append("Queue's Absolute used capacity = "); .append("Queue's Absolute used capacity = ")
diagnosticMessage.append( .append(
queueCapacities.getAbsoluteUsedCapacity(appAMNodePartitionName) * 100); queueCapacities.getAbsoluteUsedCapacity(appAMNodePartitionName)
diagnosticMessage.append(" % ; "); * 100)
diagnosticMessage.append("Queue's Absolute max capacity = "); .append(" % ; ")
diagnosticMessage.append( .append("Queue's Absolute max capacity = ")
queueCapacities.getAbsoluteMaximumCapacity(appAMNodePartitionName) .append(
* 100); queueCapacities.getAbsoluteMaximumCapacity(appAMNodePartitionName)
diagnosticMessage.append(" % ; "); * 100)
diagnosticMessage.append("Queue's capacity (absolute resource) = "); .append(" % ; ")
diagnosticMessage.append( .append("Queue's capacity (absolute resource) = ")
queueResourceQuotas.getEffectiveMinResource(appAMNodePartitionName)); .append(
diagnosticMessage.append(" ; "); queueResourceQuotas.getEffectiveMinResource(appAMNodePartitionName))
diagnosticMessage.append("Queue's used capacity (absolute resource) = "); .append(" ; ")
diagnosticMessage .append("Queue's used capacity (absolute resource) = ")
.append(queue.getQueueResourceUsage().getUsed(appAMNodePartitionName)); .append(queue.getQueueResourceUsage().getUsed(appAMNodePartitionName))
diagnosticMessage.append(" ; "); .append(" ; ")
diagnosticMessage.append("Queue's max capacity (absolute resource) = "); .append("Queue's max capacity (absolute resource) = ")
diagnosticMessage.append( .append(
queueResourceQuotas.getEffectiveMaxResource(appAMNodePartitionName)); queueResourceQuotas.getEffectiveMaxResource(appAMNodePartitionName))
diagnosticMessage.append(" ; "); .append(" ; ");
} }
/** /**
@ -1082,15 +1081,15 @@ public void updateNodeInfoForAMDiagnostics(FiCaSchedulerNode node) {
appSkipNodeDiagnostics = null; appSkipNodeDiagnostics = null;
} }
diagnosticMessageBldr.append( diagnosticMessageBldr.append(
CSAMContainerLaunchDiagnosticsConstants.LAST_NODE_PROCESSED_MSG); CSAMContainerLaunchDiagnosticsConstants.LAST_NODE_PROCESSED_MSG)
diagnosticMessageBldr.append(node.getNodeID()); .append(node.getNodeID())
diagnosticMessageBldr.append(" ( Partition : "); .append(" ( Partition : ")
diagnosticMessageBldr.append(node.getLabels()); .append(node.getLabels())
diagnosticMessageBldr.append(", Total resource : "); .append(", Total resource : ")
diagnosticMessageBldr.append(node.getTotalResource()); .append(node.getTotalResource())
diagnosticMessageBldr.append(", Available resource : "); .append(", Available resource : ")
diagnosticMessageBldr.append(node.getUnallocatedResource()); .append(node.getUnallocatedResource())
diagnosticMessageBldr.append(" )."); .append(" ).");
updateAMContainerDiagnostics(AMState.ACTIVATED, diagnosticMessageBldr.toString()); updateAMContainerDiagnostics(AMState.ACTIVATED, diagnosticMessageBldr.toString());
} }
} }

View File

@ -48,8 +48,8 @@ public ApplicationAttemptId getAppId() {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(super.toString()); StringBuilder sb = new StringBuilder(super.toString());
sb.append(" ").append(getAppId()); sb.append(" ").append(getAppId())
sb.append(" ").append(getContainer().getContainerId()); .append(" ").append(getContainer().getContainerId());
return sb.toString(); return sb.toString();
} }

View File

@ -1399,9 +1399,9 @@ private void updateAMDiagnosticMsg(Resource resource, String reason) {
} }
StringBuilder diagnosticMessageBldr = new StringBuilder(); StringBuilder diagnosticMessageBldr = new StringBuilder();
diagnosticMessageBldr.append(" (Resource request: "); diagnosticMessageBldr.append(" (Resource request: ")
diagnosticMessageBldr.append(resource); .append(resource)
diagnosticMessageBldr.append(reason); .append(reason);
updateAMContainerDiagnostics(AMState.INACTIVATED, updateAMContainerDiagnostics(AMState.INACTIVATED,
diagnosticMessageBldr.toString()); diagnosticMessageBldr.toString());
} }

View File

@ -233,12 +233,12 @@ protected Class<? extends SubView> content() {
private String nodesTableInit() { private String nodesTableInit() {
StringBuilder b = tableInit().append(", 'aaData': nodeTableData") StringBuilder b = tableInit().append(", 'aaData': nodeTableData")
.append(", bDeferRender: true").append(", bProcessing: true") .append(", bDeferRender: true").append(", bProcessing: true")
.append(", aoColumnDefs: ["); .append(", aoColumnDefs: [")
b.append("{'bSearchable': false, 'aTargets': [ 7 ]}"); .append("{'bSearchable': false, 'aTargets': [ 7 ]}")
b.append(", {'sType': 'title-numeric', 'bSearchable': false, " .append(", {'sType': 'title-numeric', 'bSearchable': false, "
+ "'aTargets': [ 9, 10 ] }"); + "'aTargets': [ 9, 10 ] }")
b.append(", {'sType': 'title-numeric', 'aTargets': [ 5 ]}"); .append(", {'sType': 'title-numeric', 'aTargets': [ 5 ]}")
b.append("]}"); .append("]}");
return b.toString(); return b.toString();
} }
} }

View File

@ -44,11 +44,12 @@ protected void preHead(Page.HTML<__> html) {
private String tablesInit() { private String tablesInit() {
StringBuilder b = tableInit().append(", aoColumnDefs: ["); StringBuilder b = tableInit().append(", aoColumnDefs: [");
b.append("{'sType': 'string', 'aTargets': [ 0 ]}"); b.append("{'sType': 'string', 'aTargets': [ 0 ]}")
b.append(", {'sType': 'string', 'bSearchable': true, 'aTargets': [ 1 ]}"); .append(", {'sType': 'string', 'bSearchable': true, 'aTargets': [ 1 ]}")
b.append(", {'sType': 'numeric', 'bSearchable': false, 'aTargets': [ 2 ]}"); .append(
b.append(", {'sType': 'date', 'aTargets': [ 3 ] }]"); ", {'sType': 'numeric', 'bSearchable': false, 'aTargets': [ 2 ]}")
b.append(", aaSorting: [[3, 'desc']]}"); .append(", {'sType': 'date', 'aTargets': [ 3 ] }]")
.append(", aaSorting: [[3, 'desc']]}");
return b.toString(); return b.toString();
} }
} }

View File

@ -47,11 +47,11 @@ protected Class<? extends SubView> content() {
private String rmsTableInit() { private String rmsTableInit() {
StringBuilder b = tableInit().append(", aoColumnDefs: ["); StringBuilder b = tableInit().append(", aoColumnDefs: [");
b.append("{'bSearchable': false, 'aTargets': [ 7 ]}"); b.append("{'bSearchable': false, 'aTargets': [ 7 ]}")
b.append(", {'sType': 'title-numeric', 'bSearchable': false, " .append(", {'sType': 'title-numeric', 'bSearchable': false, "
+ "'aTargets': [ 8, 9 ] }"); + "'aTargets': [ 8, 9 ] }")
b.append(", {'sType': 'title-numeric', 'aTargets': [ 5 ]}"); .append(", {'sType': 'title-numeric', 'aTargets': [ 5 ]}")
b.append("]}"); .append("]}");
return b.toString(); return b.toString();
} }
} }

View File

@ -50,11 +50,11 @@ protected Class<? extends SubView> content() {
private String nodesTableInit() { private String nodesTableInit() {
StringBuilder b = tableInit().append(", aoColumnDefs: ["); StringBuilder b = tableInit().append(", aoColumnDefs: [");
b.append("{'bSearchable': false, 'aTargets': [ 7 ]}"); b.append("{'bSearchable': false, 'aTargets': [ 7 ]}")
b.append(", {'sType': 'title-numeric', 'bSearchable': false, " .append(", {'sType': 'title-numeric', 'bSearchable': false, "
+ "'aTargets': [ 2, 3, 4, 5, 6 ] }"); + "'aTargets': [ 2, 3, 4, 5, 6 ] }")
b.append(", {'sType': 'title-numeric', 'aTargets': [ 5 ]}"); .append(", {'sType': 'title-numeric', 'aTargets': [ 5 ]}")
b.append("]}"); .append("]}");
return b.toString(); return b.toString();
} }
} }

View File

@ -375,8 +375,8 @@ private void testNMTokens(Configuration testConf) throws Exception {
// authentication... It should complain saying container was recently // authentication... It should complain saying container was recently
// stopped. // stopped.
sb = new StringBuilder("Container "); sb = new StringBuilder("Container ");
sb.append(validContainerId); sb.append(validContainerId)
sb.append(" was recently stopped on node manager"); .append(" was recently stopped on node manager");
Assert.assertTrue(testGetContainer(rpc, validAppAttemptId, validNode, Assert.assertTrue(testGetContainer(rpc, validAppAttemptId, validNode,
validContainerId, validNMToken, true).contains(sb.toString())); validContainerId, validNMToken, true).contains(sb.toString()));
@ -385,9 +385,9 @@ private void testNMTokens(Configuration testConf) throws Exception {
// This should fail as container is removed from recently tracked finished // This should fail as container is removed from recently tracked finished
// containers. // containers.
sb = new StringBuilder("Container "); sb = new StringBuilder("Container ")
sb.append(validContainerId.toString()); .append(validContainerId.toString())
sb.append(" is not handled by this NodeManager"); .append(" is not handled by this NodeManager");
Assert.assertTrue(testGetContainer(rpc, validAppAttemptId, validNode, Assert.assertTrue(testGetContainer(rpc, validAppAttemptId, validNode,
validContainerId, validNMToken, false).contains(sb.toString())); validContainerId, validNMToken, false).contains(sb.toString()));
@ -708,8 +708,8 @@ private void testContainerToken(Configuration conf) throws IOException,
nodeId, user, r, Priority.newInstance(0), 0); nodeId, user, r, Priority.newInstance(0), 0);
StringBuilder sb = new StringBuilder("Given Container "); StringBuilder sb = new StringBuilder("Given Container ");
sb.append(cId2); sb.append(cId2)
sb.append(" seems to have an illegally generated token."); .append(" seems to have an illegally generated token.");
Assert.assertTrue(testStartContainer(rpc, appAttemptId, nodeId, Assert.assertTrue(testStartContainer(rpc, appAttemptId, nodeId,
containerToken2, nmToken, true).contains(sb.toString())); containerToken2, nmToken, true).contains(sb.toString()));
} }

View File

@ -237,28 +237,29 @@ private static CommandLine parseArgs(String[] args) throws ParseException {
private static void printUsage() { private static void printUsage() {
StringBuilder usage = new StringBuilder("Command Usage: \n"); StringBuilder usage = new StringBuilder("Command Usage: \n");
usage.append("TimelineSchemaCreator [-help] Display help info" + usage
" for all commands. Or\n"); .append("TimelineSchemaCreator [-help] Display help info"
usage.append("TimelineSchemaCreator -create [OPTIONAL_OPTIONS]" + + " for all commands. Or\n")
" Create hbase tables.\n\n"); .append("TimelineSchemaCreator -create [OPTIONAL_OPTIONS]" +
usage.append("The Optional options for creating tables include: \n"); " Create hbase tables.\n\n")
usage.append("[-entityTableName <Entity Table Name>] " + .append("The Optional options for creating tables include: \n")
"The name of the Entity table\n"); .append("[-entityTableName <Entity Table Name>] " +
usage.append("[-entityMetricsTTL <Entity Table Metrics TTL>]" + "The name of the Entity table\n")
" TTL for metrics in the Entity table\n"); .append("[-entityMetricsTTL <Entity Table Metrics TTL>]" +
usage.append("[-appToflowTableName <AppToflow Table Name>]" + " TTL for metrics in the Entity table\n")
" The name of the AppToFlow table\n"); .append("[-appToflowTableName <AppToflow Table Name>]" +
usage.append("[-applicationTableName <Application Table Name>]" + " The name of the AppToFlow table\n")
" The name of the Application table\n"); .append("[-applicationTableName <Application Table Name>]" +
usage.append("[-applicationMetricsTTL <Application Table Metrics TTL>]" + " The name of the Application table\n")
" TTL for metrics in the Application table\n"); .append("[-applicationMetricsTTL <Application Table Metrics TTL>]" +
usage.append("[-subApplicationTableName <SubApplication Table Name>]" + " TTL for metrics in the Application table\n")
" The name of the SubApplication table\n"); .append("[-subApplicationTableName <SubApplication Table Name>]" +
usage.append("[-subApplicationMetricsTTL " + " The name of the SubApplication table\n")
" <SubApplication Table Metrics TTL>]" + .append("[-subApplicationMetricsTTL "
" TTL for metrics in the SubApplication table\n"); + " <SubApplication Table Metrics TTL>]" +
usage.append("[-skipExistingTable] Whether to skip existing" + " TTL for metrics in the SubApplication table\n")
" hbase tables\n"); .append("[-skipExistingTable] Whether to skip existing" +
" hbase tables\n");
System.out.println(usage.toString()); System.out.println(usage.toString());
} }

View File

@ -146,11 +146,11 @@ public static boolean isIntegralValue(Object obj) {
*/ */
public static String convertApplicationIdToString(ApplicationId appId) { public static String convertApplicationIdToString(ApplicationId appId) {
StringBuilder sb = new StringBuilder(64); StringBuilder sb = new StringBuilder(64);
sb.append(ApplicationId.appIdStrPrefix); sb.append(ApplicationId.appIdStrPrefix)
sb.append("_"); .append("_")
sb.append(appId.getClusterTimestamp()); .append(appId.getClusterTimestamp())
sb.append('_'); .append('_')
sb.append(APP_ID_FORMAT.get().format(appId.getId())); .append(APP_ID_FORMAT.get().format(appId.getId()));
return sb.toString(); return sb.toString();
} }
} }

View File

@ -330,8 +330,8 @@ public String joinEncoded(String... items) {
StringBuilder sb = new StringBuilder(encode(items[0].toString())); StringBuilder sb = new StringBuilder(encode(items[0].toString()));
// Start at 1, we've already grabbed the first value at index 0 // Start at 1, we've already grabbed the first value at index 0
for (int i = 1; i < items.length; i++) { for (int i = 1; i < items.length; i++) {
sb.append(this.value); sb.append(this.value)
sb.append(encode(items[i].toString())); .append(encode(items[i].toString()));
} }
return sb.toString(); return sb.toString();

View File

@ -106,12 +106,12 @@ public static FlowRunRowKey parseRowKeyFromString(String encodedRowKey) {
@Override @Override
public String toString() { public String toString() {
StringBuilder flowKeyStr = new StringBuilder(); StringBuilder flowKeyStr = new StringBuilder();
flowKeyStr.append("{clusterId=" + clusterId); flowKeyStr.append("{clusterId=" + clusterId)
flowKeyStr.append(" userId=" + userId); .append(" userId=" + userId)
flowKeyStr.append(" flowName=" + flowName); .append(" flowName=" + flowName)
flowKeyStr.append(" flowRunId="); .append(" flowRunId=")
flowKeyStr.append(flowRunId); .append(flowRunId)
flowKeyStr.append("}"); .append("}");
return flowKeyStr.toString(); return flowKeyStr.toString();
} }