Skip to content

Commit

Permalink
Revert "perf(docker): Fix for ConcurrentHashMap cast error. Added uni…
Browse files Browse the repository at this point in the history
…t tests (#3942)" (#3958)

This reverts commit 011da56.
  • Loading branch information
Mark Rampton authored and ezimanyi committed Aug 16, 2019
1 parent 8e37e6a commit 5ba456f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package com.netflix.spinnaker.clouddriver.docker.registry.cache

import com.netflix.spinnaker.cats.cache.DefaultCacheData
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ConcurrentMap

class DefaultCacheDataBuilder {
String id = ''
Expand All @@ -30,7 +28,7 @@ class DefaultCacheDataBuilder {
new DefaultCacheData(id, ttlSeconds, attributes, relationships)
}

public static ConcurrentMap<String, DefaultCacheDataBuilder> defaultCacheDataBuilderMap() {
return new ConcurrentHashMap<String, DefaultCacheDataBuilder>()
public static Map<String, DefaultCacheDataBuilder> defaultCacheDataBuilderMap() {
return [:].withDefault { String id -> new DefaultCacheDataBuilder(id: id) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import com.netflix.spinnaker.clouddriver.docker.registry.security.DockerRegistry
import groovy.util.logging.Slf4j
import retrofit.RetrofitError

import java.util.concurrent.ConcurrentMap
import java.util.concurrent.TimeUnit

import static java.util.Collections.unmodifiableSet
Expand Down Expand Up @@ -129,11 +128,11 @@ class DockerRegistryImageCachingAgent implements CachingAgent, AccountAware, Age
private CacheResult buildCacheResult(Map<String, Set<String>> tagMap) {
log.info("Describing items in ${agentType}")

ConcurrentMap<String, DefaultCacheDataBuilder> cachedTags = DefaultCacheDataBuilder.defaultCacheDataBuilderMap()
ConcurrentMap<String, DefaultCacheDataBuilder> cachedIds = DefaultCacheDataBuilder.defaultCacheDataBuilderMap()
Map<String, DefaultCacheDataBuilder> cachedTags = DefaultCacheDataBuilder.defaultCacheDataBuilderMap()
Map<String, DefaultCacheDataBuilder> cachedIds = DefaultCacheDataBuilder.defaultCacheDataBuilderMap()

tagMap.forEach { repository, tags ->
tags.parallelStream().forEach { tag ->
tags.forEach { tag ->
if (!tag) {
log.warn("Empty tag encountered for $accountName/$repository, not caching")
return
Expand All @@ -159,26 +158,23 @@ class DockerRegistryImageCachingAgent implements CachingAgent, AccountAware, Age
}
}
}
try {
creationDate = credentials.client.getCreationDate(repository, tag)
} catch (Exception e) {
log.warn("Unable to fetch tag creation date, reason: {} (tag: {}, repository: {})", e.message, tag, repository)
}

if (credentials.sortTagsByDate) {
try {
creationDate = credentials.client.getCreationDate(repository, tag)
} catch (Exception e) {
log.warn("Unable to fetch tag creation date, reason: {} (tag: {}, repository: {})", e.message, tag, repository)
}
cachedTags[tagKey].with {
attributes.name = "${repository}:${tag}".toString()
attributes.account = accountName
attributes.digest = digest
attributes.date = creationDate
}

def tagData = new DefaultCacheDataBuilder()
tagData.attributes.put("name", "${repository}:${tag}".toString())
tagData.attributes.put("account", accountName)
tagData.attributes.put("digest", digest)
tagData.attributes.put("date", creationDate)
cachedTags.put(tagKey, tagData)

def idData = new DefaultCacheDataBuilder()
idData.attributes.put("tagKey", tagKey)
idData.attributes.put("account", accountName)
cachedIds.put(imageIdKey, idData)
cachedIds[imageIdKey].with {
attributes.tagKey = tagKey
attributes.account = accountName
}
}

null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ class DockerRegistryCredentials {
return trackDigests
}

boolean getSortTagsByDate() {
return sortTagsByDate
}

List<String> getSkip(){
return skip
}
Expand Down

This file was deleted.

0 comments on commit 5ba456f

Please sign in to comment.