utils/usergrid-util-python/index_test/index_test_mixed_batch.py [130:212]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            data += json.dumps(doc)
            data += '\n'

        url = '%s/_bulk' % self.base_url

        # print data

        r = requests.post(url, data)

        # print json.dumps(r.json(), indent=2)

        if r.status_code == 200:
            print 'PUT (%s) in %sms' % (r.status_code, total_milliseconds(r.elapsed))
            return r.json()

        raise Exception('HTTP %s calling POST URL=[%s]: %s' % (r.status_code, url, r.text))

    def delete(self, index):
        url = '%s%s' % (self.base_url, index)
        r = requests.delete(url)

        if r.status_code == 200:
            print 'DELETE (%s) in %sms' % (r.status_code, total_milliseconds(r.elapsed))
            return r.json()

        raise Exception('HTTP %s calling DELETE URL=[%s]: %s' % (r.status_code, url, r.text))

    def create_index(self, name=None, shards=18 * 3, replicas=1):
        data = {
            "settings": {
                "index": {
                    "action": {
                        "write_consistency": "one"
                    },
                    "number_of_shards": shards,
                    "number_of_replicas": replicas
                }
            }
        }

        try:
            print 'Creating index %s' % name
            response = self.put('/%s/' % name.lower(), data)

            print response

        except Exception, e:
            print traceback.format_exc()

    def delete_index(self, name):
        try:
            response = self.delete('/%s/' % name.lower())

            print response

        except Exception, e:
            print traceback.format_exc()

    def define_type_mapping(self, index_name, type_name):
        try:
            url = '/%s/_mapping/%s' % (index_name, type_name)
            print url

            response = self.put(url, get_type_mapping(type_name))

            print response

        except Exception, e:
            print traceback.format_exc()


class Worker(Process):
    def __init__(self, work_queue):
        super(Worker, self).__init__()
        self.api_client = APIClient('http://%s:9200' % es_hosts[random.randint(0, len(es_hosts) - 1)].get('host'))
        self.work_queue = work_queue
        self.es = Elasticsearch(es_hosts)
        self.sentence_list = loremipsum.get_sentences(1000)
        self.re_first_word = re.compile('([A-z]+)')

    def run(self):
        print 'Starting %s ' % self.name
        counter = 0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



utils/usergrid-util-python/index_test/index_test_single_type_batch.py [128:210]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            data += json.dumps(doc)
            data += '\n'

        url = '%s/_bulk' % self.base_url

        # print data

        r = requests.post(url, data)

        # print json.dumps(r.json(), indent=2)

        if r.status_code == 200:
            print 'PUT (%s) in %sms' % (r.status_code, total_milliseconds(r.elapsed))
            return r.json()

        raise Exception('HTTP %s calling POST URL=[%s]: %s' % (r.status_code, url, r.text))

    def delete(self, index):
        url = '%s%s' % (self.base_url, index)
        r = requests.delete(url)

        if r.status_code == 200:
            print 'DELETE (%s) in %sms' % (r.status_code, total_milliseconds(r.elapsed))
            return r.json()

        raise Exception('HTTP %s calling DELETE URL=[%s]: %s' % (r.status_code, url, r.text))

    def create_index(self, name=None, shards=18 * 3, replicas=1):
        data = {
            "settings": {
                "index": {
                    "action": {
                        "write_consistency": "one"
                    },
                    "number_of_shards": shards,
                    "number_of_replicas": replicas
                }
            }
        }

        try:
            print 'Creating index %s' % name
            response = self.put('/%s/' % name.lower(), data)

            print response

        except Exception, e:
            print traceback.format_exc()

    def delete_index(self, name):
        try:
            response = self.delete('/%s/' % name.lower())

            print response

        except Exception, e:
            print traceback.format_exc()

    def define_type_mapping(self, index_name, type_name):
        try:
            url = '/%s/_mapping/%s' % (index_name, type_name)
            print url

            response = self.put(url, get_type_mapping(type_name))

            print response

        except Exception, e:
            print traceback.format_exc()


class Worker(Process):
    def __init__(self, work_queue):
        super(Worker, self).__init__()
        self.api_client = APIClient('http://%s:9200' % es_hosts[random.randint(0, len(es_hosts) - 1)].get('host'))
        self.work_queue = work_queue
        self.es = Elasticsearch(es_hosts)
        self.sentence_list = loremipsum.get_sentences(1000)
        self.re_first_word = re.compile('([A-z]+)')

    def run(self):
        print 'Starting %s ' % self.name
        counter = 0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



