-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 507-image-name-strategy-is-not-working-as-…
…expected
- Loading branch information
Showing
38 changed files
with
1,535 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
1.7.8 | ||
1.7.9 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/main/groovy/io/seqera/wave/memstore/range/AbstractRangeStore.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Wave, containers provisioning service | ||
* Copyright (c) 2023-2024, Seqera Labs | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.seqera.wave.memstore.range | ||
|
||
|
||
import groovy.transform.CompileStatic | ||
import io.seqera.wave.memstore.range.impl.RangeProvider | ||
/** | ||
* Abstract implementation for range set similar to Redis `zrange` | ||
* | ||
* @author Paolo Di Tommaso <[email protected]> | ||
*/ | ||
@CompileStatic | ||
abstract class AbstractRangeStore implements RangeStore { | ||
|
||
private RangeProvider delegate | ||
|
||
protected abstract String getKey() | ||
|
||
AbstractRangeStore(RangeProvider provider) { | ||
this.delegate = provider | ||
} | ||
|
||
@Override | ||
void add(String name, double score) { | ||
delegate.add(getKey(), name, score) | ||
} | ||
|
||
@Override | ||
List<String> getRange(double min, double max, int count) { | ||
return getRange(min, max, count, true) | ||
} | ||
|
||
List<String> getRange(double min, double max, int count, boolean remove) { | ||
return delegate.getRange(getKey(), min, max, count, remove) ?: List.<String>of() | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
src/main/groovy/io/seqera/wave/memstore/range/RangeStore.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Wave, containers provisioning service | ||
* Copyright (c) 2023-2024, Seqera Labs | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.seqera.wave.memstore.range | ||
/** | ||
* Define the contract for a storage range set similar to Redis `zrange` | ||
* | ||
* @author Paolo Di Tommaso <[email protected]> | ||
*/ | ||
interface RangeStore { | ||
|
||
void add(String member, double score) | ||
|
||
List<String> getRange(double min, double max, int count) | ||
} |
63 changes: 63 additions & 0 deletions
63
src/main/groovy/io/seqera/wave/memstore/range/impl/LocalRangeProvider.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Wave, containers provisioning service | ||
* Copyright (c) 2023-2024, Seqera Labs | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.seqera.wave.memstore.range.impl | ||
|
||
|
||
import groovy.transform.CompileStatic | ||
import groovy.util.logging.Slf4j | ||
import io.micronaut.context.annotation.Requires | ||
import jakarta.inject.Singleton | ||
/** | ||
* Local based implementation for a range set | ||
* | ||
* @author Paolo Di Tommaso <[email protected]> | ||
*/ | ||
@Slf4j | ||
@Requires(missingProperty = 'redis.uri') | ||
@Singleton | ||
@CompileStatic | ||
class LocalRangeProvider implements RangeProvider { | ||
|
||
private Map<String,Map<String,Double>> store = new HashMap<>() | ||
|
||
@Override | ||
void add(String key, String element, double score) { | ||
final map = store.getOrDefault(key, [:]) | ||
map.put(element, score) | ||
store.put(key, map) | ||
log.trace "* add range - store: $store" | ||
} | ||
|
||
@Override | ||
List<String> getRange(String key, double min, double max, int count, boolean remove) { | ||
final map = store.getOrDefault(key, [:]) | ||
final result = new ArrayList<String>() | ||
for( Map.Entry<String,Double> entry : map.entrySet().sort(it->it.value) ) { | ||
if( result.size()>=count ) | ||
break | ||
if( entry.value>=min && entry.value<=max ) { | ||
result.add(entry.key) | ||
if( remove ) | ||
map.remove(entry.key) | ||
} | ||
} | ||
log.trace "* get range result=$result - store: $store" | ||
return result | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/groovy/io/seqera/wave/memstore/range/impl/RangeProvider.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Wave, containers provisioning service | ||
* Copyright (c) 2023-2024, Seqera Labs | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.seqera.wave.memstore.range.impl | ||
/** | ||
* Contract for range store provider | ||
* | ||
* @author Paolo Di Tommaso <[email protected]> | ||
*/ | ||
interface RangeProvider { | ||
|
||
void add(String key, String member, double score) | ||
|
||
List<String> getRange(String key, double min, double max, int count, boolean remove) | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
src/main/groovy/io/seqera/wave/memstore/range/impl/RedisRangeProvider.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Wave, containers provisioning service | ||
* Copyright (c) 2023-2024, Seqera Labs | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.seqera.wave.memstore.range.impl | ||
|
||
|
||
import groovy.transform.CompileStatic | ||
import io.micronaut.context.annotation.Requires | ||
import jakarta.inject.Inject | ||
import jakarta.inject.Singleton | ||
import redis.clients.jedis.Jedis | ||
import redis.clients.jedis.JedisPool | ||
import redis.clients.jedis.resps.Tuple | ||
|
||
/** | ||
* Redis base implementation for range set | ||
* | ||
* @author Paolo Di Tommaso <[email protected]> | ||
*/ | ||
@Requires(property = 'redis.uri') | ||
@Singleton | ||
@CompileStatic | ||
class RedisRangeProvider implements RangeProvider { | ||
|
||
@Inject | ||
private JedisPool pool | ||
|
||
@Override | ||
void add(String key, String element, double score) { | ||
try(Jedis conn = pool.getResource()) { | ||
conn.zadd(key, score, element) | ||
} | ||
} | ||
|
||
@Override | ||
List<String> getRange(String key, double min, double max, int count, boolean remove) { | ||
try(Jedis conn = pool.getResource()) { | ||
List<Tuple> found = conn.zrangeByScoreWithScores(key, min, max, 0, count) | ||
final result = new ArrayList<String>(found.size()) | ||
for( Tuple it : found ) { | ||
result.add(it.element) | ||
if( remove ) | ||
conn.zrem(key, it.element) | ||
} | ||
return result | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.