Package org.fao.geonet.monitor.health

Source Code of org.fao.geonet.monitor.health.DatabaseHealthCheck

package org.fao.geonet.monitor.health;

import com.yammer.metrics.core.HealthCheck;
import jeeves.monitor.HealthCheckFactory;
import jeeves.server.context.ServiceContext;
import org.fao.geonet.repository.SettingRepository;

/**
* Checks to ensure that the database is accessible and readable
* <p/>
* User: jeichar
* Date: 3/26/12
* Time: 9:01 AM
*/
public class DatabaseHealthCheck implements HealthCheckFactory {
    public HealthCheck create(final ServiceContext context) {
        return new HealthCheck("Database Connection") {
            @Override
            protected Result check() throws Exception {
                try {
                    context.getBean(SettingRepository.class).count();
                    return Result.healthy();
                } catch (Throwable e) {
                    return Result.unhealthy(e);
                }
            }
        };
    }
}
TOP

Related Classes of org.fao.geonet.monitor.health.DatabaseHealthCheck

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.