Search in sources :

Example 1 with ContributorNotFoundException

use of io.pravega.shared.health.ContributorNotFoundException in project pravega by pravega.

the class HealthEndpointImpl method getHealth.

/**
 * Validates that the {@link HealthContributor} exists and requests it's {@link Health}.
 *
 * @param id  The id/name of the {@link HealthContributor} to check the {@link Health} of.
 * @return The {@link Health} result of the {@link HealthContributor} with name 'id'. Returns NULL if 'id' does not map to
 * a {@link HealthContributor}.
 */
@NonNull
@Override
public Health getHealth(String id) {
    Health health;
    if (id == null || id.equals(root.getName())) {
        health = updater.getLatestHealth();
    } else {
        List<String> path = Arrays.asList(id.split(DELIMITER));
        health = search(path, updater.getLatestHealth());
    }
    if (health == null) {
        throw new ContributorNotFoundException(String.format("No HealthContributor found with name '%s'", id), 404);
    }
    return health;
}
Also used : Health(io.pravega.shared.health.Health) ContributorNotFoundException(io.pravega.shared.health.ContributorNotFoundException) NonNull(lombok.NonNull)

Aggregations

ContributorNotFoundException (io.pravega.shared.health.ContributorNotFoundException)1 Health (io.pravega.shared.health.Health)1 NonNull (lombok.NonNull)1