提交 f56d60b4 编写于 作者: X Xavier Léauté

fix storage class npe

上级 b8347cf4
...@@ -24,6 +24,7 @@ import com.google.common.base.Throwables; ...@@ -24,6 +24,7 @@ import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.metamx.common.ISE;
import com.metamx.common.MapUtils; import com.metamx.common.MapUtils;
import com.metamx.common.logger.Logger; import com.metamx.common.logger.Logger;
import io.druid.segment.loading.DataSegmentMover; import io.druid.segment.loading.DataSegmentMover;
...@@ -120,23 +121,30 @@ public class S3DataSegmentMover implements DataSegmentMover ...@@ -120,23 +121,30 @@ public class S3DataSegmentMover implements DataSegmentMover
if (s3Client.isObjectInBucket(s3Bucket, s3Path)) { if (s3Client.isObjectInBucket(s3Bucket, s3Path)) {
if (s3Bucket.equals(targetS3Bucket) && s3Path.equals(targetS3Path)) { if (s3Bucket.equals(targetS3Bucket) && s3Path.equals(targetS3Path)) {
log.info("No need to move file[s3://%s/%s] onto itself", s3Bucket, s3Path); log.info("No need to move file[s3://%s/%s] onto itself", s3Bucket, s3Path);
} else if (s3Client.getObjectDetails(s3Bucket, s3Path)
.getStorageClass()
.equals(S3Object.STORAGE_CLASS_GLACIER)) {
log.warn("Cannot move file[s3://%s/%s] of storage class glacier.");
} else { } else {
log.info( final S3Object[] list = s3Client.listObjects(s3Bucket, s3Path, "");
"Moving file[s3://%s/%s] to [s3://%s/%s]", if (list.length == 0) {
s3Bucket, // should never happen
s3Path, throw new ISE("Unable to list object [s3://%s/%s]", s3Bucket, s3Path);
targetS3Bucket, }
targetS3Path final S3Object s3Object = list[0];
); if (s3Object.getStorageClass() != null &&
final S3Object target = new S3Object(targetS3Path); s3Object.getStorageClass().equals(S3Object.STORAGE_CLASS_GLACIER)) {
if(!config.getDisableAcl()) { log.warn("Cannot move file[s3://%s/%s] of storage class glacier, skipping.");
target.setAcl(GSAccessControlList.REST_CANNED_BUCKET_OWNER_FULL_CONTROL); } else {
log.info(
"Moving file[s3://%s/%s] to [s3://%s/%s]",
s3Bucket,
s3Path,
targetS3Bucket,
targetS3Path
);
final S3Object target = new S3Object(targetS3Path);
if (!config.getDisableAcl()) {
target.setAcl(GSAccessControlList.REST_CANNED_BUCKET_OWNER_FULL_CONTROL);
}
s3Client.moveObject(s3Bucket, s3Path, targetS3Bucket, target, false);
} }
s3Client.moveObject(s3Bucket, s3Path, targetS3Bucket, target, false);
} }
} else { } else {
// ensure object exists in target location // ensure object exists in target location
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册