YARN-4398. Remove unnecessary synchronization in RMStateStore. Contributed by Ning Ding

(cherry picked from commit 48cbde9083)

Conflicts:
	hadoop-yarn-project/CHANGES.txt
This commit is contained in:
Jian He 2015-12-02 11:07:18 -08:00 committed by Wangda Tan
parent cef21b7aaa
commit 9c22910570
3 changed files with 8 additions and 9 deletions

View File

@ -1099,6 +1099,8 @@ Release 2.7.3 - UNRELEASED
YARN-4452. NPE when submit Unmanaged application. (Naganarasimha G R YARN-4452. NPE when submit Unmanaged application. (Naganarasimha G R
via junping_du) via junping_du)
YARN-4398. Remove unnecessary synchronization in RMStateStore. (Ning Ding via jianhe)
Release 2.7.2 - UNRELEASED Release 2.7.2 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -64,7 +64,7 @@ public class AsyncDispatcher extends AbstractService implements Dispatcher {
// For drainEventsOnStop enabled only, block newly coming events into the // For drainEventsOnStop enabled only, block newly coming events into the
// queue while stopping. // queue while stopping.
private volatile boolean blockNewEvents = false; private volatile boolean blockNewEvents = false;
private EventHandler handlerInstance = null; private final EventHandler handlerInstance = new GenericEventHandler();
private Thread eventHandlingThread; private Thread eventHandlingThread;
protected final Map<Class<? extends Enum>, EventHandler> eventDispatchers; protected final Map<Class<? extends Enum>, EventHandler> eventDispatchers;
@ -224,9 +224,6 @@ public void register(Class<? extends Enum> eventType,
@Override @Override
public EventHandler getEventHandler() { public EventHandler getEventHandler() {
if (handlerInstance == null) {
handlerInstance = new GenericEventHandler();
}
return handlerInstance; return handlerInstance;
} }

View File

@ -737,7 +737,7 @@ public void checkVersion() throws Exception {
* RMAppStoredEvent will be sent on completion to notify the RMApp * RMAppStoredEvent will be sent on completion to notify the RMApp
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public synchronized void storeNewApplication(RMApp app) { public void storeNewApplication(RMApp app) {
ApplicationSubmissionContext context = app ApplicationSubmissionContext context = app
.getApplicationSubmissionContext(); .getApplicationSubmissionContext();
assert context instanceof ApplicationSubmissionContextPBImpl; assert context instanceof ApplicationSubmissionContextPBImpl;
@ -748,7 +748,7 @@ public synchronized void storeNewApplication(RMApp app) {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public synchronized void updateApplicationState( public void updateApplicationState(
ApplicationStateData appState) { ApplicationStateData appState) {
dispatcher.getEventHandler().handle(new RMStateUpdateAppEvent(appState)); dispatcher.getEventHandler().handle(new RMStateUpdateAppEvent(appState));
} }
@ -780,7 +780,7 @@ protected abstract void updateApplicationStateInternal(ApplicationId appId,
* This does not block the dispatcher threads * This does not block the dispatcher threads
* RMAppAttemptStoredEvent will be sent on completion to notify the RMAppAttempt * RMAppAttemptStoredEvent will be sent on completion to notify the RMAppAttempt
*/ */
public synchronized void storeNewApplicationAttempt(RMAppAttempt appAttempt) { public void storeNewApplicationAttempt(RMAppAttempt appAttempt) {
Credentials credentials = getCredentialsFromAppAttempt(appAttempt); Credentials credentials = getCredentialsFromAppAttempt(appAttempt);
AggregateAppResourceUsage resUsage = AggregateAppResourceUsage resUsage =
@ -798,7 +798,7 @@ public synchronized void storeNewApplicationAttempt(RMAppAttempt appAttempt) {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public synchronized void updateApplicationAttemptState( public void updateApplicationAttemptState(
ApplicationAttemptStateData attemptState) { ApplicationAttemptStateData attemptState) {
dispatcher.getEventHandler().handle( dispatcher.getEventHandler().handle(
new RMStateUpdateAppAttemptEvent(attemptState)); new RMStateUpdateAppAttemptEvent(attemptState));
@ -963,7 +963,7 @@ public void storeOrUpdateAMRMTokenSecretManager(
* There is no notification of completion for this operation. * There is no notification of completion for this operation.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public synchronized void removeApplication(RMApp app) { public void removeApplication(RMApp app) {
ApplicationStateData appState = ApplicationStateData appState =
ApplicationStateData.newInstance(app.getSubmitTime(), ApplicationStateData.newInstance(app.getSubmitTime(),
app.getStartTime(), app.getApplicationSubmissionContext(), app.getStartTime(), app.getApplicationSubmissionContext(),