mirror of https://gitee.com/bigwinds/arangodb
Attach ClusterInfo methods to vocbase in coordinator case.
This commit is contained in:
parent
0d3e6fc834
commit
173b5fb892
|
@ -39,6 +39,7 @@
|
|||
#include "Basics/NumberUtils.h"
|
||||
#include "Basics/ReadLocker.h"
|
||||
#include "Basics/StaticStrings.h"
|
||||
#include "Basics/StringUtils.h"
|
||||
#include "Basics/VelocyPackHelper.h"
|
||||
#include "Basics/WriteLocker.h"
|
||||
#include "Basics/conversions.h"
|
||||
|
@ -47,6 +48,7 @@
|
|||
#include "Basics/memory-map.h"
|
||||
#include "Basics/threads.h"
|
||||
#include "Basics/tri-strings.h"
|
||||
#include "Cluster/ClusterInfo.h"
|
||||
#include "Cluster/ServerState.h"
|
||||
#include "Logger/Logger.h"
|
||||
#include "Replication/DatabaseReplicationApplier.h"
|
||||
|
@ -1114,6 +1116,12 @@ std::shared_ptr<arangodb::LogicalDataSource> TRI_vocbase_t::lookupDataSource(
|
|||
std::shared_ptr<arangodb::LogicalView> TRI_vocbase_t::lookupView(
|
||||
TRI_voc_cid_t id
|
||||
) const noexcept {
|
||||
if (ServerState::instance()->isCoordinator()) {
|
||||
ClusterInfo* ci = ClusterInfo::instance();
|
||||
std::string viewId = StringUtils::itoa(id);
|
||||
return ci->getView(name(), viewId);
|
||||
}
|
||||
|
||||
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
|
||||
return std::dynamic_pointer_cast<arangodb::LogicalView>(
|
||||
lookupDataSource(id)
|
||||
|
@ -1130,6 +1138,11 @@ std::shared_ptr<arangodb::LogicalView> TRI_vocbase_t::lookupView(
|
|||
std::shared_ptr<arangodb::LogicalView> TRI_vocbase_t::lookupView(
|
||||
std::string const& nameOrId
|
||||
) const noexcept{
|
||||
if (ServerState::instance()->isCoordinator()) {
|
||||
ClusterInfo* ci = ClusterInfo::instance();
|
||||
return ci->getView(name(), nameOrId);
|
||||
}
|
||||
|
||||
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
|
||||
return std::dynamic_pointer_cast<arangodb::LogicalView>(
|
||||
lookupDataSource(nameOrId)
|
||||
|
@ -1638,6 +1651,21 @@ std::shared_ptr<arangodb::LogicalView> TRI_vocbase_t::createViewWorker(
|
|||
/// but the functionality is not advertised
|
||||
std::shared_ptr<arangodb::LogicalView> TRI_vocbase_t::createView(
|
||||
VPackSlice parameters, TRI_voc_cid_t id) {
|
||||
|
||||
if (ServerState::instance()->isCoordinator()) {
|
||||
ClusterInfo* ci = ClusterInfo::instance();
|
||||
std::string viewId = StringUtils::itoa(id);
|
||||
std::string errorMsg;
|
||||
int res = ci->createViewCoordinator(name(), viewId, parameters, errorMsg);
|
||||
if (res == TRI_ERROR_NO_ERROR) {
|
||||
return ci->getView(name(), viewId);
|
||||
}
|
||||
LOG_TOPIC(ERR, arangodb::Logger::CLUSTER)
|
||||
<< "Could not create view in agency, error: " << errorMsg
|
||||
<< ", errorCode: " << res;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
READ_LOCKER(readLocker, _inventoryLock);
|
||||
|
||||
// note: id may be modified by this function call
|
||||
|
@ -1676,8 +1704,23 @@ int TRI_vocbase_t::dropView(std::string const& name) {
|
|||
|
||||
/// @brief drops a view
|
||||
int TRI_vocbase_t::dropView(std::shared_ptr<arangodb::LogicalView> view) {
|
||||
|
||||
TRI_ASSERT(view != nullptr);
|
||||
|
||||
if (ServerState::instance()->isCoordinator()) {
|
||||
ClusterInfo* ci = ClusterInfo::instance();
|
||||
std::string errorMsg;
|
||||
int res = ci->dropViewCoordinator(name(), StringUtils::itoa(view->id()),
|
||||
errorMsg);
|
||||
if (res == TRI_ERROR_NO_ERROR) {
|
||||
return res;
|
||||
}
|
||||
LOG_TOPIC(ERR, arangodb::Logger::CLUSTER)
|
||||
<< "Could not drop view in agency, error: " << errorMsg
|
||||
<< ", errorCode: " << res;
|
||||
return res;
|
||||
}
|
||||
|
||||
READ_LOCKER(readLocker, _inventoryLock);
|
||||
|
||||
// do not acquire these locks instantly
|
||||
|
@ -2102,4 +2145,4 @@ TRI_voc_rid_t TRI_StringToRid(char const* p, size_t len, bool& isOld,
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- END-OF-FILE
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue