Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,33 +70,41 @@ public String getPathForHadoop(String dataSource)
@Override
public DataSegment push(File inDir, DataSegment segment) throws IOException
{
final String storageDir = DataSegmentPusherUtil.getHdfsStorageDir(segment);

log.info(
"Copying segment[%s] to HDFS at location[%s/%s]",
segment.getIdentifier(),
config.getStorageDirectory(),
storageDir
);

Path outFile = new Path(String.format("%s/%s/index.zip", config.getStorageDirectory(), storageDir));
FileSystem fs = outFile.getFileSystem(hadoopConfig);

fs.mkdirs(outFile.getParent());
log.info("Compressing files from[%s] to [%s]", inDir, outFile);

final long size;
try (FSDataOutputStream out = fs.create(outFile)) {
size = CompressionUtils.zip(inDir, out);
final ClassLoader priorLoader = Thread.currentThread().getContextClassLoader();
try {
// See https://github.com/druid-io/druid/issues/1714
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
final String storageDir = DataSegmentPusherUtil.getHdfsStorageDir(segment);

log.info(
"Copying segment[%s] to HDFS at location[%s/%s]",
segment.getIdentifier(),
config.getStorageDirectory(),
storageDir
);

Path outFile = new Path(String.format("%s/%s/index.zip", config.getStorageDirectory(), storageDir));
FileSystem fs = outFile.getFileSystem(hadoopConfig);

fs.mkdirs(outFile.getParent());
log.info("Compressing files from[%s] to [%s]", inDir, outFile);

final long size;
try (FSDataOutputStream out = fs.create(outFile)) {
size = CompressionUtils.zip(inDir, out);
}

return createDescriptorFile(
segment.withLoadSpec(makeLoadSpec(outFile))
.withSize(size)
.withBinaryVersion(SegmentUtils.getVersionFromDir(inDir)),
outFile.getParent(),
fs
);
}
finally {
Thread.currentThread().setContextClassLoader(priorLoader);
}

return createDescriptorFile(
segment.withLoadSpec(makeLoadSpec(outFile))
.withSize(size)
.withBinaryVersion(SegmentUtils.getVersionFromDir(inDir)),
outFile.getParent(),
fs
);
}

private DataSegment createDescriptorFile(DataSegment segment, Path outDir, final FileSystem fs) throws IOException
Expand Down