Ejemplo n.º 1
0
  def test_path_exists(self):
    try:
      root_node = '%s/%s' % (TestWithZooKeeper.namespace, 'test_path_exists')
      client = ZookeeperClient(hosts=zkensemble(), read_only=False)

      # Delete the root_node first just in case it wasn't cleaned up in previous run
      client.zk.start()
      client.zk.create(root_node, value='test_path_exists')
      client.zk.stop()

      assert_true(client.path_exists(namespace=root_node))
      assert_false(client.path_exists(namespace='bogus_path'))
    finally:
      client.delete_path(root_node)
Ejemplo n.º 2
0
  def test_path_exists(self):
    root_node = '%s/%s' % (TestWithZooKeeper.namespace, 'test_path_exists')
    client = ZookeeperClient(hosts=zkensemble(), read_only=False)

    client.zk.start()
    try:
      client.zk.create(root_node, value='test_path_exists', makepath=True)

      try:
        assert_true(client.path_exists(namespace=root_node))
        assert_false(client.path_exists(namespace='bogus_path'))
      finally:
        client.delete_path(root_node)
    finally:
      client.zk.stop()
Ejemplo n.º 3
0
    def create_index(self, name, fields, unique_key_field='id', df='text'):
        """
    Create solr collection or core and instance dir.
    Create schema.xml file so that we can set UniqueKey field.
    """
        if self.is_solr_cloud_mode():
            tmp_path, solr_config_path = copy_configs(fields, unique_key_field,
                                                      df, True)

            try:
                zc = ZookeeperClient(hosts=get_solr_ensemble(),
                                     read_only=False)
                root_node = '%s/%s' % (ZK_SOLR_CONFIG_NAMESPACE, name)
                config_root_path = '%s/%s' % (solr_config_path, 'conf')
                zc.copy_path(root_node, config_root_path)

                if not self.api.create_collection(name):
                    raise Exception('Failed to create collection: %s' % name)
            except Exception, e:
                if zc.path_exists(root_node):
                    # Remove the root node from Zookeeper
                    zc.delete_path(root_node)
                raise PopupException(_(
                    'Could not create index. Check error logs for more info.'),
                                     detail=e)
            finally:
Ejemplo n.º 4
0
    def test_path_exists(self):
        root_node = '%s/%s' % (TestWithZooKeeper.namespace, 'test_path_exists')
        client = ZookeeperClient(hosts=zkensemble(), read_only=False)

        client.zk.start()
        try:
            client.zk.create(root_node,
                             value='test_path_exists',
                             makepath=True)

            try:
                assert_true(client.path_exists(namespace=root_node))
                assert_false(client.path_exists(namespace='bogus_path'))
            finally:
                client.delete_path(root_node)
        finally:
            client.zk.stop()
Ejemplo n.º 5
0
  def create_index(self, name, fields, unique_key_field='id', df='text'):
    """
    Create solr collection or core and instance dir.
    Create schema.xml file so that we can set UniqueKey field.
    """
    if self.is_solr_cloud_mode():
      tmp_path, solr_config_path = copy_configs(fields, unique_key_field, df, True)

      try:
        zc = ZookeeperClient(hosts=get_solr_ensemble(), read_only=False)
        root_node = '%s/%s' % (ZK_SOLR_CONFIG_NAMESPACE, name)
        config_root_path = '%s/%s' % (solr_config_path, 'conf')
        zc.copy_path(root_node, config_root_path)

        if not self.api.create_collection(name):
          raise Exception('Failed to create collection: %s' % name)
      except Exception, e:
        if zc.path_exists(root_node):
          # Remove the root node from Zookeeper
          zc.delete_path(root_node)
        raise PopupException(_('Could not create index. Check error logs for more info.'), detail=e)
      finally: