public SchemaProvider getSchemaProvider(StorageEngineConfig engineConfig) throws SetupException{
SchemaProvider engine = activeEngines.get(engineConfig);
if(engine != null) return engine;
Constructor<? extends SchemaProvider> c = allProviders.get(engineConfig.getClass());
if(c == null) throw new SetupException(String.format("Failure finding StorageSchemaProvider constructor for config %s", engineConfig));
try {
return c.newInstance(engineConfig, config);
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
Throwable t = e instanceof InvocationTargetException ? ((InvocationTargetException)e).getTargetException() : e;
if(t instanceof SetupException) throw ((SetupException) t);
throw new SetupException(String.format("Failure setting up new storage engine configuration for config %s", engineConfig), t);
}
}