Skip to content

Added a feature to support migrating archive files from Aliyun OSS#6

Open
successzy wants to merge 1 commit into
aws-solutions-library-samples:developfrom
successzy:main
Open

Added a feature to support migrating archive files from Aliyun OSS#6
successzy wants to merge 1 commit into
aws-solutions-library-samples:developfrom
successzy:main

Conversation

@successzy

Copy link
Copy Markdown

Issue #, if available:
Current version of dthcli doesn't support migrating archive files.

Description of changes:
Mainly added two functions which are InitializaOss() and RestoreObject().

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Comment thread dth/client.go

for _, obj := range output.Contents {
// log.Printf("key=%s size=%d", *obj.Key, obj.Size)
if obj.StorageClass == "GLACIER" || obj.StorageClass == "DEEP_ARCHIVE" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个改动会影响现有s3 的吗? 本来过滤了Glacier,给取消了

Comment thread dth/job.go
log.Printf("Unable to load credentials - %s\n", err.Error())
}
srcCred := getCredentials(ctx, cfg.SrcCredential, cfg.SrcInCurrentAccount, sm)
aliyun_endpoint := "https://oss-" + cfg.SrcRegion + ".aliyuncs.com"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

golang 不是这种 命名规范, 驼峰, 不带下划线

Comment thread dth/job.go

// Restore Aliyun Glacier Object
func RestoreObject(obj *Object, oss_bucket *oss.Bucket) error {
err := oss_bucket.RestoreObject(obj.Key)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个功能可以事先做吗? 意思就是说, 可以先批量恢复后再 调跑dth 吗

Comment thread dth/job.go
//fmt.Println("======restore object======")
if obj.StorageClass == "GLACIER" {
fmt.Println("----------Start restoring object.----------")
err := RestoreObject(obj, oss_bucket)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

所有glacier 都能调用吗?

@successzy successzy May 23, 2022

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不好意思,回复晚了。同时,非常感谢答复!

  1. 这个改动会影响现有s3 的吗? 本来过滤了Glacier,给取消了
    //会影响,目前这个只是针对特定的客户和场景。
  2. 这个功能可以事先做吗? 意思就是说, 可以先批量恢复后再 调跑dth 吗
  • 因为程序里会过滤掉Glacier和Deep Archive,如果不注释过滤Glacier和Deep Archive的代码,则需要修改Storage Class,把Glacier改成Standard或者IA
  • 如果是批量恢复,则需要把过滤Glacier和Deep Archive的代码注释掉。因为已经做了批量恢复,不再需要过滤Glacier
  • 只是如果迁移周期比较长,那么第一种方式会增加很多成本,第二种方式需要反复解冻,也会增加成本。
  • 上述两种方式都有额外步骤需要客户操作且迁移到S3后都是Standard存储类型
  • 参考1:归档类型Object:对于归档类型的Object,解冻状态默认持续24小时,24小时内再次调用RestoreObject接口则解冻状态会自动延长24小时,一次解冻流程内可有效调用7次RestoreObject接口达到最长7天的解冻持续时间。您也可以通过传入解冻天数,一次调用RestoreObject接口指定最长7天的解冻持续时间。
  • 参考2: 数据取回费用是0.06元/GB
  1. 所有glacier 都能调用吗?
    //目前只是测试了阿里云,且我理解是需要对dth支持的每个公有云对象存储额外增加RestoreObject函数。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants