mirror of https://gitee.com/bigwinds/arangodb
endpoint unifiedForm replaces localhost with 127.0.0.1
This commit is contained in:
parent
04912c8907
commit
5858caabbe
|
@ -1185,9 +1185,10 @@ void AgencyComm::updateEndpoints(arangodb::velocypack::Slice const& current) {
|
|||
|
||||
auto stored = AgencyCommManager::MANAGER->endpoints();
|
||||
for (const auto& i : VPackObjectIterator(current)) {
|
||||
auto const endpoint = i.value.copyString();
|
||||
if (std::find(stored.begin(), stored.end(), endpoint) != stored.end()) {
|
||||
LOG(INFO) << "Adding endpoint " << endpoint << " to agent pool";
|
||||
auto const endpoint = Endpoint::unifiedForm(i.value.copyString());
|
||||
if (std::find(stored.begin(), stored.end(), endpoint) == stored.end()) {
|
||||
LOG_TOPIC(INFO, Logger::CLUSTER) << "Adding endpoint "
|
||||
<< endpoint << " to agent pool";
|
||||
AgencyCommManager::MANAGER->addEndpoint(endpoint);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -208,7 +208,6 @@ void HeartbeatThread::runDBServer() {
|
|||
VPackSlice agentPool =
|
||||
result.slice()[0].get(
|
||||
std::vector<std::string>({".agency","pool"}));
|
||||
|
||||
if (agentPool.isObject()) {
|
||||
_agency.updateEndpoints(agentPool);
|
||||
} else {
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
#include "Endpoint/EndpointUnixDomain.h"
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace arangodb;
|
||||
using namespace arangodb::basics;
|
||||
|
||||
|
@ -76,8 +78,11 @@ std::string Endpoint::unifiedForm(std::string const& specification) {
|
|||
|
||||
TransportType protocol = TransportType::HTTP;
|
||||
|
||||
std::string prefix = "http+";
|
||||
std::string copy = StringUtils::tolower(specification);
|
||||
std::string prefix("http+");
|
||||
std::string copy(StringUtils::tolower(specification));
|
||||
std::string const localName("localhost");
|
||||
std::string const localIP("127.0.0.1");
|
||||
|
||||
StringUtils::trimInPlace(copy);
|
||||
|
||||
if (specification.back() == '/') {
|
||||
|
@ -149,16 +154,20 @@ std::string Endpoint::unifiedForm(std::string const& specification) {
|
|||
return illegal;
|
||||
}
|
||||
|
||||
// Replace localhost with 127.0.0.1
|
||||
found = copy.find(localName);
|
||||
if (found != std::string::npos) {
|
||||
copy.replace(found, localName.length(), localIP);
|
||||
}
|
||||
|
||||
// ipv4
|
||||
found = temp.find(':');
|
||||
|
||||
found = temp.find(':');
|
||||
if (found != std::string::npos && found + 1 < temp.size()) {
|
||||
// hostname and port
|
||||
return prefix + copy;
|
||||
}
|
||||
|
||||
// hostname only
|
||||
|
||||
if (protocol == TransportType::HTTP) {
|
||||
return prefix + copy + ":" +
|
||||
StringUtils::itoa(EndpointIp::_defaultPortHttp);
|
||||
|
|
|
@ -222,7 +222,7 @@ start() {
|
|||
${BUILD}/bin/arangod \
|
||||
-c none \
|
||||
--database.directory cluster/data$PORT \
|
||||
$AGENCY_ENDPOINTS \
|
||||
--cluster.agency-endpoint $TRANSPORT://127.0.0.1:$BASE \
|
||||
--cluster.my-address $TRANSPORT://127.0.0.1:$PORT \
|
||||
--server.endpoint $TRANSPORT://0.0.0.0:$PORT \
|
||||
--cluster.my-role $ROLE \
|
||||
|
@ -253,7 +253,7 @@ startTerminal() {
|
|||
$XTERM $XTERMOPTIONS -e ${BUILD}/bin/arangod \
|
||||
-c none \
|
||||
--database.directory cluster/data$PORT \
|
||||
$AGENCY_ENDPOINTS \
|
||||
--cluster.agency-endpoint $TRANSPORT://127.0.0.1:$BASE \
|
||||
--cluster.my-address $TRANSPORT://127.0.0.1:$PORT \
|
||||
--server.endpoint $TRANSPORT://0.0.0.0:$PORT \
|
||||
--cluster.my-role $ROLE \
|
||||
|
@ -282,7 +282,7 @@ startDebugger() {
|
|||
${BUILD}/bin/arangod \
|
||||
-c none \
|
||||
--database.directory cluster/data$PORT \
|
||||
$AGENCY_ENDPOINTS \
|
||||
--cluster.agency-endpoint $TRANSPORT://127.0.0.1:$BASE \
|
||||
--cluster.my-address $TRANSPORT://127.0.0.1:$PORT \
|
||||
--server.endpoint $TRANSPORT://0.0.0.0:$PORT \
|
||||
--cluster.my-role $ROLE \
|
||||
|
@ -311,7 +311,7 @@ startRR() {
|
|||
$XTERM $XTERMOPTIONS -e rr ${BUILD}/bin/arangod \
|
||||
-c none \
|
||||
--database.directory cluster/data$PORT \
|
||||
$AGENCY_ENDPOINTS \
|
||||
--cluster.agency-endpoint $TRANSPORT://127.0.0.1:$BASE \
|
||||
--cluster.my-address $TRANSPORT://127.0.0.1:$PORT \
|
||||
--server.endpoint $TRANSPORT://0.0.0.0:$PORT \
|
||||
--cluster.my-role $ROLE \
|
||||
|
@ -396,7 +396,7 @@ if [ "$SECONDARIES" == "1" ] ; then
|
|||
${BUILD}/bin/arangod \
|
||||
-c none \
|
||||
--database.directory cluster/data$PORT \
|
||||
$AGENCY_ENDPOINTS \
|
||||
--cluster.agency-endpoint $TRANSPORT://127.0.0.1:$BASE \
|
||||
--cluster.my-address $TRANSPORT://127.0.0.1:$PORT \
|
||||
--server.endpoint $TRANSPORT://0.0.0.0:$PORT \
|
||||
--cluster.my-id $CLUSTER_ID \
|
||||
|
|
Loading…
Reference in New Issue