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 * ====================================================================
22 package org.onap.music.eelf.healthcheck;
24 import java.io.BufferedReader;
25 import java.io.IOException;
26 import java.io.InputStreamReader;
27 import java.util.Iterator;
30 import java.util.HashMap;
31 import java.util.Iterator;
32 import java.util.List;
34 import java.util.UUID;
36 import org.mindrot.jbcrypt.BCrypt;
37 import org.onap.music.datastore.PreparedQueryObject;
38 import org.onap.music.datastore.jsonobjects.JsonOnboard;
39 import org.onap.music.eelf.logging.EELFLoggerDelegate;
40 import org.onap.music.eelf.logging.format.AppMessages;
41 import org.onap.music.eelf.logging.format.ErrorSeverity;
42 import org.onap.music.eelf.logging.format.ErrorTypes;
43 import org.onap.music.exceptions.MusicLockingException;
44 import org.onap.music.lockingservice.MusicLockingService;
45 import org.onap.music.main.CachingUtil;
46 import org.onap.music.main.MusicCore;
47 import org.onap.music.main.MusicUtil;
48 import org.onap.music.main.ResultType;
49 import com.datastax.driver.core.DataType;
50 import com.datastax.driver.core.ResultSet;
59 public class MusicHealthCheck {
61 private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicUtil.class);
63 private String cassandrHost;
64 private String zookeeperHost;
73 public String getCassandraStatus() {
74 logger.info(EELFLoggerDelegate.applicationLogger,"Getting Status for Cassandra");
75 if(this.getAdminKeySpace()) {
78 logger.info(EELFLoggerDelegate.applicationLogger,"Cassandra Service is not responding");
84 private Boolean getAdminKeySpace() {
88 PreparedQueryObject pQuery = new PreparedQueryObject();
89 pQuery.appendQueryString(
90 "select * from admin.keyspace_master");
91 //pQuery.addValue(MusicUtil.convertToActualDataType(DataType.text(), appName));
93 ResultSet rs = MusicCore.get(pQuery);
100 } catch (Exception e) {
101 logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(),AppMessages.CASSANDRACONNECTIVITY, ErrorTypes.CONNECTIONERROR, ErrorSeverity.CRITICAL);
104 return Boolean.FALSE;
109 public String getZookeeperStatus() {
112 String host = MusicUtil.getMyZkHost();
113 logger.info(EELFLoggerDelegate.applicationLogger,"Getting Status for Zookeeper Host: "+host);
115 MusicLockingService lockingService = MusicCore.getLockingServiceHandle();
116 //additionally need to call the ZK to create,aquire and delete lock
117 } catch (MusicLockingException e) {
118 logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(),AppMessages.LOCKINGERROR, ErrorTypes.CONNECTIONERROR, ErrorSeverity.CRITICAL);
122 logger.info(EELFLoggerDelegate.applicationLogger,"Zookeeper is Active and Running");
125 //return "Zookeeper is not responding";
132 public String getCassandrHost() {
139 public void setCassandrHost(String cassandrHost) {
140 this.cassandrHost = cassandrHost;
146 public String getZookeeperHost() {
147 return zookeeperHost;
153 public void setZookeeperHost(String zookeeperHost) {
154 this.zookeeperHost = zookeeperHost;