-
Notifications
You must be signed in to change notification settings - Fork 517
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c91ad4
commit fae0f2e
Showing
16 changed files
with
2,640 additions
and
154 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
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
47 changes: 47 additions & 0 deletions
47
...e-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/execution/DbChangesRecorder.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,47 @@ | ||
package org.apache.hadoop.ozone.om.ratis.execution; | ||
|
||
import java.util.Collection; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
import org.apache.hadoop.hdds.utils.db.CodecBuffer; | ||
|
||
/** | ||
* Records db changes. | ||
*/ | ||
public class DbChangesRecorder { | ||
private Map<String, Map<String, CodecBuffer>> tableRecordsMap = new HashMap<>(); | ||
private Map<String, Pair<Long, Long>> bucketUsedQuotaMap = new HashMap<>(); | ||
|
||
public void add(String name, String dbOpenKeyName, CodecBuffer omKeyCodecBuffer) { | ||
Map<String, CodecBuffer> recordMap = tableRecordsMap.computeIfAbsent(name, k -> new HashMap<>()); | ||
recordMap.put(dbOpenKeyName, omKeyCodecBuffer); | ||
} | ||
public void add(String bucketName, long incUsedBytes, long incNamespace) { | ||
Pair<Long, Long> quotaPair = bucketUsedQuotaMap.get(bucketName); | ||
if (null == quotaPair) { | ||
bucketUsedQuotaMap.put(bucketName, Pair.of(incUsedBytes, incNamespace)); | ||
} else { | ||
bucketUsedQuotaMap.put(bucketName, Pair.of(incUsedBytes + quotaPair.getLeft(), | ||
incNamespace + quotaPair.getRight())); | ||
} | ||
} | ||
public Map<String, Map<String, CodecBuffer>> getTableRecordsMap() { | ||
return tableRecordsMap; | ||
} | ||
public Map<String, Pair<Long, Long>> getBucketUsedQuotaMap() { | ||
return bucketUsedQuotaMap; | ||
} | ||
|
||
public void clear() { | ||
for (Map<String, CodecBuffer> records : tableRecordsMap.values()) { | ||
records.values().forEach(e -> { | ||
if (e != null) { | ||
e.release(); | ||
} | ||
}); | ||
} | ||
tableRecordsMap.clear(); | ||
bucketUsedQuotaMap.clear(); | ||
} | ||
} |
Oops, something went wrong.