native_mini_dfs.h 3.5 KB

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