示例#1
0
    def test_get_ensemble_upstream_solr(self):
        client = SolrClient(self.user, api=MockSolrUpstreamCloudApi())

        client._reset_properties()

        assert_true(client.is_solr_cloud_mode())
        assert_true(client.is_solr_six_or_more())
        assert_false(client.is_solr_with_hdfs())
        assert_equal('localhost:9983', client.get_zookeeper_host())
示例#2
0
    def test_get_ensemble_cdh_solr(self):
        client = SolrClient(self.user, api=MockSolrCdhCloudHdfsApi())

        client._reset_properties()

        assert_true(client.is_solr_cloud_mode())
        assert_false(client.is_solr_six_or_more())
        assert_true(client.is_solr_with_hdfs())
        assert_equal('hue.com:2181/solr', client.get_zookeeper_host())
示例#3
0
    def _create_solr_cloud_collection(self, name, fields, unique_key_field,
                                      df):
        client = SolrClient(self.user)

        with ZookeeperClient(hosts=client.get_zookeeper_host(),
                             read_only=False) as zc:
            root_node = '%s/%s' % (ZK_SOLR_CONFIG_NAMESPACE, name)

            tmp_path, solr_config_path = copy_configs(
                fields=fields,
                unique_key_field=unique_key_field,
                df=df,
                solr_cloud_mode=client.is_solr_cloud_mode(),
                is_solr_six_or_more=client.is_solr_six_or_more(),
                is_solr_hdfs_mode=client.is_solr_with_hdfs())
            try:
                config_root_path = '%s/%s' % (solr_config_path, 'conf')
                try:
                    zc.copy_path(root_node, config_root_path)

                except Exception, e:
                    zc.delete_path(root_node)
                    raise PopupException(
                        _('Error in copying Solr configurations: %s') % e)
            finally:
                # Don't want directories laying around
                shutil.rmtree(tmp_path)

            api = SolrApi(SOLR_URL.get(), self.user, SECURITY_ENABLED.get())
            if not api.create_collection(name):
                # Delete instance directory if we couldn't create a collection.
                try:
                    zc.delete_path(root_node)
                except Exception, e:
                    raise PopupException(
                        _('Error in deleting Solr configurations.'), detail=e)
                raise PopupException(
                    _('Could not create collection. Check error logs for more info.'
                      ))