1
0
Fork 0

Bug fix/allow tcp connection to finish (#7635)

This commit is contained in:
Wilfried Goesgens 2018-12-10 10:38:34 +01:00 committed by Jan
parent d22997b01c
commit c0f9e8125a
20 changed files with 129 additions and 7 deletions

View File

@ -54,6 +54,7 @@ ClusterFeature::ClusterFeature(application_features::ApplicationServer& server)
_requestedRole(ServerState::RoleEnum::ROLE_UNDEFINED) {
setOptional(true);
startsAfter("DatabasePhase");
startsAfter("CommunicationPhase");
}
ClusterFeature::~ClusterFeature() {

View File

@ -29,6 +29,7 @@
#include "Actions/ActionFeature.h"
#include "Agency/AgencyFeature.h"
#include "ApplicationFeatures/AgencyPhase.h"
#include "ApplicationFeatures/CommunicationPhase.h"
#include "ApplicationFeatures/AQLPhase.h"
#include "ApplicationFeatures/BasicPhase.h"
#include "ApplicationFeatures/ClusterPhase.h"
@ -152,6 +153,7 @@ static int runServer(int argc, char** argv, ArangoGlobalContext &context) {
// Adding the Phases
server.addFeature(new application_features::AgencyFeaturePhase(server));
server.addFeature(new application_features::CommunicationFeaturePhase(server));
server.addFeature(new application_features::AQLFeaturePhase(server));
server.addFeature(new application_features::BasicFeaturePhase(server, false));
server.addFeature(new application_features::ClusterFeaturePhase(server));

View File

@ -25,6 +25,7 @@
#include "Basics/directories.h"
#include "ApplicationFeatures/BasicPhase.h"
#include "ApplicationFeatures/CommunicationPhase.h"
#include "ApplicationFeatures/ConfigFeature.h"
#include "ApplicationFeatures/GreetingsPhase.h"
#include "ApplicationFeatures/ShutdownFeature.h"
@ -55,6 +56,7 @@ int main(int argc, char* argv[]) {
ApplicationServer server(options, BIN_DIRECTORY);
int ret;
server.addFeature(new application_features::CommunicationFeaturePhase(server));
server.addFeature(new application_features::BasicFeaturePhase(server, true));
server.addFeature(new application_features::GreetingsFeaturePhase(server, true));

View File

@ -25,6 +25,7 @@
#include "Basics/directories.h"
#include "ApplicationFeatures/BasicPhase.h"
#include "ApplicationFeatures/CommunicationPhase.h"
#include "ApplicationFeatures/ConfigFeature.h"
#include "ApplicationFeatures/GreetingsPhase.h"
#include "ApplicationFeatures/ShellColorsFeature.h"
@ -59,6 +60,7 @@ int main(int argc, char* argv[]) {
ApplicationServer server(options, BIN_DIRECTORY);
int ret;
server.addFeature(new application_features::CommunicationFeaturePhase(server));
server.addFeature(new application_features::BasicFeaturePhase(server, true));
server.addFeature(new application_features::GreetingsFeaturePhase(server, true));

View File

@ -25,6 +25,7 @@
#include "Basics/directories.h"
#include "ApplicationFeatures/BasicPhase.h"
#include "ApplicationFeatures/CommunicationPhase.h"
#include "ApplicationFeatures/ConfigFeature.h"
#include "ApplicationFeatures/GreetingsPhase.h"
#include "ApplicationFeatures/ShellColorsFeature.h"
@ -55,6 +56,7 @@ int main(int argc, char* argv[]) {
int ret;
server.addFeature(new application_features::BasicFeaturePhase(server, true));
server.addFeature(new application_features::CommunicationFeaturePhase(server));
server.addFeature(new application_features::GreetingsFeaturePhase(server, true));
server.addFeature(new ClientFeature(server, false));
server.addFeature(new ConfigFeature(server, "arangoexport"));

View File

@ -25,6 +25,7 @@
#include "Basics/directories.h"
#include "ApplicationFeatures/BasicPhase.h"
#include "ApplicationFeatures/CommunicationPhase.h"
#include "ApplicationFeatures/ConfigFeature.h"
#include "ApplicationFeatures/GreetingsPhase.h"
#include "ApplicationFeatures/ShellColorsFeature.h"
@ -55,6 +56,7 @@ int main(int argc, char* argv[]) {
int ret;
server.addFeature(new application_features::BasicFeaturePhase(server, true));
server.addFeature(new application_features::CommunicationFeaturePhase(server));
server.addFeature(new application_features::GreetingsFeaturePhase(server, true));
server.addFeature(new ClientFeature(server, false));
server.addFeature(new ConfigFeature(server, "arangoimport"));

View File

@ -25,6 +25,7 @@
#include "Basics/directories.h"
#include "ApplicationFeatures/BasicPhase.h"
#include "ApplicationFeatures/CommunicationPhase.h"
#include "ApplicationFeatures/ConfigFeature.h"
#include "ApplicationFeatures/GreetingsPhase.h"
#include "ApplicationFeatures/ShellColorsFeature.h"
@ -60,6 +61,7 @@ int main(int argc, char* argv[]) {
int ret;
server.addFeature(new application_features::BasicFeaturePhase(server, true));
server.addFeature(new application_features::CommunicationFeaturePhase(server));
server.addFeature(new application_features::GreetingsFeaturePhase(server, true));
server.addFeature(new ClientFeature(server, false));
server.addFeature(new ConfigFeature(server, "arangorestore"));

View File

@ -72,6 +72,7 @@ ClientFeature::ClientFeature(
{
setOptional(true);
requiresElevatedPrivileges(false);
startsAfter("CommunicationPhase");
startsAfter("GreetingsPhase");
}

View File

@ -25,6 +25,7 @@
#include "Basics/directories.h"
#include "ApplicationFeatures/BasicPhase.h"
#include "ApplicationFeatures/CommunicationPhase.h"
#include "ApplicationFeatures/ConfigFeature.h"
#include "ApplicationFeatures/GreetingsPhase.h"
#include "ApplicationFeatures/LanguageFeature.h"
@ -62,6 +63,7 @@ int main(int argc, char* argv[]) {
try {
server.addFeature(new application_features::BasicFeaturePhase(server, true));
server.addFeature(new application_features::CommunicationFeaturePhase(server));
server.addFeature(new application_features::GreetingsFeaturePhase(server, true));
server.addFeature(new application_features::V8ShellFeaturePhase(server));

View File

@ -30,6 +30,7 @@ AQLFeaturePhase::AQLFeaturePhase(ApplicationServer& server)
setOptional(false);
startsAfter("V8Phase");
startsAfter("CommunicationPhase");
startsAfter("Aql");
startsAfter("AQLFunctions");
startsAfter("IResearchAnalyzer");

View File

@ -0,0 +1,34 @@
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
/// Copyright 2018 ArangoDB GmbH, Cologne, Germany
///
/// 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.
///
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author Wilfried Goesgens
////////////////////////////////////////////////////////////////////////////////
#include "CommunicationPhase.h"
namespace arangodb {
namespace application_features {
CommunicationFeaturePhase::CommunicationFeaturePhase(ApplicationServer& server)
: ApplicationFeaturePhase(server, "CommunicationPhase") {
setOptional(false);
}
} // application_features
} // arangodb

View File

@ -0,0 +1,56 @@
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
/// Copyright 2018 ArangoDB GmbH, Cologne, Germany
///
/// 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.
///
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author Michael Hackstein
////////////////////////////////////////////////////////////////////////////////
#ifndef ARANGODB_APPLICATION_FEATURES_COMM_FEATURE_PHASE_H
#define ARANGODB_APPLICATION_FEATURES_COMM_FEATURE_PHASE_H 1
#include "ApplicationFeaturePhase.h"
namespace arangodb {
namespace application_features {
class CommunicationFeaturePhase : public ApplicationFeaturePhase {
public:
explicit CommunicationFeaturePhase(ApplicationServer& server);
/**
* @brief decide whether we may freely communicate or not.
*/
bool getCommAllowed() {
switch (state()) {
case ApplicationServer::FeatureState::UNINITIALIZED:
case ApplicationServer::FeatureState::INITIALIZED:
case ApplicationServer::FeatureState::VALIDATED:
case ApplicationServer::FeatureState::PREPARED:
case ApplicationServer::FeatureState::STARTED:
case ApplicationServer::FeatureState::STOPPED:
return true;
case ApplicationServer::FeatureState::UNPREPARED:
return false;
}
return false;
}
};
} // namespace application_features
} // namespace arangodb
#endif

View File

@ -138,6 +138,7 @@ add_library(${LIB_ARANGO} STATIC
ApplicationFeatures/ApplicationFeaturePhase.cpp
ApplicationFeatures/ApplicationServer.cpp
ApplicationFeatures/AgencyPhase.cpp
ApplicationFeatures/CommunicationPhase.cpp
ApplicationFeatures/AQLPhase.cpp
ApplicationFeatures/BasicPhase.cpp
ApplicationFeatures/ClusterPhase.cpp

View File

@ -25,7 +25,7 @@
#include "SimpleHttpClient.h"
#include "ApplicationFeatures/ApplicationServer.h"
#include "ApplicationFeatures/CommunicationPhase.h"
#include "Basics/StringUtils.h"
#include "Logger/Logger.h"
#include "Rest/HttpResponse.h"
@ -253,6 +253,9 @@ SimpleHttpResult* SimpleHttpClient::doRequest(
// reset error message
_errorMessage = "";
auto comm = application_features::ApplicationServer::getFeature<
arangodb::application_features::CommunicationFeaturePhase>("CommunicationPhase");
// set body
setRequest(method, rewriteLocation(location), body, bodyLength, headers);
@ -409,7 +412,7 @@ SimpleHttpResult* SimpleHttpClient::doRequest(
break;
}
if (application_features::ApplicationServer::isStopping()) {
if (!comm->getCommAllowed()) {
setErrorMessage("Command locally aborted");
return nullptr;
}

View File

@ -26,6 +26,7 @@
#include "../IResearch/StorageEngineMock.h"
#include "Agency/Store.h"
#include "ApplicationFeatures/ApplicationServer.h"
#include "ApplicationFeatures/CommunicationPhase.h"
#include "Cluster/ClusterComm.h"
#include "Cluster/ClusterFeature.h"
#include "Cluster/ClusterInfo.h"
@ -162,6 +163,7 @@ struct ClusterInfoSetup {
// setup required application features
features.emplace_back(new arangodb::AuthenticationFeature(server), false); // required for ClusterFeature::prepare()
features.emplace_back(arangodb::DatabaseFeature::DATABASE = new arangodb::DatabaseFeature(server), false);
features.emplace_back(new arangodb::application_features::CommunicationFeaturePhase(server), false);
features.emplace_back(new arangodb::ClusterFeature(server), false); // required for ClusterInfo::instance()
features.emplace_back(new arangodb::QueryRegistryFeature(server), false); // required for DatabaseFeature::createDatabase(...)
features.emplace_back(new arangodb::V8DealerFeature(server), false); // required for DatabaseFeature::createDatabase(...)
@ -271,4 +273,4 @@ SECTION("test_drop_databse") {
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

View File

@ -30,6 +30,7 @@
#include "utils/log.hpp"
#include "ApplicationFeatures/BasicPhase.h"
#include "ApplicationFeatures/CommunicationPhase.h"
#include "ApplicationFeatures/ClusterPhase.h"
#include "ApplicationFeatures/DatabasePhase.h"
#include "ApplicationFeatures/GreetingsPhase.h"
@ -46,7 +47,6 @@
#include "Enterprise/Ldap/LdapFeature.h"
#endif
#include "Agency/AgencyFeature.h"
#include "Agency/Store.h"
#include "Cluster/ClusterComm.h"
#include "Cluster/ClusterFeature.h"
@ -135,6 +135,7 @@ struct IResearchLinkCoordinatorSetup {
arangodb::application_features::ApplicationFeature* tmpFeature;
buildFeatureEntry(new arangodb::application_features::BasicFeaturePhase(server, false), false);
buildFeatureEntry(new arangodb::application_features::CommunicationFeaturePhase(server), false);
buildFeatureEntry(new arangodb::application_features::ClusterFeaturePhase(server), false);
buildFeatureEntry(new arangodb::application_features::DatabaseFeaturePhase(server), false);
buildFeatureEntry(new arangodb::application_features::GreetingsFeaturePhase(server, false), false);
@ -509,4 +510,4 @@ SECTION("test_create_drop") {
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

View File

@ -31,6 +31,7 @@
#include "utils/locale_utils.hpp"
#include "ApplicationFeatures/BasicPhase.h"
#include "ApplicationFeatures/CommunicationPhase.h"
#include "ApplicationFeatures/ClusterPhase.h"
#include "ApplicationFeatures/DatabasePhase.h"
#include "ApplicationFeatures/GreetingsPhase.h"
@ -113,6 +114,7 @@ struct IResearchLinkMetaSetup {
arangodb::application_features::ApplicationFeature* tmpFeature;
buildFeatureEntry(new arangodb::application_features::BasicFeaturePhase(server, false), false);
buildFeatureEntry(new arangodb::application_features::CommunicationFeaturePhase(server), false);
buildFeatureEntry(new arangodb::application_features::ClusterFeaturePhase(server), false);
buildFeatureEntry(new arangodb::application_features::DatabaseFeaturePhase(server), false);
buildFeatureEntry(new arangodb::application_features::GreetingsFeaturePhase(server, false), false);
@ -637,4 +639,4 @@ SECTION("test_writeMaskNone") {
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

View File

@ -48,6 +48,7 @@
#endif
#include "ApplicationFeatures/BasicPhase.h"
#include "ApplicationFeatures/CommunicationPhase.h"
#include "ApplicationFeatures/ClusterPhase.h"
#include "ApplicationFeatures/DatabasePhase.h"
#include "ApplicationFeatures/GreetingsPhase.h"
@ -162,6 +163,7 @@ struct IResearchViewSetup {
arangodb::application_features::ApplicationFeature* tmpFeature;
buildFeatureEntry(new arangodb::application_features::BasicFeaturePhase(server, false), false);
buildFeatureEntry(new arangodb::application_features::CommunicationFeaturePhase(server), false);
buildFeatureEntry(new arangodb::application_features::ClusterFeaturePhase(server), false);
buildFeatureEntry(new arangodb::application_features::DatabaseFeaturePhase(server), false);
buildFeatureEntry(new arangodb::application_features::GreetingsFeaturePhase(server, false), false);
@ -6203,4 +6205,4 @@ SECTION("test_update_partial") {
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

View File

@ -30,6 +30,7 @@
#include "utils/log.hpp"
#include "ApplicationFeatures/BasicPhase.h"
#include "ApplicationFeatures/CommunicationPhase.h"
#include "ApplicationFeatures/ClusterPhase.h"
#include "ApplicationFeatures/DatabasePhase.h"
#include "ApplicationFeatures/GreetingsPhase.h"
@ -137,6 +138,7 @@ struct IResearchViewCoordinatorSetup {
arangodb::application_features::ApplicationFeature* tmpFeature;
buildFeatureEntry(new arangodb::application_features::BasicFeaturePhase(server, false), false);
buildFeatureEntry(new arangodb::application_features::CommunicationFeaturePhase(server), false);
buildFeatureEntry(new arangodb::application_features::ClusterFeaturePhase(server), false);
buildFeatureEntry(new arangodb::application_features::DatabaseFeaturePhase(server), false);
buildFeatureEntry(new arangodb::application_features::GreetingsFeaturePhase(server, false), false);

View File

@ -28,6 +28,7 @@
#include "AgencyMock.h"
#include "StorageEngineMock.h"
#include "ApplicationFeatures/BasicPhase.h"
#include "ApplicationFeatures/CommunicationPhase.h"
#include "ApplicationFeatures/ClusterPhase.h"
#include "ApplicationFeatures/DatabasePhase.h"
#include "ApplicationFeatures/GreetingsPhase.h"
@ -104,6 +105,7 @@ struct IResearchViewDBServerSetup {
};
buildFeatureEntry(new arangodb::application_features::BasicFeaturePhase(server, false), false);
buildFeatureEntry(new arangodb::application_features::CommunicationFeaturePhase(server), false);
buildFeatureEntry(new arangodb::application_features::ClusterFeaturePhase(server), false);
buildFeatureEntry(new arangodb::application_features::DatabaseFeaturePhase(server), false);
buildFeatureEntry(new arangodb::application_features::GreetingsFeaturePhase(server, false), false);