Skip to content

Commit

Permalink
Merge pull request #1 from spinnaker/master
Browse files Browse the repository at this point in the history
Fetch updates to 1.13.x
  • Loading branch information
Darshan authored May 3, 2019
2 parents 7c280a8 + 653dad5 commit 8ceb8f6
Show file tree
Hide file tree
Showing 737 changed files with 18,607 additions and 37,137 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ COPY . workdir/

WORKDIR workdir

RUN GRADLE_USER_HOME=cache ./gradlew buildDeb -x test && \
RUN GRADLE_USER_HOME=cache ./gradlew -I gradle/init-publish.gradle buildDeb -x test && \
dpkg -i ./clouddriver-web/build/distributions/*.deb && \
cd .. && \
rm -rf workdir && \
Expand Down
4 changes: 4 additions & 0 deletions OWNERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ajordens
asher
cfieber
robzienert
7 changes: 2 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ buildscript {
}
repositories {
jcenter()
maven { url "http://spinnaker.bintray.com/gradle" }
maven { url "https://spinnaker.bintray.com/gradle" }
maven { url "https://plugins.gradle.org/m2/" }
}

Expand All @@ -38,7 +38,7 @@ allprojects {
apply plugin: 'groovy'

ext {
spinnakerDependenciesVersion = '1.30.0'
spinnakerDependenciesVersion = '1.44.0'
if (project.hasProperty('spinnakerDependenciesVersion')) {
spinnakerDependenciesVersion = project.property('spinnakerDependenciesVersion')
}
Expand Down Expand Up @@ -104,9 +104,6 @@ subprojects { project ->
if (it.requested.group == 'cglib' || it.requested.name == 'cglib') {
it.useTarget group: 'cglib', name: 'cglib', version: '3.2.0'
}
if (it.requested.group == 'com.google.guava') {
it.useTarget group: 'com.google.guava', name: 'guava', version: '18.0'
}
if (it.requested.group == 'antlr') {
it.useTarget group: 'org.antlr', name: it.requested.name, version: '3.5.2'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;

/**
* Cache provides view access to data keyed by type and identifier.
*/
public interface Cache {
enum StoreType {
REDIS, IN_MEMORY, SQL
}

/**
* Gets a single item from the cache by type and id
*
Expand Down Expand Up @@ -115,4 +120,55 @@ default Collection<String> existingIdentifiers(String type, String... identifier
* @return the items matching the type and identifiers
*/
Collection<CacheData> getAll(String type, String... identifiers);

/**
* Retrieves all items for the specified type associated with the provided application.
* Requires a storeType with secondary indexes and support in the type's caching agent.
*
* @param type the type for which to retrieve items
* @param application the application name
* @return the matching items, keyed by type
*/
default Map<String, Collection<CacheData>> getAllByApplication(String type, String application) {
throw new UnsupportedCacheMethodException("Method only implemented for StoreType.SQL");
}

/**
* Retrieves all items for the specified type associated with the provided application.
* Requires a storeType with secondary indexes and support in the type's caching agent.
*
* @param type the type for which to retrieve items
* @param application the application name
* @param cacheFilter the cacheFilter to govern which relationships to fetch
* @return the matching items, keyed by type
*/
default Map<String, Collection<CacheData>> getAllByApplication(String type,
String application,
CacheFilter cacheFilter) {
throw new UnsupportedCacheMethodException("Method only implemented for StoreType.SQL");
}

/**
* Retrieves all items for the specified type associated with the provided application.
* Requires a storeType with secondary indexes and support in the type's caching agent.
*
* @param types collection of types for which to retrieve items
* @param application the application name
* @param cacheFilters cacheFilters to govern which relationships to fetch, as type to filter
* @return the matching items, keyed by type
*/
default Map<String, Collection<CacheData>> getAllByApplication(Collection<String> types,
String application,
Map<String, CacheFilter> cacheFilters) {
throw new UnsupportedCacheMethodException("Method only implemented for StoreType.SQL");
}

/**
* Get backing store type for Cache implementation
*
* @return the backing StoreType
*/
default StoreType storeType() {
return StoreType.REDIS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@

package com.netflix.spinnaker.cats.cache;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;

/**
* A cache that provides a unified view of multiples, merging items from each
Expand All @@ -35,6 +31,12 @@ public CompositeCache(Collection<? extends Cache> caches) {
this.caches = caches;
}

public Set<StoreType> getStoreTypes() {
return caches.stream()
.map(c -> ((Cache) c).storeType())
.collect(Collectors.toSet());
}

@Override
public CacheData get(String type, String id) {
return get(type, id, null);
Expand Down Expand Up @@ -125,6 +127,37 @@ public Collection<CacheData> getAll(String type, String... identifiers) {
return getAll(type, Arrays.asList(identifiers));
}

@Override
public Map<String, Collection<CacheData>> getAllByApplication(String type, String application) {
Map<String, Collection<CacheData>> allItems = new HashMap<>();
for (Cache cache : caches) {
allItems.putAll(cache.getAllByApplication(type, application));
}
return allItems;
}

@Override
public Map<String, Collection<CacheData>> getAllByApplication(String type,
String application,
CacheFilter filter) {
Map<String, Collection<CacheData>> allItems = new HashMap<>();
for (Cache cache : caches) {
allItems.putAll(cache.getAllByApplication(type, application, filter));
}
return allItems;
}

@Override
public Map<String, Collection<CacheData>> getAllByApplication(Collection<String> types,
String application,
Map<String, CacheFilter> cacheFilters) {
Map<String, Collection<CacheData>> allItems = new HashMap<>();
for (Cache cache : caches) {
allItems.putAll(cache.getAllByApplication(types, application, cacheFilters));
}
return allItems;
}

Map<String, CacheData> merge(Map<String, CacheData> existingItems, Collection<CacheData> results) {
final Map<String, CacheData> allItems = existingItems == null ? new HashMap<String, CacheData>() : existingItems;
for (CacheData item : results) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.netflix.spinnaker.cats.cache;

public class UnsupportedCacheMethodException extends RuntimeException {
public UnsupportedCacheMethodException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
public class InMemoryCache implements WriteableCache {
private ConcurrentMap<String, ConcurrentMap<String, CacheData>> typeMap = new ConcurrentHashMap<>();

@Override
public StoreType storeType() {
return StoreType.IN_MEMORY;
}

@Override
public void merge(String type, CacheData cacheData) {
merge(getOrCreate(type, cacheData.getId()), cacheData);
Expand Down
47 changes: 47 additions & 0 deletions cats/cats-sql/cats-sql.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2018 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

apply from: "$rootDir/gradle/kotlin.gradle"
apply plugin: "groovy"


tasks.compileGroovy.enabled = false

dependencies {
spinnaker.group("spockBase")
testCompile spinnaker.dependency("groovy")

compile project(':cats:cats-core')
compile project(':cats:cats-redis')
compile project(":clouddriver-sql")
compile project(":clouddriver-core")
compile("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1")
compile("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.1.1")
compile("org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:1.1.1")

testCompile "com.h2database:h2:1.4.197"

testCompile "io.strikt:strikt-core:0.11.5"
testCompile "org.assertj:assertj-core:3.9.0"
testCompile "org.junit.jupiter:junit-jupiter-api:${spinnaker.version("jupiter")}"
testCompile "com.nhaarman:mockito-kotlin:1.5.0"

testCompile project(':cats:cats-test')
testCompile(spinnaker.dependency("korkSqlTest"))
testRuntime "org.junit.jupiter:junit-jupiter-engine:${spinnaker.version("jupiter")}"
testRuntime "org.junit.platform:junit-platform-launcher:${spinnaker.version("junit5")}"
testRuntime "org.junit.vintage:junit-vintage-engine:${spinnaker.version("junitVintage")}"
}
Loading

0 comments on commit 8ceb8f6

Please sign in to comment.