options.cc 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 "hdfspp/options.h"
  19. namespace hdfs {
  20. // The linker needs a place to put all of those constants
  21. const int Options::kDefaultRpcTimeout;
  22. const int Options::kNoRetry;
  23. const int Options::kDefaultMaxRpcRetries;
  24. const int Options::kDefaultRpcRetryDelayMs;
  25. const unsigned int Options::kDefaultHostExclusionDuration;
  26. const unsigned int Options::kDefaultFailoverMaxRetries;
  27. const unsigned int Options::kDefaultFailoverConnectionMaxRetries;
  28. Options::Options() : rpc_timeout(kDefaultRpcTimeout),
  29. rpc_connect_timeout(kDefaultRpcConnectTimeout),
  30. max_rpc_retries(kDefaultMaxRpcRetries),
  31. rpc_retry_delay_ms(kDefaultRpcRetryDelayMs),
  32. host_exclusion_duration(kDefaultHostExclusionDuration),
  33. defaultFS(),
  34. failover_max_retries(kDefaultFailoverMaxRetries),
  35. failover_connection_max_retries(kDefaultFailoverConnectionMaxRetries),
  36. authentication(kDefaultAuthentication) {}
  37. std::string NamenodeInfo::get_host() const {
  38. return uri.get_host();
  39. }
  40. std::string NamenodeInfo::get_port() const {
  41. optional<uint16_t> p = uri.get_port();
  42. if(!p)
  43. return std::to_string(-1);
  44. return std::to_string(p.value());
  45. }
  46. }