YARN-8506. Make GetApplicationsRequestPBImpl thread safe. (wangda) Change-Id: I2c006965375823c83036e7f45f7163d13c0bdf90
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/8ad82ea5 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/8ad82ea5 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/8ad82ea5 Branch: refs/remotes/origin/branch-3.1 Commit: 8ad82ea5b5b0c87e5771dcaa5530d4fbe03c92ae Parents: 242b5ac Author: Wangda Tan <wan...@apache.org> Authored: Mon Jul 9 11:35:15 2018 -0700 Committer: Wangda Tan <wan...@apache.org> Committed: Mon Jul 9 11:35:15 2018 -0700 ---------------------------------------------------------------------- .../impl/pb/GetApplicationsRequestPBImpl.java | 44 ++++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/8ad82ea5/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationsRequestPBImpl.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationsRequestPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationsRequestPBImpl.java index ad009d6..bc6be80 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationsRequestPBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetApplicationsRequestPBImpl.java @@ -65,7 +65,7 @@ public class GetApplicationsRequestPBImpl extends GetApplicationsRequest { viaProto = true; } - public GetApplicationsRequestProto getProto() { + public synchronized GetApplicationsRequestProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; @@ -175,13 +175,13 @@ public class GetApplicationsRequestPBImpl extends GetApplicationsRequest { } @Override - public Set<String> getApplicationTypes() { + public synchronized Set<String> getApplicationTypes() { initApplicationTypes(); return this.applicationTypes; } @Override - public void setApplicationTypes(Set<String> applicationTypes) { + public synchronized void setApplicationTypes(Set<String> applicationTypes) { maybeInitBuilder(); if (applicationTypes == null) builder.clearApplicationTypes(); @@ -198,13 +198,13 @@ public class GetApplicationsRequestPBImpl extends GetApplicationsRequest { } @Override - public Set<String> getApplicationTags() { + public synchronized Set<String> getApplicationTags() { initApplicationTags(); return this.applicationTags; } @Override - public void setApplicationTags(Set<String> tags) { + public synchronized void setApplicationTags(Set<String> tags) { maybeInitBuilder(); if (tags == null || tags.isEmpty()) { builder.clearApplicationTags(); @@ -219,7 +219,7 @@ public class GetApplicationsRequestPBImpl extends GetApplicationsRequest { } @Override - public EnumSet<YarnApplicationState> getApplicationStates() { + public synchronized EnumSet<YarnApplicationState> getApplicationStates() { initApplicationStates(); return this.applicationStates; } @@ -233,12 +233,12 @@ public class GetApplicationsRequestPBImpl extends GetApplicationsRequest { } @Override - public ApplicationsRequestScope getScope() { + public synchronized ApplicationsRequestScope getScope() { initScope(); return this.scope; } - public void setScope(ApplicationsRequestScope scope) { + public synchronized void setScope(ApplicationsRequestScope scope) { maybeInitBuilder(); if (scope == null) { builder.clearScope(); @@ -247,7 +247,7 @@ public class GetApplicationsRequestPBImpl extends GetApplicationsRequest { } @Override - public void setApplicationStates(EnumSet<YarnApplicationState> applicationStates) { + public synchronized void setApplicationStates(EnumSet<YarnApplicationState> applicationStates) { maybeInitBuilder(); if (applicationStates == null) { builder.clearApplicationStates(); @@ -256,7 +256,7 @@ public class GetApplicationsRequestPBImpl extends GetApplicationsRequest { } @Override - public void setApplicationStates(Set<String> applicationStates) { + public synchronized void setApplicationStates(Set<String> applicationStates) { EnumSet<YarnApplicationState> appStates = null; for (YarnApplicationState state : YarnApplicationState.values()) { if (applicationStates.contains( @@ -272,12 +272,12 @@ public class GetApplicationsRequestPBImpl extends GetApplicationsRequest { } @Override - public Set<String> getUsers() { + public synchronized Set<String> getUsers() { initUsers(); return this.users; } - public void setUsers(Set<String> users) { + public synchronized void setUsers(Set<String> users) { maybeInitBuilder(); if (users == null) { builder.clearUsers(); @@ -286,13 +286,13 @@ public class GetApplicationsRequestPBImpl extends GetApplicationsRequest { } @Override - public Set<String> getQueues() { + public synchronized Set<String> getQueues() { initQueues(); return this.queues; } @Override - public void setQueues(Set<String> queues) { + public synchronized void setQueues(Set<String> queues) { maybeInitBuilder(); if (queues == null) { builder.clearQueues(); @@ -301,7 +301,7 @@ public class GetApplicationsRequestPBImpl extends GetApplicationsRequest { } @Override - public long getLimit() { + public synchronized long getLimit() { if (this.limit == Long.MAX_VALUE) { GetApplicationsRequestProtoOrBuilder p = viaProto ? proto : builder; this.limit = p.hasLimit() ? p.getLimit() : Long.MAX_VALUE; @@ -310,13 +310,13 @@ public class GetApplicationsRequestPBImpl extends GetApplicationsRequest { } @Override - public void setLimit(long limit) { + public synchronized void setLimit(long limit) { maybeInitBuilder(); this.limit = limit; } @Override - public LongRange getStartRange() { + public synchronized LongRange getStartRange() { if (this.start == null) { GetApplicationsRequestProtoOrBuilder p = viaProto ? proto: builder; if (p.hasStartBegin() || p.hasStartEnd()) { @@ -329,12 +329,12 @@ public class GetApplicationsRequestPBImpl extends GetApplicationsRequest { } @Override - public void setStartRange(LongRange range) { + public synchronized void setStartRange(LongRange range) { this.start = range; } @Override - public void setStartRange(long begin, long end) + public synchronized void setStartRange(long begin, long end) throws IllegalArgumentException { if (begin > end) { throw new IllegalArgumentException("begin > end in range (begin, " + @@ -344,7 +344,7 @@ public class GetApplicationsRequestPBImpl extends GetApplicationsRequest { } @Override - public LongRange getFinishRange() { + public synchronized LongRange getFinishRange() { if (this.finish == null) { GetApplicationsRequestProtoOrBuilder p = viaProto ? proto: builder; if (p.hasFinishBegin() || p.hasFinishEnd()) { @@ -357,12 +357,12 @@ public class GetApplicationsRequestPBImpl extends GetApplicationsRequest { } @Override - public void setFinishRange(LongRange range) { + public synchronized void setFinishRange(LongRange range) { this.finish = range; } @Override - public void setFinishRange(long begin, long end) { + public synchronized void setFinishRange(long begin, long end) { if (begin > end) { throw new IllegalArgumentException("begin > end in range (begin, " + "end): (" + begin + ", " + end + ")"); --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org