bharatviswa504 commented on a change in pull request #956: HDDS-1638.
Implement Key Write Requests to use Cache and DoubleBuffer.
URL: https://github.com/apache/hadoop/pull/956#discussion_r297868165
##########
File path:
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmMetadataManagerImpl.java
##########
@@ -495,12 +495,27 @@ public boolean isVolumeEmpty(String volume) throws
IOException {
public boolean isBucketEmpty(String volume, String bucket)
throws IOException {
String keyPrefix = getBucketKey(volume, bucket);
- //TODO: When Key ops are converted in to HA model, use cache also to
- // determine bucket is empty or not.
+
+ // First check in key table cache.
+ Iterator<Map.Entry<CacheKey<String>, CacheValue<OmKeyInfo>>> iterator =
+ ((TypedTable< String, OmKeyInfo>) keyTable).cacheIterator();
+ while (iterator.hasNext()) {
+ Map.Entry< CacheKey<String>, CacheValue<OmKeyInfo>> entry =
+ iterator.next();
+ String key = entry.getKey().getCacheKey();
+ OmKeyInfo omKeyInfo = entry.getValue().getCacheValue();
+ // Making sure that entry is not for delete key request.
+ if (key.startsWith(keyPrefix) && omKeyInfo != null) {
+ return false;
+ }
+ }
try (TableIterator<String, ? extends KeyValue<String, OmKeyInfo>> keyIter =
keyTable.iterator()) {
KeyValue<String, OmKeyInfo> kv = keyIter.seek(keyPrefix);
- if (kv != null && kv.getKey().startsWith(keyPrefix)) {
+ // During iteration from DB, check in mean time if this key is not
+ // marked for delete.
+ if (kv != null && kv.getKey().startsWith(keyPrefix) &&
+ keyTable.get(kv.getKey()) != null) {
Review comment:
Yes, you are correct. I have missed this part.
Updated the code to fix this.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]