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

        fla Fernando Lopez made changes -
        Fix Version/s 2021 [ 12600 ]
        mev Manuel Escriche made changes -
        HD-Enabler Cosmos [ 10872 ]
        HD-Chapter Data [ 10838 ]
        mev Manuel Escriche made changes -
        Summary FIWARE.Question.Tech.How can I Read and Transfer chunks of file with Hadoop WebHDFS? FIWARE.Question.Tech.Data.BigData-Analysis.How can I Read and Transfer chunks of file with Hadoop WebHDFS?
        mev Manuel Escriche made changes -
        Summary FIWARE.Question.Tech.FIWARE.Question.Tech.How can I Read and Transfer chunks of file with Hadoop WebHDFS? FIWARE.Question.Tech.How can I Read and Transfer chunks of file with Hadoop WebHDFS?
        mev Manuel Escriche made changes -
        Summary FIWARE.Question.Tech.How can I Read and Transfer chunks of file with Hadoop WebHDFS? FIWARE.Question.Tech.FIWARE.Question.Tech.How can I Read and Transfer chunks of file with Hadoop WebHDFS?
        mev Manuel Escriche made changes -
        Summary FIWARE.Question.Tech.FIWARE.Question.Tech.How can I Read and Transfer chunks of file with Hadoop WebHDFS? FIWARE.Question.Tech.How can I Read and Transfer chunks of file with Hadoop WebHDFS?
        mev Manuel Escriche made changes -
        Summary FIWARE.Question.Tech.How can I Read and Transfer chunks of file with Hadoop WebHDFS? FIWARE.Question.Tech.FIWARE.Question.Tech.How can I Read and Transfer chunks of file with Hadoop WebHDFS?
        mev Manuel Escriche made changes -
        Summary [fiware-stackoverflow] How can I Read and Transfer chunks of file with Hadoop WebHDFS? FIWARE.Question.Tech.How can I Read and Transfer chunks of file with Hadoop WebHDFS?
        backlogmanager Backlog Manager made changes -
        Resolution Done [ 10000 ]
        Status Answered [ 10104 ] Closed [ 6 ]
        backlogmanager Backlog Manager made changes -
        Status In Progress [ 3 ] Answered [ 10104 ]
        backlogmanager Backlog Manager made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        mev Manuel Escriche made changes -
        Assignee Francisco Romero [ frb ]
        backlogmanager Backlog Manager made changes -
        Field Original Value New Value
        Component/s FIWARE-TECH-HELP [ 10278 ]
        backlogmanager Backlog Manager created issue -

          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: