You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2021/07/07 23:27:53 UTC

[GitHub] [ozone] yuangu002 commented on a change in pull request #2389: HDDS-5386. Add a NSSummaryTask to write NSSummary info into RDB

yuangu002 commented on a change in pull request #2389:
URL: https://github.com/apache/ozone/pull/2389#discussion_r665768508



##########
File path: hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/NSSummaryTask.java
##########
@@ -0,0 +1,205 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.recon.tasks;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.hadoop.hdds.utils.db.Table;
+import org.apache.hadoop.hdds.utils.db.TableIterator;
+import org.apache.hadoop.ozone.om.OMMetadataManager;
+import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
+import org.apache.hadoop.ozone.recon.ReconConstants;
+import org.apache.hadoop.ozone.recon.ReconUtils;
+import org.apache.hadoop.ozone.recon.api.types.NSSummary;
+import org.apache.hadoop.ozone.recon.spi.ReconNamespaceSummaryManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+
+import static org.apache.hadoop.ozone.om.OmMetadataManagerImpl.KEY_TABLE;
+
+/**
+ * Task to query data from OMDB and write into Recon RocksDB.
+ */
+public class NSSummaryTask implements ReconOmTask {
+  private static final Logger LOG =
+          LoggerFactory.getLogger(NSSummaryTask.class);
+  private ReconNamespaceSummaryManager reconNamespaceSummaryManager;
+
+  @Inject
+  public NSSummaryTask(ReconNamespaceSummaryManager
+                                 reconNamespaceSummaryManager) {
+    this.reconNamespaceSummaryManager = reconNamespaceSummaryManager;
+  }
+
+  @Override
+  public String getTaskName() {
+    return "NSSummaryTask";
+  }
+
+  public Collection<String> getTaskTables() {
+    return Collections.singletonList(KEY_TABLE);
+  }
+
+  @Override
+  public Pair<String, Boolean> process(OMUpdateEventBatch events) {
+    Iterator<OMDBUpdateEvent> eventIterator = events.getIterator();
+    final Collection<String> taskTables = getTaskTables();
+
+    while (eventIterator.hasNext()) {
+      OMDBUpdateEvent<String, OmKeyInfo> omdbUpdateEvent = eventIterator.next();
+      // we only process updates on OM's KeyTable.
+      if (!taskTables.contains(omdbUpdateEvent.getTable())) {

Review comment:
       For testing I think it's fine (as long as we set parent ID correct, we don't need to enable FSO in testing).
   But for the newer version of this branch, I am going to only track the changes in the FileTable (because FSO-enabled ozone doesn't have a KeyTable anymore. Instead, DirTable and FileTable replace it, according to [this](https://ci-hadoop.apache.org/view/Hadoop%20Ozone/job/ozone-doc-master/lastSuccessfulBuild/artifact/hadoop-hdds/docs/public/feature/prefixfso.html)).
   According to the existing code, if the FSO is enabled, OmMetadataManagerImpl.getKeyTable() will simply return the fileTable:
   ![Screen Shot 2021-07-07 at 7 25 53 PM](https://user-images.githubusercontent.com/53324985/124840558-41906e80-df59-11eb-9eaa-e93ed770d43e.png)
   Let me know if it makes sense to you.




-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org