be/src/io/fs/broker_file_system.h
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #pragma once |
19 | | |
20 | | #include <stdint.h> |
21 | | |
22 | | #include <cstddef> |
23 | | #include <map> |
24 | | #include <memory> |
25 | | #include <string> |
26 | | #include <vector> |
27 | | |
28 | | #include "common/status.h" |
29 | | #include "io/fs/path.h" |
30 | | #include "io/fs/remote_file_system.h" |
31 | | #include "util/client_cache.h" |
32 | | |
33 | | namespace doris { |
34 | | class TNetworkAddress; |
35 | | |
36 | | namespace io { |
37 | | struct FileInfo; |
38 | | |
39 | | class BrokerFileSystem final : public RemoteFileSystem { |
40 | | public: |
41 | | static Result<std::shared_ptr<BrokerFileSystem>> create( |
42 | | const TNetworkAddress& broker_addr, |
43 | | const std::map<std::string, std::string>& broker_prop, std::string id); |
44 | | |
45 | 0 | ~BrokerFileSystem() override = default; |
46 | | |
47 | | protected: |
48 | | Status create_file_impl(const Path& file, FileWriterPtr* writer, |
49 | | const FileWriterOptions* opts) override; |
50 | | Status open_file_internal(const Path& file, FileReaderSPtr* reader, |
51 | | const FileReaderOptions& opts) override; |
52 | | Status create_directory_impl(const Path& dir, bool failed_if_exists = false) override; |
53 | | Status delete_file_impl(const Path& file) override; |
54 | | Status delete_directory_impl(const Path& dir) override; |
55 | | Status batch_delete_impl(const std::vector<Path>& files) override; |
56 | | Status exists_impl(const Path& path, bool* res) const override; |
57 | | Status file_size_impl(const Path& file, int64_t* file_size) const override; |
58 | | Status list_impl(const Path& dir, bool only_file, std::vector<FileInfo>* files, |
59 | | bool* exists) override; |
60 | | Status rename_impl(const Path& orig_name, const Path& new_name) override; |
61 | | |
62 | | Status upload_impl(const Path& local_file, const Path& remote_file) override; |
63 | | Status batch_upload_impl(const std::vector<Path>& local_files, |
64 | | const std::vector<Path>& remote_files) override; |
65 | | Status download_impl(const Path& remote_file, const Path& local_file) override; |
66 | | |
67 | | private: |
68 | | BrokerFileSystem(const TNetworkAddress& broker_addr, |
69 | | const std::map<std::string, std::string>& broker_prop, std::string id); |
70 | | |
71 | | Status init(); |
72 | | |
73 | | std::string error_msg(const std::string& err) const; |
74 | | |
75 | | const TNetworkAddress& _broker_addr; |
76 | | const std::map<std::string, std::string>& _broker_prop; |
77 | | |
78 | | std::shared_ptr<BrokerServiceConnection> _connection; |
79 | | }; |
80 | | } // namespace io |
81 | | } // namespace doris |