YARN-7133. Clean up lock-try order in fair scheduler. (Szilard Nemeth via Haibo Chen)
This commit is contained in:
parent
e673dd1d4d
commit
ea2c6c8c9a
@ -467,8 +467,8 @@ protected void addApplication(ApplicationId applicationId,
|
||||
return;
|
||||
}
|
||||
|
||||
writeLock.lock();
|
||||
try {
|
||||
writeLock.lock();
|
||||
RMApp rmApp = rmContext.getRMApps().get(applicationId);
|
||||
FSLeafQueue queue = assignToQueue(rmApp, queueName, user);
|
||||
if (queue == null) {
|
||||
@ -550,8 +550,8 @@ protected void addApplicationAttempt(
|
||||
ApplicationAttemptId applicationAttemptId,
|
||||
boolean transferStateFromPreviousAttempt,
|
||||
boolean isAttemptRecovering) {
|
||||
writeLock.lock();
|
||||
try {
|
||||
writeLock.lock();
|
||||
SchedulerApplication<FSAppAttempt> application = applications.get(
|
||||
applicationAttemptId.getApplicationId());
|
||||
String user = application.getUser();
|
||||
@ -653,8 +653,8 @@ private void removeApplication(ApplicationId applicationId,
|
||||
private void removeApplicationAttempt(
|
||||
ApplicationAttemptId applicationAttemptId,
|
||||
RMAppAttemptState rmAppAttemptFinalState, boolean keepContainers) {
|
||||
writeLock.lock();
|
||||
try {
|
||||
writeLock.lock();
|
||||
LOG.info("Application " + applicationAttemptId + " is done. finalState="
|
||||
+ rmAppAttemptFinalState);
|
||||
FSAppAttempt attempt = getApplicationAttempt(applicationAttemptId);
|
||||
@ -720,8 +720,8 @@ private void removeApplicationAttempt(
|
||||
protected void completedContainerInternal(
|
||||
RMContainer rmContainer, ContainerStatus containerStatus,
|
||||
RMContainerEventType event) {
|
||||
writeLock.lock();
|
||||
try {
|
||||
writeLock.lock();
|
||||
Container container = rmContainer.getContainer();
|
||||
|
||||
// Get the application for the finished container
|
||||
@ -768,8 +768,8 @@ protected void completedContainerInternal(
|
||||
|
||||
private void addNode(List<NMContainerStatus> containerReports,
|
||||
RMNode node) {
|
||||
writeLock.lock();
|
||||
try {
|
||||
writeLock.lock();
|
||||
FSSchedulerNode schedulerNode = new FSSchedulerNode(node,
|
||||
usePortForNodeName);
|
||||
nodeTracker.addNode(schedulerNode);
|
||||
@ -790,8 +790,8 @@ private void addNode(List<NMContainerStatus> containerReports,
|
||||
}
|
||||
|
||||
private void removeNode(RMNode rmNode) {
|
||||
writeLock.lock();
|
||||
try {
|
||||
writeLock.lock();
|
||||
NodeId nodeId = rmNode.getNodeID();
|
||||
FSSchedulerNode node = nodeTracker.getNode(nodeId);
|
||||
if (node == null) {
|
||||
@ -988,8 +988,8 @@ private List<MaxResourceValidationResult> validateResourceRequests(
|
||||
|
||||
@Override
|
||||
protected void nodeUpdate(RMNode nm) {
|
||||
writeLock.lock();
|
||||
try {
|
||||
writeLock.lock();
|
||||
long start = getClock().getTime();
|
||||
super.nodeUpdate(nm);
|
||||
|
||||
@ -1089,8 +1089,8 @@ static void assignPreemptedContainers(FSSchedulerNode node) {
|
||||
|
||||
@VisibleForTesting
|
||||
void attemptScheduling(FSSchedulerNode node) {
|
||||
writeLock.lock();
|
||||
try {
|
||||
writeLock.lock();
|
||||
if (rmContext.isWorkPreservingRecoveryEnabled() && !rmContext
|
||||
.isSchedulerReadyForAllocatingContainers()) {
|
||||
return;
|
||||
@ -1305,8 +1305,8 @@ public void handle(SchedulerEvent event) {
|
||||
private String resolveReservationQueueName(String queueName,
|
||||
ApplicationId applicationId, ReservationId reservationID,
|
||||
boolean isRecovering) {
|
||||
readLock.lock();
|
||||
try {
|
||||
readLock.lock();
|
||||
FSQueue queue = queueMgr.getQueue(queueName);
|
||||
if ((queue == null) || !allocConf.isReservable(queue.getQueueName())) {
|
||||
return queueName;
|
||||
@ -1372,8 +1372,8 @@ public void setRMContext(RMContext rmContext) {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void initScheduler(Configuration conf) throws IOException {
|
||||
writeLock.lock();
|
||||
try {
|
||||
writeLock.lock();
|
||||
this.conf = new FairSchedulerConfiguration(conf);
|
||||
validateConf(this.conf);
|
||||
authorizer = YarnAuthorizationProvider.getInstance(conf);
|
||||
@ -1464,8 +1464,8 @@ private void updateReservationThreshold() {
|
||||
}
|
||||
|
||||
private void startSchedulerThreads() {
|
||||
writeLock.lock();
|
||||
try {
|
||||
writeLock.lock();
|
||||
Preconditions.checkNotNull(allocsLoader, "allocsLoader is null");
|
||||
if (continuousSchedulingEnabled) {
|
||||
Preconditions.checkNotNull(schedulingThread,
|
||||
@ -1499,8 +1499,8 @@ public void serviceStart() throws Exception {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void serviceStop() throws Exception {
|
||||
writeLock.lock();
|
||||
try {
|
||||
writeLock.lock();
|
||||
if (continuousSchedulingEnabled) {
|
||||
if (schedulingThread != null) {
|
||||
schedulingThread.interrupt();
|
||||
@ -1562,8 +1562,8 @@ public int getNumClusterNodes() {
|
||||
@Override
|
||||
public boolean checkAccess(UserGroupInformation callerUGI,
|
||||
QueueACL acl, String queueName) {
|
||||
readLock.lock();
|
||||
try {
|
||||
readLock.lock();
|
||||
FSQueue queue = getQueueManager().getQueue(queueName);
|
||||
if (queue == null) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
@ -1691,8 +1691,8 @@ public List<ApplicationAttemptId> getAppsInQueue(String queueName) {
|
||||
@Override
|
||||
public String moveApplication(ApplicationId appId,
|
||||
String queueName) throws YarnException {
|
||||
writeLock.lock();
|
||||
try {
|
||||
writeLock.lock();
|
||||
SchedulerApplication<FSAppAttempt> app = applications.get(appId);
|
||||
if (app == null) {
|
||||
throw new YarnException("App to be moved " + appId + " not found.");
|
||||
@ -1700,8 +1700,8 @@ public String moveApplication(ApplicationId appId,
|
||||
FSAppAttempt attempt = (FSAppAttempt) app.getCurrentAppAttempt();
|
||||
// To serialize with FairScheduler#allocate, synchronize on app attempt
|
||||
|
||||
attempt.getWriteLock().lock();
|
||||
try {
|
||||
attempt.getWriteLock().lock();
|
||||
FSLeafQueue oldQueue = (FSLeafQueue) app.getQueue();
|
||||
// Check if the attempt is already stopped: don't move stopped app
|
||||
// attempt. The attempt has already been removed from all queues.
|
||||
@ -1737,8 +1737,8 @@ public String moveApplication(ApplicationId appId,
|
||||
@Override
|
||||
public void preValidateMoveApplication(ApplicationId appId, String newQueue)
|
||||
throws YarnException {
|
||||
writeLock.lock();
|
||||
try {
|
||||
writeLock.lock();
|
||||
SchedulerApplication<FSAppAttempt> app = applications.get(appId);
|
||||
if (app == null) {
|
||||
throw new YarnException("App to be moved " + appId + " not found.");
|
||||
@ -1747,8 +1747,8 @@ public void preValidateMoveApplication(ApplicationId appId, String newQueue)
|
||||
FSAppAttempt attempt = app.getCurrentAppAttempt();
|
||||
// To serialize with FairScheduler#allocate, synchronize on app attempt
|
||||
|
||||
attempt.getWriteLock().lock();
|
||||
try {
|
||||
attempt.getWriteLock().lock();
|
||||
FSLeafQueue oldQueue = (FSLeafQueue) app.getQueue();
|
||||
String destQueueName = handleMoveToPlanQueue(newQueue);
|
||||
FSLeafQueue targetQueue = queueMgr.getLeafQueue(destQueueName, false);
|
||||
@ -1869,8 +1869,8 @@ FSQueue findLowestCommonAncestorQueue(FSQueue queue1, FSQueue queue2) {
|
||||
@Override
|
||||
public void updateNodeResource(RMNode nm,
|
||||
ResourceOption resourceOption) {
|
||||
writeLock.lock();
|
||||
try {
|
||||
writeLock.lock();
|
||||
super.updateNodeResource(nm, resourceOption);
|
||||
updateRootQueueMetrics();
|
||||
queueMgr.getRootQueue().setSteadyFairShare(getClusterResource());
|
||||
|
Loading…
Reference in New Issue
Block a user