【问题标题】:Cannot retrieve Storage Gateway snapshots using Java API无法使用 Java API 检索 Storage Gateway 快照
【发布时间】:2013-06-16 14:19:14
【问题描述】:

我正在尝试从我们的 Storage Gateway 中获取快照列表并将它们放入 JTable 中。但是,当我使用 AWS Java API 检索快照列表时,我只能检索看似由 Amazon 发布的公共快照。当我将 DescribeSnapshotsRequest.setOwnerIds() 设置为包含“self”时,列表为空。

这是有问题的代码:

private void createTable() {
        Object[][] data = null;
        String[] columns = new String[]{"Snapshot ID", "Owner ID", "Snapshot Date"};

        DescribeSnapshotsRequest req = new DescribeSnapshotsRequest();
        req.setOwnerIds(Arrays.<String>asList("self"));

        try {
            snapshots = ec2Client.describeSnapshots(req).getSnapshots();

            data = new Object[snapshots.size()][3];

            int i = 0;
            for(Snapshot item : snapshots) {
                data[i][0] = item.getSnapshotId();
                data[i][1] = item.getOwnerId();
                data[i][2] = item.getStartTime();
                i++;
            }
        } catch(Exception e) {
            System.out.println("Invalid Credentials!");
        }

        table = new JTable(data, columns);
        table.setAutoCreateRowSorter(true);
    }

除非我删除 DescribeSnapshotsRequest 或将所有者 ID 设置为“amazon”,否则列表快照为空。

长话短说,为什么我不能从 Storage Gateway 访问我的私有快照?

【问题讨论】:

    标签: java amazon-web-services amazon-ec2 aws-storage-gateway


    【解决方案1】:

    想通了。事实证明,您必须明确定义 EC2 端点。不知怎的,我错过了那一步。

    以下是端点列表: http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region

    AmazonEC2Client.setEndpoint("<Endpoint URL>");
    

    【讨论】:

      猜你喜欢
      • 2013-01-05
      • 1970-01-01
      • 2020-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-12
      相关资源
      最近更新 更多