[GitHub] [hadoop] arp7 commented on a change in pull request #1033: HDDS-1391 : Add ability in OM to serve delta updates through an API.

2019-07-25 Thread GitBox
arp7 commented on a change in pull request #1033: HDDS-1391 : Add ability in OM 
to serve delta updates through an API.
URL: https://github.com/apache/hadoop/pull/1033#discussion_r307529200
 
 

 ##
 File path: 
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManager.java
 ##
 @@ -1395,8 +1397,41 @@ public void testDBKeyMayExist() throws Exception {
 RDBStore rdbStore = (RDBStore) cluster.getOzoneManager()
 .getMetadataManager().getStore();
 RocksDB db = rdbStore.getDb();
-UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
 
+OmKeyInfo keyInfo = getNewOmKeyInfo();
+OmKeyInfoCodec omKeyInfoCodec = new OmKeyInfoCodec();
+
+db.put(StringUtils.getBytesUtf16("OMKey1"),
+omKeyInfoCodec.toPersistedFormat(keyInfo));
+
+StringBuilder sb = new StringBuilder();
+Assert.assertTrue(db.keyMayExist(StringUtils.getBytesUtf16("OMKey1"),
+sb));
+Assert.assertTrue(sb.length() > 0);
+  }
+
+
+  @Test
+  public void testGetOMDBUpdates() throws IOException {
+
+DBUpdatesRequest dbUpdatesRequest =
+DBUpdatesRequest.newBuilder().setSequenceNumber(0).build();
+
+DBUpdatesWrapper dbUpdates =
+cluster.getOzoneManager().getDBUpdates(dbUpdatesRequest);
+Assert.assertTrue(dbUpdates.getData().isEmpty());
+
+//Write data to OM.
+OmKeyInfo keyInfo = getNewOmKeyInfo();
+Assert.assertNotNull(keyInfo);
+dbUpdates =
+cluster.getOzoneManager().getDBUpdates(dbUpdatesRequest);
+Assert.assertFalse(dbUpdates.getData().isEmpty());
 
 Review comment:
   Should we unpack the update and check the contents to ensure they were 
shipped correctly? Not sure if it will be straightforward to do.


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org



[GitHub] [hadoop] arp7 commented on a change in pull request #1033: HDDS-1391 : Add ability in OM to serve delta updates through an API.

2019-07-25 Thread GitBox
arp7 commented on a change in pull request #1033: HDDS-1391 : Add ability in OM 
to serve delta updates through an API.
URL: https://github.com/apache/hadoop/pull/1033#discussion_r307528281
 
 

 ##
 File path: 
hadoop-hdds/common/src/main/java/org/apache/hadoop/utils/db/RDBStore.java
 ##
 @@ -327,6 +329,44 @@ public CodecRegistry getCodecRegistry() {
 return codecRegistry;
   }
 
+  @Override
+  public DBUpdatesWrapper getUpdatesSince(long sequenceNumber)
+  throws SequenceNumberNotFoundException {
+
+DBUpdatesWrapper dbUpdatesWrapper = new DBUpdatesWrapper();
+try {
+  TransactionLogIterator transactionLogIterator =
+  db.getUpdatesSince(sequenceNumber);
+
+  boolean flag = true;
+
+  while (transactionLogIterator.isValid()) {
+TransactionLogIterator.BatchResult result =
+transactionLogIterator.getBatch();
+long currSequenceNumber = result.sequenceNumber();
+if (flag && currSequenceNumber > 1 + sequenceNumber) {
+  throw new SequenceNumberNotFoundException("Unable to read data from" 
+
+  " RocksDB wal to get delta updates. It may have already been" +
+  "flushed to SSTs.");
+}
+flag = false;
+if (currSequenceNumber == sequenceNumber) {
+  transactionLogIterator.next();
+  continue;
+}
+WriteBatch writeBatch = result.writeBatch();
+byte[] writeBatchData = writeBatch.data();
 
 Review comment:
   Nitpick: we can avoid temporary variables writeBatch and writeBatchData.


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org



[GitHub] [hadoop] arp7 commented on a change in pull request #1033: HDDS-1391 : Add ability in OM to serve delta updates through an API.

2019-07-25 Thread GitBox
arp7 commented on a change in pull request #1033: HDDS-1391 : Add ability in OM 
to serve delta updates through an API.
URL: https://github.com/apache/hadoop/pull/1033#discussion_r307528628
 
 

 ##
 File path: 
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java
 ##
 @@ -199,6 +199,7 @@ public static boolean isReadOnly(
 case LookupFile:
 case ListStatus:
 case GetAcl:
+case DBUpdates:
 
 Review comment:
   I believe non-leader OMs will fail to service this request in HA cluster. Is 
that fine?


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org



[GitHub] [hadoop] arp7 commented on a change in pull request #1033: HDDS-1391 : Add ability in OM to serve delta updates through an API.

2019-07-25 Thread GitBox
arp7 commented on a change in pull request #1033: HDDS-1391 : Add ability in OM 
to serve delta updates through an API.
URL: https://github.com/apache/hadoop/pull/1033#discussion_r307528176
 
 

 ##
 File path: 
hadoop-hdds/common/src/main/java/org/apache/hadoop/utils/db/RDBStore.java
 ##
 @@ -327,6 +329,44 @@ public CodecRegistry getCodecRegistry() {
 return codecRegistry;
   }
 
+  @Override
+  public DBUpdatesWrapper getUpdatesSince(long sequenceNumber)
+  throws SequenceNumberNotFoundException {
+
+DBUpdatesWrapper dbUpdatesWrapper = new DBUpdatesWrapper();
+try {
+  TransactionLogIterator transactionLogIterator =
+  db.getUpdatesSince(sequenceNumber);
+
+  boolean flag = true;
+
+  while (transactionLogIterator.isValid()) {
+TransactionLogIterator.BatchResult result =
+transactionLogIterator.getBatch();
+long currSequenceNumber = result.sequenceNumber();
+if (flag && currSequenceNumber > 1 + sequenceNumber) {
+  throw new SequenceNumberNotFoundException("Unable to read data from" 
+
+  " RocksDB wal to get delta updates. It may have already been" +
+  "flushed to SSTs.");
+}
+flag = false;
 
 Review comment:
   I didn't understand why we reset this flag after the first iteration. 
Perhaps it will be clear later.


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org



[GitHub] [hadoop] arp7 commented on a change in pull request #1033: HDDS-1391 : Add ability in OM to serve delta updates through an API.

2019-07-25 Thread GitBox
arp7 commented on a change in pull request #1033: HDDS-1391 : Add ability in OM 
to serve delta updates through an API.
URL: https://github.com/apache/hadoop/pull/1033#discussion_r307527924
 
 

 ##
 File path: 
hadoop-hdds/common/src/main/java/org/apache/hadoop/utils/db/RDBStore.java
 ##
 @@ -327,6 +329,44 @@ public CodecRegistry getCodecRegistry() {
 return codecRegistry;
   }
 
+  @Override
+  public DBUpdatesWrapper getUpdatesSince(long sequenceNumber)
+  throws SequenceNumberNotFoundException {
+
+DBUpdatesWrapper dbUpdatesWrapper = new DBUpdatesWrapper();
+try {
+  TransactionLogIterator transactionLogIterator =
+  db.getUpdatesSince(sequenceNumber);
+
+  boolean flag = true;
 
 Review comment:
   Can you give this a more descriptive name?


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org



[GitHub] [hadoop] arp7 commented on a change in pull request #1033: HDDS-1391 : Add ability in OM to serve delta updates through an API.

2019-07-25 Thread GitBox
arp7 commented on a change in pull request #1033: HDDS-1391 : Add ability in OM 
to serve delta updates through an API.
URL: https://github.com/apache/hadoop/pull/1033#discussion_r307527606
 
 

 ##
 File path: 
hadoop-hdds/common/src/main/java/org/apache/hadoop/utils/db/DBUpdatesWrapper.java
 ##
 @@ -0,0 +1,48 @@
+/*
+ * 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
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.utils.db;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Wrapper class to hold DB data read from the RocksDB log file.
+ */
+public class DBUpdatesWrapper {
+
+  private List dataList = new ArrayList<>();
+  private long currentSequenceNumber = 0;
 
 Review comment:
   Should we initialize this to -1? I am not sure if 0 can be a valid sequence 
number.


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org