You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2020/10/13 10:01:00 UTC

[jira] [Work logged] (HIVE-24267) RetryingClientTimeBased should always perform first invocation

     [ https://issues.apache.org/jira/browse/HIVE-24267?focusedWorklogId=499960&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-499960 ]

ASF GitHub Bot logged work on HIVE-24267:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 13/Oct/20 10:00
            Start Date: 13/Oct/20 10:00
    Worklog Time Spent: 10m 
      Work Description: aasha commented on a change in pull request #1573:
URL: https://github.com/apache/hive/pull/1573#discussion_r503824826



##########
File path: ql/src/test/org/apache/hadoop/hive/ql/exec/repl/TestAtlasDumpTask.java
##########
@@ -114,4 +123,55 @@ public void testAtlasRestClientBuilder() throws SemanticException, IOException {
     AtlasRestClient atlasClient = atlasRestCleintBuilder.getClient(conf);
     Assert.assertTrue(atlasClient != null);
   }
+
+  @Test
+  public void testRetryingClientTimeBased() throws SemanticException, IOException, AtlasServiceException {
+    AtlasClientV2 atlasClientV2 = mock(AtlasClientV2.class);
+    AtlasExportRequest exportRequest = mock(AtlasExportRequest.class);
+    String exportResponseData = "dumpExportContent";
+    InputStream exportedMetadataIS = new ByteArrayInputStream(exportResponseData.getBytes(StandardCharsets.UTF_8));
+    when(atlasClientV2.exportData(any(AtlasExportRequest.class))).thenReturn(exportedMetadataIS);
+    when(exportRequest.toString()).thenReturn("dummyExportRequest");
+    when(conf.getTimeVar(HiveConf.ConfVars.REPL_RETRY_TOTAL_DURATION, TimeUnit.SECONDS)).thenReturn(60L);
+    when(conf.getTimeVar(HiveConf.ConfVars.REPL_RETRY_INTIAL_DELAY, TimeUnit.SECONDS)).thenReturn(1L);
+    AtlasRestClient atlasClient = new AtlasRestClientImpl(atlasClientV2, conf);
+    AtlasRestClientImpl atlasRestClientImpl = (AtlasRestClientImpl)atlasClient;
+    InputStream inputStream = atlasRestClientImpl.exportData(exportRequest);
+    ArgumentCaptor<AtlasExportRequest> expReqCaptor = ArgumentCaptor.forClass(AtlasExportRequest.class);
+    Mockito.verify(atlasClientV2, Mockito.times(1)).exportData(expReqCaptor.capture());
+    Assert.assertEquals(expReqCaptor.getValue().toString(), "dummyExportRequest");
+    byte[] exportResponseDataReadBytes = new byte[exportResponseData.length()];
+    inputStream.read(exportResponseDataReadBytes);
+    String exportResponseDataReadString = new String(exportResponseDataReadBytes, StandardCharsets.UTF_8);
+    Assert.assertEquals(exportResponseData, exportResponseDataReadString);
+  }
+
+  @Test
+  public void testRetryingClientTimeBasedExhausted() throws AtlasServiceException {
+    AtlasClientV2 atlasClientV2 = mock(AtlasClientV2.class);
+    AtlasExportRequest exportRequest = mock(AtlasExportRequest.class);
+    AtlasServiceException atlasServiceException = mock(AtlasServiceException.class);
+    when(atlasServiceException.getMessage()).thenReturn("import or export is in progress");
+    when(atlasClientV2.exportData(any(AtlasExportRequest.class))).thenThrow(atlasServiceException);
+    when(exportRequest.toString()).thenReturn("dummyExportRequest");
+    when(conf.getTimeVar(HiveConf.ConfVars.REPL_RETRY_TOTAL_DURATION, TimeUnit.SECONDS)).thenReturn(60L);
+    when(conf.getTimeVar(HiveConf.ConfVars.REPL_RETRY_INTIAL_DELAY, TimeUnit.SECONDS)).thenReturn(10L);
+    when(conf.getTimeVar(HiveConf.ConfVars.REPL_RETRY_MAX_DELAY_BETWEEN_RETRIES, TimeUnit.SECONDS)).thenReturn(20L);
+    when(conf.getFloatVar(HiveConf.ConfVars.REPL_RETRY_BACKOFF_COEFFICIENT)).thenReturn(2.0f);
+    AtlasRestClient atlasClient = new AtlasRestClientImpl(atlasClientV2, conf);
+    AtlasRestClientImpl atlasRestClientImpl = (AtlasRestClientImpl)atlasClient;
+    InputStream inputStream = null;
+    try {
+      inputStream = atlasRestClientImpl.exportData(exportRequest);
+      Assert.fail("Should have thrown SemanticException.");
+    } catch (SemanticException ex) {
+      Assert.assertTrue(ex.getMessage().contains("Retry exhausted for retryable error code"));

Review comment:
       The actual exception should also be present

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/exec/repl/AtlasDumpTask.java
##########
@@ -194,9 +194,11 @@ long dumpAtlasMetaData(AtlasRequestBuilder atlasRequestBuilder, AtlasReplInfo at
       AtlasExportRequest exportRequest = atlasRequestBuilder.createExportRequest(atlasReplInfo,
               atlasReplInfo.getSrcCluster());
       inputStream = atlasRestClient.exportData(exportRequest);
-      FileSystem fs = atlasReplInfo.getStagingDir().getFileSystem(atlasReplInfo.getConf());
-      Path exportFilePath = new Path(atlasReplInfo.getStagingDir(), ReplUtils.REPL_ATLAS_EXPORT_FILE_NAME);
-      numBytesWritten = Utils.writeFile(fs, exportFilePath, inputStream, conf);
+      if (inputStream != null) {
+        FileSystem fs = atlasReplInfo.getStagingDir().getFileSystem(atlasReplInfo.getConf());
+        Path exportFilePath = new Path(atlasReplInfo.getStagingDir(), ReplUtils.REPL_ATLAS_EXPORT_FILE_NAME);
+        numBytesWritten = Utils.writeFile(fs, exportFilePath, inputStream, conf);
+      }

Review comment:
       An error log for null inputstream would help




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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 499960)
    Time Spent: 20m  (was: 10m)

> RetryingClientTimeBased should always perform first invocation
> --------------------------------------------------------------
>
>                 Key: HIVE-24267
>                 URL: https://issues.apache.org/jira/browse/HIVE-24267
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Pravin Sinha
>            Assignee: Pravin Sinha
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: HIVE-24267.01.patch
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)