-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store cache status info in a map by type url (#135)
Signed-off-by: Sebastian Schepens <sebastian.schepens@mercadolibre.com>
- Loading branch information
Showing
4 changed files
with
64 additions
and
9 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
cache/src/main/java/io/envoyproxy/controlplane/cache/GroupCacheStatusInfo.java
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,41 @@ | ||
package io.envoyproxy.controlplane.cache; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import javax.annotation.concurrent.ThreadSafe; | ||
|
||
/** | ||
* {@code GroupCacheStatusInfo} provides an implementation of {@link StatusInfo} for a group of {@link CacheStatusInfo}. | ||
*/ | ||
@ThreadSafe | ||
class GroupCacheStatusInfo<T> implements StatusInfo<T> { | ||
private final Collection<CacheStatusInfo<T>> statuses; | ||
|
||
public GroupCacheStatusInfo(Collection<CacheStatusInfo<T>> statuses) { | ||
this.statuses = new ArrayList<>(statuses); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public long lastWatchRequestTime() { | ||
return statuses.stream().mapToLong(CacheStatusInfo::lastWatchRequestTime).max().orElse(0); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public T nodeGroup() { | ||
return statuses.stream().map(CacheStatusInfo::nodeGroup).findFirst().orElse(null); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public int numWatches() { | ||
return statuses.stream().mapToInt(CacheStatusInfo::numWatches).sum(); | ||
} | ||
} |
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