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 2019/12/04 18:30:32 UTC

[GitHub] [hadoop-ozone] bharatviswa504 commented on a change in pull request #301: HDDS-2636. Refresh pipeline information in OzoneManager lookupFile call.

bharatviswa504 commented on a change in pull request #301: HDDS-2636. Refresh pipeline information in OzoneManager lookupFile call.
URL: https://github.com/apache/hadoop-ozone/pull/301#discussion_r353910353
 
 

 ##########
 File path: hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestKeyManagerUnit.java
 ##########
 @@ -177,4 +194,128 @@ private OmMultipartInfo initMultipartUpload(KeyManagerImpl omtest,
         .build();
     return omtest.initiateMultipartUpload(key1);
   }
+
+  @Test
+  public void testLookupFileWithDnFailure() throws IOException {
+    final ScmBlockLocationProtocol blockClient =
+        Mockito.mock(ScmBlockLocationProtocol.class);
+    final StorageContainerLocationProtocol containerClient =
+        Mockito.mock(StorageContainerLocationProtocol.class);
+    final KeyManager manager = new KeyManagerImpl(null,
+        new ScmClient(blockClient, containerClient),
+        metadataManager, configuration, "test-om",
+        Mockito.mock(OzoneBlockTokenSecretManager.class), null, null);
+
+    final DatanodeDetails dnOne = TestUtils.randomDatanodeDetails();
+    final DatanodeDetails dnTwo = TestUtils.randomDatanodeDetails();
+    final DatanodeDetails dnThree = TestUtils.randomDatanodeDetails();
+
+    final DatanodeDetails dnFour = TestUtils.randomDatanodeDetails();
+    final DatanodeDetails dnFive = TestUtils.randomDatanodeDetails();
+    final DatanodeDetails dnSix = TestUtils.randomDatanodeDetails();
+
+    final PipelineID pipelineOneId = PipelineID.randomId();
+    final Pipeline pipelineOne = Pipeline.newBuilder()
+        .setId(pipelineOneId)
+        .setType(ReplicationType.RATIS)
+        .setFactor(ReplicationFactor.THREE)
+        .setState(Pipeline.PipelineState.OPEN)
+        .setLeaderId(dnOne.getUuid())
+        .setNodes(Arrays.asList(dnOne, dnTwo, dnThree))
+        .build();
+
+    final PipelineID pipelineTwoId = PipelineID.randomId();
+    final Pipeline pipelineTwo = Pipeline.newBuilder()
+        .setId(pipelineOneId)
+        .setType(ReplicationType.RATIS)
+        .setFactor(ReplicationFactor.THREE)
+        .setState(Pipeline.PipelineState.OPEN)
+        .setLeaderId(dnFour.getUuid())
+        .setNodes(Arrays.asList(dnFour, dnFive, dnSix))
+        .build();
+
+    final ContainerBlockID blockID = new ContainerBlockID(1L, 1L);
+
+    final List<AllocatedBlock> blocks = new ArrayList<>();
+    final AllocatedBlock block = new AllocatedBlock.Builder()
+        .setPipeline(pipelineOne)
+        .setContainerBlockID(blockID)
+        .build();
+    blocks.add(block);
+
+    Mockito.when(blockClient.allocateBlock(Mockito.anyLong(), Mockito.anyInt(),
+        Mockito.any(ReplicationType.class),
+        Mockito.any(HddsProtos.ReplicationFactor.class),
+        Mockito.anyString(), Mockito.any(ExcludeList.class)))
+        .thenReturn(blocks);
+
+    Mockito.when(containerClient.getContainerWithPipeline(1L))
+        .thenReturn(new ContainerWithPipeline(null, pipelineTwo));
+
+    final OmVolumeArgs volumeArgs = OmVolumeArgs.newBuilder()
+        .setVolume("volumeOne")
+        .setAdminName("admin")
+        .setOwnerName("admin")
+        .build();
+    TestOMRequestUtils.addVolumeToOM(metadataManager, volumeArgs);
+
+    final OmBucketInfo bucketInfo = OmBucketInfo.newBuilder()
+          .setVolumeName("volumeOne")
+          .setBucketName("bucketOne")
+          .build();
+    TestOMRequestUtils.addBucketToOM(metadataManager, bucketInfo);
+
+    final OmKeyArgs.Builder keyArgs = new OmKeyArgs.Builder()
+        .setVolumeName("volumeOne")
+        .setBucketName("bucketOne")
+        .setKeyName("keyOne")
+        .setFactor(ReplicationFactor.THREE)
+        .setAcls(Collections.emptyList());
+
+    final OpenKeySession session = manager.createFile(keyArgs.build(),
+        false, false);
 
 Review comment:
   Write requests in old code will be soon removed. Can we use similar API's which are used to create bucket/volume or directly use OmMetadataManager keyTable put to add key?

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


With regards,
Apache Git Services

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