Skip to content

Commit

Permalink
[JENKINS-49117] - Stop serializing ReentrantLock to the disk in Mesos…
Browse files Browse the repository at this point in the history
…RetentionStrategy
  • Loading branch information
oleg-nenashev committed Jan 24, 2018
1 parent fa978ec commit bb2b255
Showing 1 changed file with 6 additions and 5 deletions.
Expand Up @@ -21,11 +21,9 @@

import org.joda.time.DateTimeUtils;
import hudson.slaves.OfflineCause;
import org.kohsuke.stapler.DataBoundConstructor;

import hudson.model.Descriptor;
import hudson.slaves.RetentionStrategy;
import hudson.util.TimeUnit2;

/**
* This is inspired by {@link hudson.slaves.CloudRetentionStrategy}.
Expand All @@ -38,7 +36,7 @@ public class MesosRetentionStrategy extends RetentionStrategy<MesosComputer> {
* terminated.
*/
public final int idleTerminationMinutes;
private ReentrantLock checkLock = new ReentrantLock(false);
private transient ReentrantLock computerCheckLock = new ReentrantLock(false);

private static final Logger LOGGER = Logger
.getLogger(MesosRetentionStrategy.class.getName());
Expand All @@ -47,16 +45,19 @@ public MesosRetentionStrategy(int idleTerminationMinutes) {
this.idleTerminationMinutes = idleTerminationMinutes;
}

private void readResolve() {
computerCheckLock = new ReentrantLock(false);
}

@Override
public long check(MesosComputer c) {
if (!checkLock.tryLock()) {
if (!computerCheckLock.tryLock()) {
return 1;
} else {
try {
return checkInternal(c);
} finally {
checkLock.unlock();
computerCheckLock.unlock();
}
}
}
Expand Down

0 comments on commit bb2b255

Please sign in to comment.