Improve exception handling connecting to resource group db
@@ -27,6 +27,7 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
+import io.airlift.log.Logger;
import io.airlift.units.Duration;
import javax.annotation.PostConstruct;
@@ -58,6 +59,7 @@ import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
public class DbResourceGroupConfigurationManager
extends AbstractResourceConfigurationManager
{
+ private static final Logger log = Logger.get(DbResourceGroupConfigurationManager.class);
private final ResourceGroupsDao dao;
private final ConcurrentMap<ResourceGroupId, ResourceGroup> groups = new ConcurrentHashMap<>();
@GuardedBy("this")
@@ -137,6 +139,7 @@ public class DbResourceGroupConfigurationManager
@VisibleForTesting
public synchronized void load()
{
+ try {
Map.Entry<ManagerSpec, Map<ResourceGroupIdTemplate, ResourceGroupSpec>> specsFromDb = buildSpecsFromDb();
ManagerSpec managerSpec = specsFromDb.getKey();
Map<ResourceGroupIdTemplate, ResourceGroupSpec> resourceGroupSpecs = specsFromDb.getValue();
@@ -157,6 +160,10 @@ public class DbResourceGroupConfigurationManager
configureChangedGroups(changedSpecs);
disableDeletedGroups(deletedSpecs);
}
+ catch (Throwable e) {
+ log.error(e, "Error loading configuration from db");
+ }
+ }
// Populate temporary data structures to build resource group specs and selectors from db
private synchronized void populateFromDbHelper(Map<Long, ResourceGroupSpecBuilder> recordMap,
