'Verify URL and establish a connection.'

def __init__(self, url, **kwargs):

    try:
        self.mongo = pymongo.MongoClient(url, **kwargs.get('clientOptions', {}))
    except pymongo.errors.InvalidURI:
        raise errors.ConnectionFailed('Invalid    URI    for    MongoDB')
    except pymongo.errors.ConnectionFailure:
        raise errors.ConnectionFailed('Failed    to    connect    to    MongoDB')
    self.chunk_size = kwargs.get('chunk_size', constants.DEFAULT_MAX_BULK)
    self.use_single_meta_collection = kwargs.get('use_single_meta_collection', False)
    self.meta_collection_name = kwargs.get('meta_collection_name', constants.DEFAULT_META_COLLECTION_NAME)
    self.meta_collection_cap_size = kwargs.get('meta_collection_cap_size', constants.DEFAULT_META_COLLECTION_CAP_SIZE)
    self.id_field = ('doc_id' if self.use_single_meta_collection else '_id')
    self.meta_database = self.mongo['__mongo_connector']
    if self.use_single_meta_collection:
        if (self.meta_collection_name not in self.meta_database.collection_names()):
            self.meta_database.create_collection(self.meta_collection_name, capped=True, size=self.meta_collection_cap_size)
            meta_collection = self.meta_database[self.meta_collection_name]
            meta_collection.create_index(self.id_field)
            meta_collection.create_index([('ns', 1), ('_ts', 1)])
