remote_block_reader.cc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #include "block_reader.h"
  19. namespace hdfs {
  20. hadoop::hdfs::OpReadBlockProto ReadBlockProto(const std::string &client_name,
  21. bool verify_checksum,
  22. const hadoop::common::TokenProto *token,
  23. const hadoop::hdfs::ExtendedBlockProto *block,
  24. uint64_t length, uint64_t offset) {
  25. using namespace hadoop::hdfs;
  26. using namespace hadoop::common;
  27. BaseHeaderProto *base_h = new BaseHeaderProto();
  28. base_h->set_allocated_block(new ExtendedBlockProto(*block));
  29. if (token) {
  30. base_h->set_allocated_token(new TokenProto(*token));
  31. }
  32. ClientOperationHeaderProto *h = new ClientOperationHeaderProto();
  33. h->set_clientname(client_name);
  34. h->set_allocated_baseheader(base_h);
  35. OpReadBlockProto p;
  36. p.set_allocated_header(h);
  37. p.set_offset(offset);
  38. p.set_len(length);
  39. p.set_sendchecksums(verify_checksum);
  40. // TODO: p.set_allocated_cachingstrategy();
  41. return p;
  42. }
  43. }