Ejemplo n.º 1
0
def setup():
    global __STORAGE_IMPL
    assert __STORAGE_IMPL is None

    storage_param = jsonutils.loads(config.CONF.storage_param)

    __STORAGE_IMPL = importutils.import_class(config.CONF.storage_impl)(**storage_param)
Ejemplo n.º 2
0
def setup():
    global __STORAGE_IMPL
    assert __STORAGE_IMPL is None

    storage_param = jsonutils.loads(config.CONF.storage_param)

    __STORAGE_IMPL = importutils.import_class(config.CONF.storage_impl)(
        **storage_param
    )
Ejemplo n.º 3
0
    def __init__(self, contact_points=("127.0.0.1",),
                 port=9042,
                 compression=True,
                 auth_provider=None,
                 load_balancing_policy=None,
                 reconnection_policy=None,
                 default_retry_policy=None,
                 conviction_policy_factory=None,
                 metrics_enabled=False,
                 connection_class=None,
                 ssl_options=None,
                 sockopts=None,
                 cql_version=None,
                 executor_threads=2,
                 max_schema_agreement_wait=10,
                 control_connection_timeout=2.0,
                 query_timeout=10.0):

        if connection_class:
            connection_class = importutils.import_class(connection_class)

        self.cluster = cluster.Cluster(
            contact_points=contact_points,
            port=port,
            compression=compression,
            auth_provider=auth_provider,
            load_balancing_policy=load_balancing_policy,
            reconnection_policy=reconnection_policy,
            default_retry_policy=default_retry_policy,
            conviction_policy_factory=conviction_policy_factory,
            metrics_enabled=metrics_enabled,
            connection_class=connection_class,
            ssl_options=ssl_options,
            sockopts=sockopts,
            cql_version=cql_version,
            executor_threads=executor_threads,
            max_schema_agreement_wait=max_schema_agreement_wait,
            control_connection_timeout=control_connection_timeout,
            schema_change_listeners=(self.schema_change_listener,)
        )

        self.session = self.cluster.connect()
        self.session.row_factory = decoder.dict_factory
        self.session.default_timeout = query_timeout