From a9efc16e26cd57d69bb2dc691cec01ec842930cc Mon Sep 17 00:00:00 2001 From: "Thomas Nelson Jr (arthurdent3) tn1381@att.com" Date: Mon, 17 Sep 2018 22:35:25 -0400 Subject: Update distribution files to support helm charts Helm Charts require new Docker images. Refined Cassandra and Cassandra cql loader. Change-Id: Ie7726025afd63e256a43aef9f39d53c32c90c77b Issue-ID: MUSIC-99 Signed-off-by: Thomas Nelson Jr (arthurdent3) tn1381@att.com --- distribution/cassandra/Dockerfile | 7 +- distribution/cassandra/cassandra.yaml | 5 +- distribution/cassandra_job/Dockerfile | 9 ++ distribution/cassandra_job/admin.cql | 17 +++ distribution/cassandra_job/admin_pw.cql | 2 + distribution/cassandra_job/runcql.sh | 31 +++++ distribution/cassandra_job/test.cql | 2 + pom.xml | 33 +++-- .../conductor/conditionals/MusicConditional.java | 2 +- .../org/onap/music/datastore/MusicDataStore.java | 2 +- .../music/exceptions/MusicServiceException.java | 38 ++--- src/main/java/org/onap/music/main/CachingUtil.java | 9 +- .../org/onap/music/rest/RestMusicAdminAPI.java | 154 +++++++++++---------- .../java/org/onap/music/rest/RestMusicDataAPI.java | 20 +-- version.properties | 2 +- 15 files changed, 204 insertions(+), 129 deletions(-) create mode 100644 distribution/cassandra_job/Dockerfile create mode 100644 distribution/cassandra_job/admin.cql create mode 100644 distribution/cassandra_job/admin_pw.cql create mode 100644 distribution/cassandra_job/runcql.sh create mode 100644 distribution/cassandra_job/test.cql diff --git a/distribution/cassandra/Dockerfile b/distribution/cassandra/Dockerfile index 9405fcb3..fe13322c 100644 --- a/distribution/cassandra/Dockerfile +++ b/distribution/cassandra/Dockerfile @@ -1,9 +1,4 @@ #registry.hub.docker.com/ -FROM library/cassandra:3.0 -RUN mkdir -p /docker-entrypoint-initdb.d && mkdir -p /home/cassandra/.cassandra && chown -R cassandra /home/cassandra +FROM library/cassandra:3.11 COPY cassandra.yaml /etc/cassandra/ -COPY music_single.cql /docker-entrypoint-initdb.d/ -COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh -RUN chmod 755 /usr/local/bin/docker-entrypoint.sh && chown -R cassandra /docker-entrypoint-initdb.d - ENTRYPOINT ["docker-entrypoint.sh"] diff --git a/distribution/cassandra/cassandra.yaml b/distribution/cassandra/cassandra.yaml index d4af64af..fa7c74a6 100644 --- a/distribution/cassandra/cassandra.yaml +++ b/distribution/cassandra/cassandra.yaml @@ -530,7 +530,8 @@ native_transport_port: 9042 # native_transport_max_concurrent_connections_per_ip: -1 # Whether to start the thrift rpc server. -start_rpc: false +#start_rpc: false +start_rpc: true # The address or interface to bind the Thrift RPC service and native transport # server to. @@ -720,7 +721,7 @@ sstable_preemptive_open_interval_in_mb: 50 # How long the coordinator should wait for read operations to complete read_request_timeout_in_ms: 5000 # How long the coordinator should wait for seq or index scans to complete -range_request_timeout_in_ms: 10000 +range_request_timeout_in_ms: 15000 # How long the coordinator should wait for writes to complete write_request_timeout_in_ms: 2000 # How long the coordinator should wait for counter writes to complete diff --git a/distribution/cassandra_job/Dockerfile b/distribution/cassandra_job/Dockerfile new file mode 100644 index 00000000..528c3bf4 --- /dev/null +++ b/distribution/cassandra_job/Dockerfile @@ -0,0 +1,9 @@ +#registry.hub.docker.com/ +FROM library/cassandra:3.11 +ENV DEF_USER=cassandra +ENV DEF_PASS=cassandra +COPY runcql.sh / +RUN mkdir -p cql/extra && \ + chmod 755 runcql.sh && \ + chown cassandra runcql.sh +CMD ["/runcql.sh"] diff --git a/distribution/cassandra_job/admin.cql b/distribution/cassandra_job/admin.cql new file mode 100644 index 00000000..904a2bab --- /dev/null +++ b/distribution/cassandra_job/admin.cql @@ -0,0 +1,17 @@ +CREATE KEYSPACE IF NOT EXISTS admin + WITH REPLICATION = { + 'class' : 'SimpleStrategy', + 'replication_factor': 1 + } + AND DURABLE_WRITES = true; + +CREATE TABLE IF NOT EXISTS admin.keyspace_master ( + uuid uuid, + keyspace_name text, + application_name text, + is_api boolean, + password text, + username text, + is_aaf boolean, + PRIMARY KEY (uuid) +); diff --git a/distribution/cassandra_job/admin_pw.cql b/distribution/cassandra_job/admin_pw.cql new file mode 100644 index 00000000..bbad8d1d --- /dev/null +++ b/distribution/cassandra_job/admin_pw.cql @@ -0,0 +1,2 @@ +CREATE ROLE IF NOT EXISTS WITH PASSWORD = '' AND SUPERUSER = True AND LOGIN = True; +ALTER ROLE cassandra WITH PASSWORD = 'SomeLongRandomStringNoonewillthinkof'; diff --git a/distribution/cassandra_job/runcql.sh b/distribution/cassandra_job/runcql.sh new file mode 100644 index 00000000..e1fb31fc --- /dev/null +++ b/distribution/cassandra_job/runcql.sh @@ -0,0 +1,31 @@ +#! /bin/bash +if [ $CASS_HOSTNAME ]; then + echo "#############################################" + echo "############## Let run cql's ################" + echo "#############################################" + echo "admin.cql file:" + cat /cql/admin.cql + echo "Running cqlsh -u $DEF_USER -p $DEF_PASS -f /cql/admin.cql ${CASS_HOSTNAME} ${PORT}" + sleep 1; + if cqlsh -u $DEF_USER -p $DEF_PASS -f /cql/admin.cql ${CASS_HOSTNAME} ${PORT}; then echo "success"; else echo "failure" && exit 1;fi + echo "admin_pw.cql file:" + cat /cql/admin_pw.cql + echo "Running cqlsh -u $DEF_USER -p $DEF_PASS -f /cql/admin_pw.cql ${CASS_HOSTNAME} ${PORT}" + sleep 1; + if cqlsh -u $DEF_USER -p $DEF_PASS -f /cql/admin_pw.cql ${CASS_HOSTNAME} ${PORT}; then echo "success"; else echo "failure" && exit 1;fi + + for f in /cql/extra/*; do + case "$f" in + *.cql) + echo "$0: running $f" && cqlsh -u ${USERNAME} -p ${PASSWORD} -f "$f" ${CASS_HOSTNAME} ${PORT}; + ;; + *) + echo "$0: ignoring $f" + ;; + esac + done +else + echo "Missing CASS_HOSTNAME"; + exit 1; +fi + diff --git a/distribution/cassandra_job/test.cql b/distribution/cassandra_job/test.cql new file mode 100644 index 00000000..196fea22 --- /dev/null +++ b/distribution/cassandra_job/test.cql @@ -0,0 +1,2 @@ +DESCRIBE keyspaces; + diff --git a/pom.xml b/pom.xml index 5f686d21..d370856d 100755 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - + ============LICENSE_END============================================= ==================================================================== --> @@ -25,12 +25,12 @@ org.onap.music MUSIC war - 3.0.15-SNAPSHOT + 3.0.19-SNAPSHOT This is the MUSIC REST interface, packaged as a war file. - + org.onap.oparent oparent 1.2.0 @@ -42,7 +42,7 @@ 1.19 2.25.1 2.0.1 - 3.4.0 + 3.6.0 3.4.11 UTF-8 @@ -219,7 +219,6 @@ 1.0.1-oss - com.datastax.cassandra @@ -227,7 +226,6 @@ ${cassandra.version} - org.apache.zookeeper @@ -241,7 +239,6 @@ - com.sun.jersey @@ -335,7 +332,6 @@ com.google.guava guava - org.mindrot @@ -402,17 +398,30 @@ - onap/music/cassandra_music - docker_cassandra + onap/music/cassandra_3_11 + docker_cassandra_sec true - 3.0-${timestamp} - 3.0-latest + ${docker.tag} + ${docker.latest.tag} ${project.basedir}/distribution/cassandra + + + onap/music/cassandra_job + docker_cassandra_job + + true + + ${docker.tag} + ${docker.latest.tag} + + ${project.basedir}/distribution/cassandra_job + +