Search in sources :

Example 1 with MetacatUpdateDatabasePostEvent

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

the class CatalogServiceImpl method update.

/**
     * {@inheritDoc}
     */
@Override
public void update(@Nonnull final QualifiedName name, @Nonnull final CreateCatalogDto createCatalogDto) {
    final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
    eventBus.postSync(new MetacatUpdateDatabasePreEvent(name, metacatRequestContext, this));
    connectorManager.getCatalogConfig(name);
    userMetadataService.saveMetadata(metacatRequestContext.getUserName(), createCatalogDto, true);
    eventBus.postAsync(new MetacatUpdateDatabasePostEvent(name, metacatRequestContext, this));
}
Also used : MetacatRequestContext(com.netflix.metacat.common.MetacatRequestContext) MetacatUpdateDatabasePreEvent(com.netflix.metacat.common.server.events.MetacatUpdateDatabasePreEvent) MetacatUpdateDatabasePostEvent(com.netflix.metacat.common.server.events.MetacatUpdateDatabasePostEvent)

Example 2 with MetacatUpdateDatabasePostEvent

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

the class DatabaseServiceImpl method update.

@Override
public void update(@Nonnull final QualifiedName name, @Nonnull final DatabaseDto dto) {
    validate(name);
    log.info("Updating schema {}", name);
    final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
    eventBus.postSync(new MetacatUpdateDatabasePreEvent(name, metacatRequestContext, this));
    try {
        final ConnectorContext connectorContext = converterUtil.toConnectorContext(metacatRequestContext);
        connectorManager.getDatabaseService(name.getCatalogName()).update(connectorContext, converterUtil.fromDatabaseDto(dto));
    } catch (UnsupportedOperationException ignored) {
    }
    if (dto.getDefinitionMetadata() != null) {
        log.info("Saving user metadata for schema {}", name);
        userMetadataService.saveDefinitionMetadata(name, metacatRequestContext.getUserName(), Optional.of(dto.getDefinitionMetadata()), true);
    }
    eventBus.postAsync(new MetacatUpdateDatabasePostEvent(name, metacatRequestContext, this));
}
Also used : MetacatRequestContext(com.netflix.metacat.common.MetacatRequestContext) MetacatUpdateDatabasePreEvent(com.netflix.metacat.common.server.events.MetacatUpdateDatabasePreEvent) ConnectorContext(com.netflix.metacat.common.server.connectors.ConnectorContext) MetacatUpdateDatabasePostEvent(com.netflix.metacat.common.server.events.MetacatUpdateDatabasePostEvent)

Example 3 with MetacatUpdateDatabasePostEvent

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

the class MetacatServiceHelper method postPostUpdateEvent.

/**
     * Calls the right method of the event bus for the given qualified name.
     *
     * @param name                  name
     * @param metacatRequestContext context
     * @param oldDTo                dto
     * @param currentDto            dto
     */
public void postPostUpdateEvent(final QualifiedName name, final MetacatRequestContext metacatRequestContext, final BaseDto oldDTo, final BaseDto currentDto) {
    if (name.isPartitionDefinition()) {
        final List<PartitionDto> dtos = Lists.newArrayList();
        if (currentDto != null) {
            dtos.add((PartitionDto) currentDto);
        }
        // This request neither added nor updated partitions
        final PartitionsSaveResponseDto partitionsSaveResponseDto = new PartitionsSaveResponseDto();
        this.eventBus.postAsync(new MetacatSaveTablePartitionPostEvent(name, metacatRequestContext, this, dtos, partitionsSaveResponseDto));
    } else if (name.isTableDefinition()) {
        final MetacatUpdateTablePostEvent event = new MetacatUpdateTablePostEvent(name, metacatRequestContext, this, (TableDto) oldDTo, (TableDto) currentDto);
        this.eventBus.postAsync(event);
    } else if (name.isDatabaseDefinition()) {
        this.eventBus.postAsync(new MetacatUpdateDatabasePostEvent(name, metacatRequestContext, this));
    } else {
        throw new IllegalArgumentException(String.format("Invalid name %s", name));
    }
}
Also used : MetacatUpdateTablePostEvent(com.netflix.metacat.common.server.events.MetacatUpdateTablePostEvent) MetacatSaveTablePartitionPostEvent(com.netflix.metacat.common.server.events.MetacatSaveTablePartitionPostEvent) MetacatUpdateDatabasePostEvent(com.netflix.metacat.common.server.events.MetacatUpdateDatabasePostEvent) PartitionDto(com.netflix.metacat.common.dto.PartitionDto) TableDto(com.netflix.metacat.common.dto.TableDto) PartitionsSaveResponseDto(com.netflix.metacat.common.dto.PartitionsSaveResponseDto)

Aggregations

MetacatUpdateDatabasePostEvent (com.netflix.metacat.common.server.events.MetacatUpdateDatabasePostEvent)3 MetacatRequestContext (com.netflix.metacat.common.MetacatRequestContext)2 MetacatUpdateDatabasePreEvent (com.netflix.metacat.common.server.events.MetacatUpdateDatabasePreEvent)2 PartitionDto (com.netflix.metacat.common.dto.PartitionDto)1 PartitionsSaveResponseDto (com.netflix.metacat.common.dto.PartitionsSaveResponseDto)1 TableDto (com.netflix.metacat.common.dto.TableDto)1 ConnectorContext (com.netflix.metacat.common.server.connectors.ConnectorContext)1 MetacatSaveTablePartitionPostEvent (com.netflix.metacat.common.server.events.MetacatSaveTablePartitionPostEvent)1 MetacatUpdateTablePostEvent (com.netflix.metacat.common.server.events.MetacatUpdateTablePostEvent)1