native_mini_dfs.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. #ifndef LIBHDFS_NATIVE_MINI_DFS_H
  19. #define LIBHDFS_NATIVE_MINI_DFS_H
  20. #include <jni.h> /* for jboolean */
  21. struct hdfsBuilder;
  22. struct NativeMiniDfsCluster;
  23. /**
  24. * Represents a configuration to use for creating a Native MiniDFSCluster
  25. */
  26. struct NativeMiniDfsConf {
  27. /**
  28. * Nonzero if the cluster should be formatted prior to startup.
  29. */
  30. jboolean doFormat;
  31. /**
  32. * Whether or not to enable webhdfs in MiniDfsCluster
  33. */
  34. jboolean webhdfsEnabled;
  35. /**
  36. * The http port of the namenode in MiniDfsCluster
  37. */
  38. jint namenodeHttpPort;
  39. /**
  40. * Nonzero if we should configure short circuit.
  41. */
  42. jboolean configureShortCircuit;
  43. };
  44. /**
  45. * Create a NativeMiniDfsBuilder
  46. *
  47. * @param conf (inout) The cluster configuration
  48. *
  49. * @return a NativeMiniDfsBuilder, or a NULL pointer on error.
  50. */
  51. struct NativeMiniDfsCluster* nmdCreate(struct NativeMiniDfsConf *conf);
  52. /**
  53. * Wait until a MiniDFSCluster comes out of safe mode.
  54. *
  55. * @param cl The cluster
  56. *
  57. * @return 0 on success; a non-zero error code if the cluster fails to
  58. * come out of safe mode.
  59. */
  60. int nmdWaitClusterUp(struct NativeMiniDfsCluster *cl);
  61. /**
  62. * Shut down a NativeMiniDFS cluster
  63. *
  64. * @param cl The cluster
  65. *
  66. * @return 0 on success; a non-zero error code if an exception is
  67. * thrown.
  68. */
  69. int nmdShutdown(struct NativeMiniDfsCluster *cl);
  70. /**
  71. * Destroy a Native MiniDFSCluster
  72. *
  73. * @param cl The cluster to destroy
  74. */
  75. void nmdFree(struct NativeMiniDfsCluster* cl);
  76. /**
  77. * Get the port that's in use by the given (non-HA) nativeMiniDfs
  78. *
  79. * @param cl The initialized NativeMiniDfsCluster
  80. *
  81. * @return the port, or a negative error code
  82. */
  83. int nmdGetNameNodePort(const struct NativeMiniDfsCluster *cl);
  84. /**
  85. * Get the http address that's in use by the given (non-HA) nativeMiniDfs
  86. *
  87. * @param cl The initialized NativeMiniDfsCluster
  88. * @param port Used to capture the http port of the NameNode
  89. * of the NativeMiniDfsCluster
  90. * @param hostName Used to capture the http hostname of the NameNode
  91. * of the NativeMiniDfsCluster
  92. *
  93. * @return 0 on success; a non-zero error code if failing to
  94. * get the information.
  95. */
  96. int nmdGetNameNodeHttpAddress(const struct NativeMiniDfsCluster *cl,
  97. int *port, const char **hostName);
  98. /**
  99. * Configure the HDFS builder appropriately to connect to this cluster.
  100. *
  101. * @param bld The hdfs builder
  102. *
  103. * @return the port, or a negative error code
  104. */
  105. int nmdConfigureHdfsBuilder(struct NativeMiniDfsCluster *cl,
  106. struct hdfsBuilder *bld);
  107. #endif