2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.features.sdnr.wt.common.database.responses;
24 import java.io.IOException;
25 import org.elasticsearch.client.Response;
26 import org.json.JSONException;
27 import org.json.JSONObject;
29 public class ClusterHealthResponse extends BaseResponse {
31 public static final String HEALTHSTATUS_GREEN = "green";
32 public static final String HEALTHSTATUS_YELLOW = "yellow";
33 public static final String HEALTSTATUS_RED = "red";
35 private String status;
36 private boolean timedOut;
39 * "cluster_name": "docker-cluster", "status": "yellow", "timed_out": false,
40 * "number_of_nodes": 1, "number_of_data_nodes": 1, "active_primary_shards": 5,
41 * "active_shards": 5, "relocating_shards": 0, "initializing_shards": 0,
42 * "unassigned_shards": 5, "delayed_unassigned_shards": 0,
43 * "number_of_pending_tasks": 0, "number_of_in_flight_fetch": 0,
44 * "task_max_waiting_in_queue_millis": 0, "active_shards_percent_as_number": 50
46 public ClusterHealthResponse(Response response) throws UnsupportedOperationException, IOException, JSONException {
49 JSONObject o = this.getJson(response);
51 this.status = o.getString("status");
52 this.timedOut = o.getBoolean("timed_out");
56 public boolean isTimedOut() {
60 @SuppressWarnings("hiding")
61 public boolean isStatusMinimal(String status) {
65 if (this.status.equals(HEALTHSTATUS_GREEN)) {
68 if (this.status.equals(HEALTHSTATUS_YELLOW) && !status.equals(HEALTHSTATUS_GREEN)) {
71 if (this.status.equals(status)) {
78 public String getStatus() {