// Path: harahachibu/src/main/java/uk/co/flax/harahachibu/services/DiskSpaceCheckerException.java
// public class DiskSpaceCheckerException extends Exception {
// 
// 	public DiskSpaceCheckerException() {
// 		super();
// 	}
// 
// 	public DiskSpaceCheckerException(String message) {
// 		super(message);
// 	}
// 
// 	public DiskSpaceCheckerException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// 
// 	public DiskSpaceCheckerException(Throwable cause) {
// 		super(cause);
// 	}
// 
// }
// 
// Path: harahachibu/src/main/java/uk/co/flax/harahachibu/services/data/ElasticsearchClusterStats.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class ElasticsearchClusterStats {
// 
// 	@JsonProperty("timestamp")
// 	private final long timestamp;
// 
// 	@JsonProperty("cluster_name")
// 	private final String clusterName;
// 
// 	@JsonProperty("status")
// 	private final String status;
// 
// 	@JsonProperty(value = "nodes")
// 	private final ElasticsearchClusterNodes nodes;
// 
// 	public ElasticsearchClusterStats(@JsonProperty("timestamp") long timestamp,
// 									 @JsonProperty("cluster_name") String clusterName,
// 									 @JsonProperty("status") String status,
// 									 @JsonProperty("nodes") ElasticsearchClusterNodes nodes) {
// 		this.timestamp = timestamp;
// 		this.clusterName = clusterName;
// 		this.status = status;
// 		this.nodes = nodes;
// 	}
// 
// 	public long getTimestamp() {
// 		return timestamp;
// 	}
// 
// 	public String getClusterName() {
// 		return clusterName;
// 	}
// 
// 	public String getStatus() {
// 		return status;
// 	}
// 
// 	public ElasticsearchClusterNodes getNodes() {
// 		return nodes;
// 	}
// 
// 	public long getFilesystemFreeBytes() {
// 		ElasticsearchClusterFilesystem fs = getFilesystem();
// 		if (fs != null) {
// 			return fs.getFreeBytes();
// 		}
// 		return 0;
// 	}
// 
// 	public long getFilesystemAvailableBytes() {
// 		ElasticsearchClusterFilesystem fs = getFilesystem();
// 		if (fs != null) {
// 			return fs.getAvailableBytes();
// 		}
// 		return 0;
// 	}
// 
// 	public long getFilesystemTotalBytes() {
// 		ElasticsearchClusterFilesystem fs = getFilesystem();
// 		if (fs != null) {
// 			return fs.getTotalBytes();
// 		}
// 		return 0;
// 	}
// 
// 	private ElasticsearchClusterFilesystem getFilesystem() {
// 		if (nodes != null) {
// 			return nodes.getFileSystem();
// 		}
// 		return null;
// 	}
// 
// }


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.co.flax.harahachibu.services.DiskSpaceCheckerException;
import uk.co.flax.harahachibu.services.data.ElasticsearchClusterStats;
import javax.ws.rs.client.Client;
import javax.ws.rs.core.MediaType;
import java.io.IOException;
/**
 * Copyright (c) 2016 Lemur Consulting Ltd.
 * <p/>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p/>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package uk.co.flax.harahachibu.services.impl;



/**
 * Client class for retrieving cluster stats from ES.
 *
 * Created by mlp on 15/04/16.
 */
public class ElasticsearchClient {

	private static final Logger LOGGER = LoggerFactory.getLogger(ElasticsearchClient.class);

	static final String CLUSTER_STATS_ENDPOINT = "/_cluster/stats";

	private final Client client;
	private final String baseUrl;
	private final long cacheMs;

// Path: harahachibu/src/main/java/uk/co/flax/harahachibu/services/DiskSpaceCheckerException.java
// public class DiskSpaceCheckerException extends Exception {
// 
// 	public DiskSpaceCheckerException() {
// 		super();
// 	}
// 
// 	public DiskSpaceCheckerException(String message) {
// 		super(message);
// 	}
// 
// 	public DiskSpaceCheckerException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// 
// 	public DiskSpaceCheckerException(Throwable cause) {
// 		super(cause);
// 	}
// 
// }
// 
// Path: harahachibu/src/main/java/uk/co/flax/harahachibu/services/data/ElasticsearchClusterStats.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class ElasticsearchClusterStats {
// 
// 	@JsonProperty("timestamp")
// 	private final long timestamp;
// 
// 	@JsonProperty("cluster_name")
// 	private final String clusterName;
// 
// 	@JsonProperty("status")
// 	private final String status;
// 
// 	@JsonProperty(value = "nodes")
// 	private final ElasticsearchClusterNodes nodes;
// 
// 	public ElasticsearchClusterStats(@JsonProperty("timestamp") long timestamp,
// 									 @JsonProperty("cluster_name") String clusterName,
// 									 @JsonProperty("status") String status,
// 									 @JsonProperty("nodes") ElasticsearchClusterNodes nodes) {
// 		this.timestamp = timestamp;
// 		this.clusterName = clusterName;
// 		this.status = status;
// 		this.nodes = nodes;
// 	}
// 
// 	public long getTimestamp() {
// 		return timestamp;
// 	}
// 
// 	public String getClusterName() {
// 		return clusterName;
// 	}
// 
// 	public String getStatus() {
// 		return status;
// 	}
// 
// 	public ElasticsearchClusterNodes getNodes() {
// 		return nodes;
// 	}
// 
// 	public long getFilesystemFreeBytes() {
// 		ElasticsearchClusterFilesystem fs = getFilesystem();
// 		if (fs != null) {
// 			return fs.getFreeBytes();
// 		}
// 		return 0;
// 	}
// 
// 	public long getFilesystemAvailableBytes() {
// 		ElasticsearchClusterFilesystem fs = getFilesystem();
// 		if (fs != null) {
// 			return fs.getAvailableBytes();
// 		}
// 		return 0;
// 	}
// 
// 	public long getFilesystemTotalBytes() {
// 		ElasticsearchClusterFilesystem fs = getFilesystem();
// 		if (fs != null) {
// 			return fs.getTotalBytes();
// 		}
// 		return 0;
// 	}
// 
// 	private ElasticsearchClusterFilesystem getFilesystem() {
// 		if (nodes != null) {
// 			return nodes.getFileSystem();
// 		}
// 		return null;
// 	}
// 
// }


// Path: harahachibu/src/main/java/uk/co/flax/harahachibu/services/impl/ElasticsearchClient.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.co.flax.harahachibu.services.DiskSpaceCheckerException;
import uk.co.flax.harahachibu.services.data.ElasticsearchClusterStats;
import javax.ws.rs.client.Client;
import javax.ws.rs.core.MediaType;
import java.io.IOException;

/**
 * Copyright (c) 2016 Lemur Consulting Ltd.
 * <p/>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p/>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package uk.co.flax.harahachibu.services.impl;



/**
 * Client class for retrieving cluster stats from ES.
 *
 * Created by mlp on 15/04/16.
 */
public class ElasticsearchClient {

	private static final Logger LOGGER = LoggerFactory.getLogger(ElasticsearchClient.class);

	static final String CLUSTER_STATS_ENDPOINT = "/_cluster/stats";

	private final Client client;
	private final String baseUrl;
	private final long cacheMs;

	private ElasticsearchClusterStats latestStats;