All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hubspot.baragon.agent.healthcheck.ConfigChecker Maven / Gradle / Ivy

There is a newer version: 0.6.2
Show newest version
package com.hubspot.baragon.agent.healthcheck;

import java.util.concurrent.atomic.AtomicReference;

import com.google.common.base.Optional;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import com.hubspot.baragon.agent.BaragonAgentServiceModule;
import com.hubspot.baragon.agent.lbs.LocalLbAdapter;
import com.hubspot.baragon.exceptions.InvalidConfigException;

public class ConfigChecker implements Runnable {

  private final LocalLbAdapter adapter;
  private final AtomicReference> errorMessage;

  @Inject
  public ConfigChecker(LocalLbAdapter adapter,
                       @Named(BaragonAgentServiceModule.CONFIG_ERROR_MESSAGE) AtomicReference> errorMessage) {
    this.adapter = adapter;
    this.errorMessage = errorMessage;
  }

  @Override
  public void run() {
    try {
      adapter.checkConfigs();
      errorMessage.set(Optional.absent());
    } catch (InvalidConfigException e) {
      errorMessage.set(Optional.of(e.getMessage()));
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy