cassandra cluster no load-balancing policy
monasca-api connect to cassandra cluster without load-balancing policy parameter. Task: 29958 Story: 2005196 Change-Id: Ia740f20f6b8d557a74a48cd0c78cd07c1500ca94
This commit is contained in:
parent
b1bd423822
commit
0b1bb93206
|
@ -23,6 +23,8 @@ import urllib
|
||||||
|
|
||||||
from cassandra.auth import PlainTextAuthProvider
|
from cassandra.auth import PlainTextAuthProvider
|
||||||
from cassandra.cluster import Cluster
|
from cassandra.cluster import Cluster
|
||||||
|
from cassandra.cluster import DCAwareRoundRobinPolicy
|
||||||
|
from cassandra.cluster import TokenAwarePolicy
|
||||||
from cassandra.query import FETCH_SIZE_UNSET
|
from cassandra.query import FETCH_SIZE_UNSET
|
||||||
from cassandra.query import SimpleStatement
|
from cassandra.query import SimpleStatement
|
||||||
from monasca_common.rest import utils as rest_utils
|
from monasca_common.rest import utils as rest_utils
|
||||||
|
@ -120,7 +122,12 @@ class MetricsRepository(metrics_repository.AbstractMetricsRepository):
|
||||||
auth_provider = None
|
auth_provider = None
|
||||||
|
|
||||||
self.cluster = Cluster(self.conf.cassandra.contact_points,
|
self.cluster = Cluster(self.conf.cassandra.contact_points,
|
||||||
port=self.conf.cassandra.port, auth_provider=auth_provider)
|
port=self.conf.cassandra.port,
|
||||||
|
auth_provider=auth_provider,
|
||||||
|
load_balancing_policy=TokenAwarePolicy(
|
||||||
|
DCAwareRoundRobinPolicy(
|
||||||
|
local_dc=self.conf.cassandra.local_data_center))
|
||||||
|
)
|
||||||
self.session = self.cluster.connect(self.conf.cassandra.keyspace)
|
self.session = self.cluster.connect(self.conf.cassandra.keyspace)
|
||||||
|
|
||||||
self.dim_val_by_metric_stmt = self.session.prepare(DIMENSION_VALUE_BY_METRIC_CQL)
|
self.dim_val_by_metric_stmt = self.session.prepare(DIMENSION_VALUE_BY_METRIC_CQL)
|
||||||
|
|
|
@ -40,6 +40,10 @@ Cassandra user for monasca-api service
|
||||||
cfg.StrOpt('password', default='', secret=True,
|
cfg.StrOpt('password', default='', secret=True,
|
||||||
help='''
|
help='''
|
||||||
Cassandra user password for monasca-api service
|
Cassandra user password for monasca-api service
|
||||||
|
'''),
|
||||||
|
cfg.StrOpt('local_data_center', default='',
|
||||||
|
help='''
|
||||||
|
Cassandra local data center name
|
||||||
''')
|
''')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
support cassandra cluster configuration with loadbalancing policy DCAwareRoundRobinPolicy.
|
||||||
|
'local_data_center' defalut value is ''.
|
Loading…
Reference in New Issue