use of com.netflix.metacat.common.QualifiedName in project metacat by Netflix.
the class CassandraConnectorDatabaseService method list.
/**
* {@inheritDoc}
*/
@Override
public List<DatabaseInfo> list(@Nonnull @NonNull final ConnectorContext context, @Nonnull @NonNull final QualifiedName name, @Nullable final QualifiedName prefix, @Nullable final Sort sort, @Nullable final Pageable pageable) {
log.debug("Attempting to list keyspaces for request {}", context);
final ImmutableList.Builder<DatabaseInfo> keyspacesBuilder = ImmutableList.builder();
for (final QualifiedName keyspace : this.listNames(context, name, prefix, sort, pageable)) {
keyspacesBuilder.add(DatabaseInfo.builder().name(keyspace).build());
}
final List<DatabaseInfo> keyspaces = keyspacesBuilder.build();
log.debug("Successfully listed {} keyspaces for request {}", keyspaces.size(), context);
return keyspaces;
}
use of com.netflix.metacat.common.QualifiedName in project metacat by Netflix.
the class PartitionController method savePartitions.
/**
* Add/update partitions to the given table.
*
* @param catalogName catalog name
* @param databaseName database name
* @param tableName table name
* @param partitionsSaveRequestDto partition request containing the list of partitions to be added/updated
* @return Response with the number of partitions added/updated
*/
@RequestMapping(method = RequestMethod.POST, path = "/catalog/{catalog-name}/database/{database-name}/table/{table-name}", consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
@ApiOperation(position = 5, value = "Add/update partitions to the given table", notes = "Add/update partitions to the given table")
@ApiResponses({ @ApiResponse(code = HttpURLConnection.HTTP_CREATED, message = "The partitions were successfully saved"), @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "The requested catalog or database or table cannot be located") })
@Override
public PartitionsSaveResponseDto savePartitions(@ApiParam(value = "The name of the catalog", required = true) @PathVariable("catalog-name") final String catalogName, @ApiParam(value = "The name of the database", required = true) @PathVariable("database-name") final String databaseName, @ApiParam(value = "The name of the table", required = true) @PathVariable("table-name") final String tableName, @ApiParam(value = "Request containing the list of partitions", required = true) @RequestBody final PartitionsSaveRequestDto partitionsSaveRequestDto) {
final QualifiedName name = QualifiedName.ofTable(catalogName, databaseName, tableName);
return this.requestWrapper.processRequest(name, "saveTablePartition", () -> {
final PartitionsSaveResponseDto result;
if (partitionsSaveRequestDto.getPartitions() == null || partitionsSaveRequestDto.getPartitions().isEmpty()) {
result = new PartitionsSaveResponseDto();
} else {
result = this.partitionService.save(name, partitionsSaveRequestDto);
// This metadata is actually for the table, if it is present update that
if (partitionsSaveRequestDto.getDefinitionMetadata() != null || partitionsSaveRequestDto.getDataMetadata() != null) {
final TableDto dto = new TableDto();
dto.setName(name);
dto.setDefinitionMetadata(partitionsSaveRequestDto.getDefinitionMetadata());
dto.setDataMetadata(partitionsSaveRequestDto.getDataMetadata());
this.v1.updateTable(catalogName, databaseName, tableName, dto);
}
}
return result;
});
}
use of com.netflix.metacat.common.QualifiedName in project metacat by Netflix.
the class PartitionController method deletePartitions.
/**
* Delete named partitions from a table.
*
* @param catalogName catalog name
* @param databaseName database name
* @param tableName table name
* @param partitionIds lis of partition names
*/
@RequestMapping(method = RequestMethod.DELETE, path = "/catalog/{catalog-name}/database/{database-name}/table/{table-name}", consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.NO_CONTENT)
@ApiOperation(value = "Delete named partitions from a table", notes = "List of partitions names of the given table name under the given catalog and database")
@ApiResponses({ @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "The partitions were deleted successfully"), @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "The requested catalog or database or table cannot be located"), @ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST, message = "The list of partitionNames is not present") })
@Override
public void deletePartitions(@ApiParam(value = "The name of the catalog", required = true) @PathVariable("catalog-name") final String catalogName, @ApiParam(value = "The name of the database", required = true) @PathVariable("database-name") final String databaseName, @ApiParam(value = "The name of the table", required = true) @PathVariable("table-name") final String tableName, @ApiParam(value = "partitionId of the partitions to be deleted from this table", required = true) @RequestBody final List<String> partitionIds) {
final QualifiedName name = this.requestWrapper.qualifyName(() -> QualifiedName.ofTable(catalogName, databaseName, tableName));
this.requestWrapper.processRequest(name, "deleteTablePartition", () -> {
if (partitionIds.isEmpty()) {
throw new IllegalArgumentException("partitionIds are required");
}
this.partitionService.delete(name, partitionIds);
return null;
});
}
use of com.netflix.metacat.common.QualifiedName in project metacat by Netflix.
the class TagController method removeTableTags.
/**
* Remove the tags from the given table.
*
* @param catalogName catalog name
* @param databaseName database name
* @param tableName table name
* @param deleteAll True if all tags need to be removed
* @param tags Tags to be removed from the given table
*/
@RequestMapping(method = RequestMethod.DELETE, path = "/catalog/{catalog-name}/database/{database-name}/table/{table-name}", consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.NO_CONTENT)
@ApiOperation(position = 4, value = "Remove the tags from the given table", notes = "Remove the tags from the given table")
@ApiResponses({ @ApiResponse(code = HttpURLConnection.HTTP_NO_CONTENT, message = "The tags were successfully deleted from the table"), @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "The requested catalog or database or table cannot be located") })
public void removeTableTags(@ApiParam(value = "The name of the catalog", required = true) @PathVariable("catalog-name") final String catalogName, @ApiParam(value = "The name of the database", required = true) @PathVariable("database-name") final String databaseName, @ApiParam(value = "The name of the table", required = true) @PathVariable("table-name") final String tableName, @ApiParam(value = "True if all tags need to be removed") @RequestParam(name = "all", defaultValue = "false") final boolean deleteAll, @ApiParam(value = "Tags to be removed from the given table") @Nullable @RequestBody(required = false) final Set<String> tags) {
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final QualifiedName name = this.requestWrapper.qualifyName(() -> QualifiedName.ofTable(catalogName, databaseName, tableName));
this.requestWrapper.processRequest(name, "TagV1Resource.removeTableTags", () -> {
// TODO: Business logic in API tier...
if (!this.tableService.exists(name)) {
// Delete tags if exists
this.tagService.delete(name, false);
throw new TableNotFoundException(name);
}
final TableDto oldTable = this.tableService.get(name, GetTableServiceParameters.builder().includeInfo(true).includeDataMetadata(true).includeDefinitionMetadata(true).disableOnReadMetadataIntercetor(false).build()).orElseThrow(IllegalStateException::new);
this.tagService.removeTableTags(name, deleteAll, tags, true);
final TableDto currentTable = this.tableService.get(name, GetTableServiceParameters.builder().includeInfo(true).includeDataMetadata(true).includeDefinitionMetadata(true).disableOnReadMetadataIntercetor(false).build()).orElseThrow(IllegalStateException::new);
this.eventBus.postAsync(new MetacatUpdateTablePostEvent(name, metacatRequestContext, this, oldTable, currentTable));
return null;
});
}
use of com.netflix.metacat.common.QualifiedName in project metacat by Netflix.
the class MViewServiceImpl method deletePartitions.
/**
* {@inheritDoc}
*/
@Override
public void deletePartitions(final QualifiedName name, final List<String> partitionIds) {
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final PartitionsSaveRequestDto dto = new PartitionsSaveRequestDto();
dto.setPartitionIdsForDeletes(partitionIds);
eventBus.postSync(new MetacatDeleteMViewPartitionPreEvent(name, metacatRequestContext, this, dto));
final QualifiedName viewQName = QualifiedName.ofTable(name.getCatalogName(), VIEW_DB_NAME, createViewName(name));
partitionService.delete(viewQName, partitionIds);
eventBus.postAsync(new MetacatDeleteMViewPartitionPostEvent(name, metacatRequestContext, this, partitionIds));
}
Aggregations