You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sdap.apache.org by nc...@apache.org on 2021/06/23 17:45:50 UTC
[incubator-sdap-ingester] branch dev updated: SDAP-313 added
--cassandra-keyspace option to main.py (and propagated to CassandraStore.py
and entrypoint.sh) in order to be able to specify a different one than the
default "nexustiles" (#35)
This is an automated email from the ASF dual-hosted git repository.
nchung pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-sdap-ingester.git
The following commit(s) were added to refs/heads/dev by this push:
new 6187ea1 SDAP-313 added --cassandra-keyspace option to main.py (and propagated to CassandraStore.py and entrypoint.sh) in order to be able to specify a different one than the default "nexustiles" (#35)
6187ea1 is described below
commit 6187ea137c2cc8ceabe1a0bb1c13472b935432bc
Author: WicketWarrick <36...@users.noreply.github.com>
AuthorDate: Wed Jun 23 19:45:15 2021 +0200
SDAP-313 added --cassandra-keyspace option to main.py (and propagated to CassandraStore.py and entrypoint.sh) in order to be able to specify a different one than the default "nexustiles" (#35)
Co-authored-by: Dorian FOUQUIER <df...@ifremer.fr>
---
granule_ingester/docker/entrypoint.sh | 1 +
granule_ingester/granule_ingester/main.py | 11 +++++++++--
granule_ingester/granule_ingester/writers/CassandraStore.py | 5 +++--
3 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/granule_ingester/docker/entrypoint.sh b/granule_ingester/docker/entrypoint.sh
index 662bd3d..78041de 100644
--- a/granule_ingester/docker/entrypoint.sh
+++ b/granule_ingester/docker/entrypoint.sh
@@ -7,6 +7,7 @@ python /sdap/granule_ingester/main.py \
$([[ ! -z "$RABBITMQ_QUEUE" ]] && echo --rabbitmq-queue=$RABBITMQ_QUEUE) \
$([[ ! -z "$CASSANDRA_CONTACT_POINTS" ]] && echo --cassandra-contact-points=$CASSANDRA_CONTACT_POINTS) \
$([[ ! -z "$CASSANDRA_PORT" ]] && echo --cassandra-port=$CASSANDRA_PORT) \
+ $([[ ! -z "$CASSANDRA_KEYSPACE" ]] && echo --cassandra-keyspace=$CASSANDRA_KEYSPACE) \
$([[ ! -z "$CASSANDRA_USERNAME" ]] && echo --cassandra-username=$CASSANDRA_USERNAME) \
$([[ ! -z "$CASSANDRA_PASSWORD" ]] && echo --cassandra-password=$CASSANDRA_PASSWORD) \
$([[ ! -z "$SOLR_HOST_AND_PORT" ]] && echo --solr-host-and-port=$SOLR_HOST_AND_PORT) \
diff --git a/granule_ingester/granule_ingester/main.py b/granule_ingester/granule_ingester/main.py
index b5a429c..16fd0e3 100644
--- a/granule_ingester/granule_ingester/main.py
+++ b/granule_ingester/granule_ingester/main.py
@@ -26,8 +26,8 @@ from granule_ingester.healthcheck import HealthCheck
from granule_ingester.writers import CassandraStore, SolrStore
-def cassandra_factory(contact_points, port, username, password):
- store = CassandraStore(contact_points=contact_points, port=port, username=username, password=password)
+def cassandra_factory(contact_points, port, keyspace, username, password):
+ store = CassandraStore(contact_points=contact_points, port=port, keyspace=keyspace, username=username, password=password)
store.connect()
return store
@@ -73,6 +73,10 @@ async def main(loop):
default=9042,
metavar="PORT",
help='Cassandra port. (Default: 9042)')
+ parser.add_argument('--cassandra-keyspace',
+ default='nexustiles',
+ metavar='KEYSPACE',
+ help='Cassandra Keyspace (Default: "nexustiles")')
parser.add_argument('--cassandra-username',
metavar="USERNAME",
default=None,
@@ -113,6 +117,7 @@ async def main(loop):
cassandra_password = args.cassandra_password
cassandra_contact_points = args.cassandra_contact_points
cassandra_port = args.cassandra_port
+ cassandra_keyspace = args.cassandra_keyspace
solr_host_and_port = args.solr_host_and_port
zk_host_and_port = args.zk_host_and_port
@@ -123,6 +128,7 @@ async def main(loop):
data_store_factory=partial(cassandra_factory,
cassandra_contact_points,
cassandra_port,
+ cassandra_keyspace,
cassandra_username,
cassandra_password),
metadata_store_factory=partial(solr_factory, solr_host_and_port, zk_host_and_port))
@@ -130,6 +136,7 @@ async def main(loop):
solr_store = SolrStore(zk_url=zk_host_and_port) if zk_host_and_port else SolrStore(solr_url=solr_host_and_port)
await run_health_checks([CassandraStore(cassandra_contact_points,
cassandra_port,
+ cassandra_keyspace,
cassandra_username,
cassandra_password),
solr_store,
diff --git a/granule_ingester/granule_ingester/writers/CassandraStore.py b/granule_ingester/granule_ingester/writers/CassandraStore.py
index cb5232b..6c6d2c2 100644
--- a/granule_ingester/granule_ingester/writers/CassandraStore.py
+++ b/granule_ingester/granule_ingester/writers/CassandraStore.py
@@ -40,11 +40,12 @@ class TileModel(Model):
class CassandraStore(DataStore):
- def __init__(self, contact_points=None, port=9042, username=None, password=None):
+ def __init__(self, contact_points=None, port=9042, keyspace='nexustiles', username=None, password=None):
self._contact_points = contact_points
self._username = username
self._password = password
self._port = port
+ self._keyspace = keyspace
self._session = None
async def health_check(self) -> bool:
@@ -69,7 +70,7 @@ class CassandraStore(DataStore):
default_retry_policy=RetryPolicy(),
auth_provider=auth_provider)
session = cluster.connect()
- session.set_keyspace('nexustiles')
+ session.set_keyspace(self._keyspace)
return session
def connect(self):