Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDDS-3972. Add option to limit number of items displaying through ldb tool. #1206

Merged
merged 8 commits into from
Aug 27, 2020

Conversation

sadanand48
Copy link
Contributor

What changes were proposed in this pull request?

The change here is to add an option to the ldb tool scan command to limit number of displayed items.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-3972

How was this patch tested?

Added Unit Tests for the tool.

Copy link
Member

@elek elek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sadanand48 the patch, overall it looks good to me.

I appreciate that you added a unit test (big +1), but I would prefer to keep it simple as a real unit test (without starting real MiniOzoneCluster)

@Before
public void setup() throws Exception {
conf = new OzoneConfiguration();
cluster = MiniOzoneCluster.newBuilder(conf).build();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MiniOzoneCluster is very heavy weight for this kind of testing. It's very slow (requires to start all the services) and easier to be flaky.

I would suggest to use pure rocksdb creation here (for example use pure DBStoreBuilder and create a pure rocksdb dir). Or if you prefer to test SCM specific rocksdb, you can use SCMMetadataStoreImpl

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have used DBStoreBuilder now. But i had to create a db with the same name 'om.db' as the tool only reads from those DB whose DBDefinition is defined. I'm not sure whether that would be a problem.

@sadanand48
Copy link
Contributor Author

Thanks @elek for the review. Addressed Review Comments.

@elek
Copy link
Member

elek commented Jul 30, 2020

Thanks the update @sadanand48. Yes it looks better (and significant better) for me.

I realized two other NITs in the test.

  1. @Test(expected = IllegalArgumentException.class)

When you use complex test cases (which multiple assertions) it's not safe to use the expected attribute. Actually this test passes even if the method always returns with IllegalArgumentException as the remaining asserstions will be ignored in this case.

For example the last line, is ignored in the current patch.

    Assert.assertEquals(0, keyNames.size());

It's never called.

I think it's more safe to check if that specific call throws an exception or not:

    try {
      getKeyNames(dbScanner, "keyTable", keyNames);
      Assert.fail("Illegal argument exception is expected");
    } catch (IllegalArgumentException ex) {

    }
  1. Is more minor, but the readability can be improved with using
    List<String> keyNames = getKeyNames(dbScanner, "keyTable");

instead of

getKeyNames(dbScanner, "keyTable", keyNames);

I know that it's possible to pass keyNames as reference and reset and modify the content, but the behavior seems to be more obvious (easier to read) if you just return with the selected values.

Copy link
Member

@elek elek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 Thank you very much the update @sadanand48 (and sorry for late answer).

I am merging it now.

@elek elek merged commit 7f674fd into apache:master Aug 27, 2020
rakeshadr pushed a commit to rakeshadr/hadoop-ozone that referenced this pull request Sep 3, 2020
errose28 added a commit to errose28/ozone that referenced this pull request Sep 11, 2020
* master: (26 commits)
  HDDS-4167. Acceptance test logs missing if fails during cluster startup (apache#1366)
  HDDS-4121. Implement OmMetadataMangerImpl#getExpiredOpenKeys. (apache#1351)
  HDDS-3867. Extend the chunkinfo tool to display information from all nodes in the pipeline. (apache#1154)
  HDDS-4077. Incomplete OzoneFileSystem statistics (apache#1329)
  HDDS-3903. OzoneRpcClient support batch rename keys. (apache#1150)
  HDDS-4151. Skip the inputstream while offset larger than zero in s3g (apache#1354)
  HDDS-4147. Add OFS to FileSystem META-INF (apache#1352)
  HDDS-4137. Turn on the verbose mode of safe mode check on testlib (apache#1343)
  HDDS-4146. Show the ScmId and ClusterId in the scm web ui. (apache#1350)
  HDDS-4145. Bump version to 1.1.0-SNAPSHOT on master (apache#1349)
  HDDS-4109. Tests in TestOzoneFileSystem should use the existing MiniOzoneCluster (apache#1316)
  HDDS-4149. Implement OzoneFileStatus#toString (apache#1356)
  HDDS-4153. Increase default timeout in kubernetes tests (apache#1357)
  HDDS-2411. add a datanode chunk validator fo datanode chunk generator (apache#1312)
  HDDS-4140. Auto-close /pending pull requests after 21 days of inactivity (apache#1344)
  HDDS-4152. Archive container logs for kubernetes check (apache#1355)
  HDDS-4056. Convert OzoneAdmin to pluggable model (apache#1285)
  HDDS-3972. Add option to limit number of items displaying through ldb tool. (apache#1206)
  HDDS-4068. Client should not retry same OM on network connection failure (apache#1324)
  HDDS-4062. Non rack aware pipelines should not be created if multiple racks are alive. (apache#1291)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants