Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Kate Kader
Open VDS
Commits
5a4516c3
Commit
5a4516c3
authored
Nov 13, 2019
by
David Diederich
Browse files
Merge remote-tracking branch 'upstream/master' into ci-pipeline
parents
02fb4736
a857b866
Changes
90
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
5a4516c3
...
...
@@ -2,6 +2,7 @@
Builds
Dist
CMakeSettings.json
CMakeLists.txt.user
python/.eggs
python/_skbuild
python/**/*.pyd
...
...
3rdparty/.gitignore
View file @
5a4516c3
...
...
@@ -5,3 +5,4 @@ zlib*
fmt*
cpprestapi*
azure-storage-cpp*
CMakeArtifacts*
CMake/Fetch3rdParty.cmake
View file @
5a4516c3
macro
(
Fetch3rdParty_Package name version url url_hash
)
set
(
SRC_DIR
${
PROJECT_SOURCE_DIR
}
/3rdparty/
${
name
}
-
${
version
}
)
set
(
${
name
}
_SOURCE_DIR
${
SRC_DIR
}
PARENT_SCOPE
)
set
(
${
name
}
_VERSION
${
version
}
PARENT_SCOPE
)
FetchContent_Declare
(
${
name
}
URL
${
url
}
URL_HASH
${
url_hash
}
SOURCE_DIR
${
SRC_DIR
}
)
if
(
NOT
(
EXISTS
${
SRC_DIR
}
))
FetchContent_Populate
(
${
name
}
)
endif
()
endmacro
()
function
(
Fetch3rdParty
)
include
(
CMake/FetchContentLocal.cmake
)
set
(
FETCHCONTENT_QUIET OFF
)
Fetch3rdParty_Package
(
aws-cpp-sdk 1.7.213 https://codeload.github.com/aws/aws-sdk-cpp/tar.gz/1.7.213 SHA256=dd0485837ee2b3b46a98f439fb6799e2bb63d9a0038b0de1c2173181630b775c
)
Fetch3rdParty_Package
(
gtest 1.9.0 https://codeload.github.com/google/googletest/legacy.tar.gz/33a0d4f6d76a0ed6061e612848532cba82d42870 MD5=5226644d616f5a00b436b487bf0a1dde
)
Fetch3rdParty_Package
(
jsoncpp 1.8.4 https://github.com/open-source-parsers/jsoncpp/archive/1.8.4.tar.gz MD5=fa47a3ab6b381869b6a5f20811198662
)
Fetch3rdParty_Package
(
fmt 6.0.0 https://github.com/fmtlib/fmt/archive/6.0.0.tar.gz SHA256=f1907a58d5e86e6c382e51441d92ad9e23aea63827ba47fd647eacc0d3a16c78
)
Fetch3rdParty_Package
(
cpprestapi 2.10.14 https://github.com/microsoft/cpprestsdk/archive/v2.10.14.tar.gz SHA256=f2628b248f714d7bbd6a536553bc3782602c68ca1b129017985dd70cc3515278
)
Fetch3rdParty_Package
(
azure-storage-cpp 7.0.0 https://github.com/Azure/azure-storage-cpp/archive/v7.0.0.tar.gz SHA256=2129511dcf40383de5ac643abf68cad4907b5cdbfe471c75ba264a83e3078dc7
)
if
(
BUILD_ZLIB
)
Fetch3rdParty_Package
(
zlib 1.2.11 http://zlib.net/zlib-1.2.11.tar.gz SHA256=c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1
)
endif
()
endfunction
()
include
(
CMake/Fetch3rdPartyInBuild.cmake
)
set
(
BUILD_ZLIB ON
)
Fetch3rdParty
()
CMake/Fetch3rdPartyInBuild.cmake
0 → 100644
View file @
5a4516c3
#This file depends on being in open-vds/CMake directory
set
(
Fetch3rdPartyDir
${
CMAKE_CURRENT_LIST_DIR
}
)
macro
(
Fetch3rdParty_Package name version url url_hash
)
get_filename_component
(
thirdParty
"
${
Fetch3rdPartyDir
}
/../3rdparty"
ABSOLUTE
)
set
(
SRC_DIR
${
thirdParty
}
/
${
name
}
-
${
version
}
)
set
(
${
name
}
_SOURCE_DIR
${
SRC_DIR
}
PARENT_SCOPE
)
set
(
${
name
}
_VERSION
${
version
}
PARENT_SCOPE
)
if
(
NOT
(
EXISTS
${
SRC_DIR
}
))
FetchContent_Populate
(
${
name
}
URL
${
url
}
URL_HASH
${
url_hash
}
SOURCE_DIR
${
SRC_DIR
}
SUBBUILD_DIR
${
thirdParty
}
/CMakeArtifacts/
${
name
}
-sub-
${
version
}
BINARY_DIR
${
thirdParty
}
/CMakeArtifacts/
${
name
}
-
${
version
}
)
endif
()
endmacro
()
function
(
Fetch3rdParty
)
include
(
CMake/FetchContentLocal.cmake
)
set
(
FETCHCONTENT_QUIET OFF
)
Fetch3rdParty_Package
(
aws-cpp-sdk 1.7.213 https://codeload.github.com/aws/aws-sdk-cpp/tar.gz/1.7.213 SHA256=dd0485837ee2b3b46a98f439fb6799e2bb63d9a0038b0de1c2173181630b775c
)
Fetch3rdParty_Package
(
gtest 1.9.0 https://codeload.github.com/google/googletest/legacy.tar.gz/33a0d4f6d76a0ed6061e612848532cba82d42870 MD5=5226644d616f5a00b436b487bf0a1dde
)
Fetch3rdParty_Package
(
jsoncpp 1.8.4 https://github.com/open-source-parsers/jsoncpp/archive/1.8.4.tar.gz MD5=fa47a3ab6b381869b6a5f20811198662
)
Fetch3rdParty_Package
(
fmt 6.0.0 https://github.com/fmtlib/fmt/archive/6.0.0.tar.gz SHA256=f1907a58d5e86e6c382e51441d92ad9e23aea63827ba47fd647eacc0d3a16c78
)
Fetch3rdParty_Package
(
cpprestapi 2.10.14 https://github.com/microsoft/cpprestsdk/archive/v2.10.14.tar.gz SHA256=f2628b248f714d7bbd6a536553bc3782602c68ca1b129017985dd70cc3515278
)
Fetch3rdParty_Package
(
azure-storage-cpp 7.0.0 https://github.com/Azure/azure-storage-cpp/archive/v7.0.0.tar.gz SHA256=2129511dcf40383de5ac643abf68cad4907b5cdbfe471c75ba264a83e3078dc7
)
if
(
BUILD_ZLIB
)
Fetch3rdParty_Package
(
zlib 1.2.11 http://zlib.net/zlib-1.2.11.tar.gz SHA256=c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1
)
endif
()
endfunction
()
CMakeLists.txt
View file @
5a4516c3
...
...
@@ -65,7 +65,7 @@ endif()
option
(
BUILD_ZLIB
"Build zlib"
${
DEFAULT_BUILD_ZLIB
}
)
include
(
CMake/Fetch3rdParty.cmake
)
include
(
CMake/Fetch3rdParty
InBuild
.cmake
)
Fetch3rdParty
()
include
(
CMake/Build3rdParty.cmake
)
...
...
README.md
View file @
5a4516c3
...
...
@@ -46,6 +46,15 @@ To generate a Visual Studio solution make a build directory in the OpenVDS folde
OpenVDS also supports using the cmake integration in Visual Studio. Open Visual Studio and use the "Open a local folder" to open the OpenVDS folder.
This works with default settings with Visual Studio 2019, but there are some
limitations using Visual Studio 2017. Before opening the project for the first
time in Visual Studio 2017 do the following commands in the root OpenVDS project
folder:
`$ git checkout 0d7825df9c981f624b6e1197a1b90c74ddae6aa9 -- CMakeSettings.json`
`$ cmake -P CMake/Fetch3rdParty.cmake`
Then start like other cmake projects in Visual Studio
#### Build options
-
BUILD_PYTHON (ON|OFF)
-
ENABLE_OPENMP (ON|OFF)
...
...
python/openvds/core.cpp
View file @
5a4516c3
...
...
@@ -26,6 +26,6 @@ PYBIND11_MODULE(core, m) {
py
::
class_
<
OpenVDS
::
VolumeDataAxisDescriptor
>
(
m
,
"Axis"
)
.
def
(
py
::
init
<>
())
.
def
(
py
::
init
<
int
,
const
char
*
,
const
char
*
,
float
,
float
>
())
.
def_property_readonly
(
"name"
,
&
OpenVDS
::
VolumeDataAxisDescriptor
::
g
etName
)
.
def_property_readonly
(
"name"
,
&
OpenVDS
::
VolumeDataAxisDescriptor
::
G
etName
)
;
}
src/IO/File.cpp
View file @
5a4516c3
...
...
@@ -22,7 +22,7 @@
namespace
OpenVDS
{
FileView
*
FileView
::
a
ddReference
(
FileView
*
pcFileView
)
FileView
*
FileView
::
A
ddReference
(
FileView
*
pcFileView
)
{
assert
(
pcFileView
);
...
...
@@ -32,7 +32,7 @@ FileView * FileView::addReference(FileView *pcFileView)
return
pcFileView
;
}
bool
FileView
::
r
emoveReference
(
FileView
*
pcFileView
)
bool
FileView
::
R
emoveReference
(
FileView
*
pcFileView
)
{
assert
(
pcFileView
);
assert
(
pcFileView
->
m_nReferenceCount
>
0
);
...
...
@@ -55,29 +55,29 @@ File::File()
File
::~
File
()
{
if
(
i
sOpen
())
if
(
I
sOpen
())
{
c
lose
();
C
lose
();
}
}
bool
File
::
i
sWriteable
()
const
bool
File
::
I
sWriteable
()
const
{
return
_isWriteable
;
}
bool
File
::
i
sOpen
()
const
bool
File
::
I
sOpen
()
const
{
assert
(
!!
_pxPlatformHandle
==
!
_cFileName
.
empty
());
return
_pxPlatformHandle
;
}
std
::
string
File
::
f
ileName
()
const
std
::
string
File
::
F
ileName
()
const
{
return
_cFileName
;
}
void
*
File
::
h
andle
()
const
void
*
File
::
H
andle
()
const
{
return
_pxPlatformHandle
;
}
...
...
src/IO/File.h
View file @
5a4516c3
...
...
@@ -56,36 +56,36 @@ public:
class
SystemFileMappingObject
{
public:
static
bool
o
pen
(
SystemFileMappingObject
**
ppcFileMappingObject
,
File
&
file
,
IOError
&
error
);
static
void
c
lose
(
SystemFileMappingObject
**
pcFileMappingObject
);
static
bool
O
pen
(
SystemFileMappingObject
**
ppcFileMappingObject
,
File
&
file
,
IOError
&
error
);
static
void
C
lose
(
SystemFileMappingObject
**
pcFileMappingObject
);
};
OPENVDS_EXPORT
const
void
*
p
ointer
()
const
const
void
*
P
ointer
()
const
{
return
m_pData
;
}
OPENVDS_EXPORT
int64_t
p
os
()
const
int64_t
P
os
()
const
{
return
m_nPos
;
}
OPENVDS_EXPORT
int64_t
s
ize
()
const
int64_t
S
ize
()
const
{
return
m_nSize
;
}
OPENVDS_EXPORT
virtual
bool
p
refetch
(
const
void
*
pData
,
int64_t
nSize
,
IOError
&
error
)
const
=
0
;
virtual
bool
P
refetch
(
const
void
*
pData
,
int64_t
nSize
,
IOError
&
error
)
const
=
0
;
OPENVDS_EXPORT
static
FileView
*
a
ddReference
(
FileView
*
pcFileView
);
static
FileView
*
A
ddReference
(
FileView
*
pcFileView
);
OPENVDS_EXPORT
static
bool
r
emoveReference
(
FileView
*
pcFileView
);
static
bool
R
emoveReference
(
FileView
*
pcFileView
);
};
// This class is thread-safe except for the following methods:
...
...
@@ -97,23 +97,23 @@ public:
OPENVDS_EXPORT
File
();
OPENVDS_EXPORT
~
File
();
OPENVDS_EXPORT
static
bool
e
xists
(
const
std
::
string
&
filename
);
OPENVDS_EXPORT
bool
o
pen
(
const
std
::
string
&
filename
,
bool
isCreate
,
bool
isDestroyExisting
,
bool
isWriteAccess
,
IOError
&
error
);
OPENVDS_EXPORT
void
c
lose
();
OPENVDS_EXPORT
static
bool
E
xists
(
const
std
::
string
&
filename
);
OPENVDS_EXPORT
bool
O
pen
(
const
std
::
string
&
filename
,
bool
isCreate
,
bool
isDestroyExisting
,
bool
isWriteAccess
,
IOError
&
error
);
OPENVDS_EXPORT
void
C
lose
();
OPENVDS_EXPORT
int64_t
s
ize
(
IOError
&
error
)
const
;
OPENVDS_EXPORT
int64_t
S
ize
(
IOError
&
error
)
const
;
OPENVDS_EXPORT
bool
r
ead
(
void
*
pxData
,
int64_t
nOffset
,
int32_t
nLength
,
IOError
&
error
)
const
;
OPENVDS_EXPORT
bool
w
rite
(
const
void
*
pxData
,
int64_t
nOffset
,
int32_t
nLength
,
IOError
&
error
);
OPENVDS_EXPORT
bool
R
ead
(
void
*
pxData
,
int64_t
nOffset
,
int32_t
nLength
,
IOError
&
error
)
const
;
OPENVDS_EXPORT
bool
W
rite
(
const
void
*
pxData
,
int64_t
nOffset
,
int32_t
nLength
,
IOError
&
error
);
OPENVDS_EXPORT
bool
f
lush
();
OPENVDS_EXPORT
bool
i
sWriteable
()
const
;
OPENVDS_EXPORT
bool
i
sOpen
()
const
;
OPENVDS_EXPORT
std
::
string
f
ileName
()
const
;
OPENVDS_EXPORT
bool
F
lush
();
OPENVDS_EXPORT
bool
I
sWriteable
()
const
;
OPENVDS_EXPORT
bool
I
sOpen
()
const
;
OPENVDS_EXPORT
std
::
string
F
ileName
()
const
;
OPENVDS_EXPORT
FileView
*
c
reateFileView
(
int64_t
iPos
,
int64_t
nSize
,
bool
isPopulate
,
IOError
&
error
);
OPENVDS_EXPORT
FileView
*
C
reateFileView
(
int64_t
iPos
,
int64_t
nSize
,
bool
isPopulate
,
IOError
&
error
);
OPENVDS_EXPORT
void
*
h
andle
()
const
;
OPENVDS_EXPORT
void
*
H
andle
()
const
;
private:
void
*
_pxPlatformHandle
;
bool
_isWriteable
;
...
...
src/IO/IOManager.cpp
View file @
5a4516c3
...
...
@@ -31,21 +31,21 @@ Request::~Request()
TransferDownloadHandler
::~
TransferDownloadHandler
()
{
}
void
TransferDownloadHandler
::
h
andleMetadata
(
const
std
::
string
&
key
,
const
std
::
string
&
header
)
void
TransferDownloadHandler
::
H
andleMetadata
(
const
std
::
string
&
key
,
const
std
::
string
&
header
)
{
}
IOManager
::~
IOManager
()
{}
IOManager
*
IOManager
::
c
reateIOManager
(
const
OpenOptions
&
options
,
Error
&
error
)
IOManager
*
IOManager
::
C
reateIOManager
(
const
OpenOptions
&
options
,
Error
&
error
)
{
switch
(
options
.
connectionType
)
{
case
OpenOptions
::
AWS
:
return
new
IOManagerAWS
(
static_cast
<
const
AWSOpenOptions
&>
(
options
),
error
);
default:
error
.
c
ode
=
-
1
;
error
.
s
tring
=
"Unknwon type for OpenOptions"
;
error
.
C
ode
=
-
1
;
error
.
S
tring
=
"Unknwon type for OpenOptions"
;
return
nullptr
;
}
}
...
...
src/IO/IOManager.h
View file @
5a4516c3
...
...
@@ -30,9 +30,9 @@ namespace OpenVDS
{
public:
virtual
~
TransferDownloadHandler
();
virtual
void
h
andleMetadata
(
const
std
::
string
&
key
,
const
std
::
string
&
header
);
virtual
void
h
andleData
(
std
::
vector
<
uint8_t
>
&&
data
)
=
0
;
virtual
void
c
ompleted
(
const
Request
&
request
,
const
Error
&
error
)
=
0
;
virtual
void
H
andleMetadata
(
const
std
::
string
&
key
,
const
std
::
string
&
header
);
virtual
void
H
andleData
(
std
::
vector
<
uint8_t
>
&&
data
)
=
0
;
virtual
void
C
ompleted
(
const
Request
&
request
,
const
Error
&
error
)
=
0
;
};
class
Request
...
...
@@ -40,11 +40,11 @@ namespace OpenVDS
public:
Request
(
const
std
::
string
&
objectName
);
virtual
~
Request
();
virtual
void
w
aitForFinish
()
=
0
;
virtual
bool
i
sDone
()
const
=
0
;
virtual
bool
i
sSuccess
(
Error
&
error
)
const
=
0
;
virtual
void
c
ancel
()
=
0
;
const
std
::
string
&
g
etObjectName
()
const
{
return
m_objectName
;
}
virtual
void
W
aitForFinish
()
=
0
;
virtual
bool
I
sDone
()
const
=
0
;
virtual
bool
I
sSuccess
(
Error
&
error
)
const
=
0
;
virtual
void
C
ancel
()
=
0
;
const
std
::
string
&
G
etObjectName
()
const
{
return
m_objectName
;
}
private:
std
::
string
m_objectName
;
...
...
@@ -60,19 +60,19 @@ namespace OpenVDS
{
public:
virtual
~
IOManager
();
virtual
std
::
shared_ptr
<
Request
>
d
ownload
(
const
std
::
string
objectName
,
std
::
shared_ptr
<
TransferDownloadHandler
>
handler
,
const
IORange
&
range
=
IORange
())
=
0
;
virtual
std
::
shared_ptr
<
Request
>
u
pload
(
const
std
::
string
objectName
,
const
std
::
string
&
contentDispostionFilename
,
const
std
::
string
&
contentType
,
const
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>
&
metadataHeader
,
std
::
shared_ptr
<
std
::
vector
<
uint8_t
>>
data
,
std
::
function
<
void
(
const
Request
&
request
,
const
Error
&
error
)
>
completedCallback
=
nullptr
)
=
0
;
std
::
shared_ptr
<
Request
>
u
ploadBinary
(
const
std
::
string
objectName
,
const
std
::
string
&
contentDispositionFilename
,
const
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>
&
metadataHeader
,
std
::
shared_ptr
<
std
::
vector
<
uint8_t
>>
data
,
std
::
function
<
void
(
const
Request
&
request
,
const
Error
&
error
)
>
completedCallback
=
nullptr
)
virtual
std
::
shared_ptr
<
Request
>
D
ownload
(
const
std
::
string
objectName
,
std
::
shared_ptr
<
TransferDownloadHandler
>
handler
,
const
IORange
&
range
=
IORange
())
=
0
;
virtual
std
::
shared_ptr
<
Request
>
U
pload
(
const
std
::
string
objectName
,
const
std
::
string
&
contentDispostionFilename
,
const
std
::
string
&
contentType
,
const
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>
&
metadataHeader
,
std
::
shared_ptr
<
std
::
vector
<
uint8_t
>>
data
,
std
::
function
<
void
(
const
Request
&
request
,
const
Error
&
error
)
>
completedCallback
=
nullptr
)
=
0
;
std
::
shared_ptr
<
Request
>
U
ploadBinary
(
const
std
::
string
objectName
,
const
std
::
string
&
contentDispositionFilename
,
const
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>
&
metadataHeader
,
std
::
shared_ptr
<
std
::
vector
<
uint8_t
>>
data
,
std
::
function
<
void
(
const
Request
&
request
,
const
Error
&
error
)
>
completedCallback
=
nullptr
)
{
return
u
pload
(
objectName
,
contentDispositionFilename
,
"application/octet-stream"
,
metadataHeader
,
data
,
completedCallback
);
return
U
pload
(
objectName
,
contentDispositionFilename
,
"application/octet-stream"
,
metadataHeader
,
data
,
completedCallback
);
}
std
::
shared_ptr
<
Request
>
u
ploadJson
(
const
std
::
string
objectName
,
std
::
shared_ptr
<
std
::
vector
<
uint8_t
>>
data
,
std
::
function
<
void
(
const
Request
&
request
,
const
Error
&
error
)
>
completedCallback
=
nullptr
)
std
::
shared_ptr
<
Request
>
U
ploadJson
(
const
std
::
string
objectName
,
std
::
shared_ptr
<
std
::
vector
<
uint8_t
>>
data
,
std
::
function
<
void
(
const
Request
&
request
,
const
Error
&
error
)
>
completedCallback
=
nullptr
)
{
return
u
pload
(
objectName
,
""
,
"application/json"
,
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>
(),
data
,
completedCallback
);
return
U
pload
(
objectName
,
""
,
"application/json"
,
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>
(),
data
,
completedCallback
);
}
static
IOManager
*
c
reateIOManager
(
const
OpenOptions
&
options
,
Error
&
error
);
static
IOManager
*
C
reateIOManager
(
const
OpenOptions
&
options
,
Error
&
error
);
};
}
...
...
src/IO/IOManagerAWS.cpp
View file @
5a4516c3
...
...
@@ -112,7 +112,7 @@ namespace OpenVDS
Aws
::
S3
::
Model
::
GetObjectResult
result
=
const_cast
<
Aws
::
S3
::
Model
::
GetObjectOutcome
&>
(
getObjectOutcome
).
GetResultWithOwnership
();
for
(
auto
it
:
result
.
GetMetadata
())
{
objReq
->
m_handler
->
h
andleMetadata
(
convertAwsString
(
it
.
first
),
convertAwsString
(
it
.
second
));
objReq
->
m_handler
->
H
andleMetadata
(
convertAwsString
(
it
.
first
),
convertAwsString
(
it
.
second
));
}
auto
&
retrieved_object
=
result
.
GetBody
();
auto
content_length
=
result
.
GetContentLength
();
...
...
@@ -122,7 +122,7 @@ namespace OpenVDS
{
data
.
resize
(
content_length
);
retrieved_object
.
read
((
char
*
)
&
data
[
0
],
content_length
);
objReq
->
m_handler
->
h
andleData
(
std
::
move
(
data
));
objReq
->
m_handler
->
H
andleData
(
std
::
move
(
data
));
}
lock
.
lock
();
}
...
...
@@ -130,14 +130,14 @@ namespace OpenVDS
{
lock
.
lock
();
auto
s3error
=
getObjectOutcome
.
GetError
();
objReq
->
m_error
.
c
ode
=
int
(
s3error
.
GetResponseCode
());
objReq
->
m_error
.
s
tring
=
(
s3error
.
GetExceptionName
()
+
" : "
+
s3error
.
GetMessage
()).
c_str
();
objReq
->
m_error
.
C
ode
=
int
(
s3error
.
GetResponseCode
());
objReq
->
m_error
.
S
tring
=
(
s3error
.
GetExceptionName
()
+
" : "
+
s3error
.
GetMessage
()).
c_str
();
}
objReq
->
m_done
=
true
;
objReq
->
m_waitForFinish
.
notify_all
();
lock
.
unlock
();
objReq
->
m_handler
->
c
ompleted
(
*
objReq
,
objReq
->
m_error
);
objReq
->
m_handler
->
C
ompleted
(
*
objReq
,
objReq
->
m_error
);
}
DownloadRequestAWS
::
DownloadRequestAWS
(
const
std
::
string
&
id
,
const
std
::
shared_ptr
<
TransferDownloadHandler
>&
handler
)
...
...
@@ -150,14 +150,14 @@ namespace OpenVDS
DownloadRequestAWS
::~
DownloadRequestAWS
()
{
DownloadRequestAWS
::
c
ancel
();
DownloadRequestAWS
::
C
ancel
();
}
void
DownloadRequestAWS
::
run
(
Aws
::
S3
::
S3Client
&
client
,
const
std
::
string
&
bucket
,
const
IORange
&
range
,
std
::
weak_ptr
<
DownloadRequestAWS
>
downloadRequest
)
{
Aws
::
S3
::
Model
::
GetObjectRequest
object_request
;
object_request
.
SetBucket
(
convertStdString
(
bucket
));
object_request
.
SetKey
(
convertStdString
(
g
etObjectName
()));
object_request
.
SetKey
(
convertStdString
(
G
etObjectName
()));
if
(
range
.
end
)
{
object_request
.
SetRange
(
convertStdString
(
fmt
::
format
(
"bytes={}-{}"
,
range
.
start
,
range
.
end
)));
...
...
@@ -169,31 +169,31 @@ namespace OpenVDS
client
.
GetObjectAsync
(
object_request
,
bounded_callback
);
}
void
DownloadRequestAWS
::
w
aitForFinish
()
void
DownloadRequestAWS
::
W
aitForFinish
()
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_mutex
);
m_waitForFinish
.
wait
(
lock
,
[
this
]{
return
m_done
;
});
}
bool
DownloadRequestAWS
::
i
sDone
()
const
bool
DownloadRequestAWS
::
I
sDone
()
const
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_mutex
);
return
m_done
;
}
bool
DownloadRequestAWS
::
i
sSuccess
(
Error
&
error
)
const
bool
DownloadRequestAWS
::
I
sSuccess
(
Error
&
error
)
const
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_mutex
);
if
(
!
m_done
)
{
error
.
c
ode
=
-
1
;
error
.
s
tring
=
"Download not done."
;
error
.
C
ode
=
-
1
;
error
.
S
tring
=
"Download not done."
;
return
false
;
}
error
=
m_error
;
return
m_error
.
c
ode
==
0
;
return
m_error
.
C
ode
==
0
;
}
void
DownloadRequestAWS
::
c
ancel
()
void
DownloadRequestAWS
::
C
ancel
()
{
m_cancelled
=
true
;
}
...
...
@@ -208,8 +208,8 @@ namespace OpenVDS
if
(
!
outcome
.
IsSuccess
())
{
auto
s3error
=
outcome
.
GetError
();
objReq
->
m_error
.
c
ode
=
int
(
s3error
.
GetResponseCode
());
objReq
->
m_error
.
s
tring
=
(
s3error
.
GetExceptionName
()
+
" : "
+
s3error
.
GetMessage
()).
c_str
();
objReq
->
m_error
.
C
ode
=
int
(
s3error
.
GetResponseCode
());
objReq
->
m_error
.
S
tring
=
(
s3error
.
GetExceptionName
()
+
" : "
+
s3error
.
GetMessage
()).
c_str
();
}
objReq
->
m_done
=
true
;
...
...
@@ -234,7 +234,7 @@ namespace OpenVDS
Aws
::
S3
::
Model
::
PutObjectRequest
put
;
put
.
SetBucket
(
convertStdString
(
bucket
));
put
.
SetKey
(
convertStdString
(
g
etObjectName
()));
put
.
SetKey
(
convertStdString
(
G
etObjectName
()));
put
.
SetBody
(
m_stream
);
put
.
SetContentType
(
convertStdString
(
contentType
));
put
.
SetContentLength
(
data
->
size
());
...
...
@@ -250,42 +250,42 @@ namespace OpenVDS
}
void
UploadRequestAWS
::
w
aitForFinish
()
void
UploadRequestAWS
::
W
aitForFinish
()
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_mutex
);
m_waitForFinish
.
wait
(
lock
,
[
this
]{
return
this
->
m_done
;
});
}
bool
UploadRequestAWS
::
i
sDone
()
const
bool
UploadRequestAWS
::
I
sDone
()
const
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_mutex
);
return
m_done
;
}
bool
UploadRequestAWS
::
i
sSuccess
(
Error
&
error
)
const
bool
UploadRequestAWS
::
I
sSuccess
(
Error
&
error
)
const
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_mutex
);
if
(
!
m_done
)
{
error
.
c
ode
=
-
1
;
error
.
s
tring
=
"Download not done."
;
error
.
C
ode
=
-
1
;
error
.
S
tring
=
"Download not done."
;
return
false
;
}
error
=
m_error
;
return
m_error
.
c
ode
==
0
;
return
m_error
.
C
ode
==
0
;
}
void
UploadRequestAWS
::
c
ancel
()
void
UploadRequestAWS
::
C
ancel
()
{
m_cancelled
=
true
;
}
IOManagerAWS
::
IOManagerAWS
(
const
AWSOpenOptions
&
openOptions
,
Error
&
error
)
:
m_region
(
openOptions
.
r
egion
)
,
m_bucket
(
openOptions
.
b
ucket
)
,
m_objectId
(
openOptions
.
k
ey
)
:
m_region
(
openOptions
.
R
egion
)
,
m_bucket
(
openOptions
.
B
ucket
)
,
m_objectId
(
openOptions
.
K
ey
)
{
if
(
m_region
.
empty
()
||
m_bucket
.
empty
())
{
error
.
c
ode
=
-
1
;
error
.
s
tring
=
"AWS Config error. Empty bucket or region"
;
error
.
C
ode
=
-
1
;
error
.
S
tring
=
"AWS Config error. Empty bucket or region"
;
return
;
}
...
...
@@ -307,7 +307,7 @@ namespace OpenVDS
deinitizlieAWSSDK
();
}
std
::
shared_ptr
<
Request
>
IOManagerAWS
::
d
ownload
(
const
std
::
string
objectName
,
std
::
shared_ptr
<
TransferDownloadHandler
>
handler
,
const
IORange
&
range
)
std
::
shared_ptr
<
Request
>
IOManagerAWS
::
D
ownload
(
const
std
::
string
objectName
,
std
::
shared_ptr
<
TransferDownloadHandler
>
handler
,
const
IORange
&
range
)
{
std
::
string
id
=
objectName
.
empty
()
?
m_objectId
:
m_objectId
+
"/"
+
objectName
;
auto
ret
=
std
::
make_shared
<
DownloadRequestAWS
>
(
id
,
handler
);
...
...
@@ -315,7 +315,7 @@ namespace OpenVDS
return
ret
;
}
std
::
shared_ptr
<
Request
>
IOManagerAWS
::
u
pload
(
const
std
::
string
objectName
,
const
std
::
string
&
contentDispositionFilename
,
const
std
::
string
&
contentType
,
const
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>&
metadataHeader
,
std
::
shared_ptr
<
std
::
vector
<
uint8_t
>>
data
,
std
::
function
<
void
(
const
Request
&
request
,
const
Error
&
error
)
>
completedCallback
)
std
::
shared_ptr
<
Request
>
IOManagerAWS
::
U
pload
(
const
std
::
string
objectName
,
const
std
::
string
&
contentDispositionFilename
,
const
std
::
string
&
contentType
,
const
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>&
metadataHeader
,
std
::
shared_ptr
<
std
::
vector
<
uint8_t
>>
data
,
std
::
function
<
void
(
const
Request
&
request
,
const
Error
&
error
)
>
completedCallback
)
{
std
::
string
id
=
objectName
.
empty
()
?
m_objectId
:
m_objectId
+
"/"
+
objectName
;
auto
ret
=
std
::
make_shared
<
UploadRequestAWS
>
(
id
,
completedCallback
);
...
...
src/IO/IOManagerAWS.h
View file @
5a4516c3
...
...
@@ -39,10 +39,10 @@ namespace OpenVDS
void
run
(
Aws
::
S3
::
S3Client
&
client
,
const
std
::
string
&
bucket
,
const
IORange
&
range
,
std
::
weak_ptr
<
DownloadRequestAWS
>
request
);
void
w
aitForFinish
()
override
;
bool
i
sDone
()
const
override
;
bool
i
sSuccess
(
Error
&
error
)
const
override
;
void
c
ancel
()
override
;
void
W
aitForFinish
()
override
;
bool
I
sDone
()
const
override
;
bool
I
sSuccess
(
Error
&
error
)
const
override
;
void
C
ancel
()
override
;
std
::
shared_ptr
<
TransferDownloadHandler
>
m_handler
;
std
::
atomic_bool
m_cancelled
;
...
...
@@ -78,10 +78,10 @@ namespace OpenVDS
public:
UploadRequestAWS
(
const
std
::
string
&
id
,
std
::
function
<
void
(
const
Request
&
request
,
const
Error
&
error
)
>
completedCallback
);
void
run
(
Aws
::
S3
::
S3Client
&
client
,
const
std
::
string
&
bucket
,
const
std
::
string
&
contentDispostionFilename
,
const
std
::
string
&
contentType
,
const
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>&
metadataHeader
,
std
::
shared_ptr
<
std
::
vector
<
uint8_t
>>
data
,
std
::
weak_ptr
<
UploadRequestAWS
>
uploadRequest
);
void
w
aitForFinish
()
override
;
bool
i
sDone
()
const
override
;
bool
i
sSuccess
(
Error
&
error
)
const
override
;
void
c
ancel
()
override
;
void
W
aitForFinish
()
override
;
bool
I
sDone
()
const
override
;
bool
I
sSuccess
(
Error
&
error
)
const
override
;
void
C
ancel
()
override
;
std
::
function
<
void
(
const
Request
&
request
,
const
Error
&
error
)
>
m_completedCallback
;
std
::
shared_ptr
<
IOStream
>
m_stream
;
...
...
@@ -98,8 +98,8 @@ namespace OpenVDS
IOManagerAWS
(
const
AWSOpenOptions
&
openOptions
,
Error
&
error
);
~
IOManagerAWS
()
override
;
std
::
shared_ptr
<
Request
>
d
ownload
(
const
std
::
string
objectName
,
std
::
shared_ptr
<
TransferDownloadHandler
>
handler
,
const
IORange
&
range
=
IORange
())
override
;
std
::
shared_ptr
<
Request
>
u
pload
(
const
std
::
string
objectName
,
const
std
::
string
&
contentDispostionFilename
,
const
std
::
string
&
contentType
,
const
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>&
metadataHeader
,
std
::
shared_ptr
<
std
::
vector
<
uint8_t
>>
data
,
std
::
function
<
void
(
const
Request
&
request
,
const
Error
&
error
)
>
completedCallback
=
nullptr
)
override
;
std
::
shared_ptr
<
Request
>
D
ownload
(
const
std
::
string
objectName
,
std
::
shared_ptr
<
TransferDownloadHandler
>
handler
,
const
IORange
&
range
=
IORange
())
override
;
std
::
shared_ptr
<
Request
>
U
pload
(
const
std
::
string
objectName
,
const
std
::
string
&
contentDispostionFilename
,
const
std
::
string
&
contentType
,
const
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>&
metadataHeader
,
std
::
shared_ptr
<
std
::
vector
<
uint8_t
>>
data
,
std
::
function
<
void
(
const
Request
&
request
,
const
Error
&
error
)
>
completedCallback
=
nullptr
)
override
;
private:
std
::
string
m_region
;
std
::
string
m_bucket
;
...
...
src/IO/IOManagerAzure.cpp
View file @
5a4516c3
...
...
@@ -23,7 +23,7 @@
#include <fmt/format.h>
void
d
ownloadObject
()
void
D
ownloadObject
()
{
azure
::
storage
::
cloud_storage_account
storage_account
=
azure
::
storage
::
cloud_storage_account
::
parse
(
_XPLATSTR
(
"DefaultEndpointsProtocol=https;AccountName=myaccountname;AccountKey=myaccountkey"
));
azure
::
storage
::
cloud_blob_client
blob_client
=
storage_account
.
create_cloud_blob_client
();
...
...
src/IO/IOManagerAzure.h
View file @
5a4516c3
...
...
@@ -18,6 +18,6 @@
#ifndef IOMANAGERAZURE_H
#define IOMANAGERAZURE_H
void
d
ownloadObject
();
void
D
ownloadObject
();
#endif //IOMANAGERAZURE_H
src/IO/Linux_File.cpp
View file @
5a4516c3
...
...
@@ -35,32 +35,32 @@
namespace
OpenVDS
{
static
std
::
string
e
rror
_to_s
tring
(
int
error
)
static
std
::
string
E
rror
ToS
tring
(
int
error
)
{
return
std
::
string
(
strerror
(
error
));
}
static
void
s
et
_io_e
rror
(
int
error
,
IOError
&
io_error
)