2020-10-21 15:48:40 +08:00
|
|
|
/*
|
|
|
|
* BackupContainerAzureBlobStore.h
|
|
|
|
*
|
|
|
|
* This source file is part of the FoundationDB open source project
|
|
|
|
*
|
|
|
|
* Copyright 2013-2018 Apple Inc. and the FoundationDB project authors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2020-10-23 00:40:27 +08:00
|
|
|
#if (!defined FDBCLIENT_BACKUP_CONTAINER_AZURE_BLOBSTORE_H) && (defined BUILD_AZURE_BACKUP)
|
2020-10-21 15:48:40 +08:00
|
|
|
#define FDBCLIENT_BACKUP_CONTAINER_AZURE_BLOBSTORE_H
|
|
|
|
#pragma once
|
|
|
|
|
2020-10-24 14:27:13 +08:00
|
|
|
#include "fdbclient/AsyncTaskThread.h"
|
2020-10-22 01:43:08 +08:00
|
|
|
#include "fdbclient/BackupContainerFileSystem.h"
|
2020-10-21 15:48:40 +08:00
|
|
|
|
|
|
|
#include "storage_credential.h"
|
|
|
|
#include "storage_account.h"
|
|
|
|
#include "blob/blob_client.h"
|
|
|
|
|
|
|
|
class BackupContainerAzureBlobStore final : public BackupContainerFileSystem,
|
|
|
|
ReferenceCounted<BackupContainerAzureBlobStore> {
|
|
|
|
using AzureClient = azure::storage_lite::blob_client;
|
|
|
|
|
|
|
|
std::unique_ptr<AzureClient> client;
|
|
|
|
std::string containerName;
|
|
|
|
AsyncTaskThread asyncTaskThread;
|
|
|
|
|
|
|
|
Future<bool> blobExists(const std::string& fileName);
|
|
|
|
|
2020-10-22 01:32:59 +08:00
|
|
|
friend class BackupContainerAzureBlobStoreImpl;
|
|
|
|
|
|
|
|
public:
|
2021-03-11 02:06:03 +08:00
|
|
|
BackupContainerAzureBlobStore(const NetworkAddress& address,
|
|
|
|
const std::string& accountName,
|
2020-10-24 13:48:14 +08:00
|
|
|
const std::string& containerName);
|
2020-10-21 15:48:40 +08:00
|
|
|
|
|
|
|
void addref() override;
|
|
|
|
void delref() override;
|
|
|
|
|
|
|
|
Future<Void> create() override;
|
|
|
|
|
|
|
|
Future<bool> exists() override;
|
|
|
|
|
2020-10-22 13:19:15 +08:00
|
|
|
Future<Reference<IAsyncFile>> readFile(const std::string& fileName) override;
|
2020-10-21 15:48:40 +08:00
|
|
|
|
|
|
|
Future<Reference<IBackupFile>> writeFile(const std::string& fileName) override;
|
|
|
|
|
2020-10-22 13:19:15 +08:00
|
|
|
Future<FilesAndSizesT> listFiles(const std::string& path = "",
|
2020-10-21 15:48:40 +08:00
|
|
|
std::function<bool(std::string const&)> folderPathFilter = nullptr) override;
|
|
|
|
|
2020-10-22 13:19:15 +08:00
|
|
|
Future<Void> deleteFile(const std::string& fileName) override;
|
2020-10-21 15:48:40 +08:00
|
|
|
|
|
|
|
Future<Void> deleteContainer(int* pNumDeleted) override;
|
2020-10-22 15:08:29 +08:00
|
|
|
|
2020-10-24 04:40:39 +08:00
|
|
|
static Future<std::vector<std::string>> listURLs(const std::string& baseURL);
|
|
|
|
|
2020-10-22 15:08:29 +08:00
|
|
|
static std::string getURLFormat();
|
2020-10-21 15:48:40 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|