Search in sources :

Example 21 with SegmentLoadingException

use of io.druid.segment.loading.SegmentLoadingException in project druid by druid-io.

the class GoogleDataSegmentPuller method getSegmentFiles.

public FileUtils.FileCopyResult getSegmentFiles(final String bucket, final String path, File outDir) throws SegmentLoadingException {
    LOG.info("Pulling index at path[%s] to outDir[%s]", bucket, path, outDir.getAbsolutePath());
    try {
        prepareOutDir(outDir);
        final GoogleByteSource byteSource = new GoogleByteSource(storage, bucket, path);
        final FileUtils.FileCopyResult result = CompressionUtils.unzip(byteSource, outDir, GoogleUtils.GOOGLE_RETRY, true);
        LOG.info("Loaded %d bytes from [%s] to [%s]", result.size(), path, outDir.getAbsolutePath());
        return result;
    } catch (Exception e) {
        try {
            org.apache.commons.io.FileUtils.deleteDirectory(outDir);
        } catch (IOException ioe) {
            LOG.warn(ioe, "Failed to remove output directory [%s] for segment pulled from [%s]", outDir.getAbsolutePath(), path);
        }
        throw new SegmentLoadingException(e, e.getMessage());
    }
}
Also used : FileUtils(io.druid.java.util.common.FileUtils) SegmentLoadingException(io.druid.segment.loading.SegmentLoadingException) IOException(java.io.IOException) SegmentLoadingException(io.druid.segment.loading.SegmentLoadingException) IOException(java.io.IOException)

Example 22 with SegmentLoadingException

use of io.druid.segment.loading.SegmentLoadingException in project hive by apache.

the class DruidStorageHandler method commitDropTable.

@Override
public void commitDropTable(Table table, boolean deleteData) throws MetaException {
    if (MetaStoreUtils.isExternalTable(table)) {
        return;
    }
    String dataSourceName = Preconditions.checkNotNull(table.getParameters().get(Constants.DRUID_DATA_SOURCE), "DataSource name is null !");
    if (deleteData == true) {
        LOG.info("Dropping with purge all the data for data source {}", dataSourceName);
        List<DataSegment> dataSegmentList = DruidStorageHandlerUtils.getDataSegmentList(getConnector(), getDruidMetadataStorageTablesConfig(), dataSourceName);
        if (dataSegmentList.isEmpty()) {
            LOG.info("Nothing to delete for data source {}", dataSourceName);
            return;
        }
        for (DataSegment dataSegment : dataSegmentList) {
            try {
                deleteSegment(dataSegment);
            } catch (SegmentLoadingException e) {
                LOG.error(String.format("Error while deleting segment [%s]", dataSegment.getIdentifier()), e);
            }
        }
    }
    if (DruidStorageHandlerUtils.disableDataSource(getConnector(), getDruidMetadataStorageTablesConfig(), dataSourceName)) {
        LOG.info("Successfully dropped druid data source {}", dataSourceName);
    }
}
Also used : SegmentLoadingException(io.druid.segment.loading.SegmentLoadingException) DataSegment(io.druid.timeline.DataSegment)

Aggregations

SegmentLoadingException (io.druid.segment.loading.SegmentLoadingException)22 IOException (java.io.IOException)16 DataSegment (io.druid.timeline.DataSegment)9 File (java.io.File)6 FileUtils (io.druid.java.util.common.FileUtils)4 ServiceException (org.jets3t.service.ServiceException)4 ByteSource (com.google.common.io.ByteSource)3 FileSystem (org.apache.hadoop.fs.FileSystem)3 Path (org.apache.hadoop.fs.Path)3 ImmutableList (com.google.common.collect.ImmutableList)2 SegmentLoaderFactory (io.druid.indexing.common.SegmentLoaderFactory)2 TaskToolboxFactory (io.druid.indexing.common.TaskToolboxFactory)2 LocalTaskActionClientFactory (io.druid.indexing.common.actions.LocalTaskActionClientFactory)2 TaskActionToolbox (io.druid.indexing.common.actions.TaskActionToolbox)2 TaskConfig (io.druid.indexing.common.config.TaskConfig)2 DataSegmentArchiver (io.druid.segment.loading.DataSegmentArchiver)2 DataSegmentMover (io.druid.segment.loading.DataSegmentMover)2 ArrayList (java.util.ArrayList)2 FileUtils (org.apache.commons.io.FileUtils)2 S3Object (org.jets3t.service.model.S3Object)2