Skip to content

Commit

Permalink
Merge pull request #310 from oleg-nenashev/JENKINS-49117-jep-200
Browse files Browse the repository at this point in the history
[JENKINS-49117] - Stop serializing ReentrantLocks to the disk
  • Loading branch information
Vlatombe committed Jan 29, 2018
2 parents 3e7002c + bb2b255 commit 0e5df15
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
2 changes: 2 additions & 0 deletions Jenkinsfile
@@ -0,0 +1,2 @@
// Build the plugin using https://github.com/jenkins-infra/pipeline-library
buildPlugin()
24 changes: 9 additions & 15 deletions pom.xml
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.19</version>
<version>3.2</version>
</parent>

<artifactId>mesos</artifactId>
Expand Down Expand Up @@ -91,8 +91,8 @@
</pluginRepositories>

<properties>
<jenkins.version>1.599</jenkins.version>
<jenkins-test-harness.version>1.599</jenkins-test-harness.version>
<jenkins.version>2.7.3</jenkins.version>
<java.level>7</java.level>
<findbugs.failOnError>false</findbugs.failOnError>
<mesos.version>1.0.0</mesos.version>
<protobuf.version>2.6.1</protobuf.version>
Expand Down Expand Up @@ -142,6 +142,12 @@
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
Expand All @@ -168,21 +174,9 @@

<build>
<plugins>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<target>1.6</target>
<source>1.6</source>
</configuration>
</plugin>
<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<version>1.117</version>
<configuration>
<systemProperties>
<hudson.slaves.NodeProvisioner.initialDelay>0</hudson.slaves.NodeProvisioner.initialDelay>
Expand Down
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 0e5df15

Please sign in to comment.