forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add feature and fix bugs (apache#148)
Add new features: 1. plugins of Ambari and k8s deploy 2. specified config 'priority_network' to solve some ip problems Fix bugs: fix bugs that rebalance does not work in some case. fix count(*) from union stmt bug fix some union stmt bugs fix bugs when try to schema change a clone replica
- Loading branch information
1 parent
8909f53
commit 585c21f
Showing
68 changed files
with
2,798 additions
and
979 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// Copyright (c) 2017, Baidu.com, Inc. All Rights Reserved | ||
|
||
// 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. | ||
|
||
#include "util/cidr.h" | ||
|
||
#include <arpa/inet.h> | ||
|
||
#include <boost/algorithm/string.hpp> | ||
|
||
#include "common/logging.h" | ||
|
||
namespace palo { | ||
|
||
CIDR::CIDR() : _address(0), _netmask(0xffffffff) { | ||
} | ||
|
||
void CIDR::reset() { | ||
_address = 0; | ||
_netmask = 0xffffffff; | ||
} | ||
|
||
bool CIDR::reset(const std::string& cidr_str) { | ||
reset(); | ||
|
||
// check if have mask | ||
std::string cidr_format_str = cidr_str; | ||
int32_t have_mask = cidr_str.find("/"); | ||
if (have_mask == -1) { | ||
cidr_format_str.assign(cidr_str + "/32"); | ||
} | ||
VLOG(2) << "cidr format str: " << cidr_format_str; | ||
|
||
std::vector<std::string> cidr_items; | ||
boost::split(cidr_items, cidr_format_str, boost::is_any_of("/")); | ||
if (cidr_items.size() != 2) { | ||
LOG(ERROR) << "wrong CIDR format. network=" << cidr_str; | ||
return false; | ||
} | ||
|
||
if (cidr_items[1].empty()) { | ||
LOG(ERROR) << "wrong CIDR mask format. network=" << cidr_str; | ||
return false; | ||
} | ||
|
||
char* endptr = nullptr; | ||
int32_t mask_length = strtol(cidr_items[1].c_str(), &endptr, 10); | ||
if (errno != 0 || mask_length <= 0 || mask_length > 32) { | ||
LOG(ERROR) << "wrong CIDR mask format. network=" << cidr_str; | ||
return false; | ||
} | ||
|
||
uint32_t address = 0; | ||
if (!ip_to_int(cidr_items[0], &address)) { | ||
LOG(ERROR) << "wrong CIDR IP value. network=" << cidr_str; | ||
return false; | ||
} | ||
_address = address; | ||
|
||
_netmask = 0xffffffff; | ||
_netmask = _netmask << (32 - mask_length); | ||
return true; | ||
} | ||
|
||
bool CIDR::ip_to_int(const std::string& ip_str, uint32_t* value) { | ||
struct in_addr addr; | ||
int flag = inet_aton(ip_str.c_str(), &addr); | ||
if (flag == 0) { | ||
return false; | ||
} | ||
*value = ntohl(addr.s_addr); | ||
return true; | ||
} | ||
|
||
bool CIDR::contains(uint32_t ip_int) { | ||
if ((_address & _netmask) == (ip_int & _netmask)) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
bool CIDR::contains(const std::string& ip) { | ||
uint32_t ip_int = 0; | ||
if (!ip_to_int(ip, &ip_int)) { | ||
return false; | ||
} | ||
|
||
return contains(ip_int); | ||
} | ||
|
||
} // end namespace palo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) 2017, Baidu.com, Inc. All Rights Reserved | ||
|
||
// 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. | ||
|
||
#ifndef BDG_PALO_BE_SRC_COMMON_UTIL_CIDR_H | ||
#define BDG_PALO_BE_SRC_COMMON_UTIL_CIDR_H | ||
|
||
#include <string> | ||
|
||
namespace palo { | ||
|
||
// Classless Inter-Domain Routing | ||
class CIDR { | ||
public: | ||
CIDR(); | ||
void reset(); | ||
bool reset(const std::string& cidr_str); | ||
bool contains(const std::string& ip); | ||
|
||
private: | ||
bool ip_to_int(const std::string& ip_str, uint32_t* value); | ||
bool contains(uint32_t ip_int); | ||
|
||
uint32_t _address; | ||
uint32_t _netmask; | ||
}; | ||
|
||
} // end namespace palo | ||
|
||
#endif // BDG_PALO_BE_SRC_COMMON_UTIL_CIDR_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.