conf.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/usr/bin/env python
  2. # Licensed to Cloudera, Inc. under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. Cloudera, Inc. 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. import os
  18. from urlparse import urlparse
  19. from django.utils.translation import ugettext_lazy as _t
  20. from desktop.lib.conf import Config
  21. def solrctl():
  22. """
  23. solrctl path
  24. """
  25. for dirname in os.environ.get('PATH', '').split(os.path.pathsep):
  26. path = os.path.join(dirname, 'solrctl')
  27. if os.path.exists(path):
  28. return path
  29. return None
  30. def zkensemble():
  31. """
  32. ZooKeeper Ensemble
  33. """
  34. try:
  35. from zookeeper.conf import CLUSTERS
  36. clusters = CLUSTERS.get()
  37. if clusters['default'].HOST_PORTS.get() != 'localhost:2181':
  38. return '%s/solr' % clusters['default'].HOST_PORTS.get()
  39. except:
  40. pass
  41. try:
  42. from search.conf import SOLR_URL
  43. parsed = urlparse(SOLR_URL.get())
  44. return "%s:2181/solr" % (parsed.hostname or 'localhost')
  45. except:
  46. pass
  47. # Unused
  48. BATCH_INDEXER_PATH = Config(
  49. key="batch_indexer_path",
  50. help=_t("Batch indexer path in HDFS."),
  51. type=str,
  52. default="/var/lib/search/search-mr-job.jar")
  53. CORE_INSTANCE_DIR = Config(
  54. key="core_instance_dir",
  55. help=_t("Local path to Hue folder where Solr instance directories will be created in non-solrcloud mode."),
  56. type=str,
  57. default=os.path.join(os.path.dirname(__file__), '../data/collections'))
  58. CONFIG_TEMPLATE_PATH = Config(
  59. key="config_template_path",
  60. help=_t("Default template used at collection creation."),
  61. type=str,
  62. default=os.path.join(os.path.dirname(__file__), '..', 'data', 'solrconfigs'))
  63. SOLRCTL_PATH = Config(
  64. key="solrctl_path",
  65. help=_t("Location of the solrctl binary."),
  66. type=str,
  67. dynamic_default=solrctl)
  68. SOLR_ZK_ENSEMBLE = Config(
  69. key="solr_zk_ensemble",
  70. help=_t("Zookeeper ensemble."),
  71. type=str,
  72. dynamic_default=zkensemble)