use of com.yahoo.elide.async.hooks.TableExportHook in project elide by yahoo.
the class ElideAsyncConfiguration method buildAsyncExecutorService.
/**
* Configure the AsyncExecutorService used for submitting async query requests.
* @param elide elideObject.
* @param settings Elide settings.
* @param asyncQueryDao AsyncDao object.
* @return a AsyncExecutorService.
*/
@Bean
@ConditionalOnMissingBean
public AsyncExecutorService buildAsyncExecutorService(RefreshableElide elide, ElideConfigProperties settings, AsyncAPIDAO asyncQueryDao, @Autowired(required = false) ResultStorageEngine resultStorageEngine) {
AsyncProperties asyncProperties = settings.getAsync();
ExecutorService executor = Executors.newFixedThreadPool(asyncProperties.getThreadPoolSize());
ExecutorService updater = Executors.newFixedThreadPool(asyncProperties.getThreadPoolSize());
AsyncExecutorService asyncExecutorService = new AsyncExecutorService(elide.getElide(), executor, updater, asyncQueryDao);
// Binding AsyncQuery LifeCycleHook
AsyncQueryHook asyncQueryHook = new AsyncQueryHook(asyncExecutorService, asyncProperties.getMaxAsyncAfterSeconds());
EntityDictionary dictionary = elide.getElide().getElideSettings().getDictionary();
dictionary.bindTrigger(AsyncQuery.class, CREATE, PREFLUSH, asyncQueryHook, false);
dictionary.bindTrigger(AsyncQuery.class, CREATE, POSTCOMMIT, asyncQueryHook, false);
dictionary.bindTrigger(AsyncQuery.class, CREATE, PRESECURITY, asyncQueryHook, false);
boolean exportEnabled = ElideAutoConfiguration.isExportEnabled(asyncProperties);
if (exportEnabled) {
// Initialize the Formatters.
boolean skipCSVHeader = asyncProperties.getExport() != null && asyncProperties.getExport().isSkipCSVHeader();
Map<ResultType, TableExportFormatter> supportedFormatters = new HashMap<>();
supportedFormatters.put(ResultType.CSV, new CSVExportFormatter(elide.getElide(), skipCSVHeader));
supportedFormatters.put(ResultType.JSON, new JSONExportFormatter(elide.getElide()));
// Binding TableExport LifeCycleHook
TableExportHook tableExportHook = getTableExportHook(asyncExecutorService, settings, supportedFormatters, resultStorageEngine);
dictionary.bindTrigger(TableExport.class, CREATE, PREFLUSH, tableExportHook, false);
dictionary.bindTrigger(TableExport.class, CREATE, POSTCOMMIT, tableExportHook, false);
dictionary.bindTrigger(TableExport.class, CREATE, PRESECURITY, tableExportHook, false);
}
return asyncExecutorService;
}
use of com.yahoo.elide.async.hooks.TableExportHook in project elide by yahoo.
the class ElideAsyncConfiguration method getTableExportHook.
// TODO Remove this method when ElideSettings has all the settings.
// Then the check can be done in TableExportHook.
// Trying to avoid adding too many individual properties to ElideSettings for now.
// https://github.com/yahoo/elide/issues/1803
private TableExportHook getTableExportHook(AsyncExecutorService asyncExecutorService, ElideConfigProperties settings, Map<ResultType, TableExportFormatter> supportedFormatters, ResultStorageEngine resultStorageEngine) {
boolean exportEnabled = ElideAutoConfiguration.isExportEnabled(settings.getAsync());
TableExportHook tableExportHook = null;
if (exportEnabled) {
tableExportHook = new TableExportHook(asyncExecutorService, settings.getAsync().getMaxAsyncAfterSeconds(), supportedFormatters, resultStorageEngine);
} else {
tableExportHook = new TableExportHook(asyncExecutorService, settings.getAsync().getMaxAsyncAfterSeconds(), supportedFormatters, resultStorageEngine) {
@Override
public void validateOptions(AsyncAPI export, RequestScope requestScope) {
throw new InvalidOperationException("TableExport is not supported.");
}
};
}
return tableExportHook;
}
Aggregations