Search in sources :

Example 11 with HoodieException

use of org.apache.hudi.exception.HoodieException in project hudi by apache.

the class HoodieDeltaStreamer method sync.

/**
 * Main method to start syncing.
 *
 * @throws Exception
 */
public void sync() throws Exception {
    if (bootstrapExecutor.isPresent()) {
        LOG.info("Performing bootstrap. Source=" + bootstrapExecutor.get().getBootstrapConfig().getBootstrapSourceBasePath());
        bootstrapExecutor.get().execute();
    } else {
        if (cfg.continuousMode) {
            deltaSyncService.ifPresent(ds -> {
                ds.start(this::onDeltaSyncShutdown);
                try {
                    ds.waitForShutdown();
                } catch (Exception e) {
                    throw new HoodieException(e.getMessage(), e);
                }
            });
            LOG.info("Delta Sync shutting down");
        } else {
            LOG.info("Delta Streamer running only single round");
            try {
                deltaSyncService.ifPresent(ds -> {
                    try {
                        ds.getDeltaSync().syncOnce();
                    } catch (IOException e) {
                        throw new HoodieIOException(e.getMessage(), e);
                    }
                });
            } catch (Exception ex) {
                LOG.error("Got error running delta sync once. Shutting down", ex);
                throw ex;
            } finally {
                deltaSyncService.ifPresent(DeltaSyncService::close);
                LOG.info("Shut down delta streamer");
            }
        }
    }
}
Also used : HoodieIOException(org.apache.hudi.exception.HoodieIOException) HoodieException(org.apache.hudi.exception.HoodieException) IOException(java.io.IOException) HoodieIOException(org.apache.hudi.exception.HoodieIOException) HoodieException(org.apache.hudi.exception.HoodieException) HoodieUpsertException(org.apache.hudi.exception.HoodieUpsertException) HoodieClusteringUpdateException(org.apache.hudi.exception.HoodieClusteringUpdateException) IOException(java.io.IOException) HoodieIOException(org.apache.hudi.exception.HoodieIOException)

Example 12 with HoodieException

use of org.apache.hudi.exception.HoodieException in project hudi by apache.

the class HiveIncrementalPuller method ensureTempPathExists.

private boolean ensureTempPathExists(FileSystem fs, String lastCommitTime) throws IOException {
    Path targetBaseDirPath = new Path(config.hoodieTmpDir, config.targetTable + "__" + config.sourceTable);
    if (!fs.exists(targetBaseDirPath)) {
        LOG.info("Creating " + targetBaseDirPath + " with permission drwxrwxrwx");
        boolean result = FileSystem.mkdirs(fs, targetBaseDirPath, new FsPermission(FsAction.ALL, FsAction.ALL, FsAction.ALL));
        if (!result) {
            throw new HoodieException("Could not create " + targetBaseDirPath + " with the required permissions");
        }
    }
    Path targetPath = new Path(targetBaseDirPath, lastCommitTime);
    if (fs.exists(targetPath)) {
        boolean result = fs.delete(targetPath, true);
        if (!result) {
            throw new HoodieException("Could not delete existing " + targetPath);
        }
    }
    LOG.info("Creating " + targetPath + " with permission drwxrwxrwx");
    return FileSystem.mkdirs(fs, targetBaseDirPath, new FsPermission(FsAction.ALL, FsAction.ALL, FsAction.ALL));
}
Also used : Path(org.apache.hadoop.fs.Path) HoodieException(org.apache.hudi.exception.HoodieException) FsPermission(org.apache.hadoop.fs.permission.FsPermission)

Example 13 with HoodieException

use of org.apache.hudi.exception.HoodieException in project hudi by apache.

the class HoodieClusteringJob method getSchemaFromLatestInstant.

private String getSchemaFromLatestInstant() throws Exception {
    TableSchemaResolver schemaResolver = new TableSchemaResolver(metaClient);
    if (metaClient.getActiveTimeline().getCommitsTimeline().filterCompletedInstants().countInstants() == 0) {
        throw new HoodieException("Cannot run clustering without any completed commits");
    }
    Schema schema = schemaResolver.getTableAvroSchema(false);
    return schema.toString();
}
Also used : Schema(org.apache.avro.Schema) TableSchemaResolver(org.apache.hudi.common.table.TableSchemaResolver) HoodieException(org.apache.hudi.exception.HoodieException)

Example 14 with HoodieException

use of org.apache.hudi.exception.HoodieException in project hudi by apache.

the class HoodieCompactor method getSchemaFromLatestInstant.

private String getSchemaFromLatestInstant() throws Exception {
    TableSchemaResolver schemaUtil = new TableSchemaResolver(metaClient);
    if (metaClient.getActiveTimeline().getCommitsTimeline().filterCompletedInstants().countInstants() == 0) {
        throw new HoodieException("Cannot run compaction without any completed commits");
    }
    Schema schema = schemaUtil.getTableAvroSchema(false);
    return schema.toString();
}
Also used : Schema(org.apache.avro.Schema) TableSchemaResolver(org.apache.hudi.common.table.TableSchemaResolver) HoodieException(org.apache.hudi.exception.HoodieException)

Example 15 with HoodieException

use of org.apache.hudi.exception.HoodieException in project hudi by apache.

the class HoodieDataTableValidator method run.

public void run() {
    try {
        LOG.info(cfg);
        if (cfg.continuous) {
            LOG.info(" ****** do hoodie data table validation in CONTINUOUS mode ******");
            doHoodieDataTableValidationContinuous();
        } else {
            LOG.info(" ****** do hoodie data table validation once ******");
            doHoodieDataTableValidationOnce();
        }
    } catch (Exception e) {
        throw new HoodieException("Unable to do hoodie data table validation in " + cfg.basePath, e);
    } finally {
        if (asyncDataTableValidateService.isPresent()) {
            asyncDataTableValidateService.get().shutdown(true);
        }
    }
}
Also used : HoodieException(org.apache.hudi.exception.HoodieException) HoodieException(org.apache.hudi.exception.HoodieException) HoodieValidationException(org.apache.hudi.exception.HoodieValidationException)

Aggregations

HoodieException (org.apache.hudi.exception.HoodieException)171 IOException (java.io.IOException)87 Path (org.apache.hadoop.fs.Path)45 Schema (org.apache.avro.Schema)35 HoodieIOException (org.apache.hudi.exception.HoodieIOException)35 List (java.util.List)30 ArrayList (java.util.ArrayList)27 HoodieTableMetaClient (org.apache.hudi.common.table.HoodieTableMetaClient)23 Collectors (java.util.stream.Collectors)21 HoodieInstant (org.apache.hudi.common.table.timeline.HoodieInstant)19 Option (org.apache.hudi.common.util.Option)19 HoodieTimeline (org.apache.hudi.common.table.timeline.HoodieTimeline)18 Map (java.util.Map)16 HoodieRecord (org.apache.hudi.common.model.HoodieRecord)16 GenericRecord (org.apache.avro.generic.GenericRecord)15 Arrays (java.util.Arrays)14 HoodieLogFile (org.apache.hudi.common.model.HoodieLogFile)14 Logger (org.apache.log4j.Logger)14 FileStatus (org.apache.hadoop.fs.FileStatus)13 HoodieCommitMetadata (org.apache.hudi.common.model.HoodieCommitMetadata)13