* [doris-1008] support backup and restore directly to cloud storage via aws s3 protocol * Internal][S3DirectAccess] Support backup,restore,load,export directlyconnect to s3 1. Support load and export data from/to s3 directly. 2. Add a config to auto convert broker access to s3 acces when available Change-Id: Iac96d4b3670776708bc96a119ff491db8cb4cde7 (cherry picked from commit 2f03832ca52221cc7436069b96c45c48c4bc7201) * [Internal][S3DirectAccess] File path glob compatible with broker Change-Id: Ie55e07a547aa22c6fa8d432ca926216c10384e68 (cherry picked from commit d4fb25544c0dc06d23e1ada571ec3f8edd4ba56f) * [internal] [doris-1008] fix log4j class not found Change-Id: I468176aca0d821383c74ee658d461aba9e7d5be3 (cherry picked from commit 029adaa9d6ded8503acbd6644c1519456f3db232) * add poms Co-authored-by: yangzhengguo01 <yangzhengguo01@baidu.com>
68 lines
2.4 KiB
C++
68 lines
2.4 KiB
C++
// Licensed to the Apache Software Foundation (ASF) under one
|
|
// or more contributor license agreements. See the NOTICE file
|
|
// distributed with this work for additional information
|
|
// regarding copyright ownership. The ASF licenses this file
|
|
// to you 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.
|
|
|
|
#include "util/s3_uri.h"
|
|
|
|
#include <vector>
|
|
|
|
#include "gutil/strings/split.h"
|
|
#include "gutil/strings/strip.h"
|
|
#include "util/logging.h"
|
|
|
|
namespace doris {
|
|
|
|
const std::string S3URI::_SCHEME_DELIM = "://";
|
|
const std::string S3URI::_PATH_DELIM = "/";
|
|
const std::string S3URI::_QUERY_DELIM = "?";
|
|
const std::string S3URI::_FRAGMENT_DELIM = "#";
|
|
const StringCaseSet S3URI::_VALID_SCHEMES = {"http", "https", "s3", "s3a", "s3n", "bos"};
|
|
bool S3URI::parse() {
|
|
if (_location.empty()) {
|
|
return false;
|
|
}
|
|
std::vector<std::string> scheme_split = strings::Split(_location, _SCHEME_DELIM);
|
|
if (scheme_split.size() != 2) {
|
|
LOG(WARNING) << "Invalid S3 URI: " << _location;
|
|
return false;
|
|
}
|
|
_scheme = scheme_split[0];
|
|
if (_VALID_SCHEMES.find(_scheme) == _VALID_SCHEMES.end()) {
|
|
LOG(WARNING) << "Invalid scheme: " << _scheme;
|
|
return false;
|
|
}
|
|
std::vector<std::string> authority_split =
|
|
strings::Split(scheme_split[1], strings::delimiter::Limit(_PATH_DELIM, 1));
|
|
if (authority_split.size() != 2) {
|
|
LOG(WARNING) << "Invalid S3 URI: " << _location;
|
|
return false;
|
|
}
|
|
_key = authority_split[1];
|
|
StripWhiteSpace(&_key);
|
|
if (_key.empty()) {
|
|
LOG(WARNING) << "Invalid S3 key: " << _location;
|
|
return false;
|
|
}
|
|
_bucket = authority_split[0];
|
|
// Strip query and fragment if they exist
|
|
std::vector<std::string> _query_split = strings::Split(_key, _QUERY_DELIM);
|
|
std::vector<std::string> _fragment_split = strings::Split(_query_split[0], _FRAGMENT_DELIM);
|
|
_key = _fragment_split[0];
|
|
return true;
|
|
}
|
|
|
|
} // end namespace doris
|