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