Uploaded image for project: 'Help-Desk'
  1. Help-Desk
  2. HELP-5423

FIWARE.Question.Tech.Data.BigData-Analysis.How can I Read and Transfer chunks of file with Hadoop WebHDFS?

    Details

      Description

      Created question in FIWARE Q/A platform on 28-11-2015 at 19:11
      Please, ANSWER this question AT http://stackoverflow.com/questions/33974754/how-can-i-read-and-transfer-chunks-of-file-with-hadoop-webhdfs

      Question:
      How can I Read and Transfer chunks of file with Hadoop WebHDFS?

      Description:
      I need to transfer big files (at least 14MB) from the Cosmos instance of the FIWARE Lab to my backend.

      I used the Spring RestTemplate as a client interface for the Hadoop WebHDFS REST API described here but I run into an IO Exception:

      Exception in thread "main" org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://cosmos.lab.fiware.org:14000/webhdfs/v1/user/<user.name>/<path>?op=open&user.name=<user.name>":Truncated chunk ( expected size: 14744230; actual size: 11285103); nested exception is org.apache.http.TruncatedChunkException: Truncated chunk ( expected size: 14744230; actual size: 11285103)
      at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:580)
      at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:545)
      at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:466)

      This is the actual code that generates the Exception:

      RestTemplate restTemplate = new RestTemplate();
      restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory());
      HttpEntity<?> entity = new HttpEntity<>(headers);

      UriComponentsBuilder builder =
      UriComponentsBuilder.fromHttpUrl(hdfs_path)
      .queryParam("op", "OPEN")
      .queryParam("user.name", user_name);

      ResponseEntity<byte[]> response =
      restTemplate
      .exchange(builder.build().encode().toUri(), HttpMethod.GET, entity, byte[].class);

      FileOutputStream output = new FileOutputStream(new File(local_path));
      IOUtils.write(response.getBody(), output);
      output.close();

      I think this is due to a transfer timeout on the Cosmos instance, so I tried to
      send a curl on the path by specifying offset, buffer and length parameters, but they seem to be ignored: I got the whole file.

      Thanks in advance.

        Activity

        Hide
        backlogmanager Backlog Manager added a comment -

        2015-11-28 21:05|CREATED monitor | # answers= 0, accepted answer= False

        Show
        backlogmanager Backlog Manager added a comment - 2015-11-28 21:05|CREATED monitor | # answers= 0, accepted answer= False
        Hide
        backlogmanager Backlog Manager added a comment -

        2015-11-30 12:05|UPDATED status: transition Answer| # answers= 1, accepted answer= False

        Show
        backlogmanager Backlog Manager added a comment - 2015-11-30 12:05|UPDATED status: transition Answer| # answers= 1, accepted answer= False
        Hide
        backlogmanager Backlog Manager added a comment -

        2015-11-30 15:05|UPDATED status: transition Answered| # answers= 1, accepted answer= False

        Show
        backlogmanager Backlog Manager added a comment - 2015-11-30 15:05|UPDATED status: transition Answered| # answers= 1, accepted answer= False
        Hide
        backlogmanager Backlog Manager added a comment -

        2015-11-30 21:05|UPDATED status: transition Finish| # answers= 1, accepted answer= True

        Show
        backlogmanager Backlog Manager added a comment - 2015-11-30 21:05|UPDATED status: transition Finish| # answers= 1, accepted answer= True

          People

          • Assignee:
            frb Francisco Romero
            Reporter:
            backlogmanager Backlog Manager
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: