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

2019-12-04 Thread GitBox
nandakumar131 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_r353917339
 
 

 ##
 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)
 
 Review comment:
   Thanks for the catch.


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: ozone-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org



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

2019-12-04 Thread GitBox
nandakumar131 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_r353914413
 
 

 ##
 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 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:
   Agreed, even the read path in old code will also be removed, this change is 
just to make sure that we are not breaking any functionality in the old code 
path. Both the KeyManagerImpl and the corresponding test class will be removed 
eventually.


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: ozone-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: ozone-issues-h...@hadoop.apache.org