Search in sources :

Example 1 with CoordinatorStreamProperties

use of co.cask.cdap.data.stream.CoordinatorStreamProperties in project cdap by caskdata.

the class FileStreamAdmin method updateConfig.

@Override
public void updateConfig(final StreamId streamId, final StreamProperties properties) throws Exception {
    Location streamLocation;
    // User should have admin access on the stream to update its configuration
    ensureAccess(streamId, Action.ADMIN);
    streamLocation = impersonator.doAs(streamId.getParent(), new Callable<Location>() {

        @Override
        public Location call() throws Exception {
            return getStreamLocation(streamId);
        }
    });
    Preconditions.checkArgument(streamLocation.isDirectory(), "Stream '%s' does not exist.", streamId);
    SecurityUtil.verifyOwnerPrincipal(streamId, properties.getOwnerPrincipal(), ownerAdmin);
    streamCoordinatorClient.updateProperties(streamId, new Callable<CoordinatorStreamProperties>() {

        @Override
        public CoordinatorStreamProperties call() throws Exception {
            StreamProperties oldProperties = updateProperties(streamId, properties);
            FormatSpecification format = properties.getFormat();
            if (format != null) {
                // if the schema has changed, we need to recreate the hive table.
                // Changes in format and settings don't require
                // a hive change, as they are just properties used by the stream storage handler.
                Schema currSchema = oldProperties.getFormat().getSchema();
                Schema newSchema = format.getSchema();
                if (!Objects.equals(currSchema, newSchema)) {
                    alterExploreStream(streamId, false, null);
                    alterExploreStream(streamId, true, format);
                }
            }
            publishAudit(streamId, AuditType.UPDATE);
            return new CoordinatorStreamProperties(properties.getTTL(), properties.getFormat(), properties.getNotificationThresholdMB(), null, properties.getDescription(), properties.getOwnerPrincipal());
        }
    });
}
Also used : CoordinatorStreamProperties(co.cask.cdap.data.stream.CoordinatorStreamProperties) Schema(co.cask.cdap.api.data.schema.Schema) StreamProperties(co.cask.cdap.proto.StreamProperties) CoordinatorStreamProperties(co.cask.cdap.data.stream.CoordinatorStreamProperties) FormatSpecification(co.cask.cdap.api.data.format.FormatSpecification) Callable(java.util.concurrent.Callable) NotificationFeedException(co.cask.cdap.notifications.feeds.NotificationFeedException) FileNotFoundException(java.io.FileNotFoundException) UnauthorizedException(co.cask.cdap.security.spi.authorization.UnauthorizedException) IOException(java.io.IOException) NotFoundException(co.cask.cdap.common.NotFoundException) StreamNotFoundException(co.cask.cdap.common.StreamNotFoundException) Location(org.apache.twill.filesystem.Location)

Aggregations

FormatSpecification (co.cask.cdap.api.data.format.FormatSpecification)1 Schema (co.cask.cdap.api.data.schema.Schema)1 NotFoundException (co.cask.cdap.common.NotFoundException)1 StreamNotFoundException (co.cask.cdap.common.StreamNotFoundException)1 CoordinatorStreamProperties (co.cask.cdap.data.stream.CoordinatorStreamProperties)1 NotificationFeedException (co.cask.cdap.notifications.feeds.NotificationFeedException)1 StreamProperties (co.cask.cdap.proto.StreamProperties)1 UnauthorizedException (co.cask.cdap.security.spi.authorization.UnauthorizedException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Callable (java.util.concurrent.Callable)1 Location (org.apache.twill.filesystem.Location)1