use of com.netflix.metacat.common.dto.DatabaseDto in project metacat by Netflix.
the class MetacatV1Resource method updateDatabase.
@Override
public void updateDatabase(final String catalogName, final String databaseName, final DatabaseCreateRequestDto databaseUpdateRequestDto) {
final QualifiedName name = requestWrapper.qualifyName(() -> QualifiedName.ofDatabase(catalogName, databaseName));
requestWrapper.processRequest(name, "updateDatabase", () -> {
final DatabaseDto newDto = new DatabaseDto();
newDto.setName(name);
newDto.setDefinitionMetadata(databaseUpdateRequestDto.getDefinitionMetadata());
databaseService.update(name, newDto);
return null;
});
}
use of com.netflix.metacat.common.dto.DatabaseDto in project metacat by Netflix.
the class MetacatV1Resource method createDatabase.
@Override
public void createDatabase(final String catalogName, final String databaseName, final DatabaseCreateRequestDto databaseCreateRequestDto) {
final QualifiedName name = requestWrapper.qualifyName(() -> QualifiedName.ofDatabase(catalogName, databaseName));
requestWrapper.processRequest(name, "createDatabase", () -> {
final DatabaseDto newDto = new DatabaseDto();
newDto.setName(name);
if (databaseCreateRequestDto != null) {
newDto.setDefinitionMetadata(databaseCreateRequestDto.getDefinitionMetadata());
}
databaseService.create(name, newDto);
return null;
});
}
use of com.netflix.metacat.common.dto.DatabaseDto in project metacat by Netflix.
the class MetacatElasticSearchEventHandlers method metacatDeleteDatabasePostEventHandler.
/**
* Subscriber.
*
* @param event event
*/
@EventListener
public void metacatDeleteDatabasePostEventHandler(final MetacatDeleteDatabasePostEvent event) {
log.debug("Received DeleteDatabaseEvent {}", event);
registry.counter(Metrics.CounterElasticSearchDatabaseDelete.name()).increment();
final DatabaseDto dto = event.getDatabase();
es.softDelete(ElasticSearchDoc.Type.database.name(), dto.getName().toString(), event.getRequestContext());
}
use of com.netflix.metacat.common.dto.DatabaseDto in project metacat by Netflix.
the class ElasticSearchMetacatRefresh method _processDatabases.
/**
* Process the list of databases.
*
* @param catalogName catalog name
* @param databaseNames database names
* @return future
*/
@SuppressWarnings("checkstyle:methodname")
private ListenableFuture<Void> _processDatabases(final QualifiedName catalogName, final List<QualifiedName> databaseNames) {
ListenableFuture<Void> resultFuture = null;
log.info("Full refresh of catalog {} for databases({}): {}", catalogName, databaseNames.size(), databaseNames);
final List<ListenableFuture<DatabaseDto>> getDatabaseFutures = databaseNames.stream().map(databaseName -> service.submit(() -> {
DatabaseDto result = null;
try {
result = getDatabase(databaseName);
} catch (Exception e) {
log.error("Failed to retrieve database: {}", databaseName);
elasticSearchUtil.log("ElasticSearchMetacatRefresh.getDatabase", ElasticSearchDoc.Type.database.name(), databaseName.toString(), null, e.getMessage(), e, true);
}
return result;
})).collect(Collectors.toList());
if (getDatabaseFutures != null && !getDatabaseFutures.isEmpty()) {
resultFuture = Futures.transformAsync(Futures.successfulAsList(getDatabaseFutures), input -> {
final ListenableFuture<Void> processDatabaseFuture = indexDatabaseDtos(catalogName, input);
final List<ListenableFuture<Void>> processDatabaseFutures = input.stream().filter(NOT_NULL).map(databaseDto -> {
final List<QualifiedName> tableNames = databaseDto.getTables().stream().map(s -> QualifiedName.ofTable(databaseDto.getName().getCatalogName(), databaseDto.getName().getDatabaseName(), s)).collect(Collectors.toList());
log.info("Full refresh of database {} for tables({}): {}", databaseDto.getName().toString(), databaseDto.getTables().size(), databaseDto.getTables());
return processTables(databaseDto.getName(), tableNames);
}).filter(NOT_NULL).collect(Collectors.toList());
processDatabaseFutures.add(processDatabaseFuture);
return Futures.transform(Futures.successfulAsList(processDatabaseFutures), Functions.constant(null));
});
}
return resultFuture;
}
use of com.netflix.metacat.common.dto.DatabaseDto in project metacat by Netflix.
the class TableServiceImpl method copy.
@Override
public TableDto copy(@Nonnull final TableDto tableDto, @Nonnull final QualifiedName targetName) {
final QualifiedName databaseName = QualifiedName.ofDatabase(targetName.getCatalogName(), targetName.getDatabaseName());
if (!databaseService.exists(databaseName)) {
final DatabaseDto databaseDto = new DatabaseDto();
databaseDto.setName(databaseName);
databaseService.create(databaseName, databaseDto);
}
final TableDto targetTableDto = new TableDto();
targetTableDto.setName(targetName);
targetTableDto.setFields(tableDto.getFields());
targetTableDto.setPartition_keys(tableDto.getPartition_keys());
final StorageDto storageDto = tableDto.getSerde();
if (storageDto != null) {
final StorageDto targetStorageDto = new StorageDto();
targetStorageDto.setInputFormat(storageDto.getInputFormat());
targetStorageDto.setOwner(storageDto.getOwner());
targetStorageDto.setOutputFormat(storageDto.getOutputFormat());
targetStorageDto.setParameters(storageDto.getParameters());
targetStorageDto.setUri(storageDto.getUri());
targetStorageDto.setSerializationLib(storageDto.getSerializationLib());
targetTableDto.setSerde(targetStorageDto);
}
create(targetName, targetTableDto);
return targetTableDto;
}
Aggregations