OmniSciDB  94e8789169
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
S3Archive Class Reference

#include <S3Archive.h>

+ Inheritance diagram for S3Archive:
+ Collaboration diagram for S3Archive:

Public Member Functions

 S3Archive (const std::string &url, const bool plain_text)
 
 S3Archive (const std::string &url, const std::string &s3_access_key, const std::string &s3_secret_key, const std::string &s3_region, const std::string &s3_endpoint, const bool plain_text)
 
 ~S3Archive () override
 
void init_for_read () override
 
const std::vector< std::string > & get_objkeys ()
 
const std::string land (const std::string &objkey, std::exception_ptr &teptr, const bool for_detection)
 
void vacuum (const std::string &objkey)
 
size_t get_total_file_size () const
 
- Public Member Functions inherited from Archive
 Archive (const std::string url, const bool plain_text)
 
virtual ~Archive ()
 
virtual std::string archive_error (int err)
 
virtual bool read_next_header ()
 
virtual bool read_data_block (const void **buff, size_t *size, int64_t *offset)
 
virtual int64_t get_position_compressed () const
 
virtual int open ()
 
virtual int close ()
 
virtual ssize_t read (const void **buff)
 
const std::string url_part (const int i)
 
std::string entryName ()
 

Private Attributes

std::string s3_access_key
 
std::string s3_secret_key
 
std::string s3_region
 
std::string s3_endpoint
 
std::string s3_temp_dir
 
std::string bucket_name
 
std::string prefix_name
 
std::vector< std::string > objkeys
 
std::map< const std::string,
const std::string > 
file_paths
 
size_t total_file_size {0}
 

Additional Inherited Members

- Static Public Member Functions inherited from Archive
static ssize_t read (struct archive *a, void *client_data, const void **buff)
 
static int open (struct archive *a, void *client_data)
 
static int close (struct archive *a, void *client_data)
 
static void parse_url (const std::string url, std::map< int, std::string > &url_parts)
 
- Protected Attributes inherited from Archive
std::string url
 
std::map< int, std::string > url_parts
 
archive * ar = 0
 
archive_entry * entry
 
bool plain_text
 

Detailed Description

Definition at line 38 of file S3Archive.h.

Constructor & Destructor Documentation

S3Archive::S3Archive ( const std::string &  url,
const bool  plain_text 
)
inline

Definition at line 40 of file S3Archive.h.

References s3_access_key, s3_endpoint, s3_region, and s3_secret_key.

40  : Archive(url, plain_text) {
41  // these envs are on server side so are global settings
42  // which make few senses in case of private s3 resources
43  char* env;
44  if (0 != (env = getenv("AWS_REGION"))) {
45  s3_region = env;
46  }
47  if (0 != (env = getenv("AWS_ACCESS_KEY_ID"))) {
48  s3_access_key = env;
49  }
50  if (0 != (env = getenv("AWS_SECRET_ACCESS_KEY"))) {
51  s3_secret_key = env;
52  }
53  if (0 != (env = getenv("AWS_ENDPOINT"))) {
54  s3_endpoint = env;
55  }
56  }
std::string s3_endpoint
Definition: S3Archive.h:123
std::string s3_region
Definition: S3Archive.h:122
std::string s3_access_key
Definition: S3Archive.h:120
std::string url
Definition: Archive.h:187
std::string s3_secret_key
Definition: S3Archive.h:121
bool plain_text
Definition: Archive.h:191
Archive(const std::string url, const bool plain_text)
Definition: Archive.h:31
S3Archive::S3Archive ( const std::string &  url,
const std::string &  s3_access_key,
const std::string &  s3_secret_key,
const std::string &  s3_region,
const std::string &  s3_endpoint,
const bool  plain_text 
)
inline

Definition at line 58 of file S3Archive.h.

References s3_access_key, s3_endpoint, s3_region, s3_secret_key, and s3_temp_dir.

67  this->s3_region = s3_region;
68  this->s3_endpoint = s3_endpoint;
69 
70  // this must be local to omnisci_server not client
71  // or posix dir path accessible to omnisci_server
72  auto env_s3_temp_dir = getenv("TMPDIR");
73  s3_temp_dir = env_s3_temp_dir ? env_s3_temp_dir : "/tmp";
74  }
std::string s3_endpoint
Definition: S3Archive.h:123
std::string s3_region
Definition: S3Archive.h:122
std::string s3_access_key
Definition: S3Archive.h:120
std::string s3_temp_dir
Definition: S3Archive.h:124
std::string url
Definition: Archive.h:187
std::string s3_secret_key
Definition: S3Archive.h:121
S3Archive(const std::string &url, const bool plain_text)
Definition: S3Archive.h:40
bool plain_text
Definition: Archive.h:191
S3Archive::~S3Archive ( )
inlineoverride

Definition at line 76 of file S3Archive.h.

76  {
77 #ifdef HAVE_AWS_S3
78  for (auto& thread : threads) {
79  if (thread.joinable()) {
80  thread.join();
81  }
82  }
83 #endif // HAVE_AWS_S3
84  }

Member Function Documentation

const std::vector<std::string>& S3Archive::get_objkeys ( )
inline

Definition at line 93 of file S3Archive.h.

References objkeys.

93 { return objkeys; }
std::vector< std::string > objkeys
Definition: S3Archive.h:128
size_t S3Archive::get_total_file_size ( ) const
inline

Definition at line 109 of file S3Archive.h.

References total_file_size.

109 { return total_file_size; }
size_t total_file_size
Definition: S3Archive.h:130
void S3Archive::init_for_read ( )
inlineoverridevirtual

Reimplemented from Archive.

Definition at line 89 of file S3Archive.h.

89  {
90  throw std::runtime_error("AWS S3 support not available");
91  }
const std::string S3Archive::land ( const std::string &  objkey,
std::exception_ptr &  teptr,
const bool  for_detection 
)
inline

Definition at line 100 of file S3Archive.h.

102  {
103  throw std::runtime_error("AWS S3 support not available");
104  }
void S3Archive::vacuum ( const std::string &  objkey)
inline

Definition at line 105 of file S3Archive.h.

105  {
106  throw std::runtime_error("AWS S3 support not available");
107  }

Member Data Documentation

std::string S3Archive::bucket_name
private

Definition at line 126 of file S3Archive.h.

std::map<const std::string, const std::string> S3Archive::file_paths
private

Definition at line 129 of file S3Archive.h.

std::vector<std::string> S3Archive::objkeys
private

Definition at line 128 of file S3Archive.h.

Referenced by get_objkeys().

std::string S3Archive::prefix_name
private

Definition at line 127 of file S3Archive.h.

std::string S3Archive::s3_access_key
private
std::string S3Archive::s3_endpoint
private
std::string S3Archive::s3_region
private
std::string S3Archive::s3_secret_key
private
std::string S3Archive::s3_temp_dir
private

Definition at line 124 of file S3Archive.h.

Referenced by S3Archive().

size_t S3Archive::total_file_size {0}
private

Definition at line 130 of file S3Archive.h.

Referenced by get_total_file_size().


The documentation for this class was generated from the following files: