2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (c) 2017 AT&T Intellectual Property
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.
19 * ============LICENSE_END=============================================
20 * ====================================================================
23 package org.onap.music.eelf.healthcheck;
25 import java.io.BufferedReader;
26 import java.io.IOException;
27 import java.io.InputStreamReader;
28 import java.util.Iterator;
31 import java.util.HashMap;
32 import java.util.Iterator;
33 import java.util.List;
35 import java.util.UUID;
37 import org.mindrot.jbcrypt.BCrypt;
38 import org.onap.music.datastore.PreparedQueryObject;
39 import org.onap.music.datastore.jsonobjects.JsonOnboard;
40 import org.onap.music.eelf.logging.EELFLoggerDelegate;
41 import org.onap.music.eelf.logging.format.AppMessages;
42 import org.onap.music.eelf.logging.format.ErrorSeverity;
43 import org.onap.music.eelf.logging.format.ErrorTypes;
44 import org.onap.music.exceptions.MusicLockingException;
45 import org.onap.music.lockingservice.MusicLockingService;
46 import org.onap.music.main.CachingUtil;
47 import org.onap.music.main.MusicCore;
48 import org.onap.music.main.MusicUtil;
49 import org.onap.music.main.ResultType;
50 import com.datastax.driver.core.DataType;
51 import com.datastax.driver.core.ResultSet;
60 public class MusicHealthCheck {
62 private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicUtil.class);
64 private String cassandrHost;
65 private String zookeeperHost;
74 public String getCassandraStatus() {
75 logger.info(EELFLoggerDelegate.applicationLogger,"Getting Status for Cassandra");
76 if(this.getAdminKeySpace()) {
79 logger.info(EELFLoggerDelegate.applicationLogger,"Cassandra Service is not responding");
85 private Boolean getAdminKeySpace() {
89 PreparedQueryObject pQuery = new PreparedQueryObject();
90 pQuery.appendQueryString(
91 "select * from admin.keyspace_master");
92 //pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), appName));
94 ResultSet rs = MusicCore.get(pQuery);
101 } catch (Exception e) {
102 logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(),AppMessages.CASSANDRACONNECTIVITY, ErrorTypes.CONNECTIONERROR, ErrorSeverity.CRITICAL);
105 return Boolean.FALSE;
110 public String getZookeeperStatus() {
113 String host = MusicUtil.getMyZkHost();
114 logger.info(EELFLoggerDelegate.applicationLogger,"Getting Status for Zookeeper Host: "+host);
116 MusicLockingService lockingService = MusicCore.getLockingServiceHandle();
117 //additionally need to call the ZK to create,aquire and delete lock
118 } catch (MusicLockingException e) {
119 logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(),AppMessages.LOCKINGERROR, ErrorTypes.CONNECTIONERROR, ErrorSeverity.CRITICAL);
123 logger.info(EELFLoggerDelegate.applicationLogger,"Zookeeper is Active and Running");
126 //return "Zookeeper is not responding";
133 public String getCassandrHost() {
140 public void setCassandrHost(String cassandrHost) {
141 this.cassandrHost = cassandrHost;
147 public String getZookeeperHost() {
148 return zookeeperHost;
154 public void setZookeeperHost(String zookeeperHost) {
155 this.zookeeperHost = zookeeperHost;