Search in sources :

Example 1 with MetacatDeleteDatabasePreEvent

use of com.netflix.metacat.common.server.events.MetacatDeleteDatabasePreEvent in project metacat by Netflix.

the class MetacatServiceHelper method postPreDeleteEvent.

/**
 * Calls the right method of the event bus for the given qualified name.
 *
 * @param name                  name
 * @param metacatRequestContext context
 */
public void postPreDeleteEvent(final QualifiedName name, final MetacatRequestContext metacatRequestContext) {
    if (name.isPartitionDefinition()) {
        final PartitionsSaveRequestDto partitionsSaveRequestDto = new PartitionsSaveRequestDto();
        partitionsSaveRequestDto.setPartitionIdsForDeletes(Lists.newArrayList(name.getPartitionName()));
        this.eventBus.post(new MetacatDeleteTablePartitionPreEvent(name, metacatRequestContext, this, partitionsSaveRequestDto));
    } else if (name.isViewDefinition()) {
        this.eventBus.post(new MetacatDeleteMViewPreEvent(name, metacatRequestContext, this));
    } else if (name.isTableDefinition()) {
        this.eventBus.post(new MetacatDeleteTablePreEvent(name, metacatRequestContext, this));
    } else if (name.isDatabaseDefinition()) {
        final DatabaseDto dto = new DatabaseDto();
        dto.setName(name);
        eventBus.post(new MetacatDeleteDatabasePreEvent(name, metacatRequestContext, this, dto));
    } else {
        throw new IllegalArgumentException(String.format("Invalid name %s", name));
    }
}
Also used : PartitionsSaveRequestDto(com.netflix.metacat.common.dto.PartitionsSaveRequestDto) MetacatDeleteMViewPreEvent(com.netflix.metacat.common.server.events.MetacatDeleteMViewPreEvent) MetacatDeleteDatabasePreEvent(com.netflix.metacat.common.server.events.MetacatDeleteDatabasePreEvent) DatabaseDto(com.netflix.metacat.common.dto.DatabaseDto) MetacatDeleteTablePartitionPreEvent(com.netflix.metacat.common.server.events.MetacatDeleteTablePartitionPreEvent) MetacatDeleteTablePreEvent(com.netflix.metacat.common.server.events.MetacatDeleteTablePreEvent)

Example 2 with MetacatDeleteDatabasePreEvent

use of com.netflix.metacat.common.server.events.MetacatDeleteDatabasePreEvent in project metacat by Netflix.

the class DatabaseServiceImpl method delete.

/**
 * {@inheritDoc}
 */
@Override
public void delete(final QualifiedName name) {
    validate(name);
    final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
    this.authorizationService.checkPermission(metacatRequestContext.getUserName(), name, MetacatOperation.DELETE);
    log.info("Dropping schema {}", name);
    final DatabaseDto dto = get(name, GetDatabaseServiceParameters.builder().disableOnReadMetadataIntercetor(false).includeUserMetadata(true).includeTableNames(true).build());
    eventBus.post(new MetacatDeleteDatabasePreEvent(name, metacatRequestContext, this, dto));
    final ConnectorRequestContext connectorRequestContext = converterUtil.toConnectorContext(metacatRequestContext);
    connectorManager.getDatabaseService(name).delete(connectorRequestContext, name);
    // Delete definition metadata if it exists
    if (userMetadataService.getDefinitionMetadata(name).isPresent()) {
        log.info("Deleting user metadata for schema {}", name);
        userMetadataService.deleteDefinitionMetadata(ImmutableList.of(name));
    }
    eventBus.post(new MetacatDeleteDatabasePostEvent(name, metacatRequestContext, this, dto));
}
Also used : MetacatDeleteDatabasePostEvent(com.netflix.metacat.common.server.events.MetacatDeleteDatabasePostEvent) MetacatRequestContext(com.netflix.metacat.common.MetacatRequestContext) MetacatDeleteDatabasePreEvent(com.netflix.metacat.common.server.events.MetacatDeleteDatabasePreEvent) DatabaseDto(com.netflix.metacat.common.dto.DatabaseDto) ConnectorRequestContext(com.netflix.metacat.common.server.connectors.ConnectorRequestContext)

Aggregations

DatabaseDto (com.netflix.metacat.common.dto.DatabaseDto)2 MetacatDeleteDatabasePreEvent (com.netflix.metacat.common.server.events.MetacatDeleteDatabasePreEvent)2 MetacatRequestContext (com.netflix.metacat.common.MetacatRequestContext)1 PartitionsSaveRequestDto (com.netflix.metacat.common.dto.PartitionsSaveRequestDto)1 ConnectorRequestContext (com.netflix.metacat.common.server.connectors.ConnectorRequestContext)1 MetacatDeleteDatabasePostEvent (com.netflix.metacat.common.server.events.MetacatDeleteDatabasePostEvent)1 MetacatDeleteMViewPreEvent (com.netflix.metacat.common.server.events.MetacatDeleteMViewPreEvent)1 MetacatDeleteTablePartitionPreEvent (com.netflix.metacat.common.server.events.MetacatDeleteTablePartitionPreEvent)1 MetacatDeleteTablePreEvent (com.netflix.metacat.common.server.events.MetacatDeleteTablePreEvent)1