Skip to content

Commit

Permalink
Merge pull request #116 from tomaslin/connection-leaks
Browse files Browse the repository at this point in the history
jenkins: keep no idle connections in connection pool
  • Loading branch information
tomaslin authored Jun 17, 2016
2 parents dfee049 + 9abd815 commit 9bfd201
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class EchoConfig {
new RestAdapter.Builder()
.setEndpoint(Endpoints.newFixedEndpoint(address))
.setClient(new OkClient(okHttpClientConfig.create()))
.setLogLevel(RestAdapter.LogLevel.BASIC)
.setLogLevel(RestAdapter.LogLevel.NONE)
.build()
.create(EchoService)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.netflix.spinnaker.igor.config
import com.netflix.spinnaker.igor.jenkins.client.JenkinsClient
import com.netflix.spinnaker.igor.jenkins.service.JenkinsService
import com.netflix.spinnaker.igor.service.BuildMasters
import com.squareup.okhttp.ConnectionPool
import com.squareup.okhttp.Credentials
import com.squareup.okhttp.OkHttpClient
import groovy.transform.CompileStatic
Expand Down Expand Up @@ -71,6 +72,7 @@ class JenkinsConfig {
static JenkinsClient jenkinsClient(String address, String username, String password, int timeout = 30000) {
OkHttpClient client = new OkHttpClient()
client.setReadTimeout(timeout, TimeUnit.MILLISECONDS)
client.setConnectionPool(new ConnectionPool(0, 5 * 60 * 1000));

new RestAdapter.Builder()
.setEndpoint(Endpoints.newFixedEndpoint(address))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,16 @@ class JenkinsBuildMonitor implements PollingMonitor {
log.info('Checking for new builds for ' + master)
List<Map> results = []

lastPoll = System.currentTimeMillis()
long thisPoll = lastPoll
try {
lastPoll = System.currentTimeMillis()
List<String> cachedBuilds = cache.getJobNames(master)

def startTime = System.currentTimeMillis()
List<Project> builds = buildMasters.map[master].projects?.list

log.info( "finding new builds in ${master} : ${ builds.size() } items" )

log.info("Took ${System.currentTimeMillis() - startTime}ms to retrieve projects (master: ${master})")

List<String> buildNames = builds*.name
Expand Down Expand Up @@ -234,7 +238,7 @@ class JenkinsBuildMonitor implements PollingMonitor {
log.error("failed to update master $master", e)
}

log.info("Last poll took ${System.currentTimeMillis() - lastPoll}ms (master: ${master})")
log.info("Last poll took ${System.currentTimeMillis() - thisPoll}ms (master: ${master})")
results
}

Expand Down

0 comments on commit 9bfd201

Please sign in to comment.