// Path: harahachibu/src/main/java/uk/co/flax/harahachibu/services/DiskSpaceChecker.java
// public interface DiskSpaceChecker {
// 
// 	/**
// 	 * Check whether space is available on the disk or cluster of
// 	 * disks.
// 	 * @return {@code true} if space is available, {@code false} if not
// 	 * (including if server calls fail).
// 	 * @throws DiskSpaceCheckerException if problems occur checking the
// 	 * disks.
// 	 */
// 	boolean isSpaceAvailable() throws DiskSpaceCheckerException;
// 
// 	/**
// 	 * Pass configuration properties into the checker instance, for custom
// 	 * checkers.
// 	 * @param configuration a {@link Map} of configuration details.
// 	 * @throws DiskSpaceCheckerException if the configuration cannot be read.
// 	 */
// 	void configure(Map<String, Object> configuration) throws DiskSpaceCheckerException;
// 
// 	/**
// 	 * Does the implementation require an HTTP client for remote access?
// 	 * @return {@code true} if the checker requires HTTP access.
// 	 */
// 	boolean requiresHttpClient();
// 
// 	/**
// 	 * Set the HTTP client to use for remote access. This will be supplied and managed
// 	 * by DropWizard, avoiding the requirement to implement your own.
// 	 * @param httpClient the client to use.
// 	 */
// 	void setHttpClient(Client httpClient);
// 
// 	/**
// 	 * Set the disk space threshold to use to check for available space.
// 	 * @param threshold the threshold.
// 	 */
// 	void setThreshold(DiskSpaceThreshold threshold);
// 
// }
// 
// 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);
// 	}
// 
// }


import com.codahale.metrics.health.HealthCheck;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.co.flax.harahachibu.services.DiskSpaceChecker;
import uk.co.flax.harahachibu.services.DiskSpaceCheckerException;
/**
 * 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.health;


/**
 * Generic disk checker health check.
 * <p>
 * Created by mlp on 19/04/16.
 */
public class DiskSpaceCheckerHealthCheck extends HealthCheck {

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

	private final DiskSpaceChecker checker;

	public DiskSpaceCheckerHealthCheck(DiskSpaceChecker checker) {
		this.checker = checker;
	}

	@Override
	protected Result check() throws Exception {
		try {
			if (checker.isSpaceAvailable()) {
				return Result.healthy();
			} else {
// Path: harahachibu/src/main/java/uk/co/flax/harahachibu/services/DiskSpaceChecker.java
// public interface DiskSpaceChecker {
// 
// 	/**
// 	 * Check whether space is available on the disk or cluster of
// 	 * disks.
// 	 * @return {@code true} if space is available, {@code false} if not
// 	 * (including if server calls fail).
// 	 * @throws DiskSpaceCheckerException if problems occur checking the
// 	 * disks.
// 	 */
// 	boolean isSpaceAvailable() throws DiskSpaceCheckerException;
// 
// 	/**
// 	 * Pass configuration properties into the checker instance, for custom
// 	 * checkers.
// 	 * @param configuration a {@link Map} of configuration details.
// 	 * @throws DiskSpaceCheckerException if the configuration cannot be read.
// 	 */
// 	void configure(Map<String, Object> configuration) throws DiskSpaceCheckerException;
// 
// 	/**
// 	 * Does the implementation require an HTTP client for remote access?
// 	 * @return {@code true} if the checker requires HTTP access.
// 	 */
// 	boolean requiresHttpClient();
// 
// 	/**
// 	 * Set the HTTP client to use for remote access. This will be supplied and managed
// 	 * by DropWizard, avoiding the requirement to implement your own.
// 	 * @param httpClient the client to use.
// 	 */
// 	void setHttpClient(Client httpClient);
// 
// 	/**
// 	 * Set the disk space threshold to use to check for available space.
// 	 * @param threshold the threshold.
// 	 */
// 	void setThreshold(DiskSpaceThreshold threshold);
// 
// }
// 
// 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/health/DiskSpaceCheckerHealthCheck.java
import com.codahale.metrics.health.HealthCheck;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.co.flax.harahachibu.services.DiskSpaceChecker;
import uk.co.flax.harahachibu.services.DiskSpaceCheckerException;

/**
 * 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.health;


/**
 * Generic disk checker health check.
 * <p>
 * Created by mlp on 19/04/16.
 */
public class DiskSpaceCheckerHealthCheck extends HealthCheck {

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

	private final DiskSpaceChecker checker;

	public DiskSpaceCheckerHealthCheck(DiskSpaceChecker checker) {
		this.checker = checker;
	}

	@Override
	protected Result check() throws Exception {
		try {
			if (checker.isSpaceAvailable()) {
				return Result.healthy();
			} else {
				return Result.unhealthy("DiskSpaceChecker returns no space available");