Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public RegionGroupCache(String database, Set<Integer> dataNodeIds, boolean isStr
* @param newHeartbeatSample The newest RegionHeartbeatSample
* @param overwrite Able to overwrite Adding or Removing
*/
public void cacheHeartbeatSample(
public synchronized void cacheHeartbeatSample(
int dataNodeId, RegionHeartbeatSample newHeartbeatSample, boolean overwrite) {
// Only cache sample when the corresponding loadCache exists
Optional.ofNullable(regionCacheMap.get(dataNodeId))
Expand All @@ -78,7 +78,7 @@ public void cacheHeartbeatSample(int dataNodeId, RegionHeartbeatSample newHeartb
*
* @param dataNodeId the specified DataNode
*/
public void createRegionCache(int dataNodeId) {
public synchronized void createRegionCache(int dataNodeId) {
regionCacheMap.put(dataNodeId, new RegionCache());
}

Expand All @@ -87,15 +87,15 @@ public void createRegionCache(int dataNodeId) {
*
* @param dataNodeId the specified DataNode
*/
public void removeRegionCache(int dataNodeId) {
public synchronized void removeRegionCache(int dataNodeId) {
regionCacheMap.remove(dataNodeId);
}

/**
* Update currentStatistics based on the latest NodeHeartbeatSamples that cached in the
* slidingWindow.
*/
public void updateCurrentStatistics() {
public synchronized void updateCurrentStatistics() {
regionCacheMap.values().forEach(regionCache -> regionCache.updateCurrentStatistics(false));
Map<Integer, RegionStatistics> regionStatisticsMap =
regionCacheMap.entrySet().stream()
Expand Down
Loading