2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.core.nosqldb.util;
23 import org.openecomp.core.utilities.file.FileUtils;
24 import org.openecomp.core.utilities.json.JsonUtil;
26 import java.util.HashMap;
29 public class CassandraUtils {
32 private static final String CASSANDRA_STATEMENT_DEFINITION_FILE = "cassandraStatements.json";
33 private static Map<String, String> statementMap = new HashMap<>();
35 public static String[] getAddresses() {
36 return ConfigurationManager.getInstance().getAddresses();
39 public static Long getReconnectTimeout() {
40 return ConfigurationManager.getInstance().getReconnectTimeout();
43 public static String getKeySpace() {
44 return ConfigurationManager.getInstance().getKeySpace();
50 * @param statementName the statement name
51 * @return the statement
53 public static String getStatement(String statementName) {
55 if (statementMap.size() == 0) {
56 statementMap = FileUtils.readViaInputStream(CASSANDRA_STATEMENT_DEFINITION_FILE,
57 stream -> JsonUtil.json2Object(stream, Map.class));
60 return statementMap.get(statementName);
63 public static String getUser() {
65 return ConfigurationManager.getInstance().getUsername();
68 public static String getPassword() {
69 return ConfigurationManager.getInstance().getPassword();
73 public static String getTruststore() {
74 return ConfigurationManager.getInstance().getTruststorePath();
78 public static String getTruststorePassword() {
79 return ConfigurationManager.getInstance().getTruststorePassword();
83 public static int getCassandraPort() {
84 return ConfigurationManager.getInstance().getCassandraPort();
88 public static boolean isSsl() {
89 return ConfigurationManager.getInstance().isSsl();
93 public static boolean isAuthenticate() {
94 return ConfigurationManager.getInstance().isAuthenticate();
97 public static String getConsistencyLevel() {
99 return ConfigurationManager.getInstance().getConsistencyLevel();
103 public static String getLocalDataCenter() {
104 return ConfigurationManager.getInstance().getLocalDataCenter();